/* ════════════════════════════════════════════════════
   VARIABLES & RESET
════════════════════════════════════════════════════ */
:root {
  --bg:              #0a0a0f;
  --surface:         #13131c;
  --surface2:        #1c1c2a;
  --surface3:        #222235;
  --border:          rgba(255,255,255,0.07);
  --border-hover:    rgba(255,255,255,0.14);

  --accent-r:        #ff3d5a;
  --accent-r-dim:    rgba(255, 61, 90, 0.18);
  --accent-r-glow:   rgba(255, 61, 90, 0.45);

  --accent-y:        #ffd84d;
  --accent-y-dim:    rgba(255, 216, 77, 0.18);
  --accent-y-glow:   rgba(255, 216, 77, 0.45);

  --green:           #4ade80;
  --green-glow:      rgba(74, 222, 128, 0.4);

  --diff-easy:       #4ade80;
  --diff-easy-glow:  rgba(74,222,128,0.35);
  --diff-medium:     #fbbf24;
  --diff-medium-glow:rgba(251,191,36,0.35);
  --diff-hard:       #f97316;
  --diff-hard-glow:  rgba(249,115,22,0.35);
  --diff-expert:     #ef4444;
  --diff-expert-glow:rgba(239,68,68,0.4);

  --hole:            #07070e;
  --board-blue:      #14143a;
  --text:            #f0f0f8;
  --text-dim:        #9898b8;
  --muted:           #5a5a78;

  --radius-sm:       10px;
  --radius:          16px;
  --radius-lg:       24px;

  --font-display:    'Bebas Neue', sans-serif;
  --font-body:       'DM Sans', sans-serif;
  --transition:      0.2s ease;
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html { scroll-behavior: smooth; }

body {
  background: var(--bg);
  font-family: var(--font-body);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
}

/* Background mesh — always present */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse 80% 50% at 15% 10%,  rgba(255,61,90,0.07)  0%, transparent 60%),
    radial-gradient(ellipse 60% 40% at 85% 85%,  rgba(255,216,77,0.05) 0%, transparent 55%),
    radial-gradient(ellipse 100% 80% at 50% 50%, rgba(20,20,58,0.5)    0%, transparent 70%);
  pointer-events: none;
  z-index: 0;
}

/* Grain texture */
body::after {
  content: '';
  position: fixed;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.03'/%3E%3C/svg%3E");
  background-size: 180px;
  pointer-events: none;
  z-index: 0;
  opacity: .5;
}


/* ════════════════════════════════════════════════════
   SCREEN SYSTEM
════════════════════════════════════════════════════ */
.screen {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px 48px;
  animation: fade-up 0.4s ease both;
}

.screen.hidden {
  display: none;
}

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


/* ════════════════════════════════════════════════════
   SHARED TYPOGRAPHY
════════════════════════════════════════════════════ */
.eyebrow {
  font-size: 11px;
  letter-spacing: 4px;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 500;
}

.logo {
  font-family: var(--font-display);
  font-size: clamp(52px, 10vw, 80px);
  line-height: 1;
  letter-spacing: 2px;
  background: linear-gradient(135deg, #fff 30%, var(--muted) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.logo span {
  -webkit-text-fill-color: var(--accent-r);
}

.logo.small {
  font-size: clamp(24px, 5vw, 36px);
}


/* ════════════════════════════════════════════════════
   SHARED BUTTONS
════════════════════════════════════════════════════ */
.btn {
  padding: 11px 28px;
  border-radius: 50px;
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  cursor: pointer;
  border: 1px solid var(--border);
  transition: all var(--transition);
  white-space: nowrap;
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent-r), #c41030);
  color: #fff;
  border-color: transparent;
  box-shadow: 0 4px 16px var(--accent-r-glow);
}
.btn-primary:hover  { transform: translateY(-2px); box-shadow: 0 8px 28px var(--accent-r-glow); }
.btn-primary:active { transform: translateY(0); }

.btn-ghost {
  background: var(--surface);
  color: var(--text-dim);
}
.btn-ghost:hover { background: var(--surface2); color: var(--text); transform: translateY(-1px); }

.btn-back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-dim);
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 500;
  padding: 8px 16px;
  border-radius: 50px;
  cursor: pointer;
  transition: all var(--transition);
}
.btn-back:hover { background: var(--surface2); color: var(--text); border-color: var(--border-hover); }
.btn-back.small { font-size: 12px; padding: 6px 14px; }


/* ════════════════════════════════════════════════════
   MODE SELECTION SCREEN
════════════════════════════════════════════════════ */
.mode-container {
  width: 100%;
  max-width: 520px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 40px;
}

.mode-header {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.mode-lead {
  color: var(--text-dim);
  font-size: 15px;
  margin-top: 4px;
}

.mode-cards {
  display: flex;
  flex-direction: column;
  gap: 14px;
  width: 100%;
}

.mode-card {
  display: flex;
  align-items: center;
  gap: 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 22px 24px;
  cursor: pointer;
  text-align: left;
  color: var(--text);
  font-family: var(--font-body);
  transition: all 0.25s ease;
  position: relative;
  overflow: hidden;
}

.mode-card::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(255,255,255,0.03) 0%, transparent 60%);
  pointer-events: none;
}

.mode-card:hover {
  border-color: var(--border-hover);
  background: var(--surface2);
  transform: translateY(-3px);
  box-shadow: 0 12px 40px rgba(0,0,0,0.4);
}

.mode-card:active { transform: translateY(-1px); }

.mode-card-icon {
  font-size: 36px;
  flex-shrink: 0;
  width: 56px;
  height: 56px;
  background: var(--surface3);
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.mode-card-body {
  flex: 1;
}

.mode-card-body h2 {
  font-size: 17px;
  font-weight: 700;
  margin-bottom: 4px;
}

.mode-card-body p {
  font-size: 13px;
  color: var(--text-dim);
  line-height: 1.5;
}

.mode-card-arrow {
  font-size: 20px;
  color: var(--muted);
  transition: transform var(--transition), color var(--transition);
}
.mode-card:hover .mode-card-arrow { transform: translateX(4px); color: var(--text); }


/* ════════════════════════════════════════════════════
   DIFFICULTY SCREEN
════════════════════════════════════════════════════ */
.diff-container {
  width: 100%;
  max-width: 540px;
  display: flex;
  flex-direction: column;
  gap: 28px;
}

.diff-header {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.diff-title {
  font-family: var(--font-display);
  font-size: 40px;
  letter-spacing: 1px;
  color: var(--text);
}

.diff-cards {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.diff-card {
  display: flex;
  align-items: center;
  gap: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  cursor: pointer;
  text-align: left;
  color: var(--text);
  font-family: var(--font-body);
  transition: all 0.22s ease;
  position: relative;
  overflow: hidden;
}

.diff-card:hover {
  border-color: var(--border-hover);
  background: var(--surface2);
  transform: translateX(5px);
}

.diff-card:active { transform: translateX(2px); }

.diff-badge {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  padding: 4px 12px;
  border-radius: 50px;
  flex-shrink: 0;
  min-width: 72px;
  text-align: center;
}

.diff-badge.easy   { background: rgba(74,222,128,0.15);  color: var(--diff-easy);   border: 1px solid rgba(74,222,128,0.3); }
.diff-badge.medium { background: rgba(251,191,36,0.15);  color: var(--diff-medium); border: 1px solid rgba(251,191,36,0.3); }
.diff-badge.hard   { background: rgba(249,115,22,0.15);  color: var(--diff-hard);   border: 1px solid rgba(249,115,22,0.3); }
.diff-badge.expert { background: rgba(239,68,68,0.15);   color: var(--diff-expert); border: 1px solid rgba(239,68,68,0.3); }

.diff-card:hover .diff-badge.easy   { box-shadow: 0 0 12px var(--diff-easy-glow); }
.diff-card:hover .diff-badge.medium { box-shadow: 0 0 12px var(--diff-medium-glow); }
.diff-card:hover .diff-badge.hard   { box-shadow: 0 0 12px var(--diff-hard-glow); }
.diff-card:hover .diff-badge.expert { box-shadow: 0 0 12px var(--diff-expert-glow); }

.diff-info {
  flex: 1;
}

.diff-info h3 {
  font-size: 15px;
  font-weight: 700;
  margin-bottom: 3px;
}

.diff-info p {
  font-size: 12px;
  color: var(--text-dim);
  line-height: 1.5;
}

.diff-stars {
  font-size: 14px;
  color: var(--muted);
  letter-spacing: 2px;
}


/* ════════════════════════════════════════════════════
   GAME SCREEN — LAYOUT
════════════════════════════════════════════════════ */
.wrapper {
  width: 100%;
  max-width: 680px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 22px;
}

/* ── Game Header ── */
.game-header {
  width: 100%;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 12px;
}

.header-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.mode-badge {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--muted);
  background: var(--surface2);
  border: 1px solid var(--border);
  padding: 3px 12px;
  border-radius: 50px;
}

.header-right {
  display: flex;
  justify-content: flex-end;
}

.diff-indicator {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-dim);
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 5px 12px;
  border-radius: 50px;
}

.diff-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
}

.diff-indicator.easy   .diff-dot { background: var(--diff-easy);   box-shadow: 0 0 6px var(--diff-easy-glow); }
.diff-indicator.medium .diff-dot { background: var(--diff-medium); box-shadow: 0 0 6px var(--diff-medium-glow); }
.diff-indicator.hard   .diff-dot { background: var(--diff-hard);   box-shadow: 0 0 6px var(--diff-hard-glow); }
.diff-indicator.expert .diff-dot { background: var(--diff-expert); box-shadow: 0 0 6px var(--diff-expert-glow); }

.diff-indicator.easy   { color: var(--diff-easy); }
.diff-indicator.medium { color: var(--diff-medium); }
.diff-indicator.hard   { color: var(--diff-hard); }
.diff-indicator.expert { color: var(--diff-expert); }


/* ── Scoreboard ── */
.scoreboard {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 12px;
  width: 100%;
}

.player-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 20px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  transition: border-color 0.3s, box-shadow 0.3s;
  position: relative;
  overflow: hidden;
}

.player-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  border-radius: 3px 3px 0 0;
}

.player-card.red::before    { background: var(--accent-r); }
.player-card.yellow::before { background: var(--accent-y); }

.player-card.active {
  border-color: rgba(255,255,255,0.14);
  box-shadow: 0 4px 20px rgba(0,0,0,0.4);
}

.player-card.red.active    { box-shadow: 0 0 28px var(--accent-r-glow), 0 4px 20px rgba(0,0,0,0.4); }
.player-card.yellow.active { box-shadow: 0 0 28px var(--accent-y-glow), 0 4px 20px rgba(0,0,0,0.4); }

.player-card.yellow { text-align: right; }

.player-name-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.player-card.yellow .player-name-row { flex-direction: row-reverse; }

.chip {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  flex-shrink: 0;
}

.chip.red    { background: var(--accent-r); box-shadow: 0 0 8px var(--accent-r-glow); }
.chip.yellow { background: var(--accent-y); box-shadow: 0 0 8px var(--accent-y-glow); }

.player-name {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--muted);
}

.player-score {
  font-family: var(--font-display);
  font-size: 38px;
  line-height: 1;
}

.vs-badge {
  font-family: var(--font-display);
  font-size: 22px;
  color: var(--muted);
  letter-spacing: 2px;
}


/* ── Status Bar ── */
.status-bar {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 50px;
  padding: 10px 20px;
  font-size: 14px;
  font-weight: 500;
  letter-spacing: .2px;
  min-height: 44px;
  display: flex;
  align-items: center;
  gap: 10px;
  transition: all 0.3s;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
  animation: pulse 1.4s ease-in-out infinite;
}

.status-dot.red    { background: var(--accent-r); box-shadow: 0 0 6px var(--accent-r); }
.status-dot.yellow { background: var(--accent-y); box-shadow: 0 0 6px var(--accent-y); }
.status-dot.win    { background: var(--green);    box-shadow: 0 0 6px var(--green);    animation: none; }
.status-dot.draw   { background: var(--muted);    animation: none; }

@keyframes pulse {
  0%, 100% { opacity: 1;  transform: scale(1); }
  50%       { opacity: .4; transform: scale(.75); }
}

/* AI Thinking dots */
.ai-thinking {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-left: auto;
}

.think-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--accent-y);
  animation: think 1.2s ease-in-out infinite;
}

.think-dot:nth-child(1) { animation-delay: 0s; }
.think-dot:nth-child(2) { animation-delay: 0.18s; }
.think-dot:nth-child(3) { animation-delay: 0.36s; }

@keyframes think {
  0%, 80%, 100% { transform: scale(.6); opacity: .3; }
  40%           { transform: scale(1);  opacity: 1; }
}


/* ── Board ── */
.board-outer {
  width: 100%;
  background: var(--board-blue);
  border: 1px solid rgba(255,255,255,0.07);
  border-radius: 20px;
  padding: 16px;
  box-shadow:
    0 0 0 1px rgba(255,255,255,0.025),
    0 24px 64px rgba(0,0,0,0.65),
    0 4px 12px rgba(0,0,0,0.4),
    inset 0 1px 0 rgba(255,255,255,0.05);
  position: relative;
}

.board-outer::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 20px;
  background: linear-gradient(145deg, rgba(255,255,255,0.03) 0%, transparent 50%);
  pointer-events: none;
}

/* Column hover indicators */
.col-indicators {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 8px;
  margin-bottom: 8px;
}

.col-indicator {
  height: 6px;
  border-radius: 3px;
  background: transparent;
  transition: background 0.2s, box-shadow 0.2s;
}

.col-indicator.hover-red    { background: var(--accent-r); box-shadow: 0 0 8px var(--accent-r-glow); }
.col-indicator.hover-yellow { background: var(--accent-y); box-shadow: 0 0 8px var(--accent-y-glow); }

/* Grid */
.board-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  grid-template-rows: repeat(6, 1fr);
  gap: 8px;
}

/* Cell */
.cell {
  aspect-ratio: 1;
  background: var(--hole);
  border-radius: 50%;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  box-shadow:
    inset 0 2px 8px rgba(0,0,0,0.7),
    inset 0 -1px 2px rgba(255,255,255,0.025);
  transition: transform 0.1s;
}

.cell:hover  { transform: scale(1.05); }
.cell.no-interact { cursor: default; }
.cell.no-interact:hover { transform: none; }

/* Token / inner disc */
.cell-inner {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  transform: translateY(-130%);
  transition: none;
}

.cell-inner.drop {
  animation: drop-in var(--drop-dur, .35s) cubic-bezier(0.34, 1.35, 0.64, 1) forwards;
}

@keyframes drop-in {
  from { transform: translateY(var(--drop-from, -130%)); }
  to   { transform: translateY(0); }
}

.cell-inner.red {
  background: radial-gradient(circle at 35% 35%, #ff7088, var(--accent-r) 55%, #9e001c);
  box-shadow:
    0 0 18px var(--accent-r-glow),
    inset 0 -3px 6px rgba(0,0,0,0.35),
    inset 0 2px 5px rgba(255,255,255,0.22);
}

.cell-inner.yellow {
  background: radial-gradient(circle at 35% 35%, #ffef9a, var(--accent-y) 55%, #a07800);
  box-shadow:
    0 0 18px var(--accent-y-glow),
    inset 0 -3px 6px rgba(0,0,0,0.3),
    inset 0 2px 5px rgba(255,255,255,0.32);
}

.cell-inner.win-flash {
  animation: win-pulse 0.55s ease-in-out infinite alternate;
}

@keyframes win-pulse {
  from { filter: brightness(1)   saturate(1); }
  to   { filter: brightness(1.6) saturate(1.4); }
}


/* ── Controls ── */
.controls {
  display: flex;
  gap: 10px;
}


/* ════════════════════════════════════════════════════
   WIN / RESULT OVERLAY
════════════════════════════════════════════════════ */
.win-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.78);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.35s ease;
  padding: 24px;
}

.win-overlay.show {
  opacity: 1;
  pointer-events: all;
}

.win-card {
  background: var(--surface);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: var(--radius-lg);
  padding: 44px 52px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  box-shadow: 0 32px 80px rgba(0,0,0,0.65), inset 0 1px 0 rgba(255,255,255,0.06);
  transform: scale(.86) translateY(24px);
  transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
  max-width: 380px;
  width: 100%;
}

.win-overlay.show .win-card {
  transform: scale(1) translateY(0);
}

.win-emoji { font-size: 54px; }

.win-title {
  font-family: var(--font-display);
  font-size: 46px;
  letter-spacing: 2px;
  line-height: 1;
}

.win-title.red    { color: var(--accent-r); text-shadow: 0 0 40px var(--accent-r-glow); }
.win-title.yellow { color: var(--accent-y); text-shadow: 0 0 40px var(--accent-y-glow); }
.win-title.draw   { color: var(--muted); }

.win-subtitle {
  font-size: 14px;
  color: var(--text-dim);
  font-weight: 400;
  line-height: 1.5;
}

.win-btns {
  display: flex;
  gap: 10px;
  margin-top: 8px;
  flex-wrap: wrap;
  justify-content: center;
}


/* ════════════════════════════════════════════════════
   UTILITY
════════════════════════════════════════════════════ */
.hidden { display: none !important; }


/* ════════════════════════════════════════════════════
   RESPONSIVE
════════════════════════════════════════════════════ */
@media (max-width: 520px) {
  .board-outer { padding: 10px; }
  .board-grid  { gap: 5px; }
  .col-indicators { gap: 5px; }
  .scoreboard  { gap: 8px; }
  .player-card { padding: 10px 12px; }
  .player-score { font-size: 28px; }
  .game-header { grid-template-columns: auto 1fr auto; }
  .logo.small  { font-size: 22px; }
  .win-card    { padding: 32px 28px; }
  .win-title   { font-size: 36px; }
  .diff-container, .mode-container { gap: 22px; }
}

@media (max-width: 380px) {
  .btn { padding: 9px 18px; font-size: 11px; }
  .controls { flex-direction: column; width: 100%; }
  .controls .btn { width: 100%; text-align: center; }
}
