:root {
  color-scheme: light;
  --ink: #161b2b;
  --muted: #4b5366;
  --card: rgba(255, 255, 255, 0.9);
  --accent: #e13c3c;
  --accent-dark: #a72727;
  --evergreen: #0f4c3a;
  --gold: #f4c966;
  --frost: #ecf6ff;
  --shadow: 0 35px 70px rgba(12, 21, 33, 0.22);
  --radius: 26px;
  --bg-overlay: linear-gradient(180deg, rgba(20, 35, 60, 0.2), rgba(8, 19, 36, 0.6));
  --bg-image: url("https://images.unsplash.com/photo-1482517967863-00e15c9b44be?auto=format&fit=crop&w=1600&q=80");
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

body {
  margin: 0;
  font-family: "Space Grotesk", sans-serif;
  color: var(--ink);
  background: var(--bg-overlay), var(--bg-image);
  background-size: cover;
  background-position: center;
  min-height: 100vh;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  touch-action: manipulation;
}

button:focus,
button:focus-visible {
  outline: none;
  box-shadow: none;
}

#pauseOverlay {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(8, 16, 28, 0.78);
  color: #fff;
  z-index: 9999;
  font-weight: 600;
  font-size: 1.1rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

body.is-paused #pauseOverlay {
  display: flex;
}

body.is-paused * {
  transition: none !important;
  animation: none !important;
}

body.is-paused .match-grid {
  opacity: 0;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  background:
    radial-gradient(circle at 20% 10%, rgba(244, 201, 102, 0.4), transparent 40%),
    radial-gradient(circle at 80% 20%, rgba(225, 60, 60, 0.3), transparent 45%),
    radial-gradient(circle at 50% 80%, rgba(15, 76, 58, 0.3), transparent 45%);
  opacity: 0.9;
  z-index: -2;
}

body::after {
  content: "";
  position: fixed;
  inset: 0;
  background-image: url("https://www.transparenttextures.com/patterns/snow.png");
  opacity: 0.25;
  z-index: -1;
}

body[data-theme="dark"] {
  color-scheme: dark;
  --ink: #f3f6ff;
  --muted: #c6cfdf;
  --card: rgba(12, 20, 36, 0.86);
  --accent: #f46a6a;
  --accent-dark: #f4b66b;
  --evergreen: #89f2d2;
  --gold: #f7d78a;
  --shadow: 0 35px 70px rgba(5, 10, 20, 0.6);
  --bg-overlay: linear-gradient(180deg, rgba(3, 10, 24, 0.7), rgba(8, 14, 30, 0.95));
  --bg-image: url("https://images.unsplash.com/photo-1489515217757-5fd1be406fef?auto=format&fit=crop&w=1600&q=80");
}

.page {
  width: 100%;
  margin: 0;
  padding: 32px 16px 48px;
  display: grid;
  place-items: center;
}

.app-shell {
  width: min(980px, 100%);
}

.menu-top {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: start;
  gap: 24px;
  margin-bottom: 28px;
}

.menu-controls {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 12px;
}

.theme-toggle {
  align-self: start;
  border: none;
  border-radius: 999px;
  padding: 8px 14px;
  font-family: inherit;
  font-weight: 600;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--evergreen);
  background: rgba(255, 255, 255, 0.85);
  cursor: pointer;
  box-shadow: 0 12px 24px rgba(8, 16, 32, 0.15);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.theme-toggle:hover {
  transform: translateY(-1px);
  box-shadow: 0 16px 28px rgba(8, 16, 32, 0.2);
}

body[data-theme="dark"] .theme-toggle {
  background: rgba(20, 28, 45, 0.9);
  color: var(--gold);
  box-shadow: 0 12px 24px rgba(5, 10, 20, 0.5);
}

.lang-toggle {
  display: inline-flex;
  gap: 6px;
  padding: 4px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.75);
  box-shadow: 0 12px 24px rgba(8, 16, 32, 0.12);
}

.lang-button {
  border: none;
  border-radius: 999px;
  padding: 6px 10px;
  font: inherit;
  font-weight: 700;
  font-size: 0.7rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--evergreen);
  background: transparent;
  cursor: pointer;
}

.lang-button.active {
  color: #101724;
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  box-shadow: 0 10px 18px rgba(12, 18, 32, 0.2);
}

body[data-theme="dark"] .lang-toggle {
  background: rgba(20, 28, 45, 0.9);
  box-shadow: 0 12px 24px rgba(5, 10, 20, 0.45);
}

body[data-theme="dark"] .lang-button {
  color: var(--gold);
}

body[data-theme="dark"] .lang-button.active {
  color: #0f172a;
}

.menu-card {
  width: 100%;
  background: var(--card);
  border-radius: calc(var(--radius) + 6px);
  padding: 38px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.4);
  animation: rise 0.9s ease-out 0.1s both;
}

.menu-header {
  display: grid;
  gap: 12px;
}

.menu-eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.28em;
  font-size: 0.65rem;
  font-weight: 700;
  color: var(--evergreen);
}

.menu-header h1 {
  margin: 0;
  font-family: "Fraunces", serif;
  font-size: clamp(2.2rem, 4vw, 3.4rem);
}

.menu-header p {
  margin: 0;
  color: var(--muted);
  max-width: 520px;
  line-height: 1.6;
}

.menu-grid {
  display: grid;
  gap: 14px;
}

.menu-section {
  margin-bottom: 12px;
  text-transform: uppercase;
  letter-spacing: 0.2em;
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--muted);
}

.menu-item {
  width: 100%;
  border: none;
  padding: 14px 18px;
  border-radius: 20px;
  background: linear-gradient(120deg, rgba(255, 255, 255, 0.9), rgba(244, 246, 255, 0.8));
  border: 1px solid rgba(15, 28, 48, 0.08);
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 16px;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  font-family: inherit;
  text-align: left;
  box-shadow: 0 14px 30px rgba(15, 28, 48, 0.08);
}

.menu-item:hover {
  transform: translateY(-2px);
  box-shadow: 0 18px 34px rgba(15, 28, 48, 0.16);
}

.icon-wrap {
  width: 54px;
  height: 54px;
  border-radius: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, rgba(15, 76, 58, 0.18), rgba(244, 201, 102, 0.2));
}

.icon-wrap svg {
  width: 28px;
  height: 28px;
  fill: var(--evergreen);
  filter: drop-shadow(0 4px 8px rgba(20, 30, 50, 0.18));
}

.icon-wrap img {
  width: 30px;
  height: 30px;
  object-fit: contain;
  filter: drop-shadow(0 4px 8px rgba(20, 30, 50, 0.18));
}

.menu-text {
  display: grid;
  gap: 4px;
}

.menu-title {
  font-weight: 700;
  font-size: 1rem;
}

.menu-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: max-content;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent-dark);
  background: rgba(225, 60, 60, 0.12);
}

.menu-arrow {
  font-size: 1.4rem;
  color: var(--accent);
  font-weight: 700;
}

.menu-item:disabled,
.menu-item.is-locked {
  cursor: not-allowed;
  opacity: 0.7;
  transform: none;
  box-shadow: none;
}

.menu-footer {
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid rgba(15, 28, 48, 0.08);
  font-weight: 600;
  color: var(--evergreen);
}

.raffle-card {
  margin-top: 20px;
  padding: 16px 18px;
  border-radius: 20px;
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 16px;
  background: linear-gradient(120deg, rgba(244, 201, 102, 0.22), rgba(225, 60, 60, 0.14));
  border: 1px solid rgba(15, 28, 48, 0.08);
}

.raffle-title {
  font-weight: 700;
  font-size: 1rem;
}

.raffle-sub {
  color: var(--muted);
  font-size: 0.9rem;
}

.raffle-button {
  border: none;
  border-radius: 999px;
  padding: 10px 18px;
  font-family: inherit;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.75rem;
  color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  cursor: pointer;
  box-shadow: 0 14px 24px rgba(15, 28, 48, 0.2);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.raffle-button:hover {
  transform: translateY(-1px);
  box-shadow: 0 18px 28px rgba(15, 28, 48, 0.25);
}

.raffle-button:disabled {
  cursor: default;
  opacity: 0.7;
  box-shadow: none;
  transform: none;
}

body[data-theme="dark"] .menu-item {
  background: linear-gradient(120deg, rgba(20, 28, 45, 0.92), rgba(30, 42, 66, 0.88));
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 14px 30px rgba(5, 10, 20, 0.5);
}

body[data-theme="dark"] .menu-item:hover {
  box-shadow: 0 18px 34px rgba(5, 10, 20, 0.6);
}

body[data-theme="dark"] .icon-wrap {
  background: linear-gradient(135deg, rgba(137, 242, 210, 0.18), rgba(244, 201, 102, 0.22));
}

body[data-theme="dark"] .menu-footer {
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

body[data-theme="dark"] .raffle-card {
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: linear-gradient(120deg, rgba(244, 201, 102, 0.18), rgba(244, 106, 106, 0.12));
}

.game-card {
  width: 100%;
  background: var(--card);
  border-radius: calc(var(--radius) + 6px);
  padding: 32px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.4);
  animation: rise 0.9s ease-out 0.1s both;
}

.game-card.match-game {
  width: 100%;
  padding: 32px;
}

.game-top {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 16px;
  margin-bottom: 20px;
}

.game-back {
  justify-self: start;
}

.game-head {
  justify-self: center;
}

.game-restart {
  justify-self: end;
}

.game-back,
.game-restart {
  border: none;
  background: rgba(255, 255, 255, 0.9);
  color: var(--evergreen);
  border-radius: 999px;
  padding: 8px 14px;
  font-family: inherit;
  font-weight: 600;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  box-shadow: 0 12px 24px rgba(8, 16, 32, 0.12);
}

.game-back:hover,
.game-restart:hover {
  transform: translateY(-1px);
  box-shadow: 0 16px 28px rgba(8, 16, 32, 0.18);
}

.game-head {
  display: grid;
  gap: 6px;
  text-align: center;
}

.game-title {
  font-family: "Fraunces", serif;
  font-size: clamp(1.6rem, 3vw, 2.4rem);
}

.game-score {
  color: var(--muted);
  font-weight: 600;
}

.game-stage {
  position: relative;
  border-radius: 24px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.7);
  border: 1px solid rgba(15, 28, 48, 0.1);
}

.gift-canvas {
  width: 100%;
  height: 420px;
  display: block;
}

.game-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  background: rgba(255, 255, 255, 0.7);
  gap: 8px;
  z-index: 3;
}

.overlay-title {
  font-family: "Fraunces", serif;
  font-size: clamp(1.4rem, 3vw, 2.2rem);
}

.overlay-sub {
  color: var(--muted);
  font-weight: 600;
}

.game-hint {
  margin-top: 14px;
  color: var(--muted);
  text-align: center;
  font-size: 0.9rem;
}

.match-stage {
  position: relative;
}

.match-grid {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  margin-top: 14px;
}

.match-grid.is-freeze {
  opacity: 0;
  pointer-events: none;
}

.match-card {
  position: relative;
  padding: 0;
  border: none;
  background: none;
  aspect-ratio: 1 / 1;
  perspective: 800px;
  -webkit-perspective: 800px;
  cursor: pointer;
}

.match-card:disabled {
  cursor: default;
}

.match-inner {
  position: relative;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
  -webkit-transform-style: preserve-3d;
  transform: translateZ(0);
  transition: transform 0.35s ease;
}

.match-card.flipped .match-inner,
.match-card.matched .match-inner {
  transform: rotateY(180deg);
}

.card-face {
  position: absolute;
  inset: 0;
  border-radius: 16px;
  display: grid;
  place-items: center;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  transform: translateZ(0);
  font-weight: 700;
  letter-spacing: 0.08em;
  box-shadow: 0 14px 22px rgba(13, 20, 32, 0.16);
}

.card-front {
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.9), rgba(230, 240, 255, 0.9));
  color: var(--evergreen);
  border: 1px solid rgba(15, 28, 48, 0.08);
}

.card-back {
  transform: rotateY(180deg);
  background: linear-gradient(135deg, rgba(15, 76, 58, 0.85), rgba(97, 198, 198, 0.9));
  color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.2);
  font-size: 1.4rem;
}

.pair-icon {
  width: min(76px, 80%);
  height: auto;
  filter: drop-shadow(0 6px 10px rgba(10, 20, 30, 0.18));
}

.pair-front-icon {
  width: min(54px, 64%);
  height: auto;
  opacity: 0.9;
  filter: drop-shadow(0 4px 8px rgba(10, 20, 30, 0.12));
}

.tangerine-stage {
  position: relative;
  height: 420px;
  border-radius: 24px;
  overflow: hidden;
  background: transparent;
  border: 1px solid rgba(15, 28, 48, 0.12);
  touch-action: none;
}

.tangerine-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  pointer-events: none;
}

.tangerine-hud {
  position: absolute;
  top: 16px;
  left: 16px;
  right: 16px;
  display: flex;
  justify-content: space-between;
  font-weight: 600;
  color: var(--muted);
  z-index: 2;
  pointer-events: none;
}

.ninja-stage {
  position: relative;
  height: 420px;
  border-radius: 24px;
  overflow: hidden;
  background: transparent;
  border: 1px solid rgba(15, 28, 48, 0.12);
  touch-action: none;
}

.ninja-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  pointer-events: none;
}

.ninja-hud {
  position: absolute;
  top: 16px;
  left: 16px;
  right: 16px;
  display: flex;
  justify-content: space-between;
  font-weight: 600;
  color: var(--muted);
  z-index: 2;
  pointer-events: none;
}

.sleigh-stage {
  position: relative;
  height: 420px;
  border-radius: 24px;
  overflow: hidden;
  background: transparent;
  border: 1px solid rgba(15, 28, 48, 0.12);
  touch-action: none;
}

.sleigh-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  pointer-events: none;
}

.sleigh-hud {
  position: absolute;
  top: 16px;
  left: 16px;
  right: 16px;
  display: flex;
  justify-content: space-between;
  font-weight: 600;
  color: var(--muted);
  z-index: 2;
  pointer-events: none;
}

.quiz-stage {
  position: relative;
  border-radius: 24px;
  padding: 24px;
  background: rgba(255, 255, 255, 0.75);
  border: 1px solid rgba(15, 28, 48, 0.12);
  display: grid;
  gap: 16px;
}

.quiz-question {
  font-family: "Fraunces", serif;
  font-size: clamp(1.3rem, 3vw, 1.8rem);
  line-height: 1.3;
}

.quiz-form {
  display: grid;
  gap: 12px;
}

.quiz-options {
  display: grid;
  gap: 12px;
}

.quiz-option {
  width: 100%;
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 12px;
  text-align: left;
  padding: 14px 16px;
  border-radius: 18px;
  border: 1px solid rgba(15, 28, 48, 0.12);
  background: rgba(255, 255, 255, 0.92);
  font: inherit;
  color: inherit;
  cursor: pointer;
  box-shadow: 0 10px 18px rgba(12, 18, 32, 0.12);
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.quiz-option:hover {
  transform: translateY(-1px);
  border-color: rgba(244, 201, 102, 0.7);
  box-shadow: 0 14px 22px rgba(12, 18, 32, 0.18);
}

.quiz-option:disabled {
  cursor: default;
  opacity: 0.7;
  transform: none;
  box-shadow: none;
}

.quiz-option-index {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--accent);
  color: #101724;
  font-weight: 800;
  font-size: 0.85rem;
  flex-shrink: 0;
}

.quiz-option-text {
  font-weight: 600;
}

.quiz-input {
  width: 100%;
  padding: 12px 16px;
  border-radius: 16px;
  border: 1px solid rgba(15, 28, 48, 0.18);
  background: rgba(255, 255, 255, 0.96);
  font: inherit;
  color: inherit;
  -webkit-user-select: text;
  user-select: text;
}

.quiz-input:focus {
  outline: none;
  box-shadow: 0 0 0 2px rgba(244, 201, 102, 0.6);
  border-color: rgba(244, 201, 102, 0.9);
}

.quiz-submit {
  border: none;
  border-radius: 999px;
  padding: 12px 18px;
  font-family: inherit;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
  color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  box-shadow: 0 16px 26px rgba(12, 18, 32, 0.18);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.quiz-submit:hover {
  transform: translateY(-1px);
  box-shadow: 0 20px 30px rgba(12, 18, 32, 0.24);
}

.quiz-submit:disabled {
  cursor: default;
  opacity: 0.7;
  box-shadow: none;
  transform: none;
}

.quiz-meta {
  color: var(--muted);
  font-weight: 600;
}


body[data-theme="dark"] .game-card {
  border: 1px solid rgba(255, 255, 255, 0.12);
}

body[data-theme="dark"] .game-stage {
  background: rgba(15, 24, 40, 0.9);
  border-color: rgba(255, 255, 255, 0.08);
}

body[data-theme="dark"] .game-overlay {
  background: rgba(12, 20, 36, 0.7);
}

body[data-theme="dark"] .card-front {
  background: linear-gradient(135deg, rgba(20, 30, 45, 0.9), rgba(24, 36, 56, 0.9));
  color: var(--gold);
  border-color: rgba(255, 255, 255, 0.08);
}

body[data-theme="dark"] .card-back {
  background: linear-gradient(135deg, rgba(137, 242, 210, 0.35), rgba(244, 201, 102, 0.7));
  color: #0f1a2b;
}

body[data-theme="dark"] .tangerine-stage {
  background: transparent;
  border-color: rgba(255, 255, 255, 0.1);
}

body[data-theme="dark"] .tangerine-hud {
  color: rgba(255, 255, 255, 0.7);
}

body[data-theme="dark"] .ninja-stage {
  background: transparent;
  border-color: rgba(255, 255, 255, 0.1);
}

body[data-theme="dark"] .ninja-hud {
  color: rgba(255, 255, 255, 0.7);
}

body[data-theme="dark"] .sleigh-stage {
  background: transparent;
  border-color: rgba(255, 255, 255, 0.1);
}

body[data-theme="dark"] .sleigh-hud {
  color: rgba(255, 255, 255, 0.7);
}

body[data-theme="dark"] .quiz-stage {
  background: rgba(12, 20, 36, 0.85);
  border-color: rgba(255, 255, 255, 0.12);
}

body[data-theme="dark"] .quiz-option {
  background: rgba(10, 18, 32, 0.9);
  border-color: rgba(255, 255, 255, 0.12);
  box-shadow: 0 12px 20px rgba(5, 12, 24, 0.35);
}

body[data-theme="dark"] .quiz-option:hover {
  border-color: rgba(244, 201, 102, 0.55);
}

body[data-theme="dark"] .quiz-option-index {
  color: #0f172a;
}

body[data-theme="dark"] .quiz-input {
  background: rgba(8, 14, 26, 0.9);
  border-color: rgba(255, 255, 255, 0.2);
  color: var(--ink);
}

body[data-theme="dark"] .game-back,
body[data-theme="dark"] .game-restart {
  background: rgba(20, 28, 45, 0.9);
  color: var(--gold);
  box-shadow: 0 12px 24px rgba(5, 10, 20, 0.4);
}

.status-card {
  width: min(520px, 100%);
  background: var(--card);
  border-radius: var(--radius);
  padding: 28px 32px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(8px);
  text-align: center;
  border: 1px solid rgba(255, 255, 255, 0.35);
  animation: rise 0.9s ease-out 0.1s both;
}

.status-title {
  font-family: "Fraunces", serif;
  font-size: clamp(1.6rem, 3vw, 2.2rem);
  margin-bottom: 8px;
}

.status-text {
  color: var(--muted);
  line-height: 1.6;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(18px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 640px) {
  .page {
    padding: 28px 14px 44px;
  }

  .menu-card {
    padding: 24px;
  }

  .menu-top {
    grid-template-columns: 1fr;
  }

  .menu-controls {
    align-items: flex-start;
  }

  .theme-toggle {
    justify-self: start;
  }

  .game-card {
    padding: 24px;
  }

  .game-top {
    grid-template-columns: 1fr;
    justify-items: start;
    text-align: left;
  }

  .game-head {
    text-align: left;
    justify-self: start;
  }

  .match-grid {
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 12px;
  }
}
