/* ===== RESET & BASE ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  width: 100%; height: 100%; min-height: 100vh; min-height: 100dvh; min-height: 100svh;
  overflow: hidden;
  background: #1a0f07;
  font-family: 'Segoe UI', Arial, sans-serif;
  color: #fff;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}
html::before{
  content: ''; position: fixed; inset: 0; z-index: -1;
  background: url('menu-bg.jpg') center bottom / 100% 100% no-repeat,
              url('../menu-bg.jpg') center bottom / 100% 100% no-repeat;
  background-color: #1a0f07;
  pointer-events: none;
}

/* ===== SCREENS ===== */
.screen {
  position: fixed; inset: 0;
  display: none;
  z-index: 10;
}
.screen.active { display: flex; align-items: center; justify-content: center; }

/* ===== NAME ENTRY — WOOD PLATE STRUCTURE (500% match) ===== */
#screen-name {
  background:
    linear-gradient(rgba(0,0,0,0.12), rgba(0,0,0,0.18)),
    url('../menu-bg.jpg') center bottom / 100% 100% no-repeat,
    url('menu-bg.jpg') center bottom / 100% 100% no-repeat;
  background-color: #2b1a0e;
  background-size: 100% 100%;
  background-position: center bottom;
  min-height: 100vh; min-height: 100dvh; min-height: 100svh;
  position: relative;
}
#screen-name::before{
  content: ''; position: absolute; inset: 0;
  background: radial-gradient(ellipse at center, transparent 65%, rgba(0,0,0,0.38) 100%);
  pointer-events: none;
}
.name-box {
  display: flex; flex-direction: column; align-items: center;
  gap: 16px; padding: 32px 28px 28px;
  background: linear-gradient(180deg, #5e3d1e 0%, #3d2511 100%);
  border: 3px solid #2a1608;
  border-radius: 18px;
  box-shadow: 0 8px 0 #1e0f06, 0 18px 40px rgba(0,0,0,0.6), inset 0 1px 0 rgba(255,220,150,0.18);
  min-width: 340px;
  max-width: 92vw;
  position: relative;
}
.name-box::before{
  content: ''; position: absolute; top: 12px; left: 18px; right: 18px; height: 2px;
  background: linear-gradient(90deg, transparent, rgba(255,220,150,0.22), transparent);
  border-radius: 1px;
}
.logo-small { font-size: 2.2rem; filter: drop-shadow(0 2px 6px rgba(0,0,0,0.5)); }
.game-title {
  font-size: 1.95rem; font-weight: 900; letter-spacing: 1px;
  color: #ffb700;
  background: linear-gradient(180deg, #fff6a0 0%, #ffca1a 30%, #ff8c00 65%, #e05a00 100%);
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 2px 0 #7a2b00) drop-shadow(0 4px 8px rgba(0,0,0,0.55));
  text-align: center;
  line-height: 0.95;
}
.subtitle { color: #f5e6c8; font-size: 0.78rem; letter-spacing: 2px; font-weight: 700; text-shadow: 0 1px 0 rgba(0,0,0,0.8); background: linear-gradient(180deg, #4a2e16 0%, #2f1b0c 100%); border: 2px solid #6d4a2b; border-radius: 999px; padding: 3px 12px; }
.prompt-text { color: #ffe9a8; font-size: 0.95rem; font-weight: 800; letter-spacing: 0.5px; text-shadow: 0 1px 0 #4a1f00; }

#player-name-input {
  width: 100%; padding: 13px 16px;
  background: linear-gradient(180deg, #1e0f06 0%, #2f1d0c 100%);
  border: 2.5px solid #6d4a2b;
  border-radius: 999px;
  color: #fff; font-size: 1.05rem; font-weight: 800;
  outline: none;
  text-align: center;
  text-transform: uppercase;
  letter-spacing: 1px;
  box-shadow: inset 0 2px 8px rgba(0,0,0,0.55), 0 2px 0 rgba(255,220,150,0.08);
}
#menu-player-name{ text-transform: uppercase; letter-spacing: 1px; }
#player-name-input::placeholder{ color: #c9a86a; font-weight: 600; }
#player-name-input:focus { border-color: #c9a86a; box-shadow: inset 0 2px 8px rgba(0,0,0,0.55), 0 0 0 3px rgba(255,213,74,0.22); }
/* name entry buttons wood-matched */
#screen-name .btn-gold{
  background: linear-gradient(180deg, #ffd54a 0%, #ffbf18 22%, #ff8c00 58%, #ff6a00 100%);
  color: #3a1700; border: 3px solid #6b3a0a; border-radius: 999px; padding: 14px 24px;
  box-shadow: 0 6px 0 #5a2a00, 0 12px 24px rgba(0,0,0,0.5), inset 0 2px 0 rgba(255,255,255,0.5);
  font-size: 1.05rem; letter-spacing: 1px; font-weight: 900;
}
#screen-name .btn-dark{
  background: linear-gradient(180deg, #4b2e16 0%, #2f1b0c 100%);
  color: #f5e6c8; border: 2.5px solid #6d4a2b; border-radius: 999px; padding: 11px 18px;
  box-shadow: 0 4px 0 #1e0f06, inset 0 1px 0 rgba(255,220,150,0.12);
  font-weight: 800;
}

/* ===== BUTTONS ===== */
.btn-gold {
  background: linear-gradient(135deg, #FFD700, #FF8C00);
  color: #1a0a00; font-weight: 800;
  border: none; border-radius: 10px;
  padding: 14px 32px; font-size: 1rem; letter-spacing: 1px;
  cursor: pointer; width: 100%;
  transition: transform 0.1s, box-shadow 0.2s;
  box-shadow: 0 4px 20px rgba(255,180,0,0.4);
}
.btn-gold:hover { transform: translateY(-2px); box-shadow: 0 6px 30px rgba(255,180,0,0.6); }
.btn-gold:active { transform: translateY(0); }

.btn-dark {
  background: rgba(255,255,255,0.07);
  color: #ddd; font-weight: 600;
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 10px;
  padding: 12px 28px; font-size: 0.95rem; letter-spacing: 1px;
  cursor: pointer; width: 100%;
  transition: background 0.2s, transform 0.1s;
}
.btn-dark:hover { background: rgba(255,255,255,0.13); transform: translateY(-1px); }
.btn-dark:active { transform: translateY(0); }

.btn-back {
  margin-top: 16px; width: auto; padding: 10px 24px; font-size: 0.9rem;
}

/* ===== MAIN MENU — EXACT WOOD UI FROM USER IMAGE (500%) ===== */
#screen-menu {
  background: #1a0f07;
  flex-direction: column;
  position: relative;
  overflow: hidden;
  min-height: 100vh; min-height: 100dvh; min-height: 100svh;
  padding-bottom: env(safe-area-inset-bottom, 0);
}
.menu-bg {
  position: absolute; inset: 0;
  /* raw wood – floor/crate fully visible, stretch to fill no black gap down from coin */
  background:
    linear-gradient(180deg, rgba(0,0,0,0.02) 0%, rgba(0,0,0,0.10) 100%),
    url('../menu-bg.jpg') center bottom / 100% 100% no-repeat,
    url('menu-bg.jpg') center bottom / 100% 100% no-repeat;
  background-color: #2b1a0e;
  background-size: 100% 100%;
  opacity: 1;
  filter: saturate(1.06) contrast(1.03);
}
.menu-bg::before {
  content: '';
  position: absolute; inset: 0;
  /* soft vignette + lantern glow enhance – matches reference lighting */
  background:
    radial-gradient(ellipse at 88% 12%, rgba(255,180,60,0.22) 0%, transparent 32%),
    radial-gradient(ellipse at 92% 88%, rgba(255,160,40,0.18) 0%, transparent 26%),
    radial-gradient(ellipse at center, transparent 68%, rgba(0,0,0,0.38) 100%),
    linear-gradient(180deg, rgba(255,255,255,0.06) 0%, transparent 22%);
  pointer-events: none;
}
.menu-bg::after {
  content: '';
  position: absolute; inset: 0;
  box-shadow: inset 0 0 0 1px rgba(255,210,120,0.07), inset 0 0 80px rgba(0,0,0,0.45);
  pointer-events: none;
}
.menu-content {
  position: relative; display: flex; flex-direction: column;
  align-items: center; gap: 14px;
  padding: 18px 14px 20px;
  max-width: 360px; width: calc(100% - 24px);
  /* transparent like reference – no dark card, wood fully visible */
  background: transparent;
  border: none;
  box-shadow: none;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}
/* Wooden sign title – raw bg has board/crown/ropes – overlay text centered on that board */
.menu-logo {
  text-align: center;
  position: relative;
  padding: 34px 18px 12px; /* centers text on image board */
  background: transparent;
  border: none;
  box-shadow: none;
  filter: none;
  width: 100%;
  margin-top: 2vh;
}
/* raw bg provides ropes/lanterns/crown – hide CSS duplicates */
.menu-logo::before,
.menu-logo::after{ display: none; }
/* nails on board already in image – hide duplicate */
.menu-logo .game-title-big::before,
.menu-logo .game-title-big::after{ display: none; }
.game-title-big {
  font-size: clamp(2.1rem, 8.5vw, 3.1rem);
  font-weight: 900; letter-spacing: 1px;
  line-height: 0.95; text-align: center;
  color: #ffb700;
  background: linear-gradient(180deg, #fff6a0 0%, #ffca1a 28%, #ff8c00 58%, #e05a00 100%);
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 2px 0 #7a2b00) drop-shadow(0 4px 0 #4a1600) drop-shadow(0 8px 12px rgba(0,0,0,0.55));
  position: relative;
}
.game-title-big::before{ content: '👑'; position: absolute; top: -18px; left: 50%; transform: translateX(-50%); font-size: 1.35rem; filter: drop-shadow(0 2px 6px rgba(0,0,0,0.6)); -webkit-text-fill-color: initial; }
.dev-name {
  display: inline-block;
  margin-top: 8px;
  padding: 4px 14px;
  background: linear-gradient(180deg, #4a2e16 0%, #2f1b0c 100%);
  border: 2px solid #6b4420;
  border-radius: 999px;
  color: #f5e6c8; font-size: 0.72rem; letter-spacing: 1.5px; font-weight: 700;
  text-shadow: 0 1px 0 rgba(0,0,0,0.9);
  box-shadow: 0 3px 0 #1a0d06, 0 6px 12px rgba(0,0,0,0.4);
}

.player-info-bar {
  display: flex; gap: 14px; align-items: center; justify-content: center;
  background: linear-gradient(180deg, #4b3018 0%, #2f1d0c 100%);
  border: 3px solid #6d4a2b;
  border-radius: 999px; padding: 8px 16px;
  font-size: 0.85rem; color: #f5e6c8; font-weight: 700;
  box-shadow: 0 4px 0 #1e0f06, 0 8px 18px rgba(0,0,0,0.45), inset 0 1px 0 rgba(255,220,150,0.18);
  min-width: 260px;
}
.player-info-bar #menu-player-name{ color: #fff; }
.player-info-bar span{ display: inline-flex; align-items: center; gap: 4px; }
.player-info-bar span:first-child { color: #fff; font-weight: 600; }

.menu-buttons {
  display: flex; flex-direction: column; gap: 10px; width: 100%;
}
.btn-menu { font-size: 1rem; letter-spacing: 1.5px; font-weight: 800; }
/* Icon system — proper SVG icons instead of emoji */
.ico{ display:inline-flex; align-items:center; justify-content:center; width:20px; height:20px; flex-shrink:0; }
.ico svg{ width:100%; height:100%; }
.btn-gold .ico{ color:#3a1700; }
.btn-dark .ico{ color:#f5e6c8; }
.player-info-bar .ico{ width:16px; height:16px; color:#ffd54a; }
.coin-display .ico{ width:16px; height:16px; color:#ffd54a; }
.lb-box .ico{ width:14px; height:14px; }

/* Exact match to reference: PLAY gold + wood buttons */
#screen-menu .btn-gold {
  background: linear-gradient(180deg, #ffd54a 0%, #ffbf18 22%, #ff8c00 58%, #ff6a00 100%);
  color: #3a1700; font-size: 1.35rem; letter-spacing: 1px;
  border: 3px solid #6b3a0a;
  border-radius: 999px;
  padding: 16px 24px;
  box-shadow:
    0 6px 0 #5a2a00,
    0 12px 28px rgba(0,0,0,0.55),
    inset 0 2px 0 rgba(255,255,255,0.55),
    0 0 24px rgba(255,180,0,0.55);
  position: relative;
  text-shadow: 0 1px 0 rgba(255,255,255,0.65);
}
#screen-menu .btn-gold::before,
#screen-menu .btn-gold::after{
  content: '● ●'; position: absolute; top: 50%; transform: translateY(-50%);
  font-size: 7px; color: #7a4a1a; letter-spacing: 3px; opacity: 0.9;
}
#screen-menu .btn-gold::before{ left: 14px; }
#screen-menu .btn-gold::after{ right: 14px; }
#screen-menu .btn-gold:active{ transform: translateY(3px); box-shadow: 0 3px 0 #5a2a00, 0 8px 18px rgba(0,0,0,0.45); }
#screen-menu .btn-dark {
  background: linear-gradient(180deg, #4b2e16 0%, #2f1b0c 100%);
  color: #f5e6c8; font-size: 0.95rem; letter-spacing: 1px; font-weight: 800;
  border: 2.5px solid #6d4a2b;
  border-radius: 999px;
  padding: 13px 18px;
  box-shadow: 0 5px 0 #1e0f06, 0 10px 18px rgba(0,0,0,0.45), inset 0 1px 0 rgba(255,220,150,0.14);
  display: flex; align-items: center; justify-content: center; gap: 8px;
  position: relative;
  text-shadow: 0 1px 0 rgba(0,0,0,0.9);
}
#screen-menu .btn-dark::after{
  content: '›'; position: absolute; right: 18px; font-size: 1.3rem; color: #c9a86a; font-weight: 900; opacity: 0.95;
}
#screen-menu .btn-dark:active{ transform: translateY(2px); box-shadow: 0 3px 0 #1e0f06, 0 6px 12px rgba(0,0,0,0.35); }
#screen-menu .coin-display{
  background: linear-gradient(180deg, #5e3d1e 0%, #3d2511 55%, #2a1608 100%);
  border: 2.5px solid #6d4a2b;
  border-radius: 999px;
  padding: 9px 20px 9px 14px;
  font-size: 0.98rem; font-weight: 900; color: #ffd54a;
  box-shadow: 0 5px 0 #1e0f06, 0 12px 22px rgba(0,0,0,0.45), inset 0 1px 0 rgba(255,220,150,0.18), 0 0 16px rgba(255,180,0,0.15);
  display: inline-flex; align-items: center; gap: 10px; min-width: 138px; justify-content: center;
  letter-spacing: 0.5px; position: relative;
  transition: transform 0.15s, box-shadow 0.15s;
}
#screen-menu .coin-display::before{
  content: ''; position: absolute; inset: 0; border-radius: 999px;
  background: linear-gradient(180deg, rgba(255,255,255,0.08), transparent 40%);
  pointer-events: none;
}
#screen-menu .coin-display .coin-icon-wrap{
  width: 32px; height: 32px; border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, #fff6a0 0%, #ffca1a 18%, #ff8c00 55%, #e05a00 100%);
  border: 2.5px solid #6b3a0a; display: grid; place-items: center;
  box-shadow: 0 2px 0 #5a2a00, inset 0 1px 0 rgba(255,255,255,0.55);
  flex-shrink: 0; position: relative;
}
#screen-menu .coin-display .coin-icon-wrap::after{
  content: '$'; color: #3a1700; font-weight: 900; font-size: 1.05rem; text-shadow: 0 1px 0 rgba(255,255,255,0.6);
}
#screen-menu .coin-display .coin-label{ color: #f5e6c8; font-size: 0.72rem; letter-spacing: 1.2px; font-weight: 800; opacity: 0.95; }
#screen-menu .coin-display .coin-text{ color: #ffd54a; font-size: 1.15rem; font-weight: 900; text-shadow: 0 1px 0 #4a1f00; min-width: 28px; text-align: left; }
#screen-menu .coin-display.coin-bump{ animation: coinBump 0.45s cubic-bezier(.34,1.56,.64,1); }
@keyframes coinBump{
  0%{ transform: scale(1); }
  30%{ transform: scale(1.12); box-shadow: 0 5px 0 #1e0f06, 0 16px 28px rgba(0,0,0,0.5), 0 0 22px rgba(255,215,0,0.45); }
  100%{ transform: scale(1); }
}
#screen-menu .coin-display.coin-glow{ box-shadow: 0 5px 0 #1e0f06, 0 12px 22px rgba(0,0,0,0.45), 0 0 18px rgba(255,215,0,0.35); }
#menu-coin-display{ display:inline-flex !important; visibility:visible !important; opacity:1 !important; flex-shrink:0; z-index:5; }
#menu-coin-display.hidden{ display:none !important; }
/* ? help button top-left — wood coin */
#btn-help{
  position: absolute; top: 14px; left: 14px;
  width: 42px; height: 42px; border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #ffd54a 0%, #ff8c00 55%, #d46a00 100%);
  border: 3px solid #6b3a0a; color: #3a1700; font-weight: 900; font-size: 1.35rem;
  display: grid; place-items: center; cursor: pointer; z-index: 6;
  box-shadow: 0 4px 0 #5a2a00, 0 10px 18px rgba(0,0,0,0.45), inset 0 2px 0 rgba(255,255,255,0.5);
  text-shadow: 0 1px 0 rgba(255,255,255,0.6);
}
#btn-help:active{ transform: translateY(2px); box-shadow: 0 2px 0 #5a2a00; }
/* Help overlay — GAME UI STYLE (wood board + icons) */
#help-overlay{
  position: fixed; inset: 0; z-index: 40;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0,0,0,0.68); backdrop-filter: blur(5px);
  padding: 16px;
}
#help-overlay.hidden, #mode-select.hidden{ display: none !important; }
.help-card{
  position: relative; max-width: 560px; width: 100%; max-height: 90vh; overflow-y: auto;
  background: linear-gradient(180deg, #5e3d1e 0%, #3d2511 100%);
  border: 3px solid #2a1608; border-radius: 20px;
  padding: 24px 20px 20px; display: flex; flex-direction: column; gap: 14px;
  box-shadow: 0 10px 0 #1e0f06, 0 22px 48px rgba(0,0,0,0.65), inset 0 1px 0 rgba(255,220,150,0.18);
  animation: woodPop 0.32s cubic-bezier(.34,1.56,.64,1);
}
.help-card::before{
  content: 'GAME GUIDE'; display: block; text-align: center;
  color: #ffd54a; font-size: 1.35rem; font-weight: 900; letter-spacing: 1.5px;
  text-shadow: 0 2px 0 #4a1f00;
  background: linear-gradient(180deg, #4a2e16 0%, #2f1b0c 100%);
  border: 2px solid #6d4a2b; border-radius: 999px; padding: 8px 22px; margin: 0 auto 4px;
  box-shadow: 0 4px 0 #1e0f06; width: fit-content;
}
.help-card h2{ display: none; }
.help-intro{
  color: #1a0a00; text-align: center; font-weight: 800; font-size: 0.90rem;
  background: linear-gradient(180deg, #ffd54a 0%, #ff8c00 100%);
  border: 2px solid #6b3a0a; border-radius: 999px; padding: 6px 14px;
  box-shadow: 0 3px 0 #5a2a00; margin: 0 auto;
}
.help-grid{ display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
@media (max-width: 520px){ .help-grid{ grid-template-columns: 1fr; } }
.help-item{
  background: linear-gradient(180deg, #4b3018 0%, #2f1d0c 100%);
  border: 2.5px solid #6d4a2b; border-radius: 14px; padding: 12px 12px;
  display: flex; flex-direction: column; gap: 6px;
  box-shadow: 0 4px 0 #1e0f06, inset 0 1px 0 rgba(255,220,150,0.10);
  position: relative;
}
.help-item b{
  color: #ffd54a; font-size: 0.90rem; display: flex; align-items: center; gap: 6px; letter-spacing: 0.5px;
  text-shadow: 0 1px 0 #4a1f00;
}
.help-item b::before{
  content: ''; width: 6px; height: 6px; border-radius: 50%; background: #8d6a3a; box-shadow: 0 0 6px rgba(255,180,0,0.5); flex-shrink: 0;
}
.help-box{
  background: linear-gradient(180deg, #3d2511 0%, #2a160a 100%);
  border: 1.5px solid #6d4a2b; border-radius: 10px;
  padding: 8px 10px; margin-top: 4px;
  color: #f5e6c8; font-size: 0.80rem; line-height: 1.45; font-weight: 600;
}
.help-label{
  color: #ffd54a; font-weight: 800; font-size: 0.80rem; margin-right: 4px;
}
.help-item span{ color: #f5e6c8; font-size: 0.80rem; line-height: 1.45; font-weight: 600; }
.help-foot{
  color: #ffe9a8; font-size: 0.82rem; font-weight: 700; text-align: center;
  background: linear-gradient(180deg, #3d2511 0%, #2a160a 100%);
  border: 2px dashed rgba(255,220,150,0.22); border-radius: 12px; padding: 10px;
}
.help-close{
  position: absolute; top: 12px; right: 12px; width: 36px; height: 36px; border-radius: 50%;
  background: linear-gradient(180deg, #4b3018 0%, #2f1d0c 100%);
  border: 2.5px solid #6d4a2b; color: #ffd54a; font-weight: 900; font-size: 1rem; cursor: pointer;
  box-shadow: 0 3px 0 #1e0f06; display: grid; place-items: center;
}
.help-close:active{ transform: translateY(1px); box-shadow: 0 1px 0 #1e0f06; }
/* Mode select — GAME UI STYLE */
#mode-select{
  position: fixed; inset: 0; z-index: 39;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0,0,0,0.62); backdrop-filter: blur(4px);
  padding: 16px;
}
.mode-card{
  max-width: 440px; width: 100%;
  background: linear-gradient(180deg, #5e3d1e 0%, #3d2511 100%);
  border: 3px solid #2a1608; border-radius: 20px;
  padding: 22px 18px 18px; display: flex; flex-direction: column; gap: 12px;
  box-shadow: 0 10px 0 #1e0f06, 0 22px 48px rgba(0,0,0,0.65);
  text-align: center;
  animation: woodPop 0.32s cubic-bezier(.34,1.56,.64,1);
}
@keyframes woodPop{
  0%{ transform: scale(0.85) translateY(10px); opacity: 0; }
  100%{ transform: scale(1) translateY(0); opacity: 1; }
}
.mode-card h2{
  color: #ffd54a; font-weight: 900; letter-spacing: 1.5px; font-size: 1.35rem;
  text-shadow: 0 2px 0 #4a1f00;
  background: linear-gradient(180deg, #4a2e16 0%, #2f1b0c 100%);
  border: 2px solid #6d4a2b; border-radius: 999px; padding: 8px 16px; margin: 0 auto;
  box-shadow: 0 4px 0 #1e0f06;
}
.mode-sub{ color: #ffe9a8; font-size: 0.88rem; font-weight: 700; }
.mode-opt{
  text-align: left; background: linear-gradient(180deg, #4b3018 0%, #2f1d0c 100%);
  border: 2.5px solid #6d4a2b; border-radius: 16px; padding: 14px 16px;
  cursor: pointer; display: flex; flex-direction: column; gap: 6px;
  box-shadow: 0 5px 0 #1e0f06, inset 0 1px 0 rgba(255,220,150,0.12);
  position: relative;
}
.mode-opt b{ color: #ffd54a; font-size: 1.02rem; display: flex; align-items: center; gap: 8px; }
.mode-opt b::before{ font-size: 1.25rem; }
.mode-opt[data-mode="normal"] b::before{ content: '🌟'; }
.mode-opt[data-mode="hard"] b::before{ content: '🔥'; }
.mode-opt span{ color: #f5e6c8; font-size: 0.82rem; line-height: 1.4; font-weight: 600; }
.mode-opt.hard{ border-color: #8a2a2a; background: linear-gradient(180deg, #5a1f1f 0%, #3d1212 100%); }
.mode-opt.hard b{ color: #ff8a7a; }
.mode-opt:active{ transform: translateY(2px); box-shadow: 0 2px 0 #1e0f06; }
.mode-guide{
  color: #ffe9a8; font-size: 0.80rem; line-height: 1.45; font-weight: 700;
  background: linear-gradient(180deg, #3d2511 0%, #2a160a 100%);
  border: 2px dashed rgba(255,220,150,0.22); border-radius: 12px; padding: 10px 12px;
  text-align: left;
}

/* ===== OVERLAY PANELS — WOOD STRUCTURE (Settings/Levels/Garage/Leaderboard) ===== */
#screen-levels, #screen-garage, #screen-settings, #screen-leaderboard {
  background:
    linear-gradient(rgba(0,0,0,0.10), rgba(0,0,0,0.18)),
    url('../menu-bg.jpg') center bottom / 100% 100% no-repeat,
    url('menu-bg.jpg') center bottom / 100% 100% no-repeat;
  background-color: #2b1a0e;
  background-size: 100% 100%;
  background-position: center bottom;
  min-height: 100vh; min-height: 100dvh; min-height: 100svh;
}
.overlay-panel {
  background: linear-gradient(180deg, #5e3d1e 0%, #3d2511 100%);
  border: 3px solid #2a1608;
  border-radius: 18px;
  padding: 26px 22px;
  min-width: 320px; max-width: 95vw;
  max-height: 88vh; overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  display: flex; flex-direction: column; align-items: center; gap: 14px;
  box-shadow: 0 8px 0 #1e0f06, 0 18px 40px rgba(0,0,0,0.6), inset 0 1px 0 rgba(255,220,150,0.18);
  position: relative;
}
.overlay-panel::before{
  content: ''; position: absolute; top: 10px; left: 18px; right: 18px; height: 2px;
  background: linear-gradient(90deg, transparent, rgba(255,220,150,0.22), transparent);
  border-radius: 1px;
}
.panel-title {
  font-size: 1.35rem; font-weight: 900; color: #ffd54a;
  letter-spacing: 2px; margin-bottom: 6px;
  text-shadow: 0 2px 0 #4a1f00, 0 4px 10px rgba(0,0,0,0.5);
  background: linear-gradient(180deg, #4a2e16 0%, #2f1b0c 100%);
  border: 2px solid #6d4a2b;
  border-radius: 999px;
  padding: 6px 18px;
  box-shadow: 0 3px 0 #1e0f06;
}

.overlay-panel-sm {
  position: fixed; top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  background: linear-gradient(180deg, #5e3d1e 0%, #3d2511 100%);
  border: 3px solid #2a1608;
  border-radius: 18px;
  padding: 26px 22px;
  min-width: 300px; max-width: 92vw;
  display: flex; flex-direction: column; align-items: center; gap: 12px;
  z-index: 100;
  box-shadow: 0 8px 0 #1e0f06, 0 18px 40px rgba(0,0,0,0.6), inset 0 1px 0 rgba(255,220,150,0.16);
}
.overlay-panel-sm h3 {
  font-size: 1.45rem; font-weight: 900; color: #ffd54a;
  letter-spacing: 1.5px;
  text-shadow: 0 2px 0 #4a1f00;
  text-align: center; width: 100%;
}
/* Hard failed cry emoji */
.cry-emoji{
  font-size: 3.2rem; line-height: 1; filter: drop-shadow(0 4px 10px rgba(0,0,0,0.5));
  animation: cryBounce 0.9s ease-in-out infinite alternate, cryShake 0.35s ease-in-out infinite;
}
@keyframes cryBounce{
  0%{ transform: scale(1) translateY(0); }
  100%{ transform: scale(1.08) translateY(-4px); }
}
@keyframes cryShake{
  0%,100%{ transform: translateX(0); }
  25%{ transform: translateX(-2px); }
  75%{ transform: translateX(2px); }
}
@keyframes hardPulse{
  0%{ transform: translateX(-50%) scale(1); }
  100%{ transform: translateX(-50%) scale(1.06); }
}
/* wood buttons inside all overlay panels (Garage/Settings/Levels/Pause) */
.overlay-panel .btn-gold, .overlay-panel-sm .btn-gold{
  background: linear-gradient(180deg, #ffd54a 0%, #ffbf18 22%, #ff8c00 58%, #ff6a00 100%);
  color: #3a1700; border: 2.5px solid #6b3a0a; border-radius: 999px;
  padding: 12px 22px; font-weight: 900;
  box-shadow: 0 5px 0 #5a2a00, 0 10px 18px rgba(0,0,0,0.45), inset 0 1px 0 rgba(255,255,255,0.5);
}
.overlay-panel .btn-dark, .overlay-panel-sm .btn-dark{
  background: linear-gradient(180deg, #4b2e16 0%, #2f1b0c 100%);
  color: #f5e6c8; border: 2.5px solid #6d4a2b; border-radius: 999px;
  padding: 11px 18px; font-weight: 800;
  box-shadow: 0 4px 0 #1e0f06, 0 8px 14px rgba(0,0,0,0.4), inset 0 1px 0 rgba(255,220,150,0.14);
}
.overlay-panel .btn-back, .overlay-panel-sm .btn-back{ margin-top: 12px; }

/* ===== LEVEL GRID ===== */
.level-grid {
  display: grid; grid-template-columns: repeat(3, 1fr);
  gap: 10px; width: 100%; max-height: 60vh; overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  padding: 4px;
}
.level-card {
  background: linear-gradient(180deg, #4b3018 0%, #2f1d0c 100%);
  border: 2px solid #6d4a2b;
  border-radius: 12px; padding: 12px 8px;
  text-align: center; cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s, border-color 0.15s;
  box-shadow: 0 4px 0 #1e0f06, 0 6px 14px rgba(0,0,0,0.35);
}
.level-card:hover { border-color: #c9a86a; transform: translateY(-2px) scale(1.02); box-shadow: 0 6px 0 #1e0f06, 0 10px 20px rgba(0,0,0,0.45); }
.level-card:active{ transform: translateY(1px); box-shadow: 0 2px 0 #1e0f06; }
.level-card.locked { opacity: 0.38; cursor: not-allowed; filter: grayscale(0.6); }
.level-card.locked:hover { transform: none; border-color: #6d4a2b; }
.level-card .lc-num { font-weight: 900; font-size: 1rem; color: #ffd54a; text-shadow: 0 1px 0 #4a1f00; }
.level-card .lc-name { font-size: 0.68rem; color: #f5e6c8; margin: 3px 0; font-weight: 700; }
.level-card .lc-stars { font-size: 0.78rem; color: #ffd54a; }

/* ===== SETTINGS — wood structure ===== */
.settings-group {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; width: 100%; padding: 10px 12px;
  background: linear-gradient(180deg, #3d2511 0%, #2a160a 100%);
  border: 2px solid #6d4a2b;
  border-radius: 10px;
  margin-bottom: 6px;
  box-shadow: 0 3px 0 #1e0f06;
}
.settings-group label:first-child { font-size: 0.9rem; color: #f5e6c8; min-width: 120px; font-weight: 700; }

.toggle { position: relative; display: inline-block; width: 48px; height: 26px; }
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle .slider {
  position: absolute; inset: 0; cursor: pointer;
  background: #333; border-radius: 26px; transition: 0.3s;
}
.toggle .slider:before {
  position: absolute; content: '';
  height: 20px; width: 20px; left: 3px; bottom: 3px;
  background: #fff; border-radius: 50%; transition: 0.3s;
}
.toggle input:checked + .slider { background: #FFD700; }
.toggle input:checked + .slider:before { transform: translateX(22px); background: #1a0a00; }

.vol-slider {
  -webkit-appearance: none; width: 130px; height: 4px;
  background: rgba(255,200,40,0.3); border-radius: 2px; outline: none;
}
.vol-slider::-webkit-slider-thumb {
  -webkit-appearance: none; width: 16px; height: 16px;
  border-radius: 50%; background: #FFD700; cursor: pointer;
}

/* ===== LEADERBOARD — GAME UI BOXES ===== */
.leaderboard-list {
  width: 100%; max-height: 55vh; overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  display: flex; flex-direction: column; gap: 8px; padding: 4px;
}
.lb-row {
  display: grid; grid-template-columns: 36px 1fr 70px 84px 78px 68px; gap: 6px; align-items: center;
  background: linear-gradient(180deg, #4b3018 0%, #2f1d0c 100%);
  border: 2.5px solid #6d4a2b; border-radius: 12px; padding: 8px 8px;
  box-shadow: 0 4px 0 #1e0f06, 0 8px 14px rgba(0,0,0,0.35);
  font-size: 0.82rem;
}
@media (max-width: 520px){
  .lb-row{ grid-template-columns: 32px 1fr 62px 70px; grid-template-rows: auto auto; }
  .lb-row .lb-time-box{ grid-column: 2; }
  .lb-row .lb-deaths-box{ grid-column: 3; }
}
.lb-rank{
  width: 32px; height: 32px; display: grid; place-items: center;
  background: linear-gradient(180deg, #ffd54a 0%, #ff8c00 100%);
  border: 2px solid #6b3a0a; border-radius: 50%;
  color: #3a1700; font-weight: 900; font-size: 0.82rem;
  box-shadow: 0 2px 0 #5a2a00;
}
.lb-box{
  background: linear-gradient(180deg, #3d2511 0%, #2a160a 100%);
  border: 1.5px solid #6d4a2b; border-radius: 8px; padding: 5px 6px;
  text-align: center; font-weight: 700; font-size: 0.78rem;
  box-shadow: inset 0 1px 0 rgba(255,220,150,0.10);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.lb-name-box{ color: #f5e6c8; }
.lb-level-box{ color: #ffd54a; }
.lb-stars-box{ color: #ffd54a; letter-spacing: 1px; }
.lb-time-box{ color: #aee2ff; font-family: ui-monospace, monospace; }
.lb-deaths-box{ color: #ff8a7a; }

/* ===== INTRO ===== */
#screen-intro { background: #000; }
#intro-canvas { width: 100%; height: 100%; display: block; }

/* ===== GAME CANVAS ===== */
#screen-game {
  background: #0a0a0a;
  display: block;  /* override flex – canvas fills naturally */
  position: fixed;
  inset: 0;
}
#game-canvas {
  display: block;
  width: 100%;
  height: 100%;
  position: absolute;
  top: 0; left: 0;
  touch-action: none;
}

/* ===== HUD — number plate wood structure (old timer removed, pause at top-right) ===== */
#hud {
  position: fixed; top: 0; left: 0; right: 0;
  display: flex; align-items: flex-start; justify-content: space-between;
  padding: 12px 14px;
  pointer-events: none;
  z-index: 20;
}
#hud-left, #hud-right {
  display: flex; flex-direction: column; gap: 8px;
}
#hud-right { align-items: flex-end; }
#hud-level, #hud-deaths, #hud-stars {
  background: linear-gradient(180deg, #4b3018 0%, #2f1d0c 100%);
  border: 2px solid #6d4a2b;
  border-radius: 10px;
  padding: 6px 12px;
  color: #f5e6c8;
  font-weight: 900;
  font-size: 0.82rem;
  letter-spacing: 0.5px;
  min-width: 92px;
  text-align: center;
  box-shadow: 0 3px 0 #1e0f06, 0 7px 14px rgba(0,0,0,0.42), inset 0 1px 0 rgba(255,220,150,0.14);
  position: relative;
  text-shadow: 0 1px 0 rgba(0,0,0,0.9);
}
#hud-level{ color: #ffd54a; font-size: 0.88rem; }
#hud-deaths{ color: #ff8a7a; }
#hud-stars{ color: #ffd54a; letter-spacing: 1px; }
/* small rivets on plates */
#hud-level::before, #hud-deaths::before, #hud-stars::before{
  content: '●'; position: absolute; left: 6px; top: 50%; transform: translateY(-50%);
  font-size: 6px; color: #8d6a3a; opacity: 0.9;
}
#hud-level::after, #hud-deaths::after, #hud-stars::after{
  content: '●'; position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  font-size: 6px; color: #8d6a3a; opacity: 0.9;
}
#btn-pause {
  /* top-right where old timer was — slightly down from edge to not touch notch */
  position: relative;
  background: linear-gradient(180deg, #4b3018 0%, #2f1d0c 100%);
  border: 2.5px solid #6d4a2b;
  border-radius: 999px; padding: 8px 18px;
  color: #ffd54a; font-size: 1rem; font-weight: 900; cursor: pointer;
  pointer-events: all;
  z-index: 21;
  box-shadow: 0 4px 0 #1e0f06, 0 8px 16px rgba(0,0,0,0.45), inset 0 1px 0 rgba(255,220,150,0.16);
  transition: filter 0.15s, transform 0.1s;
  margin-top: 4px;
}
#btn-pause:hover { filter: brightness(1.08); }
#btn-pause:active{ transform: translateY(2px); box-shadow: 0 2px 0 #1e0f06; }

/* pause time number plate – wood structure */
.pause-time-plate{
  background: linear-gradient(180deg, #3d2511 0%, #28160a 100%);
  border: 2px solid #6d4a2b;
  border-radius: 10px;
  padding: 8px 16px;
  color: #ffd54a;
  font-weight: 900;
  font-size: 0.90rem;
  letter-spacing: 1px;
  font-family: ui-monospace, Menlo, monospace;
  box-shadow: inset 0 1px 0 rgba(255,220,150,0.16), 0 4px 0 #1e0f06;
  min-width: 200px; text-align: center;
  text-shadow: 0 1px 0 rgba(0,0,0,0.9);
}

/* ===== DEATH FLASH ===== */
#death-flash {
  position: fixed; inset: 0;
  background: rgba(255,0,0,0.35);
  z-index: 25; pointer-events: none;
  transition: opacity 0.3s;
}

/* ===== JUMP HINT ===== */
#jump-hint {
  position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%);
  padding: 8px 18px; border-radius: 20px;
  background: rgba(255,200,40,0.12);
  border: 1px solid rgba(255,200,40,0.35);
  color: #FFD700; font-size: 0.85rem; letter-spacing: 2px;
  z-index: 22; pointer-events: none;
  animation: jump-pulse 1.6s ease-in-out infinite;
}
@keyframes jump-pulse {
  0%, 100% { opacity: 0.55; }
  50%      { opacity: 1; }
}

/* ===== LEVEL GUIDE (new long map, level 30) ===== */
#level-guide {
  position: fixed; top: 12%; left: 50%; transform: translateX(-50%);
  width: min(320px, 88vw);
  padding: 18px 22px;
  border-radius: 16px;
  text-align: center;
  background: rgba(10,10,20,0.82);
  border: 1px solid rgba(255,200,40,0.45);
  box-shadow: 0 8px 40px rgba(0,0,0,0.5);
  z-index: 24; pointer-events: none;
  animation: guide-pop 0.35s ease-out;
}
@keyframes guide-pop {
  0%   { opacity: 0; transform: translateX(-50%) scale(0.9); }
  100% { opacity: 1; transform: translateX(-50%) scale(1); }
}
#level-guide .lg-title {
  color: #FFD700; font-size: 1.05rem; font-weight: 800;
  letter-spacing: 2px; margin-bottom: 10px;
}
#level-guide .lg-line {
  color: #eef; font-size: 0.95rem; line-height: 1.6;
}
#level-guide .lg-line b { color: #FFD700; }
#level-guide .lg-pc {
  margin-top: 8px; font-size: 0.78rem; color: #9aa;
  border-top: 1px dashed rgba(255,255,255,0.15); padding-top: 8px;
}

/* ===== GARAGE / SKIN SHOP ===== */
.garage-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  width: 100%;
  max-height: 60vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  padding: 4px;
}
.garage-card {
  background: linear-gradient(180deg, #4b3018 0%, #2f1d0c 100%);
  border: 2px solid #6d4a2b;
  border-radius: 14px;
  padding: 16px 12px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  transition: all 0.2s;
  box-shadow: 0 4px 0 #1e0f06, 0 8px 16px rgba(0,0,0,0.35);
}
.garage-card:hover { border-color: #c9a86a; transform: translateY(-2px); }
.garage-card.equipped {
  border-color: #ffd54a;
  box-shadow: 0 0 0 2px #ffd54a, 0 4px 0 #1e0f06, 0 10px 22px rgba(255,180,0,0.25);
}
.garage-ball-preview {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  margin-bottom: 4px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.4), inset 0 -4px 8px rgba(0,0,0,0.3);
  border: 2px solid rgba(255,255,255,0.1);
}
.garage-skin-name {
  font-weight: 700;
  font-size: 0.85rem;
  color: #fff;
}
.garage-skin-desc {
  font-size: 0.7rem;
  color: #aaa;
}
.garage-equipped-badge {
  background: rgba(0,255,100,0.15);
  color: #00ff88;
  font-size: 0.65rem;
  font-weight: 700;
  padding: 2px 10px;
  border-radius: 999px;
  border: 1px solid rgba(0,255,100,0.3);
  letter-spacing: 1px;
}
/* ===== SKIN CELEBRATE — same wood + confetti as LEVEL COMPLETE ===== */
#skin-celebrate{ overflow: hidden; max-width: 380px; }
#skin-celebrate .skin-celebrate-ball{
  width: 78px; height: 78px; border-radius: 50%; border: 3px solid rgba(255,255,255,0.12);
  box-shadow: 0 6px 22px rgba(0,0,0,0.5), inset 0 -5px 10px rgba(0,0,0,0.35);
  margin: 4px auto 2px; position: relative; z-index: 1;
}
#skin-celebrate .skin-celebrate-name{ color:#ffd54a; font-weight:900; letter-spacing:1px; font-size:1.05rem; text-shadow:0 1px 0 #4a1f00; z-index:1; position:relative; }
#skin-celebrate .skin-celebrate-desc{ color:#f5e6c8; font-size:0.78rem; font-weight:600; opacity:0.9; z-index:1; position:relative; }
.skin-celebrate-actions{ display:flex; gap:10px; width:100%; z-index:1; position:relative; margin-top:4px; }
.skin-celebrate-actions .btn-gold, .skin-celebrate-actions .btn-dark{ flex:1; }

/* ===== LEVEL COMPLETE — CELEBRATION (loops till click, no typo) ===== */
#level-complete.celebrate{ overflow: hidden; }
.celebrate-confetti{
  position: absolute; inset: 0;
  overflow: hidden; pointer-events: none;
  border-radius: 18px; z-index: 0;
}
.confetti-piece{
  position: absolute; top: -14px; width: 9px; height: 18px;
  border-radius: 2px; opacity: 0.95;
  animation: confettiFall linear forwards;
  box-shadow: 0 1px 4px rgba(0,0,0,0.35);
}
@keyframes confettiFall{
  0%{ transform: translate3d(0,-20px,0) rotate(0deg) scale(1); opacity: 1; }
  100%{ transform: translate3d(var(--drift, 40px), 460px, 0) rotate(720deg) scale(0.9); opacity: 0; }
}
.celebrate-title{
  position: relative; z-index: 1;
  text-align: center; width: 100%;
  animation: titleBounce 0.75s cubic-bezier(.34,1.56,.64,1) 0.15s both, titleShine 1.8s ease-in-out infinite 1.4s;
}
@keyframes titleBounce{
  0%{ transform: scale(0.7) translateY(14px); opacity: 0; }
  100%{ transform: scale(1) translateY(0); opacity: 1; }
}
@keyframes titleShine{
  0%,100%{ filter: brightness(1) drop-shadow(0 2px 0 #4a1f00); }
  50%{ filter: brightness(1.18) drop-shadow(0 0 10px rgba(255,215,0,0.55)) drop-shadow(0 2px 0 #4a1f00); }
}
.celebrate-stars{
  animation: starPulse 0.9s ease-in-out infinite alternate;
  text-shadow: 0 0 10px rgba(255,215,0,0.45);
}
@keyframes starPulse{
  0%{ transform: scale(1); filter: brightness(1); }
  100%{ transform: scale(1.07); filter: brightness(1.22) drop-shadow(0 0 10px rgba(255,215,0,0.65)); }
}
.celebrate-coins{
  animation: coinShimmer 1.2s ease-in-out infinite;
}
@keyframes coinShimmer{
  0%,100%{ transform: scale(1); text-shadow: 0 0 0 rgba(255,215,0,0); }
  50%{ transform: scale(1.06); text-shadow: 0 0 14px rgba(255,215,0,0.7); }
}
.celebrate-btn{
  animation: btnGlow 1.4s ease-in-out infinite alternate;
  z-index: 1;
}
@keyframes btnGlow{
  0%{ box-shadow: 0 6px 0 #5a2a00, 0 12px 24px rgba(0,0,0,0.5), 0 0 0 rgba(255,180,0,0); }
  100%{ box-shadow: 0 6px 0 #5a2a00, 0 12px 28px rgba(0,0,0,0.55), 0 0 22px rgba(255,180,0,0.55); }
}
@media (prefers-reduced-motion: reduce){
  .confetti-piece, .celebrate-title, .celebrate-stars, .celebrate-coins, .celebrate-btn{ animation: none !important; }
}

.coin-display {
  font-weight: 700;
  text-shadow: 0 0 10px rgba(255,215,0,0.3);
}

#interstitial-ad {
  position: fixed; inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.82);
  z-index: 120;
  padding: 16px;
}
#interstitial-ad .ad-panel {
  width: min(420px, 100%);
  background: rgba(15, 15, 28, 0.97);
  border: 1px solid rgba(255, 215, 0, 0.25);
  border-radius: 18px;
  padding: 26px 24px;
  text-align: center;
  box-shadow: 0 0 40px rgba(255, 215, 0, 0.18);
}
#interstitial-ad .ad-badge {
  display: inline-block;
  margin-bottom: 14px;
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(255, 215, 0, 0.18);
  color: #FFD700;
  font-weight: 800;
  letter-spacing: 1px;
  font-size: 0.8rem;
}
#interstitial-ad h3 {
  margin-bottom: 10px;
  font-size: 1.4rem;
  letter-spacing: 1px;
  color: #fff;
}
#interstitial-ad p {
  margin-bottom: 20px;
  color: #ddd;
  line-height: 1.5;
}

/* ===== LEVEL COMPLETE ===== */
.lc-stars { font-size: 2rem; }
.lc-stat { font-size: 0.9rem; color: #ccc; }

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

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: rgba(255,255,255,0.05); border-radius: 3px; }
::-webkit-scrollbar-thumb { background: rgba(255,200,40,0.3); border-radius: 3px; }

/* ===== RESPONSIVE ===== */
@media (max-width: 480px) {
  .level-grid { grid-template-columns: repeat(3, 1fr); }
  .game-title-big { font-size: 2.5rem; }
  .overlay-panel { padding: 20px 14px; }
}
