/* ============================================================
   FORTUNE PANDA — Premium dark theme
   Color tokens, typography, and responsive layout
   ============================================================ */

:root {
  /* Backgrounds */
  --bg-main: #0e0f12;
  --bg-secondary: #1b1f2a;

  /* Gold */
  --gold-primary: #ffd469;
  --gold-secondary: #f2a93b;
  --gold-deep: #d4a017;
  --gold-glow: rgba(255, 210, 80, 0.3);

  /* Jade */
  --jade-primary: #4caf50;
  --jade-deep: #2e7d32;
  --jade-accent: #1f8f5f;

  /* Burgundy */
  --burgundy-primary: #6d1f3b;
  --burgundy-deep: #5a1f2b;
  --burgundy-glow: rgba(109, 31, 59, 0.2);

  /* Text */
  --text-primary: #e9ecf1;
  --text-secondary: rgba(233, 236, 241, 0.7);
  --text-tertiary: rgba(233, 236, 241, 0.45);

  /* Panels */
  --card-bg: rgba(15, 17, 23, 0.92);
  --soft-panel: rgba(255, 255, 255, 0.03);
  --border: rgba(255, 255, 255, 0.1);

  /* Buttons */
  --btn-primary-grad: linear-gradient(180deg, #ffd469, #f2a93b);
  --btn-text: #1b1205;

  /* Highlights */
  --win-glow: rgba(255, 210, 80, 0.3);
  --win-border: rgba(255, 210, 80, 0.35);

  /* Status */
  --success: #4caf50;
  --warning: #f2a93b;
  --error: #ff4d4d;

  /* Overlays */
  --modal-bg: rgba(0, 0, 0, 0.65);
  --glass: rgba(255, 255, 255, 0.03);

  /* Shadows */
  --shadow-main: rgba(0, 0, 0, 0.3);
  --shadow-glow: rgba(255, 210, 80, 0.2);

  /* Safe area helpers */
  --safe-top: env(safe-area-inset-top);
  --safe-bottom: env(safe-area-inset-bottom);
  --safe-left: env(safe-area-inset-left);
  --safe-right: env(safe-area-inset-right);

  /* Type */
  --font-display: "Cormorant Garamond", "Hoefler Text", "Garamond",
    "Times New Roman", serif;
  --font-body: -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue",
    Arial, sans-serif;
}

/* ===== Reset ===== */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg-main);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}

body {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100svh;
  overflow: hidden;
  background:
    radial-gradient(circle at 10% -10%, rgba(109, 31, 59, 0.18), transparent 55%),
    radial-gradient(circle at 110% 110%, rgba(31, 143, 95, 0.1), transparent 55%),
    radial-gradient(circle at 50% 50%, #14161d, var(--bg-main) 80%);
}

/* The HTML `hidden` attribute must beat any later display rules. */
[hidden] {
  display: none !important;
}

button {
  background: none;
  border: 0;
  padding: 0;
  font: inherit;
  color: inherit;
  cursor: pointer;
}

input,
button,
select,
textarea {
  font-family: inherit;
}

a {
  color: var(--gold-primary);
}

/* ============================================================
   SCREEN SHELL
   ============================================================ */
.screen {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100svh;
  display: none;
  flex-direction: column;
  padding-top: var(--safe-top);
  padding-bottom: var(--safe-bottom);
  padding-left: var(--safe-left);
  padding-right: var(--safe-right);
  animation: fadeIn 0.35s ease both;
}

.screen--active {
  display: flex;
}

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

/* ============================================================
   START SCREEN
   ============================================================ */
#start-screen {
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}

.bamboo-bg {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}

.bamboo-stalk {
  position: absolute;
  width: 18px;
  height: 100%;
  background: linear-gradient(
    180deg,
    transparent 0%,
    rgba(31, 143, 95, 0.25) 20%,
    rgba(31, 143, 95, 0.1) 80%,
    transparent 100%
  );
  border-radius: 9px;
  filter: blur(2px);
}

.bamboo-stalk::before,
.bamboo-stalk::after {
  content: "";
  position: absolute;
  inset: auto 0;
  height: 3px;
  background: rgba(46, 125, 50, 0.4);
  border-radius: 4px;
}

.bamboo-stalk--1 {
  left: -4px;
  top: -8%;
  transform: rotate(7deg);
}
.bamboo-stalk--2 {
  right: -6px;
  top: 4%;
  transform: rotate(-5deg);
  opacity: 0.7;
}
.bamboo-stalk--3 {
  left: 30%;
  top: 50%;
  height: 60%;
  transform: rotate(12deg);
  opacity: 0.4;
}

.floating-leaf {
  position: absolute;
  font-size: 22px;
  opacity: 0.5;
  animation: float 14s linear infinite;
  text-shadow: 0 4px 10px rgba(0, 0, 0, 0.5);
}

.floating-leaf--1 {
  top: 15%;
  left: 12%;
  animation-delay: 0s;
}
.floating-leaf--2 {
  top: 70%;
  right: 18%;
  animation-delay: -5s;
}
.floating-leaf--3 {
  top: 40%;
  right: 8%;
  animation-delay: -10s;
}

@keyframes float {
  0% {
    transform: translate(0, 0) rotate(0deg);
  }
  50% {
    transform: translate(-20px, -30px) rotate(180deg);
  }
  100% {
    transform: translate(0, 0) rotate(360deg);
  }
}

.start-content {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 28px;
  width: 100%;
  max-width: 420px;
  text-align: center;
}

.start-emblem {
  position: relative;
  width: 128px;
  height: 128px;
  display: grid;
  place-items: center;
  margin-bottom: 18px;
}

.start-emblem__halo {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: radial-gradient(
    circle,
    var(--gold-glow) 0%,
    transparent 65%
  );
  animation: halo 4s ease-in-out infinite;
}

@keyframes halo {
  0%, 100% {
    transform: scale(1);
    opacity: 0.85;
  }
  50% {
    transform: scale(1.15);
    opacity: 1;
  }
}

.start-emblem__icon {
  position: relative;
  font-size: 80px;
  filter: drop-shadow(0 6px 18px rgba(0, 0, 0, 0.6));
  animation: bob 5s ease-in-out infinite;
}

@keyframes bob {
  0%, 100% {
    transform: translateY(0) rotate(-2deg);
  }
  50% {
    transform: translateY(-8px) rotate(2deg);
  }
}

.start-title {
  font-family: var(--font-display);
  font-weight: 600;
  letter-spacing: 0.04em;
  margin: 0;
  display: flex;
  flex-direction: column;
  line-height: 0.9;
}

.start-title__top {
  font-size: 44px;
  background: linear-gradient(180deg, #fff7d6 0%, var(--gold-primary) 50%, var(--gold-deep) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  text-shadow: 0 4px 16px rgba(255, 210, 80, 0.15);
}

.start-title__bot {
  font-size: 56px;
  font-style: italic;
  background: linear-gradient(180deg, var(--gold-primary) 0%, var(--gold-secondary) 60%, #8a6418 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  letter-spacing: 0.02em;
}

.start-tagline {
  margin: 14px 0 36px;
  font-family: var(--font-display);
  font-style: italic;
  font-size: 16px;
  letter-spacing: 0.08em;
  color: var(--text-secondary);
}

.start-links {
  margin-top: 22px;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text-secondary);
}

.link-dot {
  opacity: 0.4;
}

.link-btn {
  color: var(--gold-primary);
  text-decoration: underline;
  text-underline-offset: 3px;
  font-size: 13px;
  padding: 4px 6px;
  opacity: 0.85;
}

.link-btn:active {
  opacity: 1;
}

.start-disclaimer {
  margin-top: 26px;
  font-size: 11px;
  color: var(--text-tertiary);
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 28px;
  border-radius: 14px;
  font-weight: 700;
  font-size: 15px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.2s ease;
  overflow: hidden;
  user-select: none;
}

.btn:active {
  transform: scale(0.97);
}

.btn[disabled],
.btn:disabled {
  opacity: 0.45;
  pointer-events: none;
}

.btn--primary {
  background: var(--btn-primary-grad);
  color: var(--btn-text);
  box-shadow:
    0 8px 22px var(--shadow-glow),
    inset 0 1px 0 rgba(255, 255, 255, 0.45),
    inset 0 -2px 0 rgba(0, 0, 0, 0.15);
}

.btn--primary:active {
  box-shadow:
    0 4px 10px var(--shadow-glow),
    inset 0 1px 0 rgba(255, 255, 255, 0.3),
    inset 0 -1px 0 rgba(0, 0, 0, 0.2);
}

.btn--ghost {
  background: var(--soft-panel);
  border: 1px solid var(--border);
  color: var(--text-primary);
}

.btn--danger {
  background: linear-gradient(180deg, #ff7a7a, #d83434);
  color: #fff;
  box-shadow: 0 8px 18px rgba(216, 52, 52, 0.4);
}

.btn--large {
  padding: 18px 44px;
  font-size: 16px;
  border-radius: 18px;
}

.btn--wide {
  width: 100%;
}

/* Shine sweep on primary buttons */
.btn__shine {
  position: absolute;
  top: 0;
  left: -50%;
  width: 50%;
  height: 100%;
  background: linear-gradient(
    100deg,
    transparent 30%,
    rgba(255, 255, 255, 0.45) 50%,
    transparent 70%
  );
  animation: shine 3s ease-in-out infinite;
  pointer-events: none;
}

@keyframes shine {
  0% { left: -60%; }
  60% { left: 110%; }
  100% { left: 110%; }
}

.icon-btn {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: var(--soft-panel);
  border: 1px solid var(--border);
  display: grid;
  place-items: center;
  transition: transform 0.1s ease;
  flex-shrink: 0;
}

.icon-btn:active {
  transform: scale(0.92);
}

.icon-btn__glyph {
  font-size: 22px;
  line-height: 1;
  color: var(--text-primary);
}

.icon-btn--bonus {
  background: linear-gradient(180deg, rgba(255, 210, 80, 0.18), rgba(242, 169, 59, 0.08));
  border-color: rgba(255, 210, 80, 0.3);
  position: relative;
}

.icon-btn--bonus .icon-btn__glyph {
  font-size: 20px;
  filter: drop-shadow(0 0 6px var(--gold-glow));
}

.bonus-dot {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--error);
  box-shadow: 0 0 8px var(--error);
  animation: pulse 1.4s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.4); opacity: 0.6; }
}

/* ============================================================
   TOPBAR
   ============================================================ */
.topbar {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: linear-gradient(
    180deg,
    rgba(15, 17, 23, 0.95) 0%,
    rgba(15, 17, 23, 0.6) 100%
  );
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}

.topbar__title {
  flex: 1;
  text-align: center;
  font-family: var(--font-display);
  font-style: italic;
  font-size: 18px;
  letter-spacing: 0.06em;
  color: var(--text-primary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.topbar__title-icon {
  font-size: 16px;
  filter: drop-shadow(0 0 4px rgba(31, 143, 95, 0.4));
}

.topbar__stat {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 10px;
  background: var(--soft-panel);
  border: 1px solid var(--border);
  font-weight: 600;
  font-size: 14px;
  color: var(--gold-primary);
}

.topbar__stat-icon {
  font-size: 14px;
}

/* Game topbar */
.topbar--game {
  padding: 10px 12px;
}

.topbar-stats {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  border-radius: 12px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
}

.chip--coins {
  border-color: rgba(255, 210, 80, 0.25);
  color: var(--gold-primary);
  background: linear-gradient(180deg, rgba(255, 210, 80, 0.08), rgba(0, 0, 0, 0.3));
}

.chip__icon {
  font-size: 13px;
  filter: drop-shadow(0 0 4px var(--gold-glow));
}

.chip--bet {
  color: var(--text-primary);
}

.chip__label {
  font-size: 10px;
  letter-spacing: 0.12em;
  color: var(--text-tertiary);
  font-weight: 700;
}

.chip__value {
  font-variant-numeric: tabular-nums;
}

/* Coins value flash on change */
.chip--coins.flash {
  animation: coinFlash 0.6s ease;
}

@keyframes coinFlash {
  0% { transform: scale(1); }
  40% { transform: scale(1.1); box-shadow: 0 0 18px var(--gold-glow); }
  100% { transform: scale(1); }
}

/* ============================================================
   ROAD MAP SCREEN
   ============================================================ */
#roadmap-screen {
  background:
    radial-gradient(circle at 0% 0%, rgba(31, 143, 95, 0.12), transparent 50%),
    radial-gradient(circle at 100% 100%, rgba(255, 210, 80, 0.08), transparent 50%);
}

.roadmap-scroll {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  padding: 24px 12px 12px;
  position: relative;
}

.roadmap-scroll::before {
  /* subtle grain texture */
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    repeating-linear-gradient(
      45deg,
      rgba(255, 255, 255, 0.012) 0px,
      rgba(255, 255, 255, 0.012) 1px,
      transparent 1px,
      transparent 4px
    );
  pointer-events: none;
}

.roadmap-grid {
  position: relative;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  grid-auto-rows: minmax(78px, auto);
  gap: 10px 6px;
  padding-bottom: 20px;
  z-index: 1;
}

.level-node {
  width: 100%;
  aspect-ratio: 1 / 1;
  max-width: 64px;
  margin: 0 auto;
  border-radius: 50%;
  display: grid;
  place-items: center;
  position: relative;
  font-weight: 700;
  font-size: 16px;
  border: 2px solid var(--border);
  background: linear-gradient(180deg, #2a2f3c, #15171d);
  color: var(--text-secondary);
  transition: transform 0.12s ease, box-shadow 0.2s ease;
}

.level-node:active:not(:disabled) {
  transform: scale(0.92);
}

.level-node:disabled {
  cursor: default;
  opacity: 0.55;
}

.level-node__num {
  font-variant-numeric: tabular-nums;
}

/* Locked */
.level-node.locked {
  background: linear-gradient(180deg, #1d1f27, #0f1116);
  color: rgba(233, 236, 241, 0.25);
  border-color: rgba(255, 255, 255, 0.06);
}

.level-node.locked .level-node__num {
  display: none;
}

.level-node.locked::after {
  content: "🔒";
  font-size: 18px;
  opacity: 0.5;
}

/* Unlocked (completed but not active) */
.level-node.unlocked {
  background: linear-gradient(180deg, #2c3142, #1a1d27);
  color: var(--text-primary);
  border-color: rgba(255, 255, 255, 0.18);
}

/* Completed */
.level-node.completed {
  background: linear-gradient(180deg, var(--jade-primary), var(--jade-deep));
  color: #fff;
  border-color: rgba(255, 255, 255, 0.3);
  box-shadow: 0 4px 12px rgba(46, 125, 50, 0.4);
}

.level-node.completed .level-node__num {
  display: none;
}

.level-node.completed::after {
  content: "✓";
  font-size: 26px;
  font-weight: 800;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

/* Current */
.level-node.current {
  background: var(--btn-primary-grad);
  color: var(--btn-text);
  border-color: rgba(255, 255, 255, 0.6);
  box-shadow:
    0 0 0 4px rgba(255, 210, 80, 0.18),
    0 6px 18px var(--shadow-glow);
  animation: currentPulse 2s ease-in-out infinite;
  z-index: 2;
}

@keyframes currentPulse {
  0%, 100% {
    box-shadow:
      0 0 0 4px rgba(255, 210, 80, 0.18),
      0 6px 18px var(--shadow-glow);
  }
  50% {
    box-shadow:
      0 0 0 8px rgba(255, 210, 80, 0.1),
      0 6px 24px rgba(255, 210, 80, 0.4);
  }
}

/* Decorative milestones every 10 levels */
.level-node.milestone:not(.locked):not(.completed):not(.current) {
  border-color: rgba(255, 210, 80, 0.5);
  box-shadow: 0 0 12px rgba(255, 210, 80, 0.15);
}

.level-node.milestone.completed {
  background: linear-gradient(180deg, #f2a93b, #6d1f3b);
}

.roadmap-actions {
  flex-shrink: 0;
  padding: 12px 16px calc(16px + var(--safe-bottom));
  background: linear-gradient(180deg, transparent, rgba(0, 0, 0, 0.7));
}

/* ============================================================
   GAME SCREEN
   ============================================================ */
#game-screen {
  background:
    radial-gradient(ellipse at 50% 0%, rgba(255, 210, 80, 0.05), transparent 40%),
    radial-gradient(ellipse at 50% 100%, rgba(31, 143, 95, 0.06), transparent 50%);
}

.mission-card {
  flex-shrink: 0;
  margin: 10px 12px 6px;
  padding: 10px 14px;
  border-radius: 14px;
  background: linear-gradient(135deg,
    rgba(31, 143, 95, 0.1),
    rgba(15, 17, 23, 0.92));
  border: 1px solid rgba(31, 143, 95, 0.25);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.mission-card__head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}

.mission-card__chip {
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  background: rgba(31, 143, 95, 0.25);
  border: 1px solid rgba(31, 143, 95, 0.4);
  border-radius: 6px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: #b6e7c0;
}

.mission-card__title {
  font-family: var(--font-display);
  font-style: italic;
  font-size: 14px;
  color: var(--text-secondary);
}

.mission-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.mission {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  line-height: 1.3;
}

.mission__check {
  flex-shrink: 0;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 1.5px solid var(--text-tertiary);
  display: grid;
  place-items: center;
  font-size: 10px;
  background: transparent;
  transition: all 0.25s ease;
}

.mission.done .mission__check {
  background: var(--jade-primary);
  border-color: var(--jade-primary);
  color: #fff;
  box-shadow: 0 0 6px rgba(76, 175, 80, 0.4);
}

.mission.done .mission__check::after {
  content: "✓";
  font-weight: 700;
}

.mission__text {
  flex: 1;
  color: var(--text-primary);
}

.mission.done .mission__text {
  color: var(--text-secondary);
  text-decoration: line-through;
  text-decoration-color: rgba(255, 255, 255, 0.3);
}

.mission__progress {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  color: var(--gold-primary);
  font-size: 11px;
}

.mission.done .mission__progress {
  color: var(--jade-primary);
}

/* ============================================================
   SLOT GRID
   ============================================================ */
.grid-shell {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 6px 12px;
  min-height: 0;
}

.grid-frame {
  position: relative;
  width: 100%;
  max-width: min(100%, calc(100svh - 360px));
  aspect-ratio: 1 / 1;
  padding: 10px;
  border-radius: 22px;
  background:
    linear-gradient(135deg,
      rgba(255, 210, 80, 0.06),
      rgba(15, 17, 23, 0.7) 50%,
      rgba(109, 31, 59, 0.08)
    );
  border: 1px solid rgba(255, 210, 80, 0.18);
  box-shadow:
    0 12px 36px rgba(0, 0, 0, 0.4),
    inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.grid-frame::before {
  /* corner ornaments */
  content: "";
  position: absolute;
  inset: 4px;
  border-radius: 18px;
  background-image:
    radial-gradient(circle at 0% 0%, rgba(255, 210, 80, 0.1) 0px, transparent 14px),
    radial-gradient(circle at 100% 0%, rgba(255, 210, 80, 0.1) 0px, transparent 14px),
    radial-gradient(circle at 0% 100%, rgba(255, 210, 80, 0.1) 0px, transparent 14px),
    radial-gradient(circle at 100% 100%, rgba(255, 210, 80, 0.1) 0px, transparent 14px);
  pointer-events: none;
}

.slot-grid {
  position: relative;
  width: 100%;
  height: 100%;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  grid-template-rows: repeat(4, 1fr);
  gap: 4px;
  padding: 6px;
  background: rgba(0, 0, 0, 0.3);
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.04);
}

.cell {
  position: relative;
  display: grid;
  place-items: center;
  background: linear-gradient(180deg, #1f2230, #131521);
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.05);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
  overflow: hidden;
  transition: transform 0.2s ease, box-shadow 0.3s ease;
}

.cell__icon {
  font-size: clamp(22px, 7vw, 38px);
  line-height: 1;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.4));
  transition: transform 0.18s ease;
  user-select: none;
}

.cell.spinning .cell__icon {
  animation: spin-blur 0.08s linear infinite;
}

@keyframes spin-blur {
  0% { transform: translateY(-3px); filter: blur(0.6px); }
  50% { transform: translateY(0); filter: blur(0.6px); }
  100% { transform: translateY(3px); filter: blur(0.6px); }
}

.cell.settled .cell__icon {
  animation: settle 0.34s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes settle {
  0% { transform: translateY(-8px) scale(0.85); }
  60% { transform: translateY(2px) scale(1.08); }
  100% { transform: translateY(0) scale(1); }
}

.cell.winning {
  background: linear-gradient(180deg,
    rgba(255, 210, 80, 0.25),
    rgba(242, 169, 59, 0.12));
  border-color: var(--win-border);
  box-shadow:
    0 0 16px var(--win-glow),
    inset 0 0 20px rgba(255, 210, 80, 0.18);
  animation: cellGlow 1.2s ease-in-out infinite;
}

@keyframes cellGlow {
  0%, 100% {
    box-shadow:
      0 0 12px var(--win-glow),
      inset 0 0 18px rgba(255, 210, 80, 0.14);
  }
  50% {
    box-shadow:
      0 0 22px rgba(255, 210, 80, 0.45),
      inset 0 0 26px rgba(255, 210, 80, 0.22);
  }
}

.cell.winning .cell__icon {
  animation: winBounce 0.6s ease infinite alternate;
  filter: drop-shadow(0 0 6px var(--gold-glow));
}

@keyframes winBounce {
  from { transform: scale(1); }
  to { transform: scale(1.12); }
}

/* SVG win lines overlay */
.win-lines {
  position: absolute;
  inset: 16px;
  width: calc(100% - 32px);
  height: calc(100% - 32px);
  pointer-events: none;
  overflow: visible;
}

.win-line-glow {
  fill: none;
  stroke: rgba(255, 210, 80, 0.45);
  stroke-width: 4;
  stroke-linecap: round;
  stroke-linejoin: round;
  filter: blur(3px);
  vector-effect: non-scaling-stroke;
}

.win-line {
  fill: none;
  stroke: var(--gold-primary);
  stroke-width: 1.4;
  stroke-linecap: round;
  stroke-linejoin: round;
  vector-effect: non-scaling-stroke;
  stroke-dasharray: 200;
  stroke-dashoffset: 200;
  animation: drawLine 0.6s ease forwards;
}

@keyframes drawLine {
  to { stroke-dashoffset: 0; }
}

/* Free spin banner inside grid frame */
.free-spin-banner {
  position: absolute;
  top: -12px;
  left: 50%;
  transform: translateX(-50%);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  background: linear-gradient(180deg, var(--gold-primary), var(--gold-deep));
  color: var(--btn-text);
  border-radius: 10px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.1em;
  box-shadow: 0 4px 12px var(--shadow-glow);
  z-index: 5;
  animation: bannerPop 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes bannerPop {
  from { transform: translateX(-50%) scale(0.6); opacity: 0; }
  to { transform: translateX(-50%) scale(1); opacity: 1; }
}

.free-spin-banner__bolt {
  font-size: 12px;
  filter: drop-shadow(0 0 3px #fff);
}

.free-spin-banner__count {
  display: inline-grid;
  place-items: center;
  min-width: 18px;
  height: 18px;
  padding: 0 4px;
  border-radius: 9px;
  background: rgba(0, 0, 0, 0.25);
  font-size: 11px;
}

/* Win toast on the grid */
.win-toast {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.6);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 12px 22px;
  background: linear-gradient(180deg,
    rgba(0, 0, 0, 0.8),
    rgba(15, 17, 23, 0.92));
  border: 1px solid var(--win-border);
  border-radius: 16px;
  box-shadow: 0 0 30px var(--win-glow);
  z-index: 8;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.18s ease, transform 0.32s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.win-toast.show {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}

.win-toast__label {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.16em;
  color: var(--text-secondary);
}

.win-toast__amount {
  font-family: var(--font-display);
  font-style: italic;
  font-size: 32px;
  font-weight: 700;
  background: var(--btn-primary-grad);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  text-shadow: 0 4px 14px var(--shadow-glow);
  font-variant-numeric: tabular-nums;
}

/* ============================================================
   FORTUNE METER
   ============================================================ */
.fortune {
  flex-shrink: 0;
  margin: 6px 14px;
  padding: 8px 12px;
  background: var(--soft-panel);
  border: 1px solid var(--border);
  border-radius: 12px;
}

.fortune__head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.fortune__icon {
  font-size: 13px;
  margin-right: 4px;
  filter: drop-shadow(0 0 3px var(--gold-glow));
}

.fortune__pct {
  color: var(--gold-primary);
  font-variant-numeric: tabular-nums;
}

.fortune__bar {
  position: relative;
  height: 10px;
  background: rgba(0, 0, 0, 0.55);
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.fortune__fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg,
    var(--burgundy-primary) 0%,
    var(--gold-secondary) 50%,
    var(--gold-primary) 100%);
  border-radius: 6px;
  transition: width 0.5s ease;
  box-shadow: 0 0 10px var(--shadow-glow);
}

.fortune__shimmer {
  position: absolute;
  top: 0;
  left: -30%;
  width: 30%;
  height: 100%;
  background: linear-gradient(90deg,
    transparent,
    rgba(255, 255, 255, 0.4),
    transparent);
  animation: shimmer 2.4s linear infinite;
}

@keyframes shimmer {
  0% { left: -30%; }
  100% { left: 110%; }
}

.fortune.full .fortune__fill {
  animation: fortuneFull 1s ease-in-out infinite alternate;
}

@keyframes fortuneFull {
  from { box-shadow: 0 0 10px var(--shadow-glow); }
  to { box-shadow: 0 0 22px var(--gold-primary); }
}

/* ============================================================
   ACTION BAR
   ============================================================ */
.actionbar {
  flex-shrink: 0;
  display: grid;
  grid-template-columns: 1fr 1.4fr 1fr;
  gap: 10px;
  padding: 10px 14px calc(12px + var(--safe-bottom));
  background: linear-gradient(180deg,
    transparent,
    rgba(0, 0, 0, 0.6) 30%);
}

.action-btn {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 12px 6px;
  background: linear-gradient(180deg, #2a2f3c, #15171d);
  border: 1px solid var(--border);
  border-radius: 14px;
  color: var(--text-primary);
  font-weight: 700;
  font-size: 11px;
  letter-spacing: 0.08em;
  transition: transform 0.1s ease;
  user-select: none;
}

.action-btn:active:not(:disabled) {
  transform: scale(0.95);
}

.action-btn:disabled {
  opacity: 0.5;
  pointer-events: none;
}

.action-btn__icon {
  font-size: 18px;
  line-height: 1;
}

.action-btn__label {
  font-weight: 800;
  letter-spacing: 0.1em;
}

.action-btn--spin {
  background: var(--btn-primary-grad);
  color: var(--btn-text);
  font-size: 16px;
  border: 1px solid rgba(255, 255, 255, 0.4);
  box-shadow:
    0 8px 22px var(--shadow-glow),
    inset 0 1px 0 rgba(255, 255, 255, 0.45),
    inset 0 -2px 0 rgba(0, 0, 0, 0.18);
}

.action-btn--spin .action-btn__label {
  font-size: 16px;
  letter-spacing: 0.16em;
}

.action-btn__ring {
  position: absolute;
  inset: -3px;
  border-radius: 16px;
  border: 2px solid transparent;
  background: linear-gradient(180deg, var(--gold-primary), transparent) border-box;
  -webkit-mask:
    linear-gradient(#fff 0 0) padding-box,
    linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.action-btn--spin:not(:disabled):active .action-btn__ring {
  opacity: 1;
}

/* ============================================================
   MODALS
   ============================================================ */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: var(--modal-bg);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 100;
  animation: backdropIn 0.2s ease;
}

@keyframes backdropIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal {
  position: fixed;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%);
  width: 100%;
  max-width: 480px;
  max-height: calc(100svh - var(--safe-top) - 24px);
  background: linear-gradient(180deg, #1d2030 0%, #14161e 100%);
  border-top: 1px solid rgba(255, 210, 80, 0.18);
  border-radius: 22px 22px 0 0;
  box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.5);
  z-index: 101;
  display: flex;
  flex-direction: column;
  padding-bottom: var(--safe-bottom);
  animation: modalIn 0.32s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes modalIn {
  from { transform: translate(-50%, 100%); }
  to { transform: translate(-50%, 0); }
}

.modal__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px 12px;
  border-bottom: 1px solid var(--border);
  position: relative;
}

.modal__head::before {
  /* drag handle */
  content: "";
  position: absolute;
  top: 6px;
  left: 50%;
  transform: translateX(-50%);
  width: 36px;
  height: 4px;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.18);
}

.modal__title {
  margin: 0;
  font-family: var(--font-display);
  font-style: italic;
  font-size: 22px;
  font-weight: 600;
  color: var(--gold-primary);
  letter-spacing: 0.02em;
}

.modal__close {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--soft-panel);
  border: 1px solid var(--border);
  color: var(--text-primary);
  font-size: 22px;
  line-height: 1;
  display: grid;
  place-items: center;
}

.modal__body {
  flex: 1;
  overflow-y: auto;
  padding: 16px 18px 22px;
  -webkit-overflow-scrolling: touch;
}

.modal--scrolly .modal__body {
  max-height: 60svh;
}

.modal__sub {
  margin: 0 0 14px;
  color: var(--text-secondary);
  font-size: 13px;
}

.modal__sub--center {
  text-align: center;
}

.modal__body--list {
  padding: 12px;
}

.modal__body--center {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.modal__body--prose h4 {
  margin: 18px 0 6px;
  color: var(--gold-primary);
  font-size: 14px;
  letter-spacing: 0.04em;
  font-weight: 700;
}

.modal__body--prose h4:first-child {
  margin-top: 4px;
}

.modal__body--prose p {
  margin: 0 0 8px;
  font-size: 13.5px;
  line-height: 1.55;
  color: var(--text-secondary);
}

.modal__body--prose strong {
  color: var(--text-primary);
}

.modal-actions {
  display: flex;
  gap: 10px;
  margin-top: 16px;
}

.modal-actions .btn {
  flex: 1;
}

/* Level Brief modal */
.brief-level-tag {
  display: inline-block;
  background: linear-gradient(135deg, var(--gold) 0%, #f0b53d 100%);
  color: #2a1a0a;
  font-weight: 800;
  font-size: 12px;
  letter-spacing: 1.5px;
  padding: 4px 10px;
  border-radius: 999px;
  margin-bottom: 6px;
  text-transform: uppercase;
}

.brief-missions {
  list-style: none;
  padding: 0;
  margin: 4px 0 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.brief-missions li {
  background: rgba(255, 210, 80, 0.06);
  border: 1px solid rgba(255, 210, 80, 0.18);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 14px;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 10px;
  line-height: 1.35;
}

.brief-missions li::before {
  content: "▸";
  color: var(--gold);
  font-size: 13px;
  flex-shrink: 0;
}

.brief-rewards {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: linear-gradient(180deg, rgba(76, 175, 80, 0.14), rgba(76, 175, 80, 0.04));
  border: 1px solid rgba(76, 175, 80, 0.32);
  border-radius: 10px;
  padding: 10px 14px;
  margin-bottom: 4px;
}

.brief-rewards__label {
  font-size: 11px;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 1.5px;
}

.brief-rewards__value {
  font-size: 16px;
  font-weight: 700;
  color: var(--jade);
}

#brief-modal .modal__sub--center {
  margin-bottom: 10px;
}

/* Bet modal grid */
.bet-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
}

.bet-cell {
  padding: 12px 4px;
  border-radius: 10px;
  background: var(--soft-panel);
  border: 1px solid var(--border);
  font-weight: 700;
  font-size: 14px;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
  transition: all 0.15s ease;
}

.bet-cell:active {
  transform: scale(0.94);
}

.bet-cell.active {
  background: var(--btn-primary-grad);
  color: var(--btn-text);
  border-color: rgba(255, 255, 255, 0.4);
  box-shadow: 0 4px 14px var(--shadow-glow);
}

/* Menu items */
.menu-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 14px;
  background: var(--soft-panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  margin-bottom: 8px;
  font-size: 15px;
  color: var(--text-primary);
  transition: background 0.15s ease;
}

.menu-item:active {
  background: rgba(255, 255, 255, 0.07);
}

.menu-item__icon {
  font-size: 20px;
  width: 28px;
  text-align: center;
}

.menu-item__label {
  flex: 1;
  text-align: left;
}

.menu-item__chev {
  color: var(--text-tertiary);
  font-size: 22px;
  font-weight: 300;
}

/* Toggle */
.toggle-row {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px;
  background: var(--soft-panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  margin-bottom: 8px;
  font-size: 15px;
  color: var(--text-primary);
  cursor: pointer;
}

.toggle-row__label {
  display: inline-flex;
  align-items: center;
  gap: 12px;
}

.toggle-row__icon {
  font-size: 18px;
  width: 22px;
  text-align: center;
}

.toggle {
  position: relative;
  display: inline-block;
}

.toggle input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle__track {
  display: block;
  width: 44px;
  height: 26px;
  background: rgba(255, 255, 255, 0.12);
  border-radius: 13px;
  transition: background 0.2s ease;
  position: relative;
}

.toggle__thumb {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #fff;
  transition: left 0.2s ease, background 0.2s ease;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

.toggle input:checked + .toggle__track {
  background: var(--jade-accent);
}

.toggle input:checked + .toggle__track .toggle__thumb {
  left: 21px;
}

/* Paytable */
.paytable {
  display: grid;
  grid-template-columns: 1fr;
  gap: 6px;
  margin-bottom: 14px;
}

.paytable-row {
  display: grid;
  grid-template-columns: 36px 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  background: var(--soft-panel);
  border: 1px solid var(--border);
  border-radius: 10px;
}

.paytable-row.dead {
  opacity: 0.5;
}

.paytable-row__sym {
  font-size: 24px;
  text-align: center;
}

.paytable-row__name {
  font-size: 13px;
  color: var(--text-primary);
}

.paytable-row__name small {
  display: block;
  color: var(--text-tertiary);
  font-size: 10px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.paytable-row__pay {
  display: flex;
  gap: 10px;
  font-size: 12px;
  color: var(--gold-primary);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.paytable-row__pay span small {
  display: block;
  color: var(--text-tertiary);
  font-size: 9px;
  font-weight: 500;
  text-align: center;
  letter-spacing: 0.08em;
}

.paytable-row.dead .paytable-row__pay {
  color: var(--text-tertiary);
}

.paytable-info {
  font-size: 11px;
  color: var(--text-tertiary);
  line-height: 1.6;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}

.paytable-info p {
  margin: 4px 0;
}

/* Reset */
.reset-icon {
  font-size: 48px;
  text-align: center;
  margin: 8px 0 14px;
}

.reset-cooldown {
  text-align: center;
  color: var(--warning);
  font-weight: 700;
  font-size: 14px;
  margin: 12px 0;
  padding: 10px;
  background: rgba(242, 169, 59, 0.08);
  border: 1px solid rgba(242, 169, 59, 0.2);
  border-radius: 10px;
  font-variant-numeric: tabular-nums;
}

/* Bonus modal */
.bonus-gift {
  font-size: 80px;
  margin: 6px 0 14px;
  filter: drop-shadow(0 8px 16px var(--shadow-glow));
  animation: bonusBob 2s ease-in-out infinite;
}

@keyframes bonusBob {
  0%, 100% { transform: translateY(0) rotate(-3deg); }
  50% { transform: translateY(-6px) rotate(3deg); }
}

.bonus-state {
  width: 100%;
}

.bonus-headline {
  font-family: var(--font-display);
  font-size: 22px;
  font-style: italic;
  margin: 0 0 6px;
  color: var(--text-primary);
}

.bonus-amount {
  font-size: 28px;
  font-weight: 700;
  margin: 6px 0 18px;
  color: var(--gold-primary);
  font-variant-numeric: tabular-nums;
}

.bonus-sub {
  margin: 4px 0;
  color: var(--text-secondary);
  font-size: 13px;
}

.bonus-countdown {
  margin: 8px 0 12px;
  font-size: 32px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--warning);
  letter-spacing: 0.06em;
}

/* Level complete modal */
.modal__body--celebrate {
  position: relative;
  padding: 30px 18px 22px;
  overflow: hidden;
}

.celebrate-burst {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.celebrate-burst span {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--gold-primary);
  box-shadow: 0 0 8px var(--gold-glow);
  animation: burst 1.4s ease-out infinite;
}

.celebrate-burst span:nth-child(1) { --bx: 80px; --by: -60px; animation-delay: 0s; }
.celebrate-burst span:nth-child(2) { --bx: -80px; --by: -60px; animation-delay: 0.1s; background: var(--jade-primary);}
.celebrate-burst span:nth-child(3) { --bx: 100px; --by: 20px; animation-delay: 0.2s; }
.celebrate-burst span:nth-child(4) { --bx: -100px; --by: 20px; animation-delay: 0.3s; background: var(--gold-secondary);}
.celebrate-burst span:nth-child(5) { --bx: 60px; --by: 80px; animation-delay: 0.4s; }
.celebrate-burst span:nth-child(6) { --bx: -60px; --by: 80px; animation-delay: 0.5s; background: var(--jade-primary);}
.celebrate-burst span:nth-child(7) { --bx: 0; --by: -90px; animation-delay: 0.6s; background: var(--gold-secondary);}
.celebrate-burst span:nth-child(8) { --bx: 0; --by: 100px; animation-delay: 0.7s; }

@keyframes burst {
  0% {
    transform: translate(-50%, -50%) translate(0, 0) scale(0.4);
    opacity: 0;
  }
  20% { opacity: 1; }
  100% {
    transform: translate(-50%, -50%) translate(var(--bx), var(--by)) scale(1);
    opacity: 0;
  }
}

.celebrate-emblem {
  font-size: 64px;
  margin: 6px 0 4px;
  filter: drop-shadow(0 8px 18px var(--shadow-glow));
  animation: bob 2.4s ease-in-out infinite;
}

.celebrate-kicker {
  margin: 0;
  font-size: 11px;
  letter-spacing: 0.24em;
  font-weight: 700;
  color: var(--jade-primary);
}

.celebrate-title {
  margin: 6px 0 14px;
  font-family: var(--font-display);
  font-style: italic;
  font-size: 38px;
  font-weight: 600;
  background: var(--btn-primary-grad);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.celebrate-rewards {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin: 12px 0;
  flex-wrap: wrap;
}

.celebrate-reward {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  background: var(--soft-panel);
  border: 1px solid rgba(255, 210, 80, 0.25);
  border-radius: 12px;
  font-weight: 700;
  font-size: 15px;
  color: var(--gold-primary);
  font-variant-numeric: tabular-nums;
}

.celebrate-reward__icon {
  font-size: 18px;
}

/* ============================================================
   TOAST
   ============================================================ */
.toast {
  position: fixed;
  bottom: calc(28px + var(--safe-bottom));
  left: 50%;
  transform: translateX(-50%);
  padding: 10px 18px;
  background: rgba(15, 17, 23, 0.95);
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--text-primary);
  font-size: 13px;
  font-weight: 600;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.5);
  z-index: 200;
  animation: toastIn 0.25s ease;
  max-width: calc(100% - 40px);
  text-align: center;
}

.toast--warn {
  border-color: rgba(242, 169, 59, 0.4);
  color: var(--warning);
}

@keyframes toastIn {
  from { opacity: 0; transform: translate(-50%, 20px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

/* ============================================================
   UTILITIES & RESPONSIVE TWEAKS
   ============================================================ */
@media (max-height: 640px) {
  .mission-card {
    margin: 6px 12px 4px;
    padding: 8px 12px;
  }
  .mission-card__head {
    margin-bottom: 4px;
  }
  .mission { font-size: 11px; }
  .fortune { padding: 6px 10px; margin: 4px 14px; }
  .actionbar { padding-top: 6px; }
}

@media (max-width: 340px) {
  .start-title__top { font-size: 36px; }
  .start-title__bot { font-size: 46px; }
  .chip { padding: 6px 9px; font-size: 12px; }
  .topbar { padding: 8px 10px; }
}

@media (min-height: 800px) {
  .grid-frame {
    max-width: min(100%, calc(100svh - 380px));
  }
}
