:root {
  --ink: #f4e6d4;
  --dim: #9aa6a8;
  --sodium: #ff8a2a;
  --teal: #2fd8cf;
  --night: #0b0d10;
  --slab: #1a1e22;
  --line: rgba(255, 170, 90, .35);
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--night); color: var(--ink); overflow: hidden;
  font: 15px/1.4 ui-monospace, "SF Mono", "Roboto Mono", Menlo, Consolas, monospace;
  -webkit-tap-highlight-color: transparent; -webkit-user-select: none; user-select: none;
  touch-action: manipulation;
}
#sky { position: fixed; inset: 0; width: 100%; height: 100%; z-index: 0; }
#shell {
  position: relative; z-index: 1; height: 100dvh; display: grid;
  grid-template-rows: auto 1fr auto auto;
  padding: max(8px, env(safe-area-inset-top)) 12px max(10px, env(safe-area-inset-bottom));
  max-width: 520px; margin: 0 auto;
}
.glow {
  font-family: "Arial Narrow", "Helvetica Neue", Arial, sans-serif; font-stretch: condensed;
  letter-spacing: .32em; font-weight: 700; color: #ffd9b0;
  text-shadow: 0 0 6px rgba(255, 138, 42, .9), 0 0 22px rgba(255, 110, 20, .55), 0 0 44px rgba(47, 216, 207, .25);
}
#hud { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding-bottom: 6px; }
#hud h1 { margin: 0; font-size: clamp(15px, 4.6vw, 22px); }
.stats { display: flex; gap: 12px; margin: 0; }
.stats div { text-align: right; }
.stats dt { font-size: 10px; letter-spacing: .2em; text-transform: uppercase; color: var(--dim); }
.stats dd { margin: 0; font-size: 17px; color: var(--teal); text-shadow: 0 0 8px rgba(47, 216, 207, .6); font-variant-numeric: tabular-nums; }
#stage { display: flex; overflow: hidden; justify-content: center; align-items: center; gap: 10px; min-height: 0; }
#board {
  width: 160px; height: 320px; flex: none;
  background: rgba(6, 8, 10, .72); border: 1px solid var(--line);
  box-shadow: 0 0 0 1px rgba(0,0,0,.6), 0 0 28px rgba(255, 120, 30, .18), inset 0 0 40px rgba(47, 216, 207, .06);
  touch-action: none; image-rendering: auto;
}
#side { align-self: stretch; display: flex; flex-direction: column; align-items: center; gap: 10px; padding-top: 4px; width: 76px; }
#side .label { margin: 0; font-size: 10px; letter-spacing: .3em; color: var(--dim); }
#next { width: 72px; height: 72px; border: 1px solid var(--line); background: rgba(6, 8, 10, .6); }
button {
  font: inherit; color: var(--ink); border-radius: 2px; cursor: pointer; min-height: 44px; min-width: 44px;
  background: linear-gradient(#262a2e, #17191c); border: 1px solid #3a3f44;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.06), 0 2px 0 #000;
}
button:active { transform: translateY(1px); }
button:focus-visible { outline: 2px solid var(--teal); outline-offset: 2px; }
button.primary {
  background: linear-gradient(#ff9a3d, #d4600f); color: #1a0e04; border-color: #ffb36b; font-weight: 700; letter-spacing: .15em;
  box-shadow: 0 0 18px rgba(255, 120, 30, .5), inset 0 1px 0 rgba(255,255,255,.35);
}
button.ghost { background: rgba(20, 24, 28, .7); border-color: rgba(47, 216, 207, .45); color: #bff4ef; }
button.small { font-size: 10px; letter-spacing: .05em; padding: 4px; min-height: 44px; width: 72px; line-height: 1.1; }
#pause { width: 72px; letter-spacing: .1em; }
#pad { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; padding-top: 10px; }
#pad button { min-height: 58px; font-size: 22px; }
#pad button[data-act="hard"] { color: var(--sodium); border-color: rgba(255, 138, 42, .55); }
#lab-offline-status { margin: 4px 0 0; min-height: 0; font-size: 11px; color: var(--dim); text-align: center; }
#lab-offline-status:empty { display: none; }

.overlay {
  position: fixed; inset: 0; z-index: 5; display: grid; place-items: center; padding: 18px;
  background: radial-gradient(ellipse at 50% 30%, rgba(255, 120, 30, .22), rgba(6, 8, 10, .86) 70%);
  backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px);
}
.overlay[hidden] { display: none; }
.card { display: none; width: min(360px, 100%); text-align: center; padding: 22px 18px;
  background: rgba(14, 16, 19, .9); border: 1px solid var(--line);
  box-shadow: 0 0 40px rgba(255, 120, 30, .15), inset 0 0 0 1px rgba(47, 216, 207, .08); }
.overlay[data-screen="title"] #card-title,
.overlay[data-screen="pause"] #card-pause,
.overlay[data-screen="over"] #card-over,
.overlay[data-screen="scores"] #card-scores { display: grid; gap: 12px; }
.card h2 { margin: 0; font-size: 22px; }
.card h2.big { font-size: clamp(34px, 12vw, 52px); line-height: 1.05; letter-spacing: .28em; padding-left: .28em; }
.tag { margin: 0; color: #e7c9a5; }
.hint { margin: 0; font-size: 11px; color: var(--dim); }
.final { margin: 0; font-size: 18px; }
.final strong { color: var(--teal); text-shadow: 0 0 10px rgba(47, 216, 207, .7); }
#save-form label { display: block; font-size: 12px; color: var(--dim); margin-bottom: 6px; }
.row { display: flex; gap: 8px; }
input {
  flex: 1; min-width: 0; min-height: 44px; font: inherit; font-size: 16px; color: var(--ink);
  background: #0d0f12; border: 1px solid rgba(47, 216, 207, .5); padding: 0 10px; border-radius: 2px;
  -webkit-user-select: text; user-select: text;
}
#save-status, #scores-status { margin: 0; min-height: 1.2em; font-size: 12px; color: #e7c9a5; }
.table { list-style: none; margin: 0; padding: 0; text-align: left; max-height: 40dvh; overflow: auto; }
.table li { display: grid; grid-template-columns: 2.2em 1fr auto; gap: 8px; padding: 6px 4px; border-bottom: 1px solid rgba(255,255,255,.06); }
.table li .r { color: var(--dim); }
.table li .s { color: var(--teal); font-variant-numeric: tabular-nums; }
.table li.me { background: rgba(255, 138, 42, .14); }
.table:empty { display: none; }
dialog { max-width: min(26rem, 90vw); background: #121519; color: var(--ink); border: 1px solid var(--line); border-radius: 4px; }
dialog::backdrop { background: rgba(0,0,0,.6); }
dialog button { margin: 4px; padding: 0 14px; }
@media (min-height: 760px) { #pad button { min-height: 64px; } }
