:root {
  --ink: #1b2238;
  --ink2: #2a3354;
  --cream: #f4efe1;
  --cap: #efe6cf;
  --capEdge: #b9ab88;
  --yellow: #f5c518;
  --red: #e2412f;
  --teal: #6fc3b8;
  --text: 1;
  font-family: ui-rounded, "Trebuchet MS", "Segoe UI", system-ui, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--ink); color: var(--cream); overflow: hidden; }
body { -webkit-user-select: none; user-select: none; -webkit-tap-highlight-color: transparent; -webkit-touch-callout: none; }
#app { position: fixed; inset: 0; display: flex; flex-direction: column; }
#stage { position: relative; flex: 1; min-height: 0; touch-action: none; }
canvas { display: block; width: 100%; height: 100%; touch-action: none; }

#hud { position: absolute; left: 0; right: 0; top: 0; display: flex; align-items: flex-start; justify-content: space-between; gap: 8px;
  padding: calc(6px + env(safe-area-inset-top)) calc(8px + env(safe-area-inset-right)) 0 calc(8px + env(safe-area-inset-left)); pointer-events: none; }
#hud[hidden] { display: none; }
#floorTag { background: var(--ink); border: 3px solid #000; border-radius: 10px; padding: 3px 9px; font-weight: 800; font-size: calc(14px * var(--text)); box-shadow: 3px 3px 0 var(--yellow); white-space: nowrap; }
#floorTag small { display: block; font-weight: 600; opacity: .85; font-size: calc(11px * var(--text)); }
#pa { flex: 1; text-align: center; font-size: calc(14px * var(--text)); font-weight: 700; color: var(--cream); text-shadow: 0 2px 0 #000, 0 0 6px #000; opacity: 0; transition: opacity .4s; padding-top: 4px; min-width: 0; }
#pa.on { opacity: 1; }
#hudRight { display: flex; align-items: center; gap: 6px; pointer-events: auto; }
#timer { background: var(--ink); border: 3px solid #000; border-radius: 10px; padding: 3px 8px; font-weight: 800; font-variant-numeric: tabular-nums; font-size: calc(15px * var(--text)); }
#hats { font-size: calc(18px * var(--text)); letter-spacing: 1px; white-space: nowrap; }
#pauseBtn { width: 44px; height: 44px; border-radius: 12px; border: 3px solid #000; background: var(--cap); color: var(--ink); font-weight: 900; font-size: 16px; box-shadow: 0 4px 0 var(--capEdge); }

#toast { position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%); background: var(--red); color: #fff; border: 3px solid #000; border-radius: 10px; padding: 6px 12px; font-weight: 800; font-size: calc(15px * var(--text)); opacity: 0; transition: opacity .25s; pointer-events: none; max-width: 92%; text-align: center; }
#toast.on { opacity: 1; }

#keybar { display: flex; justify-content: space-between; align-items: flex-end; gap: 8px; background: #11162a; border-top: 4px solid #000;
  padding: 8px calc(10px + env(safe-area-inset-right)) calc(8px + env(safe-area-inset-bottom)) calc(10px + env(safe-area-inset-left)); touch-action: none; }
#keybar[hidden] { display: none; }
.kgroup { display: flex; gap: 8px; align-items: flex-end; }
.cap { position: relative; min-width: 64px; height: 58px; padding: 0 10px; border-radius: 12px; border: 3px solid #000; background: var(--cap); color: var(--ink);
  font: inherit; font-weight: 900; font-size: calc(15px * var(--text)); letter-spacing: .5px; box-shadow: 0 5px 0 var(--capEdge), 0 5px 0 3px #000; transform: translateY(-5px); touch-action: none; cursor: pointer; }
.cap.arrow { font-size: 26px; min-width: 70px; }
.cap.down { transform: translateY(0); box-shadow: 0 0 0 var(--capEdge), 0 0 0 3px #000; background: #fff7df; }
.cap .hint { position: absolute; right: 5px; top: 3px; font-size: 10px; font-weight: 700; opacity: .55; }
.cap.empty { background: transparent; border-style: dashed; border-color: #555e80; box-shadow: none; transform: none; color: #555e80; min-width: 54px; }
.cap.empty.flash { border-color: var(--red); color: var(--red); }
.cap.off { background: var(--red); color: #fff; }
.cap.new { animation: pop .5s; }
@keyframes pop { 0% { transform: translateY(-40px) scale(1.3); } 60% { transform: translateY(0) scale(.95); } 100% { transform: translateY(-5px); } }
@media (hover: hover) and (pointer: fine) { .cap { height: 50px; min-width: 56px; } .cap.arrow { min-width: 56px; } }
@media (max-height: 500px) { .cap { height: 48px; } #keybar { padding-top: 5px; } }

#overlay { position: absolute; inset: 0; display: none; align-items: center; justify-content: center; padding: calc(12px + env(safe-area-inset-top)) 16px calc(12px + env(safe-area-inset-bottom)); background: rgba(14, 18, 34, .78); z-index: 5; }
#overlay.on { display: flex; }
#overlay.clear { background: transparent; }
.card { width: min(520px, 100%); max-height: 100%; display: flex; flex-direction: column; background: var(--ink2); border: 4px solid #000; border-radius: 18px; box-shadow: 6px 6px 0 var(--yellow); overflow: hidden; }
.card .body { overflow-y: auto; padding: 16px 18px 6px; -webkit-overflow-scrolling: touch; }
.card .btns { display: flex; flex-wrap: wrap; gap: 10px; padding: 10px 18px 16px; justify-content: center; border-top: 3px solid #000; background: #232a47; }
.card h1, .card h2 { margin: 0 0 8px; line-height: 1.1; }
.card h2 { font-size: calc(24px * var(--text)); }
.card p { margin: 0 0 10px; line-height: 1.4; font-size: calc(16px * var(--text)); }
.card .small { font-size: calc(13px * var(--text)); opacity: .85; }
.card .note { background: var(--cream); color: var(--ink); border-radius: 6px; padding: 14px; font-family: "Comic Sans MS", "Chalkboard SE", "Segoe Print", ui-rounded, sans-serif; transform: rotate(-1deg); box-shadow: 3px 3px 0 #000; font-size: calc(17px * var(--text)); line-height: 1.4; }
.btn { min-height: 48px; padding: 0 18px; border-radius: 12px; border: 3px solid #000; background: var(--yellow); color: var(--ink); font: inherit; font-weight: 900; font-size: calc(16px * var(--text)); box-shadow: 0 4px 0 #000; cursor: pointer; }
.btn.alt { background: var(--cap); }
.btn.red { background: var(--red); color: #fff; }
.btn:focus-visible, .cap:focus-visible, .pick:focus-visible { outline: 4px solid var(--teal); outline-offset: 2px; }
.btn:active { transform: translateY(3px); box-shadow: 0 1px 0 #000; }
.menu { display: flex; flex-direction: column; gap: 10px; align-items: stretch; }
.title { text-align: center; }
.title canvas { width: 100%; max-width: 440px; height: auto; aspect-ratio: 440/150; display: block; margin: 0 auto 6px; }
.stats { display: flex; justify-content: center; gap: 14px; flex-wrap: wrap; font-size: calc(13px * var(--text)); opacity: .9; margin: 8px 0 4px; }
.picks { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin: 8px 0 12px; }
.pick { display: flex; flex-direction: column; align-items: center; gap: 4px; width: 140px; padding: 10px 8px; border-radius: 14px; border: 3px solid #000; background: #1b2238; color: var(--cream); font: inherit; cursor: pointer; box-shadow: 0 4px 0 #000; }
.pick .cap { pointer-events: none; transform: none; box-shadow: 0 4px 0 var(--capEdge), 0 4px 0 3px #000; }
.pick span { font-size: calc(13px * var(--text)); line-height: 1.25; text-align: center; }
.pick.wobble .cap { animation: wob .35s infinite alternate ease-in-out; }
.pick.tight { opacity: .45; cursor: not-allowed; }
@keyframes wob { from { transform: rotate(-7deg) translateY(-2px); } to { transform: rotate(7deg) translateY(1px); } }
@media (prefers-reduced-motion: reduce) { .pick.wobble .cap { animation: none; } .cap.new { animation: none; } }
.reduce .pick.wobble .cap, .reduce .cap.new { animation: none; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 0; border-bottom: 2px solid #1b2238; font-size: calc(16px * var(--text)); }
.row input[type=range] { width: 140px; }
.row .btn { min-height: 40px; font-size: 14px; padding: 0 12px; }
.notes { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 8px; }
.notes button { min-height: 52px; border-radius: 8px; border: 3px solid #000; background: var(--cream); color: var(--ink); font: inherit; font-size: 13px; font-weight: 700; cursor: pointer; }
.notes button:disabled { background: #3a4366; color: #8890b0; cursor: default; }
.code { font-family: ui-monospace, Menlo, Consolas, monospace; background: #000; padding: 6px 10px; border-radius: 6px; display: inline-block; font-size: calc(15px * var(--text)); user-select: text; -webkit-user-select: text; }
@media (max-height: 500px) { .card h2 { font-size: 20px; } .card p { font-size: 14px; margin-bottom: 6px; } .card .body { padding-top: 10px; } .btn { min-height: 44px; } .card .btns { padding: 8px 14px 10px; } }

.hatI { display: inline-block; width: 24px; height: 14px; margin-left: 3px; background: var(--yellow); border: 3px solid #000; border-radius: 14px 14px 3px 3px; vertical-align: middle; }
.hatI.dent { background: #4a4f63; border-style: dashed; }
#hats .small { font-weight: 900; margin-left: 4px; }
.cap { display: inline-flex; align-items: center; justify-content: center; }
.cap.empty.socket { font-size: 11px; }
@media (max-width: 700px) {
  #hud { flex-wrap: wrap; row-gap: 4px; }
  #pa { order: 3; flex-basis: 100%; font-size: calc(13px * var(--text)); padding-top: 0; }
}

.duo { display: flex; gap: 10px; } .duo .btn { flex: 1; }
.album { display: flex; flex-direction: column; gap: 8px; }
.arow { display: flex; gap: 12px; align-items: center; text-align: left; }
.arow .cap { flex: none; min-width: 84px; height: 46px; font-weight: 900; pointer-events: none; }
.arow .cap.arrow { min-width: 84px; }
.arow .trick { opacity: .8; font-style: italic; }
#overlay.soft { background: rgba(14, 18, 34, .3); }
.duo .btn { white-space: nowrap; padding-left: 6px; padding-right: 6px; }
@media (max-height: 500px) { .title canvas { max-width: 270px; margin-bottom: 0; } .title .stats { margin: 4px 0 2px; } .menu { gap: 7px; } }
@media (max-height: 500px) { .title .menu { display: grid; grid-template-columns: 1fr 1fr; } .title .menu > :first-child { grid-column: span 2; } .title .duo { display: contents; } }
