:root {
  color-scheme: dark;
  --ink: #0d0b1a;
  --night-900: #141032;
  --night-800: #1b1544;
  --night-700: #241c5c;
  --night-500: #3b2f8f;
  --hansip: #5c7a2e;
  --lamp: #ffd23f;
  --pink: #ff4f9a;
  --cyan: #3df5ff;
  --green: #7dff6a;
  --paper: #fff6d6;
  --muted: #b9b0e6;
  --font: 'Press Start 2P', ui-monospace, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--night-900);
  background-image:
    radial-gradient(circle at 20% 10%, rgba(255, 210, 63, 0.08), transparent 40%),
    radial-gradient(circle at 85% 90%, rgba(255, 79, 154, 0.08), transparent 40%);
  color: var(--paper);
  font-family: var(--font);
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
}

button { font-family: inherit; color: inherit; cursor: pointer; }

/* game layout (HUD, stage, tasks, controls) lives in css/layout.css */

/* ---------- screens ---------- */
.screen {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
  overflow-y: auto;
  background: rgba(20, 16, 50, 0.72);
  z-index: 10;
}
.screen.active { display: flex; }
#screen-title, #screen-select, #screen-howto { background: rgba(20, 16, 50, 0.55); }
.screen-dialog { align-items: flex-end; background: rgba(8, 6, 32, 0.35); }

.panel {
  background: var(--night-700);
  border: 4px solid var(--ink);
  outline: 2px solid var(--night-500);
  outline-offset: -8px;
  box-shadow: 8px 8px 0 var(--ink);
  padding: 28px;
  max-width: 460px;
  width: 100%;
  text-align: center;
  margin: auto;
}
.small-panel { max-width: 420px; }
h2 { font-size: 18px; color: var(--lamp); margin: 0 0 12px; line-height: 1.5; text-shadow: 3px 3px 0 var(--ink); }
.muted { color: var(--muted); font-size: 10px; line-height: 1.8; margin: 0 0 16px; }
.eyebrow { color: var(--cyan); font-size: 10px; letter-spacing: 2px; margin: 0 0 14px; }

.btn {
  font-size: 12px;
  padding: 14px 18px;
  background: var(--lamp);
  color: var(--ink);
  border: 4px solid var(--ink);
  box-shadow: 4px 4px 0 var(--ink);
  transition: transform 0.06s steps(1), box-shadow 0.06s steps(1);
  line-height: 1.4;
}
.btn:hover { transform: translate(-2px, -2px); box-shadow: 6px 6px 0 var(--ink); }
.btn:active { transform: translate(3px, 3px); box-shadow: 1px 1px 0 var(--ink); }
.btn:focus-visible, .card:focus-visible { outline: 3px dashed var(--cyan); outline-offset: 3px; }
.btn-big { font-size: 14px; padding: 16px 22px; background: var(--lamp); }
.btn-ghost { background: var(--night-500); color: var(--paper); }
.btn-row { display: flex; flex-wrap: wrap; gap: 14px; justify-content: center; margin-top: 22px; }
.btn-col { display: flex; flex-direction: column; gap: 12px; }

/* title */
.title-panel { max-width: 460px; background: rgba(36, 28, 92, 0.92); }
.logo {
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: clamp(32px, 9vw, 64px);
  line-height: 1;
  color: var(--lamp);
  text-shadow: 4px 4px 0 var(--pink), 8px 8px 0 var(--ink);
}
.logo span:last-child { color: var(--paper); text-shadow: 4px 4px 0 var(--hansip), 8px 8px 0 var(--ink); }
.subtitle {
  display: inline-block;
  margin: 18px 0 8px;
  background: var(--pink);
  color: var(--ink);
  border: 3px solid var(--ink);
  padding: 8px 12px;
  font-size: 14px;
  transform: rotate(-3deg);
  box-shadow: 4px 4px 0 var(--ink);
}
.parade { display: flex; justify-content: center; gap: 18px; margin: 22px 0 10px; }
.parade canvas { animation: hop 0.8s steps(2) infinite; filter: drop-shadow(3px 3px 0 var(--ink)); }
.tagline { font-size: 10px; line-height: 2; color: var(--muted); margin: 8px 0 0; }

/* select: see css/select.css */

/* howto */
.howto-panel { max-width: 460px; text-align: left; }
.howto-panel h2 { text-align: center; }
.howto { font-size: 10px; line-height: 2; padding-left: 24px; margin: 0; }
.howto li { margin-bottom: 8px; }
.howto b { color: var(--lamp); font-weight: normal; }
.c-ok, .c-green { color: var(--green); }
.c-pink { color: var(--pink); }
.c-lamp { color: var(--lamp); }
.c-cyan { color: var(--cyan); }
.keys { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 6px 16px; font-size: 9px; margin-top: 16px; color: var(--muted); }
kbd {
  display: inline-block;
  background: var(--paper);
  color: var(--ink);
  border: 2px solid var(--ink);
  box-shadow: 2px 2px 0 var(--night-500);
  padding: 3px 5px;
  margin-right: 3px;
  font-family: inherit;
  font-size: 8px;
}

/* dialog */
.dialog-panel {
  max-width: 460px;
  background: var(--paper);
  color: var(--ink);
  outline-color: var(--lamp);
  text-align: left;
  margin: 0 auto 4vh;
  animation: popin 0.15s steps(3);
}
.dlg-who { display: inline-block; background: var(--ink); color: var(--lamp); padding: 6px 10px; font-size: 10px; margin: 0 0 12px; }
.dlg-q { font-size: 12px; line-height: 1.9; margin: 0 0 16px; }
.dlg-choices { display: flex; flex-direction: column; gap: 10px; }
.btn-choice { text-align: left; font-size: 10px; background: var(--night-700); color: var(--paper); }
.btn-choice .key { display: inline-block; background: var(--lamp); color: var(--ink); padding: 3px 6px; margin-right: 8px; }

/* result */
.result-panel { max-width: 460px; }
.res-portrait { display: flex; justify-content: center; margin: 4px 0 14px; }
.res-portrait canvas { animation: hop 0.7s steps(2) infinite; filter: drop-shadow(4px 4px 0 var(--ink)); }
.res-rpg { margin: 0 auto 14px; max-width: 400px; text-align: left; background: var(--night-800); border: 3px solid var(--ink); padding: 12px; }
.rpg-lvl { display: flex; gap: 12px; align-items: center; }
.rpg-lvl > div { flex: 1; display: flex; flex-direction: column; gap: 6px; font-size: 10px; }
.rpg-lvl b { color: var(--lamp); font-weight: normal; }
.rpg-lvl small { font-size: 7px; color: var(--cyan); }
.rpg-lvl .badge { background: var(--cyan); color: var(--ink); font-size: 14px; padding: 8px; border: 3px solid var(--ink); box-shadow: 3px 3px 0 var(--ink); }
.rpg-xp { margin: 10px 0 0; font-size: 11px; color: var(--cyan); }
.rpg-xp small { font-size: 7px; color: var(--muted); }
.rpg-up { margin: 8px 0 0; font-size: 10px; color: var(--lamp); animation: blink 0.8s steps(2) infinite; }
.rpg-skill { margin: 8px 0 0; font-size: 8px; line-height: 1.7; color: var(--green); }
.rpg-skill b { font-weight: normal; color: var(--paper); }
.rpg-next { margin: 8px 0 0; font-size: 7px; color: var(--muted); }
.res-stats { list-style: none; padding: 0; margin: 0 auto; max-width: 400px; font-size: 10px; text-align: left; }
.res-stats li { display: flex; justify-content: space-between; padding: 7px 0; border-bottom: 2px dashed var(--night-500); }
.res-stats b { color: var(--cyan); font-weight: normal; }
.res-stats li.total { border: 0; font-size: 13px; color: var(--lamp); padding-top: 12px; }
.res-stats li.total b { color: var(--lamp); }
.res-best { color: var(--pink); font-size: 11px; margin: 14px 0 0; animation: blink 0.8s steps(2) infinite; }

/* ---------- responsive menus ---------- */
@media (max-width: 520px) {
  .panel { padding: 20px 16px; }
  h2 { font-size: 14px; }
  .btn { font-size: 10px; padding: 12px 14px; }
  .btn-big { font-size: 11px; }
  .parade { gap: 10px; }
  .dlg-q { font-size: 10px; }
}

@keyframes hop { 50% { transform: translateY(-4px); } }
@keyframes blink { 50% { opacity: 0.35; } }
@keyframes glow { 50% { box-shadow: 4px 4px 0 var(--ink), 0 0 0 3px var(--lamp); } }
@keyframes pulse { 50% { box-shadow: 4px 4px 0 var(--ink), 0 0 0 5px rgba(255, 210, 63, 0.45); } }
@keyframes popin { from { transform: translateY(20px); opacity: 0; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---------- warung (shop) ---------- */
.shop-panel { text-align: left; }
.shop-panel h2, .shop-panel .eyebrow { text-align: center; }
.shop-wallet { display: flex; justify-content: space-between; align-items: center; background: var(--ink); padding: 10px 12px; font-size: 9px; color: var(--muted); }
.shop-wallet b { font-weight: normal; color: var(--green); font-size: 13px; }
.shop-stats { font-size: 7px; line-height: 1.7; color: var(--cyan); margin: 8px 0; }
.shop-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-bottom: 8px; }
.shop-tab { font-size: 9px; padding: 10px 6px; background: var(--night-800); color: var(--muted); border: 3px solid var(--ink); }
.shop-tab.on { background: var(--lamp); color: var(--ink); }
.shop-list { display: flex; flex-direction: column; gap: 6px; max-height: 46vh; overflow-y: auto; padding-right: 2px; }
.shop-item { display: flex; align-items: center; gap: 10px; padding: 8px 10px; background: var(--night-800); border: 3px solid var(--ink); box-shadow: 3px 3px 0 var(--ink); text-align: left; min-height: 52px; }
.shop-item:active:not(:disabled) { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--ink); }
.shop-item:disabled { opacity: 0.45; cursor: not-allowed; }
.shop-item.owned { opacity: 0.8; border-color: var(--green); }
.si-ic { font-size: 20px; width: 28px; text-align: center; flex: none; }
.si-tx { flex: 1; display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.si-tx b { font-weight: normal; font-size: 9px; color: var(--paper); }
.si-tx small { font-size: 7px; color: var(--muted); line-height: 1.5; }
.si-pr { font-size: 8px; color: var(--lamp); flex: none; }
.shop-item.owned .si-pr { color: var(--green); }
.shop-msg { font-size: 8px; line-height: 1.7; margin: 10px 0 0; min-height: 2.4em; }
.shop-msg.ok { color: var(--green); }
.shop-msg.bad { color: var(--pink); }

/* ---------- boot watchdog ---------- */
#boot-error {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 24px;
  background: var(--night-900);
  text-align: center;
  font-size: 12px;
  line-height: 1.7;
}
#boot-error[hidden] { display: none; }
#boot-error code { max-width: 92vw; font-family: monospace; font-size: 11px; color: var(--pink); word-break: break-word; background: var(--ink); padding: 10px; }
#boot-error small { color: var(--muted); font-size: 9px; }
#boot-error button { font-size: 12px; padding: 14px 18px; background: var(--lamp); color: var(--ink); border: 4px solid var(--ink); box-shadow: 4px 4px 0 var(--ink); }
