:root {
  --bg: #12101f;
  --panel: #1d1a33;
  --panel2: #27234a;
  --line: #3a3566;
  --text: #f3f0ff;
  --muted: #a9a3d1;
  --accent: #ffd23f;
  --accent2: #3ee6a8;
  --danger: #ff6b6b;
  --radius: 14px;
  font-family: "Nunito", system-ui, -apple-system, "Segoe UI", sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); overflow: hidden; -webkit-tap-highlight-color: transparent; }
button { font: inherit; cursor: pointer; }
input { font: inherit; }

#game { position: fixed; inset: 0; width: 100vw; height: 100vh; height: 100dvh; display: block; touch-action: none; }

.btn { background: var(--accent); color: #1b1530; border: 0; border-radius: 12px; padding: 12px 18px; font-weight: 800; font-size: 16px; box-shadow: 0 4px 0 #b38f12; transition: transform .08s; }
.btn:active { transform: translateY(3px); box-shadow: 0 1px 0 #b38f12; }
.btn.alt { background: var(--panel2); color: var(--text); box-shadow: 0 4px 0 #0c0a18; }
.btn.green { background: var(--accent2); box-shadow: 0 4px 0 #1a8f66; }
.btn.small { padding: 8px 12px; font-size: 14px; }
.btn[disabled] { opacity: .5; pointer-events: none; }

.overlay { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; background: rgba(10, 8, 22, .82); z-index: 20; padding: 16px; }
.overlay.hidden { display: none; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 20px; padding: 22px; width: min(420px, 100%); max-height: calc(100dvh - 32px); overflow: auto; }
.card h1 { margin: 0 0 4px; font-size: 30px; letter-spacing: .5px; }
.card h2 { margin: 0 0 12px; font-size: 22px; }
.card p { color: var(--muted); margin: 6px 0 14px; line-height: 1.4; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.row { display: flex; gap: 8px; }
.row > * { flex: 1; }
.field { background: var(--bg); border: 1px solid var(--line); color: var(--text); border-radius: 12px; padding: 12px; font-size: 16px; width: 100%; }
.howto { background: var(--panel2); border-radius: 12px; padding: 10px 12px; font-size: 14px; color: var(--muted); margin-bottom: 14px; }
.howto b { color: var(--text); }
.linkrow { display: flex; justify-content: space-between; margin-top: 12px; font-size: 14px; }
.linkrow a { color: var(--muted); }
.err { color: var(--danger); min-height: 1em; font-size: 14px; }

#hud { position: fixed; top: 0; left: 0; right: 0; display: flex; align-items: center; gap: 8px; padding: 8px 10px; z-index: 10; pointer-events: none; }
#hud > * { pointer-events: auto; }
.pill { background: rgba(29, 26, 51, .85); border: 1px solid var(--line); border-radius: 999px; padding: 6px 12px; font-weight: 800; font-size: 14px; white-space: nowrap; }
.pill.coin::before { content: "●"; color: var(--accent); margin-right: 6px; }
#hud .spacer { flex: 1; }
#hudInfo { overflow: hidden; text-overflow: ellipsis; }

.results table { width: 100%; border-collapse: collapse; margin: 6px 0 12px; }
.results td { padding: 7px 6px; border-bottom: 1px solid var(--line); }
.results tr.me td { color: var(--accent); font-weight: 800; }
.results td.n { text-align: right; font-variant-numeric: tabular-nums; }
.adslot { border: 1px dashed var(--line); border-radius: 12px; padding: 14px; text-align: center; color: var(--muted); font-size: 12px; margin: 10px 0; background: repeating-linear-gradient(45deg, transparent 0 8px, rgba(255,255,255,.02) 8px 16px); }
.adfull { position: fixed; inset: 0; z-index: 50; background: #000; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; color: #fff; }
.adfull .adbox { width: min(560px, 90vw); aspect-ratio: 16/9; border-radius: 12px; background: linear-gradient(135deg, #3b2b8f, #c2367a); display: flex; align-items: center; justify-content: center; font-size: 22px; font-weight: 800; text-align: center; padding: 20px; }

#touch { position: fixed; inset: 0; z-index: 5; pointer-events: none; }
.tbtn { position: fixed; pointer-events: auto; width: 84px; height: 84px; border-radius: 50%; background: rgba(255, 210, 63, .25); border: 3px solid rgba(255, 210, 63, .8); color: #fff; font-weight: 900; font-size: 15px; display: flex; align-items: center; justify-content: center; user-select: none; -webkit-user-select: none; touch-action: none; }
.tbtn.on { background: rgba(255, 210, 63, .6); }
.stick-base { position: fixed; width: 120px; height: 120px; border-radius: 50%; border: 3px solid rgba(255,255,255,.3); background: rgba(255,255,255,.06); pointer-events: none; transform: translate(-50%, -50%); }
.stick-knob { position: absolute; left: 50%; top: 50%; width: 52px; height: 52px; margin: -26px 0 0 -26px; border-radius: 50%; background: rgba(255,255,255,.5); }

.toast { position: fixed; left: 50%; top: 56px; transform: translateX(-50%); background: var(--panel2); border: 1px solid var(--line); padding: 8px 14px; border-radius: 999px; z-index: 60; font-weight: 700; font-size: 14px; transition: opacity .3s; }
.center-msg { position: fixed; left: 50%; top: 40%; transform: translate(-50%, -50%); font-size: clamp(28px, 7vw, 56px); font-weight: 900; text-shadow: 0 4px 0 rgba(0,0,0,.4); pointer-events: none; z-index: 8; text-align: center; }

.reward-offer { position: fixed; left: 50%; bottom: 120px; transform: translateX(-50%); z-index: 40; font-size: 17px; box-shadow: 0 4px 0 #1a8f66, 0 8px 30px rgba(0,0,0,.5); }
.reward-offer small { opacity: .7; font-weight: 800; }

/* ---------- phones ---------- */
body { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; touch-action: manipulation; overscroll-behavior: none; }
input, textarea { -webkit-user-select: text; user-select: text; }
#hud { padding: max(8px, env(safe-area-inset-top)) max(10px, env(safe-area-inset-right)) 8px max(10px, env(safe-area-inset-left)); }
#hudInfo { min-width: 0; flex: 0 1 auto; }
#hudInfo:empty { display: none; }
#hudHelp { width: 34px; padding: 6px 0; text-align: center; color: var(--text); }
.hintbtn { color: var(--text); }
.hintbtn small { color: var(--accent); font-weight: 900; }
#hud button.pill { cursor: pointer; font-family: inherit; color: var(--text); }
@media (max-width: 430px) {
  #hud { gap: 5px; }
  .pill { padding: 6px 9px; font-size: 13px; }
  #hudHelp { width: 30px; }
  .card { padding: 18px; }
  .card h1 { font-size: 26px; }
}
@media (max-width: 360px) { #hudRoom { display: none; } }

.stick-ghost { position: fixed; left: calc(18px + env(safe-area-inset-left)); bottom: calc(40px + env(safe-area-inset-bottom)); width: 132px; display: flex; flex-direction: column; align-items: center; gap: 6px; pointer-events: none; opacity: .75; animation: ghostPulse 1.6s ease-in-out infinite; }
.stick-ghost.full { left: 50%; transform: translateX(-50%); }
.stick-ghost div { width: 96px; height: 96px; border-radius: 50%; border: 3px dashed rgba(255,255,255,.45); background: radial-gradient(circle, rgba(255,255,255,.35) 0 22px, transparent 23px); }
.stick-ghost span { font-weight: 800; font-size: 13px; color: #fff; text-shadow: 0 1px 3px #000; }
@keyframes ghostPulse { 50% { opacity: .35; } }

.tipcard { position: fixed; left: 50%; top: calc(56px + env(safe-area-inset-top)); transform: translateX(-50%); width: min(440px, calc(100vw - 24px)); display: flex; align-items: center; gap: 10px; background: #fff8d6; color: #1b1530; border-radius: 16px; padding: 10px 12px; z-index: 30; font-weight: 800; font-size: 15px; line-height: 1.3; box-shadow: 0 8px 30px rgba(0,0,0,.45); transition: opacity .3s; }
.tipcard::before { content: "💡"; font-size: 22px; }
.tiparrow { flex: 0 0 auto; width: 34px; height: 34px; border-radius: 50%; background: #1b1530; color: #ffd23f; display: flex; align-items: center; justify-content: center; font-size: 20px; }
.tiptext { flex: 1; }
.tipx { background: none; border: 0; color: #1b1530; opacity: .5; font-size: 16px; padding: 4px; }

.tut .card { text-align: center; }
.tutstep { color: var(--muted); font-size: 13px; font-weight: 800; }
.tuticon { font-size: 64px; line-height: 1.1; margin: 10px 0 4px; }
.tut .card h2 { margin: 4px 0 6px; }
.tuttext { min-height: 66px; color: var(--text) !important; font-size: 16px; }
.tuttext b { color: var(--accent); }
.tutdots { display: flex; justify-content: center; gap: 6px; margin: 4px 0 14px; }
.tutdots span { width: 8px; height: 8px; border-radius: 50%; background: var(--line); }
.tutdots span.on { background: var(--accent); width: 20px; border-radius: 4px; }
#hud > .pill { flex-shrink: 0; }
#hud > #hudInfo { flex-shrink: 1; }
.stick-ghost.full { bottom: calc(150px + env(safe-area-inset-bottom)); }
