[hidden]{display:none!important}
:root {
  --bg: #0e1611; --panel: #18241c; --tile: #1f2f24; --tile-edge: #33513c;
  --text: #ecf5e9; --dim: #93a893; --good: #4ade80; --bad: #f87171;
  --c0: #f87171; --c1: #60a5fa; --c2: #fbbf24;
}
* { 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%, #16281a 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 4px; }
.brand { font-weight: 800; letter-spacing: 1.5px; font-size: 18px; }
.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, .lvl:active { transform: scale(.95); }
main { flex: 1; display: flex; flex-direction: column; align-items: center; padding: 4px 12px; }

/* ---------- home ---------- */
#homeView { width: min(94vw, 430px); display: flex; flex-direction: column; align-items: center; }
.demo { margin: 20px 0 24px; text-align: center; }
.dbeam { position: relative; width: 280px; height: 96px; margin: 0 auto; }
.dbar {
  position: absolute; left: 0; right: 0; top: 62px; height: 12px; border-radius: 6px;
  background: linear-gradient(180deg, #8a6a44, #664d2f);
  animation: rock 3.4s ease-in-out infinite; transform-origin: 50% 100%;
}
@keyframes rock { 0%,100% { transform: rotate(-5deg); } 40% { transform: rotate(4deg); } 60%,90% { transform: rotate(0deg); } }
.dpivot { position: absolute; left: 50%; top: 72px; transform: translateX(-50%); width: 0; height: 0; border-left: 18px solid transparent; border-right: 18px solid transparent; border-bottom: 26px solid #4a5e4f; }
.da { position: absolute; top: 26px; font-size: 34px; animation: bobA 3.4s ease-in-out infinite; }
.da:nth-child(2) { font-size: 24px; top: 36px; }
.da:nth-child(3) { font-size: 27px; top: 33px; }
@keyframes bobA { 0%,100% { transform: translateY(0) rotate(-4deg); } 40% { transform: translateY(-2px) rotate(3deg); } 60%,90% { transform: translateY(0) rotate(0); } }
.dsparkle { position: absolute; right: 38%; top: 0; font-size: 22px; opacity: 0; animation: spark 3.4s ease-in-out infinite; }
@keyframes spark { 0%,55% { opacity: 0; } 65%,85% { opacity: 1; } 95%,100% { opacity: 0; } }
.demo-cap { margin-top: 14px; 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: #4ade80; }
.lvl.daily { border-color: #a16207; background: linear-gradient(135deg, #25300c, #18241c); }
.lvl.daily .ln { background: #31400e; }
#homeStreak { margin-top: 16px; color: var(--dim); font-size: 14px; }

/* ---------- game ---------- */
#gameView { width: 100%; display: flex; flex-direction: column; align-items: center; }
#beamWrap { position: relative; width: min(96vw, 460px); height: 250px; margin-top: 26px; }
.tut-on #beamWrap { margin-top: 120px; }
#beam { position: absolute; left: 0; right: 0; top: 110px; height: 0; transition: transform .35s ease; transform-origin: 50% 0; }
#bar { position: absolute; left: 0; right: 0; top: -7px; height: 14px; border-radius: 7px; background: linear-gradient(180deg, #8a6a44, #664d2f); box-shadow: 0 3px 8px #0008; }
#beam.balanced #bar { box-shadow: 0 0 16px #4ade8088; }
#pivot { position: absolute; left: 50%; top: 118px; transform: translateX(-50%); width: 0; height: 0; border-left: 26px solid transparent; border-right: 26px solid transparent; border-bottom: 40px solid #4a5e4f; }
#slotsRow { position: absolute; left: 0; right: 0; top: -64px; height: 64px; }
.slot { position: absolute; width: 44px; height: 58px; margin-left: -22px; bottom: 0; display: flex; flex-direction: column; align-items: center; justify-content: flex-start; }
.slot .dist { font-size: 10px; color: var(--dim); margin-top: 2px; }
.slot .seat { width: 42px; height: 42px; border-radius: 50%; border: 2px dashed #42507a; display: flex; align-items: center; justify-content: center; }
.slot .seat { border-color: #3f5a48; background: #16281a99; }
.slot.occupied .seat { border: none; background: none; }
.weight {
  border-radius: 50%; color: #fff; display: flex; align-items: center; justify-content: center;
  cursor: pointer; position: relative; transition: transform .12s, box-shadow .12s;
  box-shadow: inset -3px -4px 0 #0003, 0 2px 6px #0007; flex-direction: column;
}
.weight.c0 { background: var(--c0); } .weight.c1 { background: var(--c1); } .weight.c2 { background: var(--c2); }
.weight .an { line-height: 1; }
.weight .wv { font-size: 9px; font-weight: 800; background: #0006; border-radius: 7px; padding: 0 4px; line-height: 1.4; }
.weight.pinned { cursor: default; filter: brightness(.8); }
.weight.pinned::after { content: '📌'; position: absolute; top: -12px; right: -8px; font-size: 13px; }
.weight.selected { transform: translateY(-8px) scale(1.08); box-shadow: 0 0 0 3px #fff, 0 6px 14px #000; z-index: 7; }
.weight.badpair { box-shadow: 0 0 0 3px var(--bad), 0 0 14px var(--bad); }
.weight.drop { animation: dropin .3s ease; }
@keyframes dropin { 0% { transform: translateY(-16px) scale(1.1); } 100% { transform: translateY(0) scale(1); } }
#hint { min-height: 22px; font-size: 14px; color: var(--dim); margin-top: 4px; text-align: center; }
#hint.ok { color: var(--good); } #hint.bad { color: var(--bad); } #hint.near { color: #fbbf24; }
#trayLabel { font-size: 11px; letter-spacing: 3px; color: var(--dim); margin: 12px 0 6px; }
#tray { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; align-items: center; width: min(96vw, 460px); background: var(--panel); border: 1px solid var(--tile-edge); border-radius: 14px; padding: 12px; min-height: 72px; }
#movesRow { margin-top: 10px; color: var(--dim); font-size: 14px; }

/* ---------- overlays ---------- */
#toast { position: fixed; left: 50%; bottom: 86px; transform: translateX(-50%); background: #20301f; border: 1px solid #3c5a38; 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, #16a34a, #4ade80); color: #06210f; font-size: 16px; font-weight: 800; }
.shareBtn.plain { background: #243528; color: var(--text); margin-top: 8px; }
.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: #0c140e; 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: #24402c; border: 1px solid #3f6846; 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; }
@keyframes glowpulse { 0%,100% { box-shadow: 0 0 0 2px #4ade80, 0 0 12px #4ade8088; } 50% { box-shadow: 0 0 0 4px #4ade80, 0 0 22px #4ade80cc; } }
#confettiCv { position: fixed; inset: 0; z-index: 60; pointer-events: none; }
