/* Subscription Snake. A green phone screen framed in the studio's blocky style:
   square corners, 3px black outlines, hard offset shadows, Rubik type.
   main.js picks the layout: body.side = HUD in a side panel (phones held sideways), otherwise HUD on top. */
:root {
  --T: 20px;
  --paper: #FAF7F0;
  --beige: #EFE7D3;
  --slate: #4C5966;
  --slate-dark: #2C343D;
  --ink: #1E2328;
  --slime: #22AA3A;
  --sunny: #FFC845;
  --sky: #3DA5F4;
  --coral: #FF6B57;
  --grape: #7A5CFF;
  --glow: #80FF84;
  --lcd: #A8C66C;
  --lcd-dark: #2B3A1E;
  --font: "Rubik", system-ui, -apple-system, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  height: 100dvh;
  overflow: hidden;
  background: var(--slate);
  color: var(--ink);
  font: 400 16px/1.35 var(--font);
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
  overscroll-behavior: none;
}
button { font: inherit; color: inherit; }
kbd { font: 500 0.85em var(--font); padding: 0 4px; border: 2px solid #000; background: var(--paper); }

/* The arcade link only shows on the menus, never over the board. */
body:not(.menu) .ml-arcade { display: none; }

/* ---------- Stage ---------- */
.stage {
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: max(8px, env(safe-area-inset-top)) max(8px, env(safe-area-inset-right)) max(8px, env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left));
}
body.side .stage { flex-direction: row; }

/* ---------- HUD ---------- */
.hud {
  flex: none;
  display: flex;
  align-items: stretch;
  gap: 6px;
  height: 48px;
  max-width: 100%;
}
.hud-item {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 2px 8px;
  background: var(--beige);
  border: 3px solid #000;
  box-shadow: 3px 3px 0 #000;
}
.hud .label { font-size: 11px; font-weight: 500; color: #4A4F55; line-height: 1.2; white-space: nowrap; }
.hud .val { font-weight: 800; font-size: 18px; line-height: 1.1; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; }
.hud .val small { font-size: 11px; font-weight: 500; }
.hud-item.low { background: var(--coral); }
.hud-item.low .label { color: #000; }
.hud-item.month { flex-grow: 1.2; gap: 4px; }
.hud-item.month .label { font-weight: 800; font-size: 13px; color: var(--ink); }
.bill-bar { display: block; height: 10px; border: 2px solid #000; background: var(--paper); }
#bill-fill { display: block; height: 100%; width: 0; background: var(--coral); }
.hud-buttons { flex: none; display: flex; gap: 6px; }
.icon-btn {
  width: 44px;
  min-height: 44px;
  padding: 0;
  border: 3px solid #000;
  background: var(--beige);
  box-shadow: 3px 3px 0 #000;
  font-weight: 800;
  font-size: 16px;
  cursor: pointer;
}
.icon-btn:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 #000; }

/* Narrow screens: hide the labels' bulk, keep numbers. */
@media (max-width: 420px) {
  .hud { gap: 4px; }
  .hud-item { padding: 1px 5px; }
  .hud .val { font-size: 15px; }
  .hud .val small { display: none; }
  .icon-btn { width: 36px; }
}

/* Side panel (phones held sideways, short wide windows). */
body.side .hud {
  flex-direction: column;
  height: auto;
  max-height: 100%;
  gap: 5px;
}
body.side .hud-item { flex: none; flex-direction: row; align-items: baseline; justify-content: space-between; gap: 6px; padding: 3px 8px; }
body.side .hud-item.month { flex-direction: column; align-items: stretch; }
body.side .hud-buttons { gap: 8px; }
@media (max-height: 300px) {
  body.side .hud-item { padding: 1px 8px; }
  body.side .hud .val { font-size: 16px; }
  body.side .icon-btn { min-height: 36px; }
}

/* ---------- Board ---------- */
.board-wrap {
  position: relative;
  flex: none;
  line-height: 0;
  border: 3px solid #000;
  box-shadow: 5px 5px 0 #000;
  background: var(--lcd);
}
#board { display: block; image-rendering: pixelated; cursor: pointer; }
.toast {
  position: absolute;
  left: 6px;
  right: 6px;
  top: 6px;
  margin: 0;
  padding: 4px 8px;
  background: rgba(30, 35, 40, 0.88);
  color: #fff;
  font: 500 13px/1.3 var(--font);
  text-align: center;
  pointer-events: none;
  max-height: 3.9em;
  overflow: hidden;
}
.toast.bottom { top: auto; bottom: 6px; }
.toast[hidden] { display: none; }
.count {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font: 800 calc(var(--T) * 4) / 1 var(--font);
  color: var(--lcd-dark);
  opacity: 0.7;
  pointer-events: none;
}
.count[hidden] { display: none; }

/* ---------- Cancel window ---------- */
.cancel {
  position: fixed;
  z-index: 10;
  width: 300px;
  display: flex;
  flex-direction: column;
  background: var(--paper);
  border: 3px solid #000;
  box-shadow: 5px 5px 0 #000;
  line-height: 1.3;
  animation: popin 0.12s steps(3) 1;
}
.cancel[hidden] { display: none; }
@keyframes popin { from { transform: scale(0.7); } to { transform: scale(1); } }
.cancel-title {
  flex: none;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 2px 3px 2px 10px;
  background: var(--slate);
  color: #fff;
  font-weight: 700;
  font-size: 14px;
  border-bottom: 3px solid #000;
}
.cancel-title span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cancel-x { width: 34px; height: 30px; padding: 0; border: 2px solid #000; background: var(--beige); color: #000; font-weight: 700; cursor: pointer; }
.cancel-body { padding: 8px 10px 10px; overflow: auto; min-height: 0; }
.c-sub { display: flex; align-items: center; gap: 6px; margin: 0; font-size: 12px; font-weight: 500; color: #4A4F55; }
.c-swatch { flex: none; width: 12px; height: 12px; border: 2px solid #000; }
.c-sub span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.c-step { margin: 2px 0 0; font-size: 11px; color: #4A4F55; }
.c-h { margin: 4px 0 2px; font-size: 17px; font-weight: 800; }
.c-h.done { color: var(--slime); color: #1D6831; }
.c-text { margin: 0 0 8px; font-size: 13px; }
.c-buttons { display: flex; flex-wrap: wrap; gap: 8px; }
.c-buttons.stack { flex-direction: column; align-items: stretch; }
.cbtn {
  flex: 1 1 auto;
  min-height: 40px;
  padding: 6px 10px;
  border: 3px solid #000;
  background: var(--paper);
  box-shadow: 3px 3px 0 #000;
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
}
.cbtn.bright { background: var(--sunny); }
.cbtn.big { min-height: 48px; font-size: 16px; }
.cbtn:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 #000; }
.c-link {
  align-self: center;
  min-height: 32px;
  padding: 4px 8px;
  border: 0;
  background: none;
  color: #8A9097;
  font-size: 11px;
  text-decoration: underline;
  cursor: pointer;
}
.cbtn kbd, .c-link kbd { display: none; margin-right: 6px; font-size: 10px; padding: 0 3px; border-width: 1px; }
@media (hover: hover) and (pointer: fine) { .cbtn kbd, .c-link kbd { display: inline-block; } }
.c-bar { flex: 1; height: 18px; border: 3px solid #000; background: var(--beige); }
.c-bar span { display: block; height: 100%; width: 0; background: var(--sky); }
@media (max-height: 300px) {
  .cancel-body { padding: 4px 8px 8px; }
  .c-step { display: none; }
  .c-h { font-size: 15px; margin-top: 2px; }
  .c-text { font-size: 12px; margin-bottom: 6px; }
  .cbtn { min-height: 36px; padding: 4px 8px; font-size: 13px; }
  .c-buttons { gap: 6px; }
}

/* ---------- Menus ---------- */
.scrim {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: max(12px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) max(12px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
  background: rgba(30, 35, 40, 0.5);
}
.scrim[hidden] { display: none; }
.dialog {
  display: flex;
  flex-direction: column;
  width: min(460px, 100%);
  max-height: 100%;
  background: var(--beige);
  border: 3px solid #000;
  box-shadow: 5px 5px 0 #000;
}
.dialog-title {
  flex: none;
  margin: 0;
  padding: 8px 14px;
  background: var(--lcd);
  border-bottom: 3px solid #000;
  font-size: 22px;
  font-weight: 800;
  line-height: 1.2;
}
.dialog-text { flex: 1 1 auto; min-height: 0; overflow: auto; padding: 12px 16px 0; }
.dialog-text p { margin: 0 0 10px; }
.dialog-buttons { flex: none; display: flex; flex-wrap: wrap; gap: 10px; padding: 12px 16px 16px; }
.lead { font-size: 17px; font-weight: 500; }
.how { margin: 0 0 10px; padding-left: 20px; font-size: 15px; }
.how li { margin-bottom: 4px; }
.chip { display: inline-block; min-width: 20px; padding: 0 4px; border: 2px solid #000; font-weight: 800; text-align: center; line-height: 1.2; }
.chip.cash { background: var(--slime); color: #fff; }
.keys { font-size: 13px; color: #4A4F55; }
.touch-only { display: none; }
body.touch .touch-only { display: inline; }
body.touch .key-only { display: none; }
.best-line { font-weight: 700; }
.btn {
  min-height: 46px;
  padding: 10px 18px;
  border: 3px solid #000;
  background: var(--paper);
  box-shadow: 5px 5px 0 #000;
  font-weight: 700;
  font-size: 16px;
  cursor: pointer;
}
.btn.primary { background: var(--sunny); }
.btn:hover { transform: translate(-1px, -1px); box-shadow: 6px 6px 0 #000; }
.btn:active { transform: translate(3px, 3px); box-shadow: 2px 2px 0 #000; }
.btn:focus-visible, .icon-btn:focus-visible, .cbtn:focus-visible, .cancel-x:focus-visible { outline: 3px solid var(--sky); outline-offset: 2px; }
.big-score { font-size: 40px; font-weight: 800; margin: 0 0 8px; font-variant-numeric: tabular-nums; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.tag { font-size: 14px; font-weight: 700; padding: 4px 10px; background: var(--glow); border: 3px solid #000; box-shadow: 3px 3px 0 #000; }
.facts { display: grid; grid-template-columns: auto 1fr; gap: 4px 14px; margin: 0 0 6px; font-size: 15px; }
.facts dt { color: #4A4F55; }
.facts dd { margin: 0; font-weight: 700; }

/* Phones held sideways: everything smaller, and the arcade link gets its corner. */
@media (max-height: 420px) {
  .scrim { padding-left: max(12px, env(safe-area-inset-left)); }
  .dialog-title { font-size: 18px; padding: 5px 12px; }
  .dialog-text { padding: 8px 12px 0; }
  .dialog-text p, .how { font-size: 13px; margin-bottom: 6px; }
  .how li { margin-bottom: 2px; }
  .lead { font-size: 14px; }
  .dialog-buttons { padding: 8px 12px 12px; }
  .btn { min-height: 42px; padding: 8px 16px; }
  .big-score { font-size: 28px; margin-bottom: 4px; }
  .facts { font-size: 13px; gap: 2px 12px; }
}
@media (max-height: 420px) and (min-width: 600px) {
  .dialog { width: min(560px, calc(100% - 170px)); margin-left: 150px; }
}

@media (prefers-reduced-motion: reduce) {
  .cancel { animation: none; }
}
