@font-face { font-family: "Lilita One"; src: url(../fonts/lilita-one-latin-400-normal.woff2) format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Rubik"; src: url(../fonts/rubik-latin-400-normal.woff2) format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Rubik"; src: url(../fonts/rubik-latin-500-normal.woff2) format("woff2"); font-weight: 500; font-display: swap; }
@font-face { font-family: "Rubik"; src: url(../fonts/rubik-latin-700-normal.woff2) format("woff2"); font-weight: 700; font-display: swap; }
@font-face { font-family: "Rubik"; src: url(../fonts/rubik-latin-800-normal.woff2) format("woff2"); font-weight: 800; font-display: swap; }

:root {
  --ink: #1f1a17;
  --ink-2: #4a413a;
  --cream: #fff4dc;
  --paper: #fffaf0;
  --red: #e23b2e;
  --yellow: #ffc93c;
  --blue: #2f6fe0;
  --green: #2fae5a;
  --line: 3px;
  --radius: 18px;
  --display: "Lilita One", "Arial Rounded MT Bold", Impact, sans-serif;
  --body: "Rubik", system-ui, -apple-system, "Segoe UI", sans-serif;
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: #1f1a17; overflow: hidden; }
body { font: 500 16px/1.4 var(--body); color: var(--ink); -webkit-font-smoothing: antialiased; user-select: none; -webkit-user-select: none; touch-action: none; }
#game { position: fixed; inset: 0; width: 100vw; height: 100vh; height: 100dvh; display: block; }
button { font: inherit; color: inherit; cursor: pointer; }
kbd { font: 700 0.8em var(--body); background: var(--paper); border: 2px solid var(--ink); border-bottom-width: 3px; border-radius: 6px; padding: 0 0.35em; margin: 0 0.1em; display: inline-block; min-width: 1.6em; text-align: center; line-height: 1.5; color: var(--ink); }
a { color: inherit; }
.hidden { display: none !important; }

/* ---------- boot / loading ---------- */
#boot, #loading { position: fixed; inset: 0; display: grid; place-content: center; justify-items: center; gap: 14px; background: radial-gradient(circle at 50% 40%, #3a2e26, #1f1a17 70%); color: var(--cream); font-family: var(--display); font-size: 22px; letter-spacing: .02em; z-index: 50; transition: opacity .5s; text-align: center; }
#boot.done { opacity: 0; pointer-events: none; }
#loading { opacity: 0; pointer-events: none; background: rgba(31, 26, 23, .82); }
#loading.show { opacity: 1; pointer-events: auto; }
#boot p, #loading p { margin: 0; }
#boot small { font-family: var(--body); font-size: 13px; opacity: .7; }
.boot-car { width: 70px; height: 30px; border-radius: 14px 18px 8px 8px; background: var(--red); position: relative; box-shadow: inset 0 -6px 0 rgba(0,0,0,.18); animation: bob .5s ease-in-out infinite alternate; }
.boot-car::before, .boot-car::after { content: ""; position: absolute; bottom: -9px; width: 18px; height: 18px; border-radius: 50%; background: var(--ink); border: 4px solid #d9dce1; }
.boot-car::before { left: 8px; } .boot-car::after { right: 8px; }
@keyframes bob { to { transform: translateY(-5px) rotate(-2deg); } }

/* ---------- screens ---------- */
.screen { position: fixed; inset: 0; display: none; z-index: 10; padding: 16px; overflow: auto; }
.screen.active { display: grid; place-items: center; }
#screen-title.active { background: linear-gradient(180deg, rgba(20, 15, 12, .55), rgba(20, 15, 12, .1) 45%, rgba(20, 15, 12, .65)); }
#screen-lobby.active, #screen-controls.active, #screen-pause.active, #screen-results.active { background: rgba(20, 15, 12, .45); backdrop-filter: blur(2px); }

.title-wrap { text-align: center; color: var(--cream); max-width: 760px; }
.logo { font-family: var(--display); font-weight: 400; margin: 0 0 10px; line-height: .86; transform: rotate(-3deg); }
.logo span { display: block; text-transform: uppercase; letter-spacing: .02em; }
.logo .l1 { font-size: clamp(54px, 10vw, 112px); color: var(--yellow); -webkit-text-stroke: 3px var(--ink); paint-order: stroke fill; text-shadow: 0 6px 0 var(--ink), 0 10px 30px rgba(0,0,0,.4); }
.logo .l2 { font-size: clamp(70px, 14vw, 160px); color: var(--red); -webkit-text-stroke: 4px var(--ink); paint-order: stroke fill; text-shadow: 0 8px 0 var(--ink), 0 14px 40px rgba(0,0,0,.45); margin-left: .6em; }
.tagline { font-size: clamp(16px, 2vw, 20px); margin: 18px auto 26px; max-width: 34em; text-shadow: 0 2px 8px rgba(0,0,0,.7); }
.title-buttons { display: flex; gap: 14px; justify-content: center; flex-wrap: wrap; }
.small { font-size: 14px; opacity: .9; }
.back { margin-top: 26px; }
.back a { text-decoration: none; border-bottom: 1px solid currentColor; }
.center { text-align: center; }

/* ---------- buttons ---------- */
.btn { background: var(--paper); color: var(--ink); border: var(--line) solid var(--ink); border-radius: 999px; padding: 10px 22px; font-weight: 700; box-shadow: 0 4px 0 var(--ink); transition: transform .08s, box-shadow .08s; }
.btn:hover { transform: translateY(-1px); box-shadow: 0 5px 0 var(--ink); }
.btn:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--ink); }
.btn:focus-visible, .seg button:focus-visible, .world-card:focus-visible, .slot-type:focus-visible, .ctl-row:focus-visible { outline: 3px solid var(--blue); outline-offset: 3px; }
.btn.big { font-family: var(--display); font-weight: 400; font-size: 26px; padding: 10px 30px; letter-spacing: .02em; }
.btn.yellow { background: var(--yellow); }
.btn.ghost { background: transparent; box-shadow: none; border-color: transparent; }
.btn.ghost:hover { background: rgba(31,26,23,.07); transform: none; box-shadow: none; }
.small-btn { padding: 6px 12px; font-size: 15px; }
.btn kbd { font-size: 12px; vertical-align: 3px; margin-left: 6px; }

#corner { position: fixed; top: 10px; right: 10px; z-index: 30; display: flex; gap: 8px; }
.icon-btn { width: 40px; height: 40px; border-radius: 12px; border: 2px solid rgba(255,255,255,.35); background: rgba(31,26,23,.45); color: #fff; font-size: 18px; line-height: 1; backdrop-filter: blur(4px); }
.icon-btn:hover { background: rgba(31,26,23,.7); }
body[data-screen="none"] #corner { opacity: .45; }
body[data-screen="none"] #corner:hover { opacity: 1; }

/* ---------- panels ---------- */
.panel { background: var(--cream); border: var(--line) solid var(--ink); border-radius: var(--radius); box-shadow: 0 8px 0 var(--ink), 0 20px 50px rgba(0,0,0,.4); padding: 18px 22px 20px; width: min(1080px, 100%); max-height: calc(100dvh - 32px); overflow: auto; }
.panel h2 { font-family: var(--display); font-weight: 400; font-size: 34px; margin: 0; letter-spacing: .01em; }
.panel h3 { font-family: var(--display); font-weight: 400; font-size: 21px; margin: 14px 0 10px; letter-spacing: .01em; }
.panel h3 .sub { font-family: var(--body); font-size: 13px; font-weight: 500; color: var(--ink-2); margin-left: 6px; }
.panel-head { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 8px; border-bottom: 2px dashed rgba(31,26,23,.25); padding-bottom: 10px; }
.panel-head > :first-child { justify-self: start; } .panel-head > :last-child { justify-self: end; }
.panel-foot { display: flex; justify-content: space-between; align-items: center; gap: 12px; border-top: 2px dashed rgba(31,26,23,.25); padding-top: 14px; margin-top: 14px; flex-wrap: wrap; }
.lobby-grid { display: grid; grid-template-columns: 1fr 1.15fr; gap: 26px; }
@media (max-width: 860px) { .lobby-grid { grid-template-columns: 1fr; } }

.world-list { display: grid; gap: 10px; }
.world-card { display: grid; grid-template-columns: 112px 1fr; grid-template-rows: auto 1fr; column-gap: 12px; text-align: left; padding: 8px; border: var(--line) solid var(--ink); border-radius: 14px; background: var(--paper); box-shadow: 0 3px 0 var(--ink); }
.world-card .thumb { grid-row: 1 / 3; width: 112px; height: 70px; border-radius: 9px; background: #6b5240 center / cover no-repeat; border: 2px solid var(--ink); }
.world-card .wname { font-family: var(--display); font-size: 20px; line-height: 1.1; align-self: end; }
.world-card .wblurb { font-size: 13px; color: var(--ink-2); line-height: 1.3; }
.world-card.selected { background: var(--yellow); transform: translateY(1px); }
.world-card:hover:not(.selected) { background: #fff; }

.player-list { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
@media (max-width: 520px) { .player-list { grid-template-columns: 1fr; } }
.slot { border: var(--line) solid var(--ink); border-radius: 14px; background: var(--paper); padding: 10px 12px; box-shadow: 0 3px 0 var(--ink); position: relative; overflow: hidden; }
.slot::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 8px; background: var(--pc); }
.slot-head { display: flex; align-items: center; gap: 8px; }
.slot-car { width: 30px; height: 15px; border-radius: 7px 9px 4px 4px; background: var(--pc); border: 2px solid var(--ink); position: relative; }
.slot-name { font-family: var(--display); font-size: 20px; }
.slot-type { margin-top: 6px; width: 100%; display: flex; justify-content: space-between; align-items: center; background: #fff; border: 2px solid var(--ink); border-radius: 10px; padding: 6px 10px; font-weight: 700; }
.slot-type .cyc { opacity: .5; }
.slot-hint { font-size: 12.5px; color: var(--ink-2); margin-top: 6px; min-height: 2.6em; }
.slot-hint kbd { font-size: 11px; }
.slot-off { opacity: .55; }
.slot-off .slot-car { background: transparent; border-style: dashed; }
.warn { background: #fff0c2; border: 2px solid var(--ink); border-radius: 10px; padding: 8px 10px; font-size: 13px; margin: 10px 0 0; }

.opts { display: grid; gap: 8px; }
.opt-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.opt-row[hidden] { display: none; }
.opt-row > span { font-weight: 700; }
.opt-help { font-size: 13px; color: var(--ink-2); margin: -2px 0 2px; }
.seg { display: inline-flex; border: 2px solid var(--ink); border-radius: 999px; overflow: hidden; background: #fff; }
.seg button { border: 0; background: transparent; padding: 6px 13px; font-weight: 700; font-size: 14px; }
.seg button + button { border-left: 2px solid var(--ink); }
.seg button.on { background: var(--ink); color: var(--yellow); }

.controls { width: min(980px, 100%); }
.controls-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-top: 12px; }
@media (max-width: 760px) { .controls-grid { grid-template-columns: repeat(2, 1fr); } }
.ctl-col { border: var(--line) solid var(--ink); border-radius: 14px; background: var(--paper); padding: 10px; border-top: 10px solid var(--pc); }
.ctl-col h3 { margin: 0 0 8px; }
.ctl-row { width: 100%; display: flex; justify-content: space-between; align-items: center; gap: 6px; background: transparent; border: 0; border-bottom: 1px dashed rgba(31,26,23,.25); padding: 7px 2px; font-size: 14px; text-align: left; }
.ctl-row:hover { background: #fff; }
.ctl-row.listening kbd { background: var(--yellow); animation: blink .6s infinite alternate; }
@keyframes blink { to { opacity: .4; } }

.small-panel { width: min(440px, 100%); text-align: center; }
.stack { display: grid; gap: 12px; margin-top: 18px; }
.stack.row { grid-template-columns: 1fr auto; align-items: center; }
.results h2 { color: var(--pc); -webkit-text-stroke: 2px var(--ink); paint-order: stroke fill; font-size: 40px; text-shadow: 0 3px 0 var(--ink); }
#results-list { list-style: none; padding: 0; margin: 16px 0 0; display: grid; gap: 8px; }
#results-list li { display: grid; grid-template-columns: 48px 1fr auto; align-items: center; gap: 10px; border: var(--line) solid var(--ink); border-radius: 12px; padding: 8px 12px; background: var(--paper); text-align: left; border-left: 12px solid var(--pc); }
#results-list li:first-child { background: var(--yellow); }
#results-list .pos { font-family: var(--display); font-size: 22px; }
#results-list .who { font-weight: 700; }
#results-list .det { font-size: 14px; color: var(--ink-2); }

/* ---------- HUD ---------- */
#hud { position: fixed; inset: 0; pointer-events: none; z-index: 5; }
#chips { position: absolute; top: 10px; left: 50%; transform: translateX(-50%); display: flex; gap: 10px; }
.chip { display: flex; align-items: center; gap: 8px; background: rgba(255, 244, 220, .93); border: 3px solid var(--ink); border-radius: 999px; padding: 3px 12px 3px 4px; box-shadow: 0 3px 0 var(--ink); transition: opacity .3s, transform .3s; }
.chip-name { background: var(--pc); color: #fff; font-family: var(--display); font-size: 16px; padding: 1px 10px; border-radius: 999px; border: 2px solid var(--ink); -webkit-text-stroke: 1px rgba(0,0,0,.35); }
.chip-info { font-weight: 800; font-size: 15px; letter-spacing: .06em; color: var(--ink); white-space: nowrap; }
.chip.out { opacity: .45; transform: scale(.92); }
.chip.out .chip-name { text-decoration: line-through; }
.msg { position: absolute; left: 0; right: 0; top: 34%; text-align: center; font-family: var(--display); font-size: clamp(40px, 8vw, 96px); color: var(--mc, #fff); -webkit-text-stroke: 4px var(--ink); paint-order: stroke fill; text-shadow: 0 6px 0 var(--ink); opacity: 0; transition: opacity .2s; letter-spacing: .02em; }
.msg.show { opacity: 1; }
.msg.count, .msg.go { font-size: clamp(90px, 18vw, 200px); top: 28%; }
.msg.go { color: var(--yellow); }
.msg.round { font-size: clamp(34px, 6vw, 72px); }
.msg.pop { animation: pop .5s cubic-bezier(.2, 1.6, .4, 1); }
@keyframes pop { from { transform: scale(2.2); opacity: 0; } to { transform: scale(1); opacity: 1; } }
#flash { position: absolute; left: 0; right: 0; top: 66px; display: grid; justify-items: center; gap: 6px; }
.flash-item { font-family: var(--display); font-size: 26px; color: var(--fc); -webkit-text-stroke: 2.5px var(--ink); paint-order: stroke fill; text-shadow: 0 3px 0 var(--ink); animation: flash 1.9s ease-out forwards; }
@keyframes flash { 0% { transform: translateY(-10px) scale(.8); opacity: 0; } 10% { transform: none; opacity: 1; } 80% { opacity: 1; } 100% { opacity: 0; transform: translateY(6px); } }

/* touch controls */
#touch { position: fixed; inset: 0; z-index: 6; display: none; }
#touch.show { display: flex; }
body:not([data-screen="none"]) #touch { display: none; }
#touch > div { flex: 1; display: flex; align-items: flex-end; padding: 24px; touch-action: none; }
#touch-right { justify-content: flex-end; }
#touch span { width: 74px; height: 74px; border-radius: 50%; display: grid; place-items: center; font-size: 30px; color: #fff; background: rgba(31,26,23,.35); border: 3px solid rgba(255,255,255,.5); }
#touch .down span { background: rgba(255,201,60,.6); }

@media (max-width: 600px) {
  .chip { padding: 2px 8px 2px 3px; } .chip-name { font-size: 13px; padding: 0 7px; } .chip-info { font-size: 12px; }
  #chips { gap: 5px; top: 58px; }
}
@media (prefers-reduced-motion: reduce) { .boot-car, .msg.pop, .flash-item { animation: none; } }

/* lobby: keep the Start button in view while the lists scroll */
.panel.lobby { padding-bottom: 0; }
.panel.lobby .panel-foot { position: sticky; bottom: 0; background: var(--cream); padding-bottom: 16px; z-index: 2; }
.world-list { gap: 8px; }
.world-card { padding: 6px 8px; }
@media (max-height: 760px) and (min-width: 861px) {
  .world-card { grid-template-columns: 88px 1fr; }
  .world-card .thumb { width: 88px; height: 55px; }
  .world-card .wname { font-size: 18px; }
  .world-card .wblurb { font-size: 12.5px; }
  .panel h3 { margin: 10px 0 8px; }
}
/* small screens: the sound/fullscreen buttons would sit on top of the menu panels */
@media (max-width: 600px) {
  body[data-screen="lobby"] #corner, body[data-screen="controls"] #corner, body[data-screen="results"] #corner { display: none; }
}
