@font-face { font-family: "Fredoka"; src: url(/fonts/fredoka-700.woff2) format("woff2"); font-weight: 700; font-display: swap; }
@font-face { font-family: "Space Grotesk"; src: url(/fonts/space-grotesk-500.woff2) format("woff2"); font-weight: 500; font-display: swap; }
@font-face { font-family: "Space Grotesk"; src: url(/fonts/space-grotesk-700.woff2) format("woff2"); font-weight: 700; font-display: swap; }

:root {
  --field: #ff6b1a;   /* hi-vis orange */
  --deep: #c43f00;    /* a deep shade of the field */
  --well: #e25408;
  --go: #c8ff2e;      /* hi-vis lime */
  --ink: #2a1206;
  --paper: #fff8ee;
  --bad: #ff1f3d;
  --top: 44px;
  --dock: 300px;
  --row: 38px;
  --slot: 38px;
  --label: 54px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--field); color: var(--paper); font: 500 15px/1.3 "Space Grotesk", system-ui, sans-serif; touch-action: manipulation; user-select: none; -webkit-user-select: none; overscroll-behavior: none; }
button { font: inherit; color: inherit; border: 0; background: none; padding: 0; cursor: pointer; }
h1, h2 { margin: 0; font-family: "Fredoka", system-ui, sans-serif; font-weight: 700; }

#app { position: fixed; inset: 0; display: grid; grid-template-columns: minmax(0, 1fr); grid-template-rows: var(--top) minmax(0, 1fr) var(--dock); }
#top { grid-row: 1; display: flex; align-items: center; gap: 10px; padding: 0 max(10px, env(safe-area-inset-left)); background: var(--field); border-bottom: 3px solid var(--deep); z-index: 2; }
#top h2 { flex: 1; min-width: 0; font-size: clamp(14px, 4.6vw, 19px); line-height: 1; text-align: center; text-wrap: balance; }
#lv-num { font-weight: 700; min-width: 34px; text-align: right; }
#stage { grid-row: 2; position: relative; min-height: 0; }
#board { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
#dock { grid-row: 3; position: relative; background: var(--field); border-top: 3px solid var(--deep); display: grid; grid-template-rows: 40px minmax(0, 1fr) 52px 52px; padding: 0 max(8px, env(safe-area-inset-left)) env(safe-area-inset-bottom); z-index: 2; }

/* screens */
#app[data-screen="home"] #top, #app[data-screen="home"] #dock, #app[data-screen="levels"] #top, #app[data-screen="levels"] #dock, #app[data-screen="credits"] #top, #app[data-screen="credits"] #dock { display: none; }
#app:not([data-screen="play"]) #stage { grid-row: 1 / -1; }
.screen { display: none; position: absolute; inset: 0; z-index: 3; }
#app[data-screen="home"] #home, #app[data-screen="levels"] #levels, #app[data-screen="credits"] #credits { display: flex; flex-direction: column; }

.key { display: none; font: 700 11px/1 "Space Grotesk"; padding: 4px 6px; border-radius: 5px; background: rgba(42, 18, 6, .16); border: 1.5px solid currentColor; margin-right: 8px; }
@media (hover: hover) and (pointer: fine) { .key { display: inline-block; } }

.btn { display: inline-flex; align-items: center; justify-content: center; height: 44px; padding: 0 16px; border-radius: 10px; background: var(--paper); color: var(--ink); font: 700 16px/1 "Fredoka", system-ui; box-shadow: 0 4px 0 var(--deep); white-space: nowrap; }
.btn:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--deep); }
.btn.primary { background: var(--go); }
.btn.big { height: 68px; font-size: 30px; padding: 0 44px; border-radius: 16px; box-shadow: 0 7px 0 var(--ink); }
.btn[disabled] { opacity: .45; }
.chip { display: inline-flex; align-items: center; height: 34px; padding: 0 12px; border-radius: 8px; background: var(--ink); color: var(--paper); font-weight: 700; font-size: 14px; white-space: nowrap; }

/* home */
#home { align-items: center; justify-content: space-between; padding: max(22px, env(safe-area-inset-top)) 16px max(26px, env(safe-area-inset-bottom)); pointer-events: none; }
#home > * { pointer-events: auto; }
.title { display: flex; flex-direction: column; align-items: center; font-size: clamp(64px, 21vw, 170px); line-height: .84; letter-spacing: .01em; color: #fff; text-shadow: 0 .05em 0 var(--ink), 0 .09em 0 var(--ink), .03em .06em 0 var(--ink), -.03em .06em 0 var(--ink); transform: rotate(-4deg); animation: bob 2.4s ease-in-out infinite; }
.title span:last-child { color: var(--go); }
@keyframes bob { 50% { transform: rotate(-2.5deg) translateY(-6px) scale(1.02); } }
@media (min-aspect-ratio: 1/1) { .title { flex-direction: row; gap: .22em; font-size: clamp(64px, 12vw, 180px); margin-top: 5vw; } }
.home-foot { display: flex; flex-direction: column; align-items: center; gap: 16px; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
#go { animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { box-shadow: 0 7px 0 var(--ink), 0 0 0 10px rgba(200, 255, 46, .45); } }

/* sites */
#levels, #credits { background: var(--field); overflow-y: auto; }
.bar { display: flex; align-items: center; gap: 12px; padding: max(10px, env(safe-area-inset-top)) 12px 10px; position: sticky; top: 0; background: var(--field); z-index: 1; border-bottom: 3px solid var(--deep); }
.bar h2 { font-size: 26px; }
#world-list { display: flex; flex-direction: column; }
.world { display: grid; grid-template-columns: 76px minmax(0, 1fr); gap: 4px 12px; align-items: center; padding: 12px max(12px, env(safe-area-inset-left)); color: #fff; }
.world img { width: 76px; height: 76px; grid-row: 1 / 3; filter: drop-shadow(0 4px 0 rgba(42, 18, 6, .35)); }
.world h3 { margin: 0; font: 700 21px/1.1 "Fredoka"; text-shadow: 0 2px 0 rgba(42, 18, 6, .45); }
.world .sites { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; max-width: 520px; }
.site { aspect-ratio: 1; border-radius: 9px; background: var(--paper); color: var(--ink); display: flex; flex-direction: column; align-items: center; justify-content: center; font: 700 17px/1 "Fredoka"; box-shadow: 0 3px 0 rgba(42, 18, 6, .5); position: relative; gap: 2px; }
.site small { font: 700 10px/1 "Space Grotesk"; }
.site.locked { background: rgba(42, 18, 6, .28); color: rgba(255, 255, 255, .7); box-shadow: none; }
.site.gold { background: #ffe14a; }
.site.gold::after { content: ""; position: absolute; top: -5px; right: -3px; width: 13px; height: 10px; background: var(--bad); clip-path: polygon(0 0, 100% 50%, 0 100%); border-left: 2px solid var(--ink); height: 12px; }
.credit-list { padding: 18px 16px; display: flex; flex-direction: column; gap: 4px; font-size: 16px; }
.credit-list p { margin: 4px 0; } .credit-list b { display: block; font-family: "Fredoka"; font-size: 18px; }

/* dock */
#strip { display: flex; align-items: center; gap: 10px; font: 700 15px/1.15 "Fredoka"; padding: 0 4px; }
#goal { flex: 1; font-size: 17px; }
#par { white-space: nowrap; font: 700 13px/1 "Space Grotesk"; background: var(--deep); padding: 6px 8px; border-radius: 6px; }
#strip.bad { background: var(--bad); margin: 4px 0; border-radius: 8px; padding: 0 10px; }
#strip.bad #goal { font-size: 14px; }
#strip.note { background: var(--ink); margin: 4px 0; border-radius: 8px; padding: 0 10px; }
#timeline { overflow-x: auto; overflow-y: hidden; background: var(--well); border-radius: 10px; padding: 4px; scrollbar-width: none; display: flex; flex-direction: column; justify-content: center; gap: 3px; }
#timeline::-webkit-scrollbar { display: none; }
.trow { display: flex; align-items: center; gap: 3px; height: var(--row); flex: none; }
.tlabel { position: sticky; left: 0; z-index: 1; flex: none; width: var(--label); height: var(--row); border-radius: 8px; display: flex; align-items: center; justify-content: center; box-shadow: inset 0 -3px 0 rgba(42, 18, 6, .25); outline: 3px solid var(--well); }
.tlabel img { height: calc(var(--row) - 4px); pointer-events: none; }
.trow.sel .tlabel { outline: 3px solid #fff; }
.slot { flex: none; width: var(--slot); height: calc(var(--row) - 2px); border-radius: 7px; background: var(--deep); display: flex; align-items: center; justify-content: center; color: var(--ink); position: relative; }
.slot.full { background: var(--paper); box-shadow: inset 0 -3px 0 rgba(42, 18, 6, .22); }
.slot.full.power { background: var(--go); }
.slot.full.wait { background: #ffd0b0; }
.slot svg { width: 22px; height: 22px; pointer-events: none; }
.slot.cursor { outline: 3px solid #fff; outline-offset: -1px; }
.slot.now { box-shadow: 0 0 0 3px var(--go); }
.slot.bad { background: var(--bad); color: #fff; box-shadow: 0 0 0 3px var(--bad); }
.slot .n { position: absolute; font: 700 10px/1 "Space Grotesk"; color: rgba(255, 255, 255, .45); }
.slot.full .n { display: none; }
#palette { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 5px; align-items: center; padding-top: 6px; }
.order { height: 44px; border-radius: 9px; background: var(--paper); color: var(--ink); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; font: 700 10.5px/1 "Space Grotesk"; box-shadow: 0 3px 0 var(--deep); position: relative; touch-action: none; }
.order svg { width: 20px; height: 20px; }
.order.power { background: var(--go); }
.order.off { opacity: .4; }
.order .key { position: absolute; top: 3px; left: 4px; margin: 0; padding: 2px 4px; font-size: 10px; border-width: 1px; }
.order.nudge, .btn.nudge { animation: nudge .7s ease-in-out infinite; }
@keyframes nudge { 50% { transform: translateY(-5px) scale(1.06); box-shadow: 0 8px 0 var(--deep); } }
#controls { display: grid; grid-template-columns: 2fr 1fr 1fr 1fr; gap: 6px; align-items: center; }
#controls .btn { padding: 0 6px; width: 100%; }
#result { display: none; position: absolute; inset: 0; z-index: 3; background: var(--field); flex-direction: column; align-items: center; justify-content: center; gap: 10px; padding: 8px 12px; text-align: center; }
#dock.done #result { display: flex; }
#r-head { font-size: 30px; color: #fff; text-shadow: 0 3px 0 var(--ink); }
#r-score { display: flex; align-items: center; gap: 12px; font: 700 18px/1 "Fredoka"; min-height: 44px; }
#r-ticks { font-size: 38px; color: var(--go); text-shadow: 0 3px 0 var(--ink); }
#r-flag svg { width: 44px; height: 44px; display: block; animation: wave 1s ease-in-out infinite; transform-origin: 10% 90%; }
@keyframes wave { 50% { transform: rotate(-8deg) scale(1.08); } }
.r-buttons { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; width: min(100%, 560px); }
.r-buttons .btn { padding: 0 6px; font-size: 15px; } #r-next { grid-column: 1 / 3; height: 52px; font-size: 20px; } #r-share { height: 52px; }

#drag-chip { position: fixed; z-index: 9; width: 44px; height: 44px; border-radius: 9px; background: var(--paper); color: var(--ink); display: flex; align-items: center; justify-content: center; pointer-events: none; transform: translate(-50%, -60%) scale(1.15); box-shadow: 0 8px 14px rgba(42, 18, 6, .4); }
#drag-chip[hidden] { display: none; } #drag-chip svg { width: 24px; height: 24px; }
#tweaks { position: fixed; top: 52px; right: 8px; z-index: 8; background: var(--ink); color: var(--paper); border-radius: 10px; padding: 10px 12px; display: flex; flex-direction: column; gap: 8px; font-size: 13px; width: 200px; }
#tweaks[hidden] { display: none; } #tweaks b { font-family: "Fredoka"; font-size: 15px; }
#tweaks button { background: var(--paper); color: var(--ink); border-radius: 6px; padding: 6px 8px; font-weight: 700; text-align: left; } #tweaks button.on { background: var(--go); }
#tweaks input { width: 100%; }

@media (max-height: 610px) { :root { --dock: 268px; --row: 31px; --slot: 34px; --top: 40px; } #dock { grid-template-rows: 36px minmax(0, 1fr) 48px 50px; } .order { height: 40px; } .btn { height: 40px; } }
@media (min-width: 900px) {
  :root { --dock: 290px; --row: 40px; --slot: 46px; --label: 70px; }
  #dock { grid-template-columns: minmax(0, 1fr) 380px; grid-template-rows: 44px minmax(0, 1fr) 60px; column-gap: 16px; padding: 0 max(20px, calc(50vw - 560px)) 12px; }
  #strip { grid-column: 1 / -1; } #timeline { grid-row: 2 / 4; grid-column: 1; } #palette { grid-column: 2; grid-row: 2; grid-auto-flow: row; grid-template-columns: repeat(3, 1fr); align-content: center; padding: 0; } #controls { grid-column: 2; grid-row: 3; }
  .order { height: 54px; font-size: 12px; } .order svg { width: 24px; height: 24px; }
  #r-head { font-size: 38px; }
}

@media (max-width: 340px) { .btn { font-size: 14px; } .order { font-size: 9.5px; } .r-buttons .btn { font-size: 13px; } .chip { padding: 0 9px; font-size: 13px; } }
