@font-face { font-family: "VT323"; src: url("fonts/vt323/VT323-Regular.woff2") format("woff2"); font-display: swap; }
@font-face { font-family: "Neucha"; src: url("fonts/neucha/Neucha.woff2") format("woff2"); font-display: swap; }
@font-face { font-family: "Caveat"; src: url("fonts/caveat/Caveat%5Bwght%5D.woff2") format("woff2"); font-weight: 400 700; font-display: swap; }

:root {
  --ink: #1A1033; --orange: #FF7A1F; --lemon: #FFE94A; --pink: #FF3D8E; --cyan: #33E1FF; --cream: #FFF4DC; --wood: #B8743F;
  --bar: 48px;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; background: var(--ink); color: var(--cream); overflow: hidden; }
body {
  height: 100dvh;
  display: grid; grid-template-rows: auto minmax(0, 1fr);
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  font: 18px/1.3 "Neucha", "Comic Sans MS", cursive;
  -webkit-tap-highlight-color: transparent;
}
button { font: inherit; color: inherit; cursor: pointer; }
button:focus-visible, a:focus-visible { outline: 4px solid var(--lemon); outline-offset: 2px; }

.bar { display: flex; align-items: center; gap: 10px; min-height: var(--bar); padding: 2px 12px; border-bottom: 3px solid var(--orange); }
.mark { font-size: 26px; color: var(--lemon); letter-spacing: .02em; white-space: nowrap; }
.spacer { flex: 1; }
.chip, .jam {
  display: inline-flex; align-items: center; justify-content: center; min-height: 44px; min-width: 44px; padding: 0 16px;
  font-size: 18px; color: var(--cream); background: transparent; border: 2px solid var(--cream); border-radius: 22px; text-decoration: none; white-space: nowrap;
}
.chip[aria-pressed="false"] { color: #b9aed3; border-color: #6e6290; }
.jam { border-color: var(--lemon); color: var(--lemon); }
.chip.dark { color: var(--ink); border-color: var(--ink); }
.chip.armed { background: var(--pink); border-color: var(--pink); color: var(--ink); }

#stage { position: relative; min-width: 0; min-height: 0; overflow: hidden; }
#game { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; user-select: none; -webkit-user-select: none; }

.card {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: min(520px, calc(100% - 24px)); max-height: calc(100% - 24px); overflow-y: auto;
  padding: 18px 22px 20px; text-align: center; color: var(--ink); background: var(--cream);
  border: 4px solid var(--ink); border-radius: 6px; box-shadow: 8px 8px 0 var(--pink);
}
.card[hidden], .shelfbar[hidden] { display: none; }
.card h1, .card h2 { margin: 0; font-weight: 400; font-size: clamp(38px, 7vw, 56px); line-height: 1; color: var(--ink); }
.card h1 { text-shadow: 3px 3px 0 var(--orange); }
.goal { margin: 10px 0 6px; font-size: 20px; }
#t-sketch { display: block; width: 300px; max-width: 100%; height: 120px; margin: 4px auto; }
.steps { display: flex; justify-content: center; gap: 6px; margin: 0 0 12px; padding: 0; list-style: none; counter-reset: s; }
.steps li { counter-increment: s; flex: 1 1 0; max-width: 150px; padding: 4px 6px; font-size: 16px; border-radius: 6px; color: #5a4f72; }
.steps li::before { content: counter(s) " "; font-family: "VT323", monospace; font-size: 20px; }
.steps li.on { background: var(--lemon); color: var(--ink); }
.rule { margin: 0 0 14px; font-size: 17px; }
.rule:empty { display: none; }
.row { display: flex; flex-wrap: wrap; gap: 12px; justify-content: center; align-items: center; }

/* primary buttons are cut like a redemption ticket: notches on both short ends */
.go {
  min-height: 58px; padding: 0 34px; font-size: 28px; color: var(--ink); background: var(--orange); border: 0;
  -webkit-mask: radial-gradient(circle at 0 50%, transparent 10px, #000 10.5px) left / 51% 100% no-repeat, radial-gradient(circle at 100% 50%, transparent 10px, #000 10.5px) right / 51% 100% no-repeat;
  mask: radial-gradient(circle at 0 50%, transparent 10px, #000 10.5px) left / 51% 100% no-repeat, radial-gradient(circle at 100% 50%, transparent 10px, #000 10.5px) right / 51% 100% no-repeat;
}
.go:active { transform: translateY(2px); }
.go.small { min-height: 44px; font-size: 22px; padding: 0 26px; }

.score { margin: 6px 0 0; display: flex; justify-content: center; align-items: baseline; gap: 12px; }
#e-score { font-family: "VT323", monospace; font-size: 72px; line-height: 1; color: var(--orange); text-shadow: 3px 3px 0 var(--ink); }
.best { font-size: 20px; padding: 2px 10px; background: var(--lemon); border-radius: 4px; }
.best:empty { display: none; }
.shot { display: inline-flex; align-items: center; gap: 10px; max-width: 100%; margin: 0 0 14px; padding: 4px 14px 4px 4px; border: 2px dashed var(--ink); border-radius: 8px; font-size: 20px; text-align: left; }
.shot[hidden] { display: none; }
#e-shot-pic { flex: none; width: 72px; height: 72px; }
.shot .words { display: flex; flex-direction: column; min-width: 0; line-height: 1.15; }
.shot .lbl { font-size: 16px; color: #5a4f72; }
.shot .note { font: 18px/1.1 "Caveat", cursive; color: #5a4f72; }
.shot .note:empty { display: none; }
.shot .award { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; }
.shot .pts { font-family: "VT323", monospace; font-size: 28px; color: var(--pink); }
.shot .mult { white-space: nowrap; font-size: 16px; padding: 2px 8px; border-radius: 6px; background: var(--cyan); color: var(--ink); }
.shot .mult[hidden] { display: none; }

.shelfbar { position: absolute; left: 0; right: 0; top: 0; height: 64px; display: flex; align-items: center; gap: 12px; padding: 0 12px; background: var(--ink); border-bottom: 3px solid var(--wood); }
.shelfbar h2 { flex: 1; margin: 0; font: 400 30px/1 "Caveat", cursive; color: var(--lemon); text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.shelfbar .nav { display: flex; gap: 10px; flex: none; }
#s-again { background: var(--lemon); }
.shelfbar.rows { display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-rows: 46px 48px; row-gap: 6px; align-items: center; align-content: center; }
.shelfbar.rows .nav { grid-column: 1 / -1; grid-row: 2; justify-content: center; }
.shelfbar.rows .go.small { min-height: 48px; }

/* phone held sideways: the header becomes a rail so the counter gets the full height */
@media (orientation: landscape) and (max-height: 520px) {
  body { grid-template-rows: minmax(0, 1fr); grid-template-columns: auto minmax(0, 1fr); }
  .bar { flex-direction: column; justify-content: flex-start; width: 64px; padding: 6px 4px; border-bottom: 0; border-right: 3px solid var(--orange); gap: 8px; }
  .mark { writing-mode: vertical-rl; transform: rotate(180deg); font-size: 20px; }
  .spacer { display: none; }
  .bar .chip, .bar .jam { padding: 0 6px; font-size: 14px; width: 56px; white-space: normal; text-align: center; line-height: 1.05; }
  .bar .jam { order: -1; }
  .card { padding: 10px 16px 12px; }
  .card h1, .card h2 { font-size: 34px; }
  #t-sketch { height: 84px; width: 210px; }
  .goal { margin: 4px 0; font-size: 18px; }
  .go { min-height: 48px; font-size: 24px; }
}
@media (max-width: 420px) {
  .mark { font-size: 21px; }
  .chip, .jam { padding: 0 12px; font-size: 16px; }
  .shelfbar { gap: 8px; padding: 0 8px; }
  .shelfbar h2 { font-size: 24px; line-height: .95; white-space: normal; }
  .go.small { padding: 0 20px; }
}
