:root {
  --cream: #F7F4EA;
  --paper: #E6DEC6;
  --ink: #121212;
  --red: #FF2E2E;
  --yellow: #FFE600;
  --display: "Archivo Black", "Arial Black", Impact, sans-serif;
  --text: "Archivo", system-ui, -apple-system, "Segoe UI", sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--cream); color: var(--ink); font-family: var(--text); overflow: hidden; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.stage { position: fixed; inset: 0; height: 100dvh; overflow: hidden; }
canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
[hidden] { display: none !important; }

button { font: inherit; color: inherit; cursor: pointer; }
:focus-visible { outline: 4px solid var(--red); outline-offset: 3px; }

.btn {
  font-family: var(--display); text-transform: uppercase; font-size: 1.05rem; letter-spacing: .02em;
  background: var(--cream); border: 4px solid var(--ink); padding: .7em 1.1em; border-radius: 0;
  box-shadow: 6px 6px 0 var(--ink); transition: transform .08s, box-shadow .08s;
}
.btn:hover { transform: translate(-2px, -2px); box-shadow: 8px 8px 0 var(--ink); }
.btn:active { transform: translate(4px, 4px); box-shadow: 2px 2px 0 var(--ink); }
.btn.yellow { background: var(--yellow); }
.btn.red { background: var(--red); color: var(--ink); }
.btn.ghost { box-shadow: none; background: transparent; }
.btn.ghost:hover { background: var(--ink); color: var(--cream); transform: none; }
.btn.big { font-size: 1.6rem; padding: .55em 1.6em; }
.btn:disabled { opacity: .5; cursor: progress; }

.screen {
  position: absolute; inset: 0; overflow-y: auto; z-index: 5; grid-template-columns: minmax(0, 1fr);
  background:
    repeating-linear-gradient(-45deg, transparent 0 38px, rgba(18,18,18,.045) 38px 76px),
    var(--cream);
  display: grid; place-items: start center; padding: max(16px, env(safe-area-inset-top)) 16px 32px;
}
.screen.dim { background: rgba(247,244,234,.86); place-items: center; }
.panel { width: min(1040px, 100%); padding: 12px 0 24px; }
.panel.small { width: min(460px, 100%); background: var(--cream); border: 5px solid var(--ink); box-shadow: 10px 10px 0 var(--ink); padding: 24px; }

.kicker { font-family: var(--display); text-transform: uppercase; background: var(--ink); color: var(--yellow); display: inline-block; padding: .3em .7em; margin: 8px 0 0; font-size: .9rem; }
.logo { font-family: var(--display); text-transform: uppercase; line-height: .82; margin: 12px 0 8px; font-size: clamp(4rem, 17vw, 10.5rem); letter-spacing: -.03em; display: flex; flex-wrap: wrap; column-gap: .22em; }
.logo span { display: block; }
.red-word { color: var(--red); text-shadow: 5px 5px 0 var(--ink); }
.head { font-family: var(--display); text-transform: uppercase; font-size: clamp(2.4rem, 8vw, 4.6rem); line-height: .9; margin: 10px 0 10px; letter-spacing: -.02em; }
.panel.small .head { font-size: clamp(2rem, 9vw, 3rem); }
.tag { font-size: 1.15rem; font-weight: 800; margin: 0 0 18px; max-width: 40ch; }
.row { display: flex; flex-wrap: wrap; gap: 14px; margin: 18px 0; align-items: center; }
.row.col { flex-direction: column; align-items: stretch; }

.week {
  display: grid; grid-template-columns: auto 1fr; gap: 2px 14px; align-items: center; text-align: left;
  background: var(--yellow); border: 4px solid var(--ink); box-shadow: 6px 6px 0 var(--ink);
  padding: 12px 16px; margin: 10px 0 18px; width: min(560px, 100%); border-radius: 0; transition: transform .08s;
  animation: wobble 2.4s ease-in-out infinite;
}
.week:hover { transform: rotate(-1deg) scale(1.02); }
.week-k { grid-column: 1 / -1; font-family: var(--display); text-transform: uppercase; font-size: .85rem; background: var(--ink); color: var(--yellow); justify-self: start; padding: 2px 8px; }
.week-n { font-family: var(--display); font-size: 1.6rem; text-transform: uppercase; }
.week-t { font-weight: 800; }
.week-when { grid-column: 1 / -1; font-weight: 800; font-size: .8rem; margin-top: 4px; }
@media (max-width: 560px) { .week { grid-template-columns: 1fr; } .week-t { grid-column: 1; } }
.week-new { background: var(--red); color: var(--ink); font-size: .7rem; padding: 1px 6px; margin-left: 6px; border: 2px solid var(--ink); vertical-align: 2px; }
@keyframes wobble { 0%, 100% { rotate: -0.6deg; } 50% { rotate: 0.6deg; } }

.controls { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 8px; max-width: 760px; }
.controls p { margin: 0; border: 3px solid var(--ink); padding: 8px 10px; font-weight: 500; background: var(--cream); }
.controls b { font-family: var(--display); text-transform: uppercase; display: block; font-weight: 400; }

.global { font-family: var(--display); text-transform: uppercase; margin: 22px 0 4px; font-size: 1rem; display: flex; flex-wrap: wrap; align-items: baseline; gap: .3em; }
.global b { font-weight: 400; font-size: 2.6rem; color: var(--red); text-shadow: 3px 3px 0 var(--ink); line-height: 1; }
.saved-note { font-size: .9rem; margin: 6px 0; }
.fine { font-size: .8rem; margin: 4px 0 0; }
.fine a { color: var(--ink); font-weight: 700; }

/* hover / focus tips on menu buttons */
[data-tip] { position: relative; }
[data-tip]::after {
  content: attr(data-tip); position: absolute; left: 50%; bottom: calc(100% + 10px);
  transform: translate(-50%, 4px); z-index: 20; pointer-events: none;
  background: var(--ink); color: var(--cream); font-family: var(--text); font-weight: 700;
  font-size: .8rem; line-height: 1.25; letter-spacing: 0; text-transform: none; text-align: center;
  padding: 7px 10px; width: max-content; max-width: min(220px, 70vw);
  border: 3px solid var(--ink); box-shadow: 4px 4px 0 rgba(18,18,18,.25);
  opacity: 0; transition: opacity .12s ease, transform .12s ease;
}
[data-tip]:hover::after, [data-tip]:focus-visible::after { opacity: 1; transform: translate(-50%, 0); }
.topbar [data-tip]::after { bottom: auto; top: calc(100% + 10px); }
@media (hover: none) { [data-tip]::after { display: none; } }

.dare-banner { background: var(--red); border: 5px solid var(--ink); box-shadow: 8px 8px 0 var(--ink); padding: 14px 16px; margin: 6px 0 14px; display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between; animation: pulse 1.2s ease-in-out infinite; }
.dare-banner p { margin: 0; font-family: var(--display); font-size: clamp(1.1rem, 3.6vw, 1.6rem); text-transform: uppercase; line-height: 1.05; max-width: 28ch; }
.dare-banner .btn { background: var(--yellow); }
@keyframes pulse { 50% { transform: scale(1.012); } }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 14px; }
.lvl { text-align: left; border: 4px solid var(--ink); background: var(--cream); box-shadow: 6px 6px 0 var(--ink); padding: 12px; min-height: 130px; display: flex; flex-direction: column; gap: 4px; border-radius: 0; transition: transform .08s; position: relative; }
.lvl:hover:not(:disabled) { transform: translate(-2px, -2px) rotate(-1deg); }
.lvl .n { font-family: var(--display); font-size: 2.4rem; line-height: 1; }
.lvl .nm { font-family: var(--display); text-transform: uppercase; font-size: .95rem; }
.lvl .bst { margin-top: auto; font-weight: 800; }
.lvl.done { background: var(--yellow); }
.lvl.week-pick::after { content: "THIS WEEK"; position: absolute; top: -12px; right: -8px; background: var(--red); border: 3px solid var(--ink); font-family: var(--display); font-size: .7rem; padding: 2px 6px; }
.lvl:disabled { background: var(--paper); cursor: not-allowed; box-shadow: none; }
.lvl:disabled .n::after { content: " 🔒"; font-size: 1.4rem; }

.total { display: flex; align-items: baseline; gap: 14px; flex-wrap: wrap; }
.total b { font-family: var(--display); font-weight: 400; font-size: clamp(5rem, 22vw, 9rem); line-height: .9; color: var(--red); text-shadow: 6px 6px 0 var(--ink); }
.total span { font-family: var(--display); text-transform: uppercase; font-size: 1.4rem; }
.per { list-style: none; padding: 0; margin: 18px 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.per li { border: 3px solid var(--ink); padding: 6px 10px; display: flex; justify-content: space-between; gap: 8px; font-weight: 800; background: var(--cream); }
.per li b { font-family: var(--display); font-weight: 400; }
.per li.worst { background: var(--red); }
.msg { font-weight: 800; min-height: 1.3em; }

.vs { display: flex; align-items: center; justify-content: space-around; margin: 12px 0; }
.vs div { display: flex; flex-direction: column; align-items: center; }
.vs b { font-family: var(--display); font-weight: 400; font-size: 4rem; line-height: 1; }
.vs span { font-family: var(--display); text-transform: uppercase; }
.vs-x { font-family: var(--display); font-size: 1.4rem; background: var(--ink); color: var(--yellow); padding: 4px 10px; }

.topbar { position: absolute; z-index: 4; top: max(8px, env(safe-area-inset-top)); left: 50%; transform: translateX(-50%); display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; width: max-content; max-width: calc(100% - 16px); }
.share-hint { position: absolute; top: calc(100% + 12px); left: 50%; transform: translateX(-50%); margin: 0; white-space: nowrap; font-family: var(--display); text-transform: uppercase; font-size: .72rem; background: var(--red); color: var(--ink); border: 3px solid var(--ink); padding: 4px 8px; box-shadow: 3px 3px 0 var(--ink); animation: hintIn .2s ease-out; }
.share-hint::before { content: ""; position: absolute; top: -9px; left: 50%; transform: translateX(-50%) rotate(45deg); width: 12px; height: 12px; background: var(--red); border-left: 3px solid var(--ink); border-top: 3px solid var(--ink); }
@keyframes hintIn { from { opacity: 0; transform: translate(-50%, -6px); } to { opacity: 1; transform: translate(-50%, 0); } }
.chip.glow { animation: glowPulse 1.15s ease-in-out infinite; }
@keyframes glowPulse {
  0%, 100% { background: var(--yellow); box-shadow: 3px 3px 0 var(--ink), 0 0 0 0 rgba(255,46,46,.9); }
  50% { background: var(--red); box-shadow: 3px 3px 0 var(--ink), 0 0 0 12px rgba(255,46,46,0); }
}
.chip { font-family: var(--display); text-transform: uppercase; font-size: .8rem; background: var(--yellow); border: 3px solid var(--ink); padding: 6px 10px; border-radius: 0; box-shadow: 3px 3px 0 var(--ink); min-width: 44px; min-height: 36px; }
.chip:hover { background: var(--cream); }

.touch { position: absolute; z-index: 3; left: 0; right: 0; bottom: 0; pointer-events: none; display: flex; align-items: flex-end; gap: 12px; padding: 12px max(12px, env(safe-area-inset-right)) max(14px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left)); }
.tbtn { pointer-events: auto; width: 84px; height: 84px; border: 4px solid var(--ink); background: rgba(247,244,234,.8); font-size: 2rem; border-radius: 0; box-shadow: 5px 5px 0 var(--ink); touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; color: var(--ink); }
.tbtn.jump { margin-left: auto; width: 120px; height: 96px; background: rgba(255,230,0,.9); font-family: var(--display); font-size: 1.4rem; }
.tbtn.on { transform: translate(3px, 3px); box-shadow: 2px 2px 0 var(--ink); background: var(--yellow); }
@media (orientation: portrait) { .tbtn { width: 96px; height: 96px; } .tbtn.jump { width: 130px; height: 110px; } }

@media (prefers-reduced-motion: reduce) {
  .week, .dare-banner, .share-hint { animation: none; }
  .chip.glow { animation: none; background: var(--red); box-shadow: 3px 3px 0 var(--ink), 0 0 0 4px var(--yellow); }
  .btn, .lvl, [data-tip]::after { transition: none; }
}
