/* ============================================================
   Dosa Defense Force — NNPlays
   Food-themed neon tower defense. Portrait stage.
   ============================================================ */
:root {
  --bg0: #1a1030;
  --gold: #ffd24a;
  --orange: #ff7a3d;
  --pink: #ff6b9d;
  --cyan: #46f3a0;
  --green: #5ee0a8;
  --violet: #8a5bff;
  --danger: #ff4d5e;
  --ink: #f3f7ff;
  --panel: rgba(22, 14, 42, 0.94);
  --font: 'Chakra Petch', system-ui, sans-serif;
  --mono: 'Share Tech Mono', monospace;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; }
body {
  background: radial-gradient(120% 90% at 50% 0%, #2a1a50 0%, var(--bg0) 55%, #0a0820 100%);
  color: var(--ink); font-family: var(--font); overflow: hidden;
  display: flex; align-items: center; justify-content: center; height: 100vh; height: 100dvh;
  -webkit-user-select: none; user-select: none; -webkit-tap-highlight-color: transparent;
}
#stage { position: relative; width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; overflow: hidden; }
.bg-glow { position: absolute; inset: 0; pointer-events: none;
  background: radial-gradient(50% 30% at 25% 12%, rgba(255,210,74,0.15), transparent 70%), radial-gradient(50% 30% at 78% 16%, rgba(255,107,157,0.12), transparent 70%);
  animation: glowDrift 14s ease-in-out infinite alternate; }
@keyframes glowDrift { from { transform: translateY(0); } to { transform: translateY(-12px); } }
.bg-vignette { position: absolute; inset: 0; pointer-events: none; background: radial-gradient(120% 100% at 50% 50%, transparent 55%, rgba(0,0,0,0.5) 100%); }

#frame { position: relative; height: 100%; aspect-ratio: 540 / 960; max-width: 100%; max-height: 100%;
  border-radius: 18px; overflow: hidden; box-shadow: 0 0 0 2px rgba(255,210,74,0.12), 0 24px 80px rgba(0,0,0,0.6); }
canvas#game { display: block; width: 100%; height: 100%; background: #1a1030; touch-action: none; }

/* HUD */
.hud { position: absolute; top: 0; left: 0; right: 0; z-index: 6; padding: 8px 10px 6px;
  background: linear-gradient(180deg, rgba(10,8,32,0.88) 0%, rgba(10,8,32,0) 100%); pointer-events: none; transition: opacity .3s; }
.hud.hidden { opacity: 0; }
.hud-top { display: flex; align-items: center; gap: 5px; pointer-events: none; flex-wrap: wrap; }
.hud-cell { display: flex; flex-direction: column; line-height: 1; pointer-events: none; min-width: 0; }
.hud-label { font-size: 8px; letter-spacing: 2px; color: rgba(243,247,255,0.5); font-weight: 600; }
.hud-value { font-family: var(--mono); font-size: 18px; color: var(--gold); text-shadow: 0 0 10px rgba(255,210,74,0.4); }
.hud-value.coins { color: var(--gold); }
.hud-value.lives { color: var(--pink); text-shadow: 0 0 10px rgba(255,107,157,0.4); }
.hud-combo { font-family: var(--mono); font-size: 15px; font-weight: 700; color: var(--orange); text-shadow: 0 0 14px rgba(255,122,61,0.7); pointer-events: none; margin-left: 4px; }
.hud-remaining { font-size: 10px; color: rgba(243,247,255,0.5); font-weight: 600; pointer-events: none; margin-left: auto; }

.hud-btn { pointer-events: auto; width: 34px; height: 34px; border: none; border-radius: 9px; background: rgba(255,255,255,0.07); color: var(--ink); font-size: 13px; cursor: pointer; display: grid; place-items: center; backdrop-filter: blur(6px); transition: background .15s, transform .1s; flex-shrink: 0; }
.hud-btn:hover { background: rgba(255,255,255,0.14); }
.hud-btn:active { transform: scale(0.92); }
.hud-btn.next-btn { background: rgba(70,243,160,0.15); color: var(--cyan); border: 1px solid rgba(70,243,160,0.3); }

/* Boss warning */
.boss-warn { position: absolute; left: 50%; top: 38%; transform: translate(-50%,-50%); z-index: 15; pointer-events: none;
  opacity: 0; transition: opacity .25s; }
.boss-warn.show { opacity: 1; animation: bosspulse 1s ease-in-out infinite; }
.boss-warn span { display: block; font-weight: 1000; font-size: clamp(1.2rem, 6vw, 2rem); color: #ff3b6b;
  text-shadow: 0 0 24px rgba(255,59,107,.9); letter-spacing: .06em; }
@keyframes bosspulse { 50% { transform: translate(-50%,-50%) scale(1.08); } }

/* Build/upgrade bottom sheet */
.tw-menu { position: absolute; left: 0; right: 0; bottom: max(8px, env(safe-area-inset-bottom, 0px)); z-index: 18; display: flex; flex-direction: column; align-items: center; padding: 0 8px; pointer-events: none; }
.tw-menu.hidden { display: none; }
.tw-menu-head { pointer-events: auto; max-width: 540px; width: 100%; display: flex; justify-content: center; }
.tw-menu-head .th-card { background: rgba(14,10,30,.92); border: 1px solid rgba(255,255,255,.14); border-bottom: none; border-radius: 12px 12px 0 0; padding: .35rem .7rem; font-weight: 900; font-size: .78rem; display: flex; gap: .4rem; align-items: center; backdrop-filter: blur(10px); }
.tw-menu-head .th-card small { color: var(--muted, #9aa4c8); font-weight: 700; font-size: .68rem; }
.tw-menu-inner { pointer-events: auto; display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; background: rgba(14,10,30,.92); border: 1px solid rgba(255,255,255,.14); border-radius: 14px; padding: 8px; backdrop-filter: blur(12px); max-width: 540px; width: 100%; }
.tw-opt { min-width: 64px; flex: 1 0 auto; max-width: 110px; border: 1px solid rgba(255,255,255,.12); background: rgba(255,255,255,.05); border-radius: 10px; padding: .4rem .3rem; display: flex; flex-direction: column; align-items: center; gap: 1px; font-weight: 800; font-size: .65rem; cursor: pointer; transition: transform .08s; }
.tw-opt:active { transform: scale(0.95); }
.tw-opt .ic { font-size: 1.4rem; line-height: 1; }
.tw-opt .nm { font-size: .7rem; }
.tw-opt .role { color: var(--muted, #9aa4c8); font-size: .55rem; font-weight: 700; text-align: center; line-height: 1.1; }
.tw-opt .cost { color: var(--gold); font-size: .66rem; font-weight: 900; }
.tw-opt:disabled { opacity: .35; cursor: not-allowed; }
.tw-opt:disabled:active { transform: none; }
.tw-opt.sell { border-color: rgba(255,91,92,.5); color: #ff8a8a; }
.tw-opt.up { border-color: rgba(60,232,106,.5); color: #9cff5a; }
.tw-opt.close { border-color: rgba(255,255,255,.2); color: var(--muted, #9aa4c8); min-width: 48px; }
.tw-stat { width: 100%; display: flex; justify-content: center; gap: 10px; flex-wrap: wrap; color: var(--muted, #9aa4c8); font-size: .64rem; font-weight: 700; padding: 2px 0 4px; flex: 0 0 100%; }
.tw-stat b { color: var(--text, #f3f7ff); }

/* Screens */
.screen { position: absolute; inset: 0; z-index: 10; display: none; align-items: center; justify-content: center; padding: 20px;
  background: radial-gradient(120% 90% at 50% 0%, rgba(42,26,80,0.6), rgba(10,8,32,0.85) 75%); backdrop-filter: blur(3px); }
.screen.active { display: flex; animation: fadeIn .3s ease; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.panel { width: 100%; max-width: 380px; background: var(--panel); border: 1px solid rgba(255,210,74,0.15); border-radius: 22px; padding: 26px 22px; text-align: center; box-shadow: 0 20px 60px rgba(0,0,0,0.55), inset 0 1px 0 rgba(255,255,255,0.06); }
.panel-sm { max-width: 320px; padding: 22px 18px; }
.tag { display: inline-block; font-size: 11px; letter-spacing: 4px; font-weight: 700; color: var(--gold); padding: 4px 12px; margin-bottom: 14px; border: 1px solid rgba(255,210,74,0.4); border-radius: 999px; text-shadow: 0 0 12px rgba(255,210,74,0.6); }
.logo { font-size: clamp(26px, 8vw, 42px); line-height: 0.95; font-weight: 700; letter-spacing: 1px; margin-bottom: 14px; color: var(--gold); text-shadow: 0 0 20px rgba(255,210,74,0.5); }
.logo span { display: block; color: var(--orange); text-shadow: 0 0 22px rgba(255,122,61,0.6); }
.logo em { display: block; font-style: normal; font-size: 0.58em; letter-spacing: 5px; color: var(--pink); text-shadow: 0 0 18px rgba(255,107,157,0.6); }
.subtitle { font-size: 13px; color: rgba(243,247,255,0.7); margin-bottom: 22px; line-height: 1.5; }
.screen-title { font-size: 30px; font-weight: 700; letter-spacing: 2px; margin-bottom: 18px; color: var(--ink); }
.screen-title.gold { color: var(--gold); text-shadow: 0 0 20px rgba(255,210,74,0.5); }
.btn { display: block; width: 100%; border: none; border-radius: 14px; padding: 15px; font-family: var(--font); font-size: 16px; font-weight: 700; letter-spacing: 2px; cursor: pointer; margin-bottom: 10px; transition: transform .1s, filter .15s, box-shadow .15s; }
.btn:active { transform: scale(0.97); }
.btn.primary { background: linear-gradient(135deg, var(--gold), var(--orange)); color: #2a1500; box-shadow: 0 8px 24px rgba(255,122,61,0.32); }
.btn.primary:hover { filter: brightness(1.08); box-shadow: 0 10px 30px rgba(255,122,61,0.5); }
.btn.ghost { background: rgba(255,255,255,0.06); color: var(--ink); border: 1px solid rgba(255,255,255,0.12); }
.btn.ghost:hover { background: rgba(255,255,255,0.12); }
.best-line { margin-top: 8px; font-family: var(--mono); font-size: 13px; letter-spacing: 2px; color: rgba(243,247,255,0.6); }
.best-line span { color: var(--gold); }
.stat-strip-menu { margin: 14px 0 6px; font-size: 12px; color: rgba(243,247,255,0.5); }
.how-list { text-align: left; margin-bottom: 18px; font-size: 13px; line-height: 1.55; color: rgba(243,247,255,0.85); }
.how-list li { margin-bottom: 8px; list-style: none; padding-left: 18px; position: relative; }
.how-list li::before { content: '▸'; position: absolute; left: 0; color: var(--gold); }
.how-list b { color: var(--ink); }
.stat-row { display: flex; justify-content: space-between; align-items: center; padding: 9px 4px; border-bottom: 1px solid rgba(255,255,255,0.07); font-size: 14px; }
.stat-row span { color: rgba(243,247,255,0.6); letter-spacing: 1px; font-size: 12px; }
.stat-row b { font-family: var(--mono); font-size: 18px; color: var(--gold); }
.new-best { margin: 12px 0; font-weight: 700; letter-spacing: 3px; color: var(--cyan); text-shadow: 0 0 16px rgba(70,243,160,0.6); animation: blink 1s steps(2) infinite; }
@keyframes blink { 50% { opacity: 0.4; } }

.auth-row { margin-top: 16px; display: flex; flex-direction: column; align-items: center; gap: 8px; }
.auth-status { font-size: 12px; color: rgba(243,247,255,0.6); }
.auth-status b { color: var(--gold); }
.auth-link { background: none; border: none; color: var(--pink); font-size: 12px; cursor: pointer; text-decoration: underline; }
.hidden { display: none !important; }

.leaderboard { margin: 16px 0 4px; text-align: left; position: relative; }
.lb-title { font-size: 11px; letter-spacing: 3px; color: rgba(243,247,255,0.55); margin-bottom: 8px; text-align: center; }
.lb-list { list-style: none; }
.lb-list li { display: flex; align-items: center; gap: 10px; padding: 6px 8px; border-radius: 8px; font-size: 13px; }
.lb-list li.me { background: rgba(255,210,74,0.12); }
.lb-rank { font-family: var(--mono); color: var(--gold); width: 22px; }
.lb-name { flex: 1; color: rgba(243,247,255,0.85); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb-pts { font-family: var(--mono); color: var(--orange); }
.lb-loading, .lb-empty { color: rgba(243,247,255,0.45); font-size: 12px; text-align: center; padding: 10px; }
.nn-score-nudge { margin: 14px 0; padding: 14px; border-radius: 14px; background: rgba(255,210,74,0.08); border: 1px solid rgba(255,210,74,0.25); }
.nn-score-nudge p { font-size: 13px; margin-bottom: 10px; }
.nn-nudge-btns { display: flex; gap: 8px; }
.nn-nudge-signup { flex: 1; text-decoration: none; text-align: center; padding: 10px; border-radius: 10px; background: linear-gradient(135deg, var(--gold), var(--orange)); color: #2a1500; font-weight: 700; font-size: 13px; }
.nn-nudge-later { flex: 1; padding: 10px; border-radius: 10px; border: 1px solid rgba(255,255,255,0.15); background: transparent; color: rgba(243,247,255,0.7); font-size: 13px; cursor: pointer; }
.fb-btn:empty { display: none; }
.logo-orb { width: 64px; height: 64px; margin: 0 auto 16px; border-radius: 18px; background: linear-gradient(135deg, var(--gold), var(--orange)); box-shadow: 0 0 40px rgba(255,122,61,0.5); animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 50% { transform: scale(1.08); filter: brightness(1.25); } }
.panel h1 { font-size: clamp(1.6rem, 8vw, 2.8rem); line-height: 1.0; letter-spacing: -0.03em; margin-bottom: 12px;
  background: linear-gradient(135deg, var(--gold), var(--orange), var(--pink)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.panel p { color: rgba(243,247,255,0.6); font-size: 13px; }

@media (max-height: 600px) { .panel { padding: 16px 14px; } .logo { font-size: clamp(20px, 6vw, 30px); } .subtitle { margin-bottom: 12px; } .leaderboard { display: none; } .how-list { font-size: 12px; } }
