/* EDGE interface. The scene is a canvas; everything here is the text and buttons around it.
   Colours come from the same palette as the pixel art (js/art.js). */

@font-face { font-family: 'Jersey 20'; src: url('../fonts/jersey-20-latin-400-normal.woff2') format('woff2'); font-weight: 400; font-display: swap; unicode-range: U+0000-00FF, U+2013-2014, U+2018-201D, U+2026; }
@font-face { font-family: 'Jersey 20'; src: url('../fonts/jersey-20-latin-ext-400-normal.woff2') format('woff2'); font-weight: 400; font-display: swap; unicode-range: U+0100-02AF, U+1E00-1EFF; }
@font-face { font-family: 'Jersey 10'; src: url('../fonts/jersey-10-latin-400-normal.woff2') format('woff2'); font-weight: 400; font-display: swap; unicode-range: U+0000-00FF, U+2013-2014, U+2018-201D, U+2026; }
@font-face { font-family: 'Jersey 10'; src: url('../fonts/jersey-10-latin-ext-400-normal.woff2') format('woff2'); font-weight: 400; font-display: swap; unicode-range: U+0100-02AF, U+1E00-1EFF; }

:root {
  --ink: #2b1830;
  --abyss: #2e1d3a;
  --deep: #3b2040;
  --plum: #582942;
  --butter: #fdf0c8;
  --paper: #f6e8c4;
  --dim: #c9aeb4;
  --sun: #ffd84a;
  --sun-d: #d99a2a;
  --rock: #cf6c3e;
  --red: #e0452f;
  --ok: #7fd66b;
  --ok-d: #3f8a4a;
  --text: 'Jersey 20', ui-monospace, 'Courier New', monospace;
  --display: 'Jersey 10', 'Jersey 20', ui-monospace, monospace;
  --step: 4px;
  --corner: polygon(0 var(--step), var(--step) var(--step), var(--step) 0, calc(100% - var(--step)) 0, calc(100% - var(--step)) var(--step), 100% var(--step), 100% calc(100% - var(--step)), calc(100% - var(--step)) calc(100% - var(--step)), calc(100% - var(--step)) 100%, var(--step) 100%, var(--step) calc(100% - var(--step)), 0 calc(100% - var(--step)));
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: #1d1226; overflow: hidden; overscroll-behavior: none; }
body { font-family: var(--text); font-size: 19px; line-height: 1.25; font-weight: 400; font-synthesis: none; font-variant-ligatures: none; letter-spacing: .2px; color: var(--butter); -webkit-font-smoothing: none; font-smooth: never; -webkit-text-size-adjust: 100%; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }

#app {
  position: fixed; top: 0; left: 50%; width: 100%; max-width: 520px; height: 100%;
  transform: translateX(-50%);
  display: flex; flex-direction: column;
  background: var(--abyss);
  overflow: hidden;
}
@media (min-width: 560px) { #app { box-shadow: 0 0 0 4px var(--ink), 0 0 0 8px var(--plum); } }

/* ---------- stage ---------- */
#stage { position: relative; flex: 1 1 auto; min-height: 96px; overflow: hidden; background: #d97a5c; }
#scene { position: absolute; left: 0; top: 0; image-rendering: pixelated; image-rendering: crisp-edges; }

#hud {
  position: absolute; left: 0; right: 0; top: 0; z-index: 3;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: calc(6px + env(safe-area-inset-top)) 10px 6px;
  color: var(--ink);
}
.hud-btn { background: none; border: 0; padding: 4px 2px; display: inline-flex; align-items: baseline; gap: 6px; color: var(--ink); }
.hud-btn.icon { font-size: 22.5px; width: 34px; height: 34px; justify-content: center; align-items: center; background: var(--butter); clip-path: var(--corner); }
.hud-btn.icon[aria-pressed="false"] { background: transparent; opacity: .55; text-decoration: line-through; }
.wordmark { font-family: var(--display); font-size: 28px; line-height: 1; letter-spacing: 1px; }
#hud-day { font-size: 15.5px; font-weight: 400; }
.hud-right { display: flex; align-items: center; gap: 8px; }
#hud-score { font-family: var(--display); font-size: 26px; line-height: 1; min-width: 1ch; text-align: right; }
#pips { display: flex; gap: 5px; align-items: center; }
#pips i { width: 12px; height: 12px; background: rgba(43, 24, 48, .22); display: block; }
#pips i.now { background: var(--butter); box-shadow: 0 0 0 2px var(--ink); }
#pips i.done { box-shadow: 0 0 0 2px var(--ink); }
#pips.count { font-weight: 400; font-size: 15.5px; }
[data-view="menu"] #pips, [data-view="menu"] #hud-score, [data-view="menu"] #btn-home, [data-view="boot"] #hud { visibility: hidden; }
[data-view="menu"] #btn-sound { visibility: visible; }

#title { position: absolute; left: 0; right: 0; top: max(40px, 8%); z-index: 2; text-align: center; pointer-events: none; opacity: 0; visibility: hidden; color: var(--ink); }
[data-view="menu"] #title { opacity: 1; visibility: visible; }
.logo { font-family: var(--display); font-size: clamp(60px, min(34vw, 19vh), 170px); line-height: .8; letter-spacing: 2px; display: inline-flex; padding-right: .12em; }
.logo span { display: inline-block; text-shadow: 5px 5px 0 var(--butter); }
.logo span:last-child { transform-origin: 0% 100%; animation: tip 5.5s steps(1) infinite; }
@keyframes tip {
  0%, 52% { transform: rotate(0deg); }
  56% { transform: rotate(7deg) translateY(1px); }
  60% { transform: rotate(3deg); }
  64%, 100% { transform: rotate(14deg) translate(2px, 3px); }
}
.tagline { margin: 8px 0 0; font-size: 19.5px; font-weight: 400; }

#pop { position: absolute; left: 0; right: 0; top: 18%; z-index: 4; text-align: center; pointer-events: none; opacity: 0; transform: translateY(8px); }
#pop.on { opacity: 1; transform: none; transition: transform .12s steps(3), opacity .1s; }
.pop-num { font-family: var(--display); font-size: 104px; line-height: .78; color: var(--ink); text-shadow: 4px 4px 0 var(--butter); }
.pop-tier { display: inline-block; margin-top: 10px; padding: 3px 12px 4px; font-weight: 400; font-size: 20.5px; color: var(--ink); background: var(--sun); clip-path: var(--corner); }

#toast { position: absolute; left: 50%; bottom: 14px; z-index: 6; transform: translateX(-50%); background: var(--ink); color: var(--butter); padding: 6px 12px; font-size: 16.5px; clip-path: var(--corner); opacity: 0; pointer-events: none; white-space: nowrap; }
#toast.on { opacity: 1; }
#studio-flag { position: absolute; left: 8px; bottom: 14px; z-index: 5; background: var(--red); color: #fff; font-size: 13.5px; padding: 2px 6px; }

/* timeline text, placed by js/timeline.js */
.tl-box { position: absolute; left: 0; top: 0; right: 0; bottom: 0; z-index: 2; pointer-events: none; opacity: 0; color: var(--ink); }
.tl-box.on { opacity: 1; }
.tl-label { position: absolute; white-space: nowrap; line-height: 1.1; text-shadow: 1px 1px 0 var(--butter), -1px 1px 0 var(--butter), 1px -1px 0 var(--butter), -1px -1px 0 var(--butter), 0 2px 0 var(--butter), 2px 0 0 var(--butter), -2px 0 0 var(--butter), 0 -2px 0 var(--butter); }
.tl-flag, .tl-ans { display: flex; gap: 5px; font-size: 15.5px; }
.tl-flag b, .tl-ans b { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.tl-flag span, .tl-ans span { flex: none; }
.tl-flag b { color: #a52a33; }
.tl-ans b { color: #183f6c; }
.tl-gap { left: 0; right: 0; text-align: center; font-family: var(--display); font-size: 27px; line-height: .9; letter-spacing: .5px; }
.tl-gap.good { color: #2c6e3a; }
.tl-gap.bad { color: #b4281f; }
.tl-tick { transform: translateX(-50%); font-size: 13.5px; font-weight: 400; opacity: .8; }
.tl-ctx { transform: translateX(-50%); font-size: 13.5px; max-width: 31%; overflow: hidden; text-overflow: ellipsis; color: #833741; }
.tl-ctx:not(:empty)::before { content: '\25C6\00a0'; font-size: 10.5px; }
.tl-scale { left: 0; right: 0; text-align: center; font-size: 13.5px; font-weight: 400; }

/* ---------- panel ---------- */
#panel { flex: 0 0 auto; max-height: 68%; overflow-y: auto; padding: 4px 14px calc(14px + env(safe-area-inset-bottom)); background: var(--abyss); position: relative; z-index: 1; }
.view { display: none; }
[data-view="menu"] .view[data-for="menu"],
[data-view="prompt"] .view[data-for="prompt"],
[data-view="rolling"] .view[data-for="rolling"],
[data-view="reveal"] .view[data-for="reveal"],
[data-view="results"] .view[data-for="results"] { display: block; }

.btn {
  display: block; width: 100%; margin: 10px 0 0; padding: 12px 14px 15px; border: 0;
  font-weight: 400; font-size: 20.5px; text-align: center; color: var(--butter);
  background: var(--plum); box-shadow: inset 0 -4px 0 rgba(0, 0, 0, .28);
  clip-path: var(--corner);
}
.btn:active { transform: translateY(2px); box-shadow: inset 0 -2px 0 rgba(0, 0, 0, .28); }
.btn.primary { background: var(--sun); color: var(--ink); box-shadow: inset 0 -4px 0 var(--sun-d); font-size: 22.5px; }
.btn.small { font-size: 17.5px; padding: 9px 8px 12px; font-weight: 400; }
.btn.ghost { background: transparent; box-shadow: none; color: var(--dim); text-decoration: underline; text-underline-offset: 3px; }
.btn-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.btn-row.two { grid-template-columns: 1.4fr 1fr; }
.btn:focus-visible, .hud-btn:focus-visible, .link:focus-visible, a:focus-visible, #answer:focus-visible, #suggest li:focus-visible { outline: 3px solid #8fe0ee; outline-offset: 2px; }
.fine { margin: 12px 0 0; font-size: 15px; color: var(--dim); text-align: center; }
.fine a, .link, .rv-links a { color: var(--dim); text-decoration: underline; text-underline-offset: 3px; background: none; border: 0; padding: 0; font-size: inherit; }

.lead { margin: 6px 0 0; color: var(--dim); font-size: 17.5px; font-weight: 400; }
.target { margin: 0; font-family: var(--display); font-weight: 400; font-size: clamp(34px, 10.5vw, 46px); line-height: .88; letter-spacing: .5px; color: var(--butter); text-wrap: balance; overflow-wrap: anywhere; }
.target-note { margin: 4px 0 0; min-height: 0; font-size: 15.5px; color: var(--sun); font-weight: 400; }
.target-note:empty { display: none; }

.timer { height: 8px; margin: 10px 0 0; background: var(--deep); position: relative; }
.timer i { position: absolute; left: 0; top: 0; bottom: 0; width: 100%; background: var(--sun); transform-origin: 0 50%; }
.timer.low i { background: var(--red); }
.timer.off { visibility: hidden; height: 2px; margin-top: 6px; }

.entry { margin-top: 10px; }
#answer {
  display: block; width: 100%; padding: 11px 12px 12px; border: 0; border-radius: 0;
  background: var(--paper); color: var(--ink); font-size: 21.5px; font-weight: 400;
  clip-path: var(--corner); outline-offset: -3px;
}
#answer::placeholder { color: rgba(43, 24, 48, .5); font-weight: 400; }
#suggest { list-style: none; margin: 6px 0 0; padding: 0; min-height: 0; }
#suggest li { display: flex; align-items: baseline; gap: 8px; padding: 9px 10px 10px; margin-top: 4px; background: var(--deep); cursor: pointer; min-height: 42px; }
#suggest li b { font-weight: 400; font-size: 19px; flex: 0 1 auto; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#suggest li span { flex: 1 1 0; min-width: 0; font-size: 15px; color: var(--dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#suggest li.active { background: var(--sun); color: var(--ink); }
#suggest li.active span { color: rgba(43, 24, 48, .7); }
#suggest li.none { background: transparent; color: var(--dim); cursor: default; font-size: 16.5px; padding-left: 2px; }

/* compact while the phone keyboard is open */
#app.typing .lead { display: none; }
#app.typing .target { font-size: 30px; display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; overflow: hidden; margin-top: 2px; }
#app.typing .target-note { display: none; }
#app.typing #suggest li { min-height: 38px; padding: 7px 10px 8px; }
#app.typing #panel { padding-bottom: 8px; }

.score-line { display: flex; align-items: center; gap: 12px; margin-top: 2px; }
.score-num { font-family: var(--display); font-size: 64px; line-height: .8; color: var(--butter); min-width: 1.1ch; }
.score-tier { padding: 3px 10px 4px; font-weight: 400; font-size: 19.5px; color: var(--ink); background: var(--sun); clip-path: var(--corner); }
.rv-line { margin: 8px 0 0; font-size: 18px; }
.rv-line b { font-weight: 400; }
.rv-line.dim { color: var(--dim); margin-top: 3px; font-size: 16.5px; }
.rv-actions { display: flex; align-items: center; gap: 14px; margin-top: 2px; }
.rv-actions .btn { flex: 1 1 auto; }
.rv-links { display: flex; flex-direction: column; gap: 4px; font-size: 15px; align-items: flex-end; flex: 0 0 auto; padding-top: 10px; }

.res-head { display: flex; align-items: baseline; gap: 8px; }
.res-total { font-family: var(--display); font-size: 84px; line-height: .8; color: var(--sun); }
.res-of { font-family: var(--display); font-size: 30px; color: var(--dim); }
.lanes { list-style: none; margin: 10px 0 2px; padding: 0; }
.lanes li { margin-top: 9px; }
.lane-top { display: flex; justify-content: space-between; gap: 10px; font-size: 16.5px; font-weight: 400; }
.lane-top span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lane-top .pts { font-family: var(--display); font-size: 22px; line-height: .8; }
.lane-track { position: relative; height: 12px; margin-top: 4px; background: linear-gradient(90deg, var(--plum) 0 86%, transparent 86%); }
.lane-track::before { content: ''; position: absolute; left: 0; width: 86%; top: 0; height: 3px; background: #dcc79b; }
.lane-track::after { content: ''; position: absolute; left: 86%; top: -4px; width: 3px; height: 16px; background: var(--red); }
.lane-ball { position: absolute; top: -3px; width: 10px; height: 10px; margin-left: -10px; background: #3aa6cf; box-shadow: inset 0 -3px 0 #fff4d6, 0 0 0 2px var(--ink); }
.lane-ball.over { top: 7px; background: var(--red); box-shadow: 0 0 0 2px var(--ink); margin-left: 0; }
.lane-sub { margin-top: 5px; font-size: 15px; color: var(--dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- sheets ---------- */
#sheet { position: absolute; inset: 0; z-index: 10; background: rgba(29, 18, 38, .72); display: flex; align-items: flex-end; }
.sheet-card { width: 100%; max-height: 88%; display: flex; flex-direction: column; background: var(--abyss); box-shadow: 0 -4px 0 var(--plum), 0 -8px 0 var(--ink); }
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 14px 4px; }
.sheet-head h2 { margin: 0; font-family: var(--display); font-weight: 400; font-size: 38px; line-height: .9; }
.sheet-head .btn { width: auto; margin: 0; padding-left: 14px; padding-right: 14px; }
.sheet-body { overflow-y: auto; padding: 4px 14px calc(18px + env(safe-area-inset-bottom)); font-size: 18px; }
.sheet-body p { margin: 10px 0 0; }
.sheet-body h3 { margin: 18px 0 0; font-size: 17.5px; font-weight: 400; color: var(--sun); }
.ladder { list-style: none; margin: 8px 0 0; padding: 0; }
.ladder li { display: grid; grid-template-columns: 14px 1fr auto; gap: 10px; align-items: center; padding: 5px 0; }
.ladder i { width: 14px; height: 14px; display: block; }
.ladder span:last-child { font-family: var(--display); font-size: 22px; line-height: .8; }
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 10px; text-align: center; }
.stat-grid b { display: block; font-family: var(--display); font-weight: 400; font-size: 44px; line-height: .85; color: var(--sun); }
.stat-grid span { font-size: 14.5px; color: var(--dim); }
.bars { margin-top: 8px; }
.bar { display: grid; grid-template-columns: 110px 1fr 28px; gap: 8px; align-items: center; font-size: 15.5px; padding: 3px 0; }
.bar i { display: block; height: 12px; min-width: 2px; }
.bar em { font-style: normal; text-align: right; }
.daylist { list-style: none; margin: 8px 0 0; padding: 0; }
.daylist li { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 0; border-bottom: 2px solid var(--deep); }
.daylist .btn { width: auto; margin: 0; }
.daylist small { display: block; color: var(--dim); font-size: 14.5px; }
.daylist .pts { font-family: var(--display); font-size: 28px; line-height: .8; color: var(--sun); }
.pack { display: block; width: 100%; text-align: left; margin-top: 10px; padding: 12px 14px 14px; background: var(--deep); border: 0; clip-path: var(--corner); }
.pack b { display: block; font-size: 20.5px; }
.pack span { color: var(--dim); font-size: 16px; }
.pack em { font-style: normal; font-size: 13.5px; background: var(--rock); color: var(--ink); padding: 1px 5px; margin-left: 6px; vertical-align: 2px; }

@media (prefers-reduced-motion: reduce) {
  .logo span:last-child { animation: none; transform: rotate(14deg) translate(2px, 3px); }
  #pop.on { transition: none; }
}

b, strong, h1, h2, h3 { font-weight: 400; }
.sheet-body b { color: var(--sun); }
.rv-line b { color: var(--butter); }
.rv-line { color: var(--paper); }
