/* チンチロリン飲みゲームのスタイル */

:root {
  --color-amber-300: #fcd34d;
  --color-amber-400: #fbbf24;
  --color-amber-500: #f59e0b;
  --color-orange-500: #f97316;
  --color-slate-500: #64748b;
  --color-slate-700: #334155;
  --color-slate-800: #1e293b;
  --color-slate-900: #0f172a;
  --color-indigo-600: #4f46e5;
  --color-purple-600: #9333ea;
}

.chinchiro-page {
  background-color: var(--color-slate-900);
  color: var(--color-surface);
}

.chinchiro-game {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  max-width: 800px;
  margin: 0 auto;
  position: relative;
  overflow: hidden;
}

[hidden] {
  display: none !important;
}

/* ヘッダー */
.chinchiro-game__header {
  display: flex;
  justify-content: flex-start;
  align-items: center;
  padding: 1rem;
  background-color: rgba(30, 41, 59, 0.5);
  backdrop-filter: blur(8px);
  position: relative;
  z-index: 10;
}

.chinchiro-game__header-left {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.chinchiro-game__header-left.chinchiro-game__header-left--title {
  position: absolute;
  top: 1rem;
  left: 1rem;
}

.chinchiro-game__back-button {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background-color: var(--color-slate-700);
  color: var(--color-surface);
  text-decoration: none;
  transition: background-color 0.2s;
}

.chinchiro-game__rules-button {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  border-radius: 9999px;
  background-color: var(--color-slate-700);
  color: var(--color-surface);
  font-weight: bold;
  font-size: 0.875rem;
  transition: background-color 0.2s;
}

/* ゲームエリア */
.chinchiro-game__game-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  gap: 2rem;
  position: relative;
}

/* お椀とサイコロ */
.chinchiro-game__bowl {
  --roll-glow: 0.3;
  --roll-orbit-speed: 850ms;
  --roll-spin-speed: 220ms;
  --roll-saturation: 1;
  --roll-scale: 1;
  --spark-density: 0;
  position: relative;
  width: 18rem;
  height: 18rem;
  border-radius: 50%;
  background-color: var(--color-slate-800);
  border: 8px solid var(--color-slate-700);
  box-shadow: inset 0 10px 40px rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  overflow: visible;
  transition: box-shadow 0.14s ease-out;
}

.chinchiro-game__bowl::after {
  content: '';
  position: absolute;
  left: 50%;
  top: 50%;
  width: 14%;
  height: 14%;
  border-radius: 50%;
  border: 3px solid rgba(252, 211, 77, 0.8);
  transform: translate(-50%, -50%) scale(0.3);
  opacity: 0;
  pointer-events: none;
}

.chinchiro-game__bowl.chinchiro-game__bowl--rolling {
  animation: bowlOrbitGlow var(--roll-orbit-speed, 850ms) linear infinite;
  filter: saturate(var(--roll-saturation, 1));
  box-shadow:
    inset 0 10px 40px rgba(0, 0, 0, 0.5),
    0 0 28px rgba(252, 211, 77, calc(var(--roll-glow) * 0.7)),
    0 0 68px rgba(79, 70, 229, calc(var(--roll-glow) * 0.52)),
    0 0 110px rgba(249, 115, 22, calc(var(--roll-glow) * 0.26));
}

.chinchiro-game__bowl.chinchiro-game__bowl--rolling .chinchiro-game__bowl-inner {
  animation: pulse 0.75s ease-in-out infinite;
}

.chinchiro-game__bowl.chinchiro-game__bowl--impact::after {
  animation: shockwaveRing 0.46s cubic-bezier(0.2, 0.78, 0.2, 1);
}

@media (min-width: 640px) {
  .chinchiro-game__bowl {
    width: 24rem;
    height: 24rem;
  }
}

.chinchiro-game__bowl-inner {
  position: absolute;
  inset: 0.5rem;
  border-radius: 50%;
  background-color: var(--color-slate-800);
  opacity: 0.5;
  border: 2px dashed rgba(71, 85, 105, 0.3);
}

.chinchiro-game__dice-container {
  display: flex;
  gap: 1rem;
  z-index: 10;
  transform: rotate(12deg);
  transition: transform 0.08s linear;
}

.chinchiro-game__dice-container.chinchiro-game__dice-container--rolling {
  transform: rotate(calc(12deg + var(--roll-tilt, 0deg))) scale(var(--roll-scale, 1));
}

@media (min-width: 640px) {
  .chinchiro-game__dice-container {
    gap: 2rem;
  }
}

.chinchiro-game__dice {
  width: 5rem;
  height: 5rem;
  background-color: white;
  border-radius: 0.75rem;
  box-shadow: 0 4px 0 rgb(200, 200, 200);
  border: 2px solid #e5e7eb;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  gap: 0.25rem;
  padding: 0.5rem;
  transition: transform 0.2s, box-shadow 0.12s ease-out, filter 0.12s ease-out;
  will-change: transform;
}

@media (min-width: 640px) {
  .chinchiro-game__dice {
    width: 6rem;
    height: 6rem;
  }
}

.chinchiro-game__dice.chinchiro-game__dice--rolling-left {
  animation: diceSpinChaos var(--roll-spin-speed, 220ms) linear infinite;
  filter: saturate(var(--roll-saturation, 1)) brightness(calc(0.96 + (var(--roll-glow, 0.3) * 0.1)));
}

.chinchiro-game__dice.chinchiro-game__dice--rolling-right {
  animation: diceSpinChaos var(--roll-spin-speed, 220ms) linear infinite reverse;
  filter: saturate(var(--roll-saturation, 1)) brightness(calc(0.96 + (var(--roll-glow, 0.3) * 0.1)));
}

.chinchiro-game__dice.chinchiro-game__dice--reveal {
  animation: rollImpactPop 0.38s cubic-bezier(0.24, 0.88, 0.32, 1.2);
  box-shadow: 0 8px 0 rgb(190, 190, 190), 0 0 26px rgba(251, 191, 36, 0.5);
  filter: brightness(1.08);
}

.chinchiro-game__spark {
  position: absolute;
  left: 50%;
  top: 50%;
  width: var(--spark-size, 0.4rem);
  height: var(--spark-size, 0.4rem);
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 253, 213, 1) 0%, rgba(251, 191, 36, 0.9) 45%, rgba(239, 68, 68, 0.95) 100%);
  transform: translate(-50%, -50%) rotate(var(--spark-angle)) translateY(0) scale(0.4);
  pointer-events: none;
  animation: sparkBurst var(--spark-duration, 560ms) ease-out forwards;
  animation-delay: var(--spark-delay, 0ms);
}

.chinchiro-game__dice-dot {
  width: 0.75rem;
  height: 0.75rem;
  background-color: black;
  border-radius: 50%;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.5);
}

@media (min-width: 640px) {
  .chinchiro-game__dice-dot {
    width: 1rem;
    height: 1rem;
  }
}

.chinchiro-game__dice-dot.chinchiro-game__dice-dot--red {
  background-color: #dc2626;
}

/* 操作パネル */
.chinchiro-game__controls {
  width: 100%;
  max-width: 20rem;
  z-index: 20;
}

.chinchiro-game__control-group {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  align-items: center;
}

.chinchiro-game__action-button {
  width: 100%;
  padding: 0.75rem 1rem;
  border-radius: 1rem;
  font-weight: bold;
  font-size: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  transition: all 0.2s;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

.chinchiro-game__action-button:active {
  transform: scale(0.95);
}

.chinchiro-game__action-button.chinchiro-game__action-button--primary {
  background: linear-gradient(to right, var(--color-indigo-600), var(--color-purple-600));
  color: white;
}

.chinchiro-game__action-button.chinchiro-game__action-button--primary:disabled {
  background: var(--color-slate-700);
  color: var(--color-slate-500);
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.chinchiro-game__action-button.chinchiro-game__action-button--large {
  padding: 1rem;
  font-size: 1.25rem;
}

.chinchiro-game__status-text {
  width: 100%;
  padding: 1rem;
  text-align: center;
  font-family: monospace;
  color: var(--color-text-muted);
  min-height: 3.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.chinchiro-game__status-text span {
  color: var(--color-text-muted);
  font-weight: bold;
}

/* モーダル */
.chinchiro-game__modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background-color: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(4px);
  animation: fadeIn 0.2s ease-out;
}

.chinchiro-game__modal[hidden] {
  display: none;
}

.chinchiro-game__modal-content {
  background-color: var(--color-slate-900);
  border: 1px solid var(--color-slate-700);
  border-radius: 1rem;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
  width: 100%;
  max-width: 28rem;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* 結果モーダル */
.chinchiro-game__modal-content--result {
  padding: 2rem;
  text-align: center;
  animation: zoomIn 0.2s ease-out;
}

.chinchiro-game__result-sum {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.55rem;
  width: fit-content;
  padding: 0.5rem 0.85rem 0.5rem 1rem;
  background-color: #111827;
  border: 2px solid var(--color-amber-400);
  border-radius: 9999px;
  color: #f8fafc;
  font-family: monospace;
  font-size: 1rem;
  font-weight: 800;
  letter-spacing: 0.02em;
  text-align: center;
  margin: 0 auto 1rem;
  box-shadow:
    0 0 0 3px rgba(251, 191, 36, 0.22),
    0 10px 20px rgba(0, 0, 0, 0.35);
}

.chinchiro-game__result-sum #result-sum-val {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2.5ch;
  padding: 0.08rem 0.62rem;
  border-radius: 0.55rem;
  background: #fcd34d;
  color: #0f172a;
  font-size: 2rem;
  font-weight: 900;
  line-height: 1;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.45),
    0 3px 10px rgba(252, 211, 77, 0.45);
}

@media (max-width: 420px) {
  .chinchiro-game__result-sum {
    font-size: 0.9rem;
  }

  .chinchiro-game__result-sum #result-sum-val {
    font-size: 1.7rem;
    min-width: 2.3ch;
  }
}

.chinchiro-game__result-title {
  display: block;
  width: fit-content;
  max-width: 100%;
  padding: 0.42rem 1.05rem;
  border-radius: 0.8rem;
  border: 2px solid rgba(252, 211, 77, 0.72);
  background: linear-gradient(135deg, rgba(30, 41, 59, 0.96), rgba(51, 65, 85, 0.88));
  color: #fef3c7;
  font-size: clamp(1.9rem, 8vw, 2.5rem);
  font-weight: 900;
  letter-spacing: 0.03em;
  line-height: 1.15;
  margin: 0 auto 1rem;
  text-shadow:
    0 2px 0 rgba(0, 0, 0, 0.35),
    0 0 18px rgba(251, 191, 36, 0.45);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.14),
    0 0 0 2px rgba(251, 191, 36, 0.18),
    0 10px 20px rgba(15, 23, 42, 0.45);
  -webkit-text-fill-color: currentColor;
  background-clip: border-box;
  -webkit-background-clip: border-box;
}

.chinchiro-game__result-desc {
  font-size: 1.125rem;
  color: #cbd5e1;
  margin-bottom: 2rem;
  line-height: 1.6;
}

/* ルールモーダル */
.chinchiro-game__modal-content--rules {
  max-height: 80vh;
}

.chinchiro-game__modal-header {
  padding: 1rem;
  background-color: var(--color-slate-800);
  border-bottom: 1px solid var(--color-slate-700);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.chinchiro-game__modal-header h3 {
  font-size: 1.125rem;
  font-weight: bold;
  color: white;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.chinchiro-game__modal-header h3 i {
  color: var(--color-amber-400);
}

.chinchiro-game__close-button {
  color: var(--color-text-muted);
  padding: 0.25rem;
}

.chinchiro-game__rules-list {
  padding: 1rem;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.chinchiro-game__rule-item {
  display: flex;
  gap: 1rem;
  align-items: flex-start;
  padding: 0.75rem;
  background-color: rgba(30, 41, 59, 0.5);
  border-radius: 0.5rem;
  border: 1px solid rgba(51, 65, 85, 0.5);
}

.chinchiro-game__rule-sum {
  width: 4rem;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background-color: var(--color-slate-700);
  border-radius: 0.25rem;
  padding: 0.5rem;
  font-size: 1.25rem;
  font-weight: 900;
  color: var(--color-amber-400);
}

.chinchiro-game__rule-sum::before {
  content: "合計";
  font-size: 0.75rem;
  color: var(--color-text-muted);
  font-weight: normal;
}

.chinchiro-game__rule-sum.chinchiro-game__rule-sum--no-total-label::before {
  content: none;
}

.chinchiro-game__rule-info {
  flex: 1;
}

.chinchiro-game__rule-title {
  font-weight: bold;
  color: #e2e8f0;
  font-size: 0.875rem;
  margin-bottom: 0.25rem;
}

.chinchiro-game__rule-desc {
  font-size: 0.75rem;
  color: var(--color-text-muted);
  line-height: 1.5;
}

/* アニメーション */
@keyframes bowlOrbitGlow {
  0% {
    transform: rotate(0deg) scale(1);
  }

  20% {
    transform: rotate(1.2deg) scale(1.015);
  }

  50% {
    transform: rotate(0deg) scale(1.03);
  }

  80% {
    transform: rotate(-1.2deg) scale(1.015);
  }

  100% {
    transform: rotate(0deg) scale(1);
  }
}

@keyframes diceSpinChaos {
  0% {
    transform: translate(-4px, 3px) rotate(0deg) scale(1);
  }

  20% {
    transform: translate(4px, -4px) rotate(95deg) scale(1.05);
  }

  40% {
    transform: translate(-3px, 2px) rotate(186deg) scale(0.98);
  }

  60% {
    transform: translate(5px, 3px) rotate(276deg) scale(1.06);
  }

  80% {
    transform: translate(-2px, -3px) rotate(338deg) scale(1);
  }

  100% {
    transform: translate(-4px, 3px) rotate(360deg) scale(1);
  }
}

@keyframes rollImpactPop {
  0% {
    transform: scale(1) rotate(0deg);
  }

  35% {
    transform: scale(1.2) rotate(-7deg);
  }

  60% {
    transform: scale(0.9) rotate(5deg);
  }

  100% {
    transform: scale(1) rotate(0deg);
  }
}

@keyframes shockwaveRing {
  0% {
    opacity: 0.95;
    transform: translate(-50%, -50%) scale(0.35);
  }

  100% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(2.7);
  }
}

@keyframes sparkBurst {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) rotate(var(--spark-angle)) translateY(0) scale(0.25);
  }

  25% {
    opacity: 1;
  }

  100% {
    opacity: 0;
    transform: translate(-50%, -50%) rotate(var(--spark-angle)) translateY(var(--spark-distance, -110px)) scale(1);
  }
}

@keyframes pulse {

  0%,
  100% {
    opacity: 1;
  }

  50% {
    opacity: .5;
  }
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

@keyframes zoomIn {
  from {
    opacity: 0;
    transform: scale(0.95);
  }

  to {
    opacity: 1;
    transform: scale(1);
  }
}

@media (prefers-reduced-motion: reduce) {
  .chinchiro-game__bowl.chinchiro-game__bowl--rolling {
    animation: none;
    filter: none;
  }

  .chinchiro-game__bowl.chinchiro-game__bowl--rolling .chinchiro-game__bowl-inner {
    animation: none;
  }

  .chinchiro-game__dice-container.chinchiro-game__dice-container--rolling {
    transition: none;
    transform: rotate(12deg) scale(1);
  }

  .chinchiro-game__dice.chinchiro-game__dice--rolling-left,
  .chinchiro-game__dice.chinchiro-game__dice--rolling-right {
    animation: none;
    transform: none;
    filter: none;
  }

  .chinchiro-game__bowl.chinchiro-game__bowl--impact::after {
    animation: none;
    opacity: 0.4;
    transform: translate(-50%, -50%) scale(1.2);
  }

  .chinchiro-game__spark {
    display: none;
  }

  .chinchiro-game__status-text span {
    animation: none;
  }
}

/* サイコログリッド用ユーティリティクラス */
.chinchiro-game__dice-dot--col-1 {
  grid-column-start: 1;
}

.chinchiro-game__dice-dot--col-2 {
  grid-column-start: 2;
}

.chinchiro-game__dice-dot--col-3 {
  grid-column-start: 3;
}

.chinchiro-game__dice-dot--row-1 {
  grid-row-start: 1;
}

.chinchiro-game__dice-dot--row-2 {
  grid-row-start: 2;
}

.chinchiro-game__dice-dot--row-3 {
  grid-row-start: 3;
}

/* タイトル画面のスタイル */
.chinchiro-game__title-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 2rem;
  text-align: center;
  background: linear-gradient(to bottom, var(--color-slate-900), var(--color-slate-800));
}

.chinchiro-game__title-icon {
  display: inline-flex;
  align-items: flex-end;
  justify-content: center;
  gap: 0.9rem;
  color: var(--color-amber-400);
  margin-bottom: 2rem;
  background-color: rgba(255, 255, 255, 0.05);
  padding: 1.6rem 2.4rem;
  border-radius: 9999px;
  border: 2px solid rgba(251, 191, 36, 0.45);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

.chinchiro-game__title-icon-symbol {
  font-size: 3.6rem;
  line-height: 1;
}

.chinchiro-game__title-icon-symbol.chinchiro-game__title-icon-symbol--beer {
  filter: drop-shadow(0 0 14px rgba(251, 191, 36, 0.42));
}

.chinchiro-game__title-icon-symbol.chinchiro-game__title-icon-symbol--dice {
  font-size: 2.7rem;
  color: #fef3c7;
  transform: translateY(-0.25rem) rotate(-14deg);
  filter: drop-shadow(0 0 12px rgba(252, 211, 77, 0.4));
}

@media (max-width: 420px) {
  .chinchiro-game__title-icon {
    gap: 0.7rem;
    padding: 1.3rem 1.9rem;
  }

  .chinchiro-game__title-icon-symbol {
    font-size: 3rem;
  }

  .chinchiro-game__title-icon-symbol.chinchiro-game__title-icon-symbol--dice {
    font-size: 2.25rem;
  }
}

.chinchiro-game__title {
  font-size: 2.5rem;
  font-weight: 900;
  margin-bottom: 1rem;
  background: linear-gradient(to right, var(--color-amber-300), var(--color-orange-500));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  line-height: 1.2;
}

.chinchiro-game__action-button.chinchiro-game__action-button--large-start {
  padding: 1rem 2rem;
  font-size: 1.25rem;
  width: auto;
  min-width: 12rem;
}

.chinchiro-game__start-subtext {
  display: block;
  font-size: 0.95rem;
  font-weight: 700;
  margin-top: 0.125rem;
}

.chinchiro-game__start-note {
  margin-top: 0.5rem;
  font-size: 0.75rem;
  font-weight: 700;
  color: #f87171;
}

/* ゲーム画面のレイアウト */
#game-screen {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}
