/* ============================================================
   SINH TỒN — Last Light · AAA-styled UI
   ============================================================ */
:root {
  --bg: #05060f;
  --panel: rgba(13, 16, 27, 0.88);
  --panel-edge: rgba(140, 224, 74, 0.22);
  --text: #e9eef4;
  --muted: #8a93a6;
  --accent: #8be04a;        /* radioactive green */
  --accent-2: #5fb330;
  --danger: #ff4d3b;
  --blood: #c0392b;
  --gold: #ffce5c;
  --shadow: 0 14px 40px rgba(0, 0, 0, 0.6);
  --font-title: 'Oswald', 'Arial Narrow', sans-serif;
  --font-num: 'Teko', 'Oswald', sans-serif;
  --font-ui: 'Rajdhani', 'Segoe UI', system-ui, sans-serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-ui);
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}

/* ===== stage / canvas ===== */
#stage {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: radial-gradient(circle at 50% 35%, #111426 0%, #05060f 70%, #000 100%);
}
#game {
  display: block;
  image-rendering: pixelated;
  box-shadow: 0 0 80px rgba(0, 0, 0, 0.8);
}

/* ===== full-screen overlays ===== */
.overlay { position: fixed; inset: 0; pointer-events: none; z-index: 30; }
#vignette { background: radial-gradient(ellipse at center, transparent 55%, rgba(0,0,0,0.55) 100%); }
#scanlines {
  background: repeating-linear-gradient(to bottom, rgba(0,0,0,0) 0 2px, rgba(0,0,0,0.18) 2px 3px);
  opacity: 0.25; mix-blend-mode: multiply;
}
/* mobile: scanlines mix-blend + backdrop blur ép compositor GPU re-blend cả
   khung mỗi frame -> giật trên browser mobile (webview Zalo tắt sẵn 1 phần).
   Touch device: bỏ scanlines, blur chỉ giữ ở màn menu tĩnh. */
body.touch #scanlines { display: none; }
body.touch #day-badge, body.touch .chip, body.touch .tbtn, body.touch .floating-btn { backdrop-filter: none; }
#lowhp {
  background: radial-gradient(ellipse at center, transparent 50%, rgba(192,30,30,0.55) 100%);
  opacity: 0; transition: opacity 0.4s; z-index: 31;
}
#lowhp.active { opacity: 1; animation: hpPulse 1.1s ease-in-out infinite; }
@keyframes hpPulse { 0%,100% { opacity: 0.45; } 50% { opacity: 0.9; } }
#drowning {
  background: radial-gradient(ellipse at center, rgba(40,110,170,0.12) 38%, rgba(18,63,95,0.62) 100%);
  opacity: 0; transition: opacity 0.3s; z-index: 31;
}
#drowning.active { opacity: 1; animation: drownPulse 1.4s ease-in-out infinite; }
@keyframes drownPulse { 0%,100% { opacity: 0.6; } 50% { opacity: 1; } }
#damage-flash { background: radial-gradient(ellipse at center, rgba(192,30,30,0.1) 0%, rgba(192,30,30,0.65) 100%); opacity: 0; z-index: 32; }
#damage-flash.hit { animation: flashHit 0.4s ease-out; }
@keyframes flashHit { 0% { opacity: 0.7; } 100% { opacity: 0; } }

/* ============================================================
   HUD
   ============================================================ */
#hud {
  position: fixed; inset: 0; z-index: 20;
  opacity: 0; pointer-events: none; transition: opacity 0.35s;
  padding: max(14px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) 14px max(16px, env(safe-area-inset-left));
}
body[data-state="PLAYING"] #hud, body[data-state="PAUSED"] #hud { opacity: 1; }

#topbar { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }

/* --- stat bars --- */
.stats { display: flex; flex-direction: column; gap: 7px; width: min(38vw, 260px); }
.stat { display: flex; align-items: center; gap: 8px; }
.stat .ic { font-size: 16px; width: 20px; text-align: center; filter: drop-shadow(0 1px 2px #000); }
.meter {
  position: relative; flex: 1; height: 15px; border-radius: 8px;
  background: rgba(0,0,0,0.55);
  border: 1px solid rgba(255,255,255,0.08);
  box-shadow: inset 0 2px 5px rgba(0,0,0,0.6);
  overflow: hidden;
}
.meter .fill {
  position: absolute; inset: 0; width: 100%;
  border-radius: 8px;
  transition: width 0.25s ease, filter 0.2s;
  box-shadow: 0 0 10px rgba(0,0,0,0.4) inset;
}
.meter .fill::after { /* glossy top sheen */
  content: ''; position: absolute; left: 0; right: 0; top: 0; height: 45%;
  background: linear-gradient(rgba(255,255,255,0.35), transparent);
  border-radius: 8px 8px 0 0;
}
.stat.hp .meter { height: 19px; }
.stat.hp .fill { background: linear-gradient(90deg, #d33b3b, #6ad35a); }
.stat.hunger .fill { background: linear-gradient(90deg, #b5651d, #ff9f43); }
.stat.thirst .fill { background: linear-gradient(90deg, #1d6fb5, #4fa8ff); }
.stat.stamina .fill { background: linear-gradient(90deg, #b59a1d, #ffe14f); }
.fill.low { animation: lowBlink 0.7s steps(2) infinite; }
@keyframes lowBlink { 50% { filter: brightness(1.7) saturate(1.4); } }
.num {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  font-family: var(--font-num); font-size: 15px; line-height: 1; color: #fff;
  text-shadow: 0 1px 2px #000; pointer-events: none;
}

/* --- day / status --- */
.status { display: flex; flex-direction: column; align-items: flex-end; gap: 8px; }
#day-badge {
  display: flex; align-items: center; gap: 10px;
  background: var(--panel); border: 1px solid var(--panel-edge);
  border-radius: 12px; padding: 7px 14px; box-shadow: var(--shadow);
  backdrop-filter: blur(6px);
}
#phase-icon { font-size: 22px; filter: drop-shadow(0 0 6px rgba(255,206,92,0.6)); }
.day-text { display: flex; flex-direction: column; align-items: center; line-height: 0.9; }
.day-text .lbl { font-size: 10px; letter-spacing: 2px; color: var(--muted); }
#day-num { font-family: var(--font-num); font-size: 30px; color: var(--accent); }
.clock-wrap { display: flex; flex-direction: column; align-items: flex-end; line-height: 1; }
#clock { font-family: var(--font-num); font-size: 22px; }
#phase-label { font-size: 10px; letter-spacing: 2px; color: var(--muted); }
#topbar.night #phase-label { color: #7aa6ff; }
#objective {
  font-weight: 600; font-size: 13px; letter-spacing: 0.5px;
  background: rgba(0,0,0,0.5); border: 1px solid rgba(255,255,255,0.08);
  padding: 5px 12px; border-radius: 20px;
}

/* --- inventory --- */
#inventory {
  position: absolute; left: max(16px, env(safe-area-inset-left)); bottom: max(16px, env(safe-area-inset-bottom));
  display: flex; gap: 8px;
}
/* touch: né pad trái (◀▶ chiếm góc dưới-trái) để chip nào cũng đọc được */
body.touch #inventory { left: 186px; }
.chip {
  display: flex; align-items: center; gap: 5px;
  background: var(--panel); border: 1px solid rgba(255,255,255,0.1);
  border-radius: 10px; padding: 6px 10px; box-shadow: var(--shadow);
  backdrop-filter: blur(6px);
}
.chip .ci { font-size: 16px; }
.chip .cn { font-family: var(--font-num); font-size: 19px; min-width: 14px; text-align: center; }
.chip.food { border-bottom: 2px solid #ff9f43; }
.chip.water { border-bottom: 2px solid #4fa8ff; }
.chip.scrap { border-bottom: 2px solid #b8b8b8; }
.chip.wood { border-bottom: 2px solid #b8843f; }
.chip.bandage { border-bottom: 2px solid #ff5d6c; }

/* --- pause button --- */
.icon-btn {
  position: absolute; right: max(16px, env(safe-area-inset-right)); bottom: max(16px, env(safe-area-inset-bottom));
  width: 46px; height: 46px; border-radius: 12px;
  background: var(--panel); border: 1px solid var(--panel-edge); color: var(--text);
  font-size: 18px; cursor: pointer; box-shadow: var(--shadow); pointer-events: auto;
  display: none;
}
body[data-state="PLAYING"] .icon-btn { display: block; }
body.touch .icon-btn { right: auto; left: 50%; transform: translateX(-50%); top: max(14px, env(safe-area-inset-top)); bottom: auto; }

/* --- desktop control hints --- */
#hints {
  position: absolute; left: 50%; transform: translateX(-50%);
  bottom: max(16px, env(safe-area-inset-bottom));
  font-size: 11px; color: var(--muted); letter-spacing: 0.4px;
  background: rgba(0,0,0,0.4); padding: 5px 14px; border-radius: 20px; white-space: nowrap;
}
#hints b { color: var(--accent); }
body.touch #hints { display: none; }
body.touch #screen-menu .foot { display: none; }  /* keyboard hints vô nghĩa trên touch */

/* màn hẹp: thu day-badge để topbar không tràn/wrap (stats 38vw + badge ~160px > 360px) */
@media (max-width: 420px) {
  .stats { width: 34vw; }
  #day-badge { padding: 5px 8px; gap: 6px; }
  #day-num { font-size: 22px; }
  #clock { font-size: 18px; }
}

/* portrait: canvas 16:9 lùn tịt giữa màn — nhắc xoay ngang (controls vẫn dùng được) */
@media (orientation: portrait) {
  body.touch #inventory { left: max(16px, env(safe-area-inset-left)); flex-wrap: wrap; max-width: 60vw; }
  body.touch[data-state="PLAYING"] #stage::after {
    content: '🔄 Xoay ngang màn hình để chơi thoải mái hơn';
    position: fixed; top: calc(max(14px, env(safe-area-inset-top)) + 120px); left: 50%;
    transform: translateX(-50%); white-space: nowrap;
    font-size: 13px; color: var(--muted); background: rgba(0,0,0,0.55);
    padding: 6px 14px; border-radius: 18px; pointer-events: none; z-index: 27;
  }
}

/* ============================================================
   TOUCH CONTROLS
   ============================================================ */
#touch-controls { display: none; }
#touch-quick    { display: none; }

body.touch[data-state="PLAYING"] #touch-controls {
  display: flex; justify-content: space-between; align-items: flex-end;
  position: fixed; inset: auto 0 0 0; z-index: 25;
  padding: 0 max(14px, env(safe-area-inset-right)) max(16px, env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left));
  pointer-events: none;
}

/* Quick-action bar — hàng ngang TRÁI-TRÊN, ngay dưới thanh máu (stats đáy
   ~139px, pad trái đỉnh ≥208px mọi cỡ màn → dải 146-190 luôn trống).
   Đáy-giữa cũ che vùng chơi. */
body.touch[data-state="PLAYING"] #touch-quick {
  display: flex; gap: 8px; align-items: center;
  position: fixed; left: max(14px, env(safe-area-inset-left)); top: 146px;
  z-index: 26; pointer-events: auto;
}

/* Base touch button */
.tbtn {
  width: 64px; height: 64px; border-radius: 50%;
  background: rgba(20,24,38,0.45); border: 2px solid rgba(255,255,255,0.15);
  color: #fff; font-size: 24px; cursor: pointer;
  backdrop-filter: blur(4px); box-shadow: var(--shadow);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.tbtn:active { background: rgba(139,224,74,0.35); border-color: rgba(139,224,74,0.5); transform: scale(0.93); }

/* Quick bar buttons — smaller, more transparent */
.tbtn.quick { width: 44px; height: 44px; font-size: 18px; opacity: 0.55; }
.tbtn.quick:active { opacity: 0.9; }

/* Accent variants */
.tbtn.atk { background: rgba(192,57,43,0.5); border-color: rgba(255,120,100,0.45); }
.tbtn.jmp { background: rgba(139,224,74,0.35); border-color: rgba(139,224,74,0.55); }

/* ---- Left pad ---- */
.pad-left {
  display: flex; flex-direction: column; align-items: center;
  gap: 8px; pointer-events: auto;
}
.lr-row { display: flex; gap: 14px; align-items: center; }
.tbtn.lr-btn  { width: 72px; height: 72px; font-size: 28px; }
.tbtn.run-btn { width: 56px; height: 56px; font-size: 22px; }

/* ---- Right pad — arc/grid layout ---- */
.pad-right {
  position: relative;
  /* grid: swap top-left, aim-up top-right, action mid-left, jump mid-right, attack bottom spanning */
  display: grid;
  grid-template-columns: 68px 76px;
  grid-template-rows: 56px 68px 76px;
  gap: 8px;
  pointer-events: auto;
  align-items: center; justify-items: center;
}

/* row 1: swap (col1) + aim-up (col2) */
.tbtn.arc-swap   { grid-column: 1; grid-row: 1; width: 56px; height: 56px; font-size: 20px; }
.tbtn.arc-aim    { grid-column: 2; grid-row: 1; width: 56px; height: 56px; font-size: 20px;
                   background: rgba(100,160,255,0.3); border-color: rgba(130,180,255,0.45); }
.tbtn.arc-aim:active { background: rgba(100,160,255,0.6); }

/* row 2: action (col1) + jump (col2) */
.tbtn.arc-action { grid-column: 1; grid-row: 2; width: 68px; height: 68px; font-size: 24px; }
.tbtn.arc-jump   { grid-column: 2; grid-row: 2; width: 68px; height: 68px; font-size: 24px; }

/* row 3: aim-down (col1) + attack (col2) */
.tbtn.arc-aim-down { grid-column: 1; grid-row: 3; width: 56px; height: 56px; font-size: 20px; }
.tbtn.arc-atk    { grid-column: 2; grid-row: 3; width: 76px; height: 76px; font-size: 28px; }

/* ============================================================
   TOASTS
   ============================================================ */
#toasts {
  /* +safe-area: né notch (portrait) và né pause btn top-center trên touch */
  position: fixed; top: calc(max(14px, env(safe-area-inset-top)) + 72px);
  left: 50%; transform: translateX(-50%);
  z-index: 28; display: flex; flex-direction: column; align-items: center; gap: 7px; pointer-events: none;
}
.toast {
  font-weight: 600; font-size: 14px; letter-spacing: 0.4px;
  padding: 8px 18px; border-radius: 22px;
  background: rgba(13,16,27,0.92); border: 1px solid rgba(255,255,255,0.12);
  box-shadow: var(--shadow); white-space: nowrap;
  animation: toastLife 2.6s ease forwards;
}
.toast.good { border-color: rgba(139,224,74,0.6); color: #d6ffb0; }
.toast.bad { border-color: rgba(255,77,59,0.6); color: #ffc2b8; }
.toast.info { border-color: rgba(120,170,255,0.5); color: #cfe0ff; }
@keyframes toastLife {
  0% { opacity: 0; transform: translateY(-12px) scale(0.9); }
  12% { opacity: 1; transform: translateY(0) scale(1); }
  80% { opacity: 1; }
  100% { opacity: 0; transform: translateY(-6px); }
}

/* ============================================================
   SCREENS / OVERLAYS
   ============================================================ */
.screen {
  position: fixed; inset: 0; z-index: 40;
  display: none; align-items: flex-start; justify-content: center;
  padding: 24px;
  /* scroll container riêng: touch-action của body (none, cho canvas) không còn
     chặn pan bên trong; margin:auto ở con = giữa màn khi ngắn, cuộn khi tràn */
  overflow-y: auto;
  touch-action: pan-y;
  -webkit-overflow-scrolling: touch;
}
.screen > * { margin: auto; }
.screen.visible { display: flex; animation: fadeIn 0.4s ease; }
.screen.dim { background: rgba(3,4,10,0.74); backdrop-filter: blur(7px); }
.screen.danger { background: radial-gradient(ellipse at center, rgba(80,8,8,0.55), rgba(3,4,10,0.86)); }
.screen.win { background: radial-gradient(ellipse at center, rgba(20,70,20,0.45), rgba(3,4,10,0.86)); }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.panel {
  background: var(--panel); border: 1px solid var(--panel-edge);
  border-radius: 18px; padding: 34px 40px; box-shadow: var(--shadow);
  max-width: 540px; width: 100%;
  animation: panelIn 0.45s cubic-bezier(0.2, 0.9, 0.3, 1.3);
}
.panel.center { display: flex; flex-direction: column; align-items: center; gap: 14px; text-align: center; }
@keyframes panelIn { from { opacity: 0; transform: translateY(24px) scale(0.94); } to { opacity: 1; transform: none; } }

.panel-title { font-family: var(--font-title); font-weight: 700; font-size: 38px; letter-spacing: 3px; }
.panel-title.bad { color: var(--danger); text-shadow: 0 0 24px rgba(255,77,59,0.5); }
.panel-title.good { color: var(--accent); text-shadow: 0 0 24px rgba(139,224,74,0.5); }
.cause { color: var(--muted); font-size: 15px; margin-bottom: 6px; }

.summary { display: flex; gap: 34px; margin: 6px 0 10px; }
.sum { display: flex; flex-direction: column; align-items: center; }
.sum .big { font-family: var(--font-num); font-size: 56px; line-height: 0.9; color: var(--gold); text-shadow: 0 2px 10px rgba(0,0,0,0.6); }
.sum .cap { font-size: 11px; letter-spacing: 1.5px; color: var(--muted); }

/* ===== MENU ===== */
.menu-wrap { display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center; max-width: 560px; }
.overline { letter-spacing: 6px; font-size: 12px; color: var(--accent); font-weight: 600; }
.title {
  font-family: var(--font-title); font-weight: 700; font-size: clamp(56px, 13vw, 120px);
  letter-spacing: 8px; line-height: 0.9; color: #fff;
  text-shadow: 0 0 30px rgba(139,224,74,0.45), 0 6px 0 rgba(0,0,0,0.5);
  animation: flicker 5s infinite;
}
@keyframes flicker {
  0%,19%,21%,23%,80%,100% { opacity: 1; }
  20%,22% { opacity: 0.6; }
  81% { opacity: 0.85; }
}
.subtitle { font-family: var(--font-title); letter-spacing: 8px; color: var(--muted); font-size: 16px; margin-top: -6px; }
.tagline { color: #c2c9d6; font-size: 15px; max-width: 420px; line-height: 1.5; margin: 8px 0 6px; }
.how { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; margin: 8px 0; }
.how-item { font-size: 13px; color: #cfd6e2; background: rgba(0,0,0,0.4); border: 1px solid rgba(255,255,255,0.08); padding: 7px 14px; border-radius: 20px; }
.how-item b { color: var(--accent); }
.foot { font-size: 12px; color: var(--muted); margin-top: 8px; }
.foot b { color: #cfd6e2; }

/* ===== CRAFT ===== */
.recipe { display: flex; align-items: center; gap: 16px; background: rgba(0,0,0,0.4); padding: 14px 22px; border-radius: 14px; }
.recipe .ci { font-size: 26px; }
.r-out, .r-in { display: flex; align-items: center; gap: 8px; font-weight: 600; }
.r-out small { color: var(--accent); }
.r-arrow { font-size: 22px; color: var(--muted); }
.have { color: var(--muted); }
.have b { color: var(--gold); font-family: var(--font-num); font-size: 20px; }

/* ===== loading ===== */
.spinner {
  width: 46px; height: 46px; border-radius: 50%;
  border: 4px solid rgba(255,255,255,0.12); border-top-color: var(--accent);
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-text { letter-spacing: 4px; color: var(--muted); font-size: 14px; }

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
  font-family: var(--font-title); font-weight: 500; font-size: 17px; letter-spacing: 2px;
  color: var(--text); cursor: pointer;
  padding: 13px 30px; min-width: 220px; border-radius: 12px;
  background: rgba(255,255,255,0.06); border: 1px solid rgba(255,255,255,0.18);
  transition: transform 0.12s, box-shadow 0.2s, background 0.2s, border-color 0.2s;
}
.btn:hover { transform: translateY(-2px); background: rgba(255,255,255,0.12); border-color: rgba(255,255,255,0.3); }
.btn:active { transform: translateY(0); }
.btn.primary {
  background: linear-gradient(180deg, var(--accent), var(--accent-2));
  border: none; color: #06210a;
  box-shadow: 0 8px 24px rgba(139,224,74,0.35);
}
.btn.primary:hover { box-shadow: 0 12px 32px rgba(139,224,74,0.55); filter: brightness(1.06); }
.btn.big { font-size: 22px; padding: 16px 48px; min-width: 260px; margin-top: 6px; }
.btn.ghost { background: transparent; border-color: rgba(255,255,255,0.14); color: var(--muted); }
.btn.ghost:hover { color: var(--text); }

/* ============================================================
   v2/v3 ADDITIONS — mute btn, weapon chip, craft list, scoreboard
   ============================================================ */
.floating-btn {
  position: fixed; z-index: 60;
  top: max(12px, env(safe-area-inset-top)); right: max(12px, env(safe-area-inset-right));
  width: 42px; height: 42px; border-radius: 11px;
  background: var(--panel); border: 1px solid var(--panel-edge); color: var(--text);
  font-size: 18px; cursor: pointer; box-shadow: var(--shadow); backdrop-filter: blur(6px);
}
.floating-btn:hover { border-color: rgba(255,255,255,0.35); }
/* keep the day badge clear of the mute button while in game */
body[data-state="PLAYING"] #topbar, body[data-state="PAUSED"] #topbar { padding-right: 50px; }

.chip.weapon { border-bottom: 2px solid var(--gold); }
.chip.weapon .wn { font-weight: 600; font-size: 13px; }
.chip.weapon .ac { font-family: var(--font-num); font-size: 16px; color: var(--gold); margin-left: 2px; }
.chip.weapon.empty .ac { color: var(--danger); animation: lowBlink 0.7s steps(2) infinite; }

.craft-list { display: flex; flex-direction: column; gap: 10px; width: 100%; margin: 4px 0 6px; }
.craft-card {
  display: flex; align-items: center; gap: 14px; text-align: left;
  background: rgba(0,0,0,0.4); border: 1px solid rgba(255,255,255,0.12);
  border-radius: 12px; padding: 12px 16px; cursor: pointer; color: var(--text);
  transition: transform 0.12s, border-color 0.2s, background 0.2s;
}
.craft-card:hover { transform: translateY(-2px); border-color: var(--accent); background: rgba(139,224,74,0.1); }
.cc-ic { font-size: 26px; width: 32px; text-align: center; }
.cc-txt { display: flex; flex-direction: column; flex: 1; }
.cc-txt b { font-size: 16px; }
.cc-txt small { color: var(--muted); font-size: 12px; }
.cc-cost { font-family: var(--font-num); font-size: 18px; color: var(--gold); }

.scoreboard { width: 100%; max-width: 340px; margin: 2px 0; }
.best { color: var(--gold); font-weight: 600; font-size: 14px; margin-bottom: 6px; }
.score-list { display: flex; flex-direction: column; gap: 4px; width: 100%; max-width: 340px; margin: 0 auto; }
.score-row {
  display: flex; align-items: center; gap: 10px; justify-content: space-between;
  background: rgba(0,0,0,0.35); border: 1px solid rgba(255,255,255,0.07);
  border-radius: 8px; padding: 5px 12px; font-size: 13px;
}
.score-row .rank { color: var(--muted); font-family: var(--font-num); font-size: 16px; min-width: 26px; }
.score-row .sd { flex: 1; text-align: left; }
.score-row .sk { color: var(--muted); }
.score-row.hot { border-color: var(--gold); background: rgba(255,206,92,0.12); color: #fff; }
.score-empty { color: var(--muted); font-size: 13px; text-align: center; padding: 8px; }

.record {
  color: var(--gold); font-family: var(--font-title); letter-spacing: 2px; font-size: 18px;
  animation: recordPulse 1s ease-in-out infinite;
}
@keyframes recordPulse { 0%,100% { opacity: 1; transform: scale(1); } 50% { opacity: 0.72; transform: scale(1.05); } }

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 720px) {
  .stats { width: 46vw; }
  .panel { padding: 26px 22px; }
  .panel-title { font-size: 30px; }
  .summary { gap: 22px; }
  .sum .big { font-size: 44px; }
  #objective { font-size: 11px; }
}
@media (max-height: 520px) {
  .how { display: none; }
  .scoreboard { display: none; }
  .title { font-size: clamp(44px, 12vw, 80px); }
}

/* ============================================================
   v4 VISUAL POLISH — panels, meters, buttons, badges
   ============================================================ */

/* glowing accent line along the top edge of every panel */
.panel { position: relative; overflow: hidden; }
.panel::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: 3px;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  opacity: 0.85;
}

/* stat meters: animated glossy sweep so bars feel alive */
.meter { border-color: rgba(255,255,255,0.12); }
.meter .fill { background-size: 200% 100%; animation: fillShift 6s linear infinite; }
@keyframes fillShift { to { background-position: 200% 0; } }

/* inventory chips lift + glow on hover/press */
.chip { transition: transform 0.15s ease, border-color 0.2s, box-shadow 0.2s; }
.chip:hover, .chip:active { transform: translateY(-2px); box-shadow: 0 10px 24px rgba(0,0,0,0.5); }

/* day badge + clock: stronger radioactive glow */
#day-num { text-shadow: 0 0 14px rgba(139,224,74,0.55); }
#clock { text-shadow: 0 0 10px rgba(255,255,255,0.25); }
#day-badge { position: relative; overflow: hidden; }
#day-badge::after {
  content: ''; position: absolute; left: 0; right: 0; bottom: 0; height: 2px;
  background: linear-gradient(90deg, transparent, var(--accent-2), transparent);
}
#objective { box-shadow: inset 0 0 0 1px rgba(139,224,74,0.1); }

/* main call-to-action button: sweeping light sheen */
.btn.primary.big { position: relative; overflow: hidden; }
.btn.primary.big::after {
  content: ''; position: absolute; top: 0; left: -60%; width: 42%; height: 100%;
  background: linear-gradient(100deg, transparent, rgba(255,255,255,0.55), transparent);
  transform: skewX(-20deg); animation: btnSheen 3.6s ease-in-out infinite;
}
@keyframes btnSheen { 0%, 62% { left: -60%; } 88%, 100% { left: 130%; } }

/* deeper, warmer title glow */
.title { text-shadow: 0 0 34px rgba(139,224,74,0.5), 0 0 60px rgba(139,224,74,0.2), 0 6px 0 rgba(0,0,0,0.5); }

/* crafting cards: accent glow on hover */
.craft-card:hover { box-shadow: 0 10px 28px rgba(139,224,74,0.18); }

/* ============================================================
   HELP SCREEN
   ============================================================ */
#screen-help {
  align-items: flex-start;
  justify-content: center;
  overflow-y: auto;
  padding: 24px 16px;
}

.help-panel {
  background: var(--panel);
  border: 1px solid var(--panel-edge);
  border-radius: 18px;
  padding: 30px 36px 28px;
  box-shadow: var(--shadow);
  width: 100%;
  max-width: 700px;
  position: relative;
  overflow: hidden;
  /* glowing top accent */
}
.help-panel::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0; height: 3px;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  opacity: 0.85;
}

.help-title {
  font-family: var(--font-title);
  font-weight: 700;
  font-size: 30px;
  letter-spacing: 3px;
  color: var(--accent);
  text-align: center;
  margin-bottom: 18px;
}

.help-section {
  margin-bottom: 18px;
  border-top: 1px solid rgba(255,255,255,0.07);
  padding-top: 14px;
}
.help-section:first-of-type { border-top: none; padding-top: 0; }

.help-heading {
  font-family: var(--font-title);
  font-weight: 700;
  font-size: 16px;
  letter-spacing: 2px;
  color: var(--gold);
  margin-bottom: 10px;
  text-transform: uppercase;
}

/* Two-column controls grid */
.ctrl-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px 20px;
  margin-bottom: 10px;
}
.ctrl-col { display: flex; flex-direction: column; gap: 5px; }
.ctrl-group-label {
  font-size: 10px;
  letter-spacing: 2px;
  color: var(--muted);
  text-transform: uppercase;
  margin-bottom: 4px;
  font-weight: 600;
}
.ctrl-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 6px;
  background: rgba(0,0,0,0.25);
  border-radius: 8px;
  padding: 5px 10px;
  font-size: 13px;
}
.ctrl-action { color: var(--muted); white-space: nowrap; flex: 1; }
.ctrl-keys { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; justify-content: flex-end; }

/* Generic list */
.help-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 13px;
  color: #cfd6e2;
  line-height: 1.45;
}
.help-list li { padding-left: 4px; }
.help-list b { color: var(--accent); }
.help-list-sm { margin-top: 8px; }

/* Two side-by-side prose columns */
.help-cols2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px 20px;
}
.help-subhead {
  font-size: 10px;
  letter-spacing: 2px;
  color: var(--muted);
  text-transform: uppercase;
  margin-bottom: 6px;
  font-weight: 600;
}

/* Key badge — looks like a physical key cap */
kbd {
  display: inline-block;
  font-family: var(--font-ui);
  font-size: 11px;
  font-weight: 600;
  color: var(--text);
  background: rgba(255,255,255,0.10);
  border: 1px solid rgba(255,255,255,0.22);
  border-bottom-width: 2px;
  border-radius: 5px;
  padding: 1px 6px;
  line-height: 1.4;
  white-space: nowrap;
}

.help-back-btn {
  display: block;
  margin: 20px auto 0;
  min-width: 180px;
  font-size: 14px;
}

/* Mobile: single column */
@media (max-width: 560px) {
  .help-panel { padding: 20px 16px 18px; }
  .help-title  { font-size: 22px; }
  .help-heading{ font-size: 14px; }
  .ctrl-grid   { grid-template-columns: 1fr; }
  .help-cols2  { grid-template-columns: 1fr; }
  .ctrl-row    { font-size: 12px; }
  .help-list   { font-size: 12px; }
  kbd          { font-size: 10px; }
}
