[hidden]{display:none!important}
:root {
  --bg: #14100a; --panel: #241c10; --tile: #2e2413; --tile-edge: #4d3d1e;
  --arrow: #fcd34d; --tap: #fbbf24; --entry: #a3e635; --target: #fb7185;
  --text: #fdf3e0; --dim: #b3a687;
}
* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body {
  background: radial-gradient(120% 100% at 50% 0%, #241b08 0%, var(--bg) 60%);
  color: var(--text); font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  display: flex; flex-direction: column; min-height: 100dvh; user-select: none;
}
header { display: flex; align-items: center; gap: 10px; padding: 12px 14px 6px; }
.brand { font-weight: 800; letter-spacing: 2px; font-size: 20px; }
.puz-line { color: var(--dim); font-size: 13px; flex: 1; }
.hbtns { display: flex; gap: 8px; }
.icon-btn { width: 36px; height: 36px; border-radius: 50%; border: 1px solid var(--tile-edge); background: var(--panel); color: var(--text); font-size: 16px; font-weight: 700; }
.icon-btn:active, .ctl:active, .lvl:active { transform: scale(.95); }
main { flex: 1; display: flex; flex-direction: column; align-items: center; padding: 6px 12px; }

/* ---------- home ---------- */
#homeView { width: min(94vw, 430px); display: flex; flex-direction: column; align-items: center; }
.demo { margin: 18px 0 22px; text-align: center; }
.dstrip { position: relative; display: flex; gap: 6px; align-items: center; justify-content: center; height: 64px; }
.dtile { width: 52px; height: 52px; background: var(--tile); border: 1px solid var(--tile-edge); border-radius: 12%; display: flex; align-items: center; justify-content: center; }
.dtile svg { width: 62%; height: 62%; transform: rotate(90deg); }
.dtile.spin svg { animation: spin4 1.6s steps(4) infinite; }
@keyframes spin4 { to { transform: rotate(450deg); } }
.dgoal { font-size: 40px; margin-left: 4px; }
.dbee { position: absolute; left: 4px; top: 8px; font-size: 30px; animation: flyby 3.2s ease-in-out infinite; }
@keyframes flyby {
  0% { left: -2px; opacity: 0; } 8% { opacity: 1; }
  70% { left: calc(100% - 66px); opacity: 1; }
  85%, 100% { left: calc(100% - 60px); opacity: 0; }
}
.demo-cap { margin-top: 12px; color: var(--dim); font-size: 15px; line-height: 1.5; }
#levelList { width: 100%; display: flex; flex-direction: column; gap: 10px; }
.lvl {
  display: flex; align-items: center; gap: 14px; width: 100%; text-align: left;
  background: var(--panel); border: 1px solid var(--tile-edge); border-radius: 16px;
  padding: 14px 16px; color: var(--text); transition: transform .1s;
}
.lvl .ln {
  width: 44px; height: 44px; border-radius: 12px; background: var(--tile);
  display: flex; align-items: center; justify-content: center; font-size: 20px; font-weight: 800; flex-shrink: 0;
}
.lvl .lt { flex: 1; font-size: 16px; font-weight: 700; }
.lvl .lt small { display: block; color: var(--dim); font-weight: 400; font-size: 12px; margin-top: 2px; }
.lvl .lc { font-size: 20px; color: #65a30d; }
.lvl.daily { border-color: #a16207; background: linear-gradient(135deg, #2b2008, #241c10); }
.lvl.daily .ln { background: #3b2f0b; }
#homeStreak { margin-top: 16px; color: var(--dim); font-size: 14px; }

/* ---------- game ---------- */
#gameView { width: 100%; display: flex; flex-direction: column; align-items: center; }
#boardWrap { position: relative; width: min(94vw, 430px); padding: 26px; }
#grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 4px; width: 100%; aspect-ratio: 1; }
.tile {
  position: relative; background: var(--tile); border: 1px solid var(--tile-edge);
  border-radius: 12%; display: flex; align-items: center; justify-content: center;
  cursor: pointer; transition: background .15s, border-color .15s;
}
.tile svg { width: 62%; height: 62%; transition: transform .18s ease; }
.tile.tapped { border-color: var(--tap); background: #40330f; box-shadow: 0 0 10px #fbbf2455 inset; }
.tile .badge {
  position: absolute; top: -6px; right: -6px; background: var(--tap); color: #1a1a1a;
  font-size: 11px; font-weight: 800; min-width: 18px; height: 18px; border-radius: 9px;
  display: flex; align-items: center; justify-content: center; padding: 0 4px;
}
.tile.entrycell { border-color: var(--entry); }
.tile.targetcell { border-color: var(--target); }
.gate { position: absolute; width: 32px; height: 32px; display: flex; align-items: center; justify-content: center; font-size: 26px; pointer-events: none; }
#ball {
  position: absolute; width: 26px; height: 26px; font-size: 22px; line-height: 26px; text-align: center;
  transition: top .13s linear, left .13s linear; z-index: 5; pointer-events: none;
  filter: drop-shadow(0 0 6px #fcd34d);
}
#tapRow { display: flex; align-items: center; gap: 8px; margin: 4px 0 10px; font-size: 20px; }
#tapDots i { display: inline-block; width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--tap); margin: 0 3px; vertical-align: middle; }
#tapDots i.used { background: var(--tap); }
#controls { display: flex; gap: 10px; width: min(94vw, 430px); }
.ctl { flex: 1; padding: 13px 0; border-radius: 12px; border: 1px solid var(--tile-edge); background: var(--panel); color: var(--text); font-size: 16px; font-weight: 700; transition: transform .1s; }
.ctl:disabled { opacity: .35; }
.ctl.primary { background: linear-gradient(135deg, #d97706, #fbbf24); border: none; font-size: 17px; color: #241a05; }
.ctl.primary:disabled { opacity: .5; }
#attemptRow { display: flex; gap: 5px; margin-top: 12px; min-height: 22px; font-size: 18px; }

/* ---------- overlays ---------- */
#toast {
  position: fixed; left: 50%; bottom: 86px; transform: translateX(-50%);
  background: #3a2c10; border: 1px solid #6b5518; color: var(--text);
  padding: 10px 18px; border-radius: 20px; font-size: 14px; z-index: 30; max-width: 86vw; text-align: center;
}
#modal { position: fixed; inset: 0; background: #000a; z-index: 40; display: flex; align-items: flex-end; justify-content: center; }
#modal[hidden]{display:none}
.sheet { background: var(--panel); border-radius: 20px 20px 0 0; width: min(100vw, 480px); padding: 22px 20px 30px; position: relative; max-height: 82dvh; overflow-y: auto; }
.sheet .x { position: absolute; top: 12px; right: 14px; background: none; border: none; color: var(--dim); font-size: 18px; }
#modalBody h2 { font-size: 19px; margin-bottom: 10px; }
#modalBody p { color: var(--dim); font-size: 14px; line-height: 1.55; margin: 8px 0; }
#modalBody .big { font-size: 15px; color: var(--text); }
.statgrid { display: flex; gap: 10px; margin: 14px 0; }
.statgrid div { flex: 1; background: var(--tile); border-radius: 12px; padding: 10px 4px; text-align: center; }
.statgrid b { display: block; font-size: 22px; }
.statgrid span { font-size: 11px; color: var(--dim); }
.shareBtn { width: 100%; padding: 14px; border-radius: 12px; border: none; margin-top: 10px; background: linear-gradient(135deg, #65a30d, #f59e0b); color: #fff; font-size: 16px; font-weight: 800; }
.howstep { display: flex; gap: 12px; align-items: center; margin: 12px 0; }
.howstep .ic { font-size: 26px; width: 40px; text-align: center; flex-shrink: 0; }
footer { text-align: center; color: var(--dim); font-size: 12px; padding: 12px 0 16px; }
footer a { color: var(--dim); }
.winemoji { font-size: 44px; text-align: center; margin: 6px 0 2px; animation: pop .45s ease; }
@keyframes pop { 0% { transform: scale(0); } 70% { transform: scale(1.25); } 100% { transform: scale(1); } }
.sharepreview { background: #171106; border-radius: 10px; padding: 12px; font-family: ui-monospace, monospace; font-size: 15px; white-space: pre-wrap; margin-top: 12px; border: 1px solid var(--tile-edge); }

/* tutorial coach */
#coach {
  position: fixed; top: 58px; left: 50%; transform: translateX(-50%); z-index: 25;
  display: flex; align-items: center; gap: 10px; max-width: 92vw;
  background: #3d3013; border: 1px solid #6b5518; border-radius: 22px;
  padding: 10px 14px; font-size: 14px; box-shadow: 0 6px 20px #000a;
}
#coach[hidden]{display:none}
#coachSkip { background: none; border: none; color: var(--dim); font-size: 13px; white-space: nowrap; }
#pointer { position: fixed; z-index: 26; font-size: 26px; pointer-events: none; animation: bob 0.9s ease-in-out infinite; filter: drop-shadow(0 2px 4px #000); }
#pointer[hidden]{display:none}
@keyframes bob { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-9px); } }
.tut-glow { animation: glowpulse 1.1s ease-in-out infinite; z-index: 6; }
@keyframes glowpulse { 0%,100% { box-shadow: 0 0 0 2px #fbbf24, 0 0 12px #fbbf2488; } 50% { box-shadow: 0 0 0 4px #fbbf24, 0 0 22px #fbbf24cc; } }

/* confetti canvas */
#confettiCv { position: fixed; inset: 0; z-index: 60; pointer-events: none; }
