:root {
  --ink: #5a2f46;
  --paper: #fffaf7;
  --rose: #e2588e;
  --rose-dark: #b93a6c;
  --line: #efcad7;
  --sky: #bfe8ff;
  --font: ui-rounded, 'Arial Rounded MT Bold', 'Nunito', system-ui, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--sky); color: var(--ink); font-family: var(--font); overflow: hidden; }
body { touch-action: none; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }

#stage { position: fixed; inset: 0; display: grid; place-items: center; }
#game { display: block; }

.overlay { position: absolute; inset: 0; display: grid; place-items: center; padding: 16px; background: #5a2f4633; z-index: 10; }
.overlay[hidden] { display: none; }
.card { background: var(--paper); border: 3px solid var(--ink); border-radius: 24px; padding: 22px 26px; max-width: 520px; width: 100%; max-height: calc(100% - 8px); overflow: auto; box-shadow: 0 8px 0 var(--ink); text-align: center; touch-action: pan-y; }
.card.small { max-width: 380px; }
h1 { font-size: clamp(30px, 6vw, 48px); margin: 0; color: var(--rose); letter-spacing: 1px; }
h2 { margin: 0 0 14px; font-size: 30px; }
.tag { margin: 4px 0 14px; font-size: 18px; }
.label { margin: 0 0 8px; font-weight: 700; }
.group { margin: 12px 0; }
.row { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
button { font: inherit; font-size: 20px; font-weight: 700; color: #fff; background: var(--rose); border: 3px solid var(--ink); border-radius: 16px; padding: 10px 18px; min-height: 48px; cursor: pointer; box-shadow: 0 4px 0 var(--ink); }
button:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--ink); }
button:focus-visible { outline: 3px solid #2a7cc7; outline-offset: 3px; }
button.wide { width: 100%; }
.help { margin-top: 10px; text-align: left; font-size: 16px; }
.help summary { cursor: pointer; font-weight: 700; text-align: center; }
.help table { border-collapse: collapse; margin: 8px auto; }
.help td, .help th { padding: 3px 10px; text-align: left; }
.muted { opacity: .75; font-size: 14px; }
.hub-link { display: inline-block; margin-top: 12px; color: var(--ink); font-weight: 700; }

.toolbar { position: absolute; top: max(8px, env(safe-area-inset-top)); right: max(8px, env(safe-area-inset-right)); display: flex; gap: 8px; z-index: 20; }
button.round { width: 44px; height: 44px; min-height: 0; padding: 0; border-radius: 50%; font-size: 20px; background: var(--paper); color: var(--ink); box-shadow: 0 3px 0 var(--ink); }
.toolbar[data-playing] { top: auto; bottom: max(8px, env(safe-area-inset-bottom)); left: 50%; right: auto; transform: translateX(-50%); }

/* Touch controls */
#touch { position: absolute; inset: 0; pointer-events: none; z-index: 5; }
#touch[hidden] { display: none; }
.pad { position: absolute; bottom: max(14px, env(safe-area-inset-bottom)); display: flex; gap: 10px; align-items: flex-end; pointer-events: none; }
.pad.left { left: max(14px, env(safe-area-inset-left)); }
.pad.right { right: max(14px, env(safe-area-inset-right)); }
.pad .stack { display: flex; flex-direction: column; gap: 10px; }
.tbtn { pointer-events: auto; width: 68px; height: 68px; min-height: 0; padding: 0; border-radius: 50%; font-size: 30px; background: #ffffffb8; color: var(--ink); box-shadow: 0 4px 0 var(--ink); touch-action: none; }
.tbtn.big { width: 88px; height: 88px; font-size: 40px; background: #ffd1e1e6; }
.tbtn.on { transform: translateY(3px); box-shadow: 0 1px 0 var(--ink); background: #fff; }
.p2 .tbtn { background: #d7ecffcc; }
.p2 .tbtn.big { background: #bfe0ffe6; }
@media (max-height: 430px) {
  .tbtn { width: 56px; height: 56px; font-size: 24px; }
  .tbtn.big { width: 72px; height: 72px; font-size: 32px; }
}

/* Waiting for the art */
body:not(.loaded) [data-mode] { opacity: .5; pointer-events: none; }

/* Character select */
.card.wide { max-width: 760px; }
.chars { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin: 8px 0 14px; }
.char { position: relative; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 4px 10px; background: #fff; color: var(--ink); border-color: var(--ink); box-shadow: 0 4px 0 var(--glove); font-size: 20px; }
.char canvas { width: 100%; max-width: 140px; height: auto; aspect-ratio: 220 / 240; }
.char:hover:not(:disabled) { background: color-mix(in srgb, var(--glove) 12%, #fff); }
.char.picked { background: color-mix(in srgb, var(--glove) 22%, #fff); opacity: 1; }
.char:disabled { cursor: default; }
.char:not(.picked):disabled { opacity: .5; }
.badge { position: absolute; top: 6px; right: 6px; font-style: normal; font-size: 15px; background: var(--glove); color: #fff; border: 2px solid var(--ink); border-radius: 10px; padding: 1px 7px; }
.badge:empty { display: none; }
button.ghost { background: var(--paper); color: var(--ink); font-size: 17px; min-height: 40px; padding: 6px 16px; }
@media (max-width: 560px), (max-height: 430px) {
  .chars { gap: 8px; }
  .char { font-size: 16px; padding: 4px 2px 6px; }
  .card { padding: 14px 16px; }
  h2 { font-size: 24px; margin-bottom: 8px; }
}
