@font-face { font-family: 'Luckiest Guy'; src: url(/fonts/luckiest-guy-latin-400-normal.woff2) format('woff2'); font-display: swap; }
@font-face { font-family: 'Rubik'; font-weight: 400; src: url(/fonts/rubik-latin-400-normal.woff2) format('woff2'); font-display: swap; }
@font-face { font-family: 'Rubik'; font-weight: 600; src: url(/fonts/rubik-latin-600-normal.woff2) format('woff2'); font-display: swap; }
@font-face { font-family: 'Rubik'; font-weight: 800; src: url(/fonts/rubik-latin-800-normal.woff2) format('woff2'); font-display: swap; }

:root {
  --bg: #dff3ff; --paper: #ffffff; --ink: #12304a; --muted: #5d7b92; --line: #b9dcf2;
  --aqua: #19b5e6; --aqua-dark: #0b7ea6; --orange: #ff8a3d; --orange-dark: #b9541a;
  --green: #23b67f; --red: #f0524f; --yellow: #ffd23f; --me: #19b5e6; --them: #ff8a3d;
  --display: 'Luckiest Guy', 'Arial Black', Impact, sans-serif;
  --body: 'Rubik', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body {
  margin: 0; color: var(--ink); font: 16px/1.45 var(--body); overscroll-behavior: none; background: var(--bg);
  background-image: radial-gradient(circle at 14px 14px, rgba(25, 181, 230, .16) 4px, transparent 5px); background-size: 34px 34px;
}
#app { min-height: 100dvh; display: flex; flex-direction: column; align-items: center; padding: 14px 14px calc(18px + env(safe-area-inset-bottom, 0px)); }
.screen { width: min(540px, 100%); display: flex; flex-direction: column; gap: 14px; flex: 1; }
button { font: inherit; color: inherit; cursor: pointer; }
img { -webkit-user-drag: none; user-select: none; }
p { margin: 0; } .muted { color: var(--muted); } .center { text-align: center; }

.bar { display: flex; align-items: center; gap: 8px; min-height: 44px; }
.bar .sp { flex: 1; }
.logo { font: 22px/1 var(--display); color: var(--aqua-dark); letter-spacing: .4px; padding-top: 4px; text-decoration: none; }
.logo span { color: var(--orange); }
.chip { border: 2px solid var(--line); background: var(--paper); border-radius: 999px; padding: 6px 12px; font-size: 13.5px; font-weight: 600; color: var(--muted); text-decoration: none; }
.round { width: 40px; height: 40px; border-radius: 50%; border: 2px solid var(--line); background: var(--paper); font-size: 18px; font-weight: 800; display: grid; place-items: center; }

.card { background: var(--paper); border: 3px solid var(--ink); border-radius: 22px; padding: 18px; box-shadow: 0 6px 0 rgba(18, 48, 74, .2); }
h1 { font: 42px/1 var(--display); margin: 2px 0 0; text-align: center; letter-spacing: .5px; }
h1 em { font-style: normal; color: var(--aqua-dark); }
h2 { font: 26px/1.08 var(--display); margin: 0; letter-spacing: .3px; }
.btn { border: 3px solid var(--ink); border-radius: 16px; padding: 14px 18px 10px; font: 22px/1 var(--display); letter-spacing: .5px; background: var(--paper); box-shadow: 0 5px 0 var(--ink); transition: transform .08s, box-shadow .08s; width: 100%; }
.btn:active { transform: translateY(4px); box-shadow: 0 1px 0 var(--ink); }
.btn.blue { background: var(--aqua); color: #fff; } .btn.orange { background: var(--orange); color: #fff; } .btn.yellow { background: var(--yellow); }
.btn.small { font-size: 17px; padding: 10px 14px 7px; width: auto; }
.btn[disabled] { opacity: .55; pointer-events: none; }
label.f { display: flex; flex-direction: column; gap: 6px; font-weight: 600; font-size: 14px; color: var(--muted); }
input[type=text] { font: 600 18px var(--body); color: var(--ink); border: 3px solid var(--ink); border-radius: 14px; padding: 11px 14px; background: #fff; width: 100%; }
input[type=text]:focus { outline: 3px solid var(--yellow); }
.hero { width: min(100%, 420px); aspect-ratio: 16 / 9; object-fit: cover; border-radius: 20px; border: 3px solid var(--ink); margin: 0 auto; display: block; box-shadow: 0 6px 0 rgba(18, 48, 74, .2); }
.cats { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; }
.cats img { width: 100%; aspect-ratio: 1; object-fit: contain; }

.code { font: 54px/1 var(--display); letter-spacing: 6px; text-align: center; color: var(--orange); padding-top: 8px; }
.linkbox { display: flex; gap: 8px; align-items: center; background: #fff; border: 2px dashed var(--line); border-radius: 14px; padding: 8px 8px 8px 12px; font-size: 14px; }
.linkbox span { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.dots::after { content: ''; animation: dots 1.4s steps(4) infinite; }
@keyframes dots { 25% { content: '.'; } 50% { content: '..'; } 75% { content: '...'; } }

/* the tug of war */
.tug { padding: 12px 14px 14px; display: flex; flex-direction: column; gap: 8px; }
.names { display: flex; justify-content: space-between; gap: 8px; font-weight: 800; font-size: 15px; }
.names span { max-width: 46%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.names .me { color: var(--aqua-dark); } .names .them { color: var(--orange-dark); }
.names i { font-style: normal; font-weight: 600; color: var(--muted); }
.rope { position: relative; height: 74px; border-radius: 16px; background: linear-gradient(90deg, rgba(25,181,230,.28) 0 14%, #f2f8fc 14% 86%, rgba(255,138,61,.3) 86%); border: 3px solid var(--ink); overflow: hidden; }
.rope::before { content: ''; position: absolute; left: 6%; right: 6%; top: 50%; height: 6px; margin-top: -3px; border-radius: 3px; background: repeating-linear-gradient(90deg, #c69a5b 0 10px, #a67c3d 10px 20px); }
.rope::after { content: ''; position: absolute; left: 50%; top: 6px; bottom: 6px; border-left: 3px dashed rgba(18,48,74,.25); }
.rope .cooler { position: absolute; top: 4px; width: 60px; height: 60px; margin-left: -30px; left: 50%; transition: left .7s cubic-bezier(.3,1.4,.5,1); z-index: 1; object-fit: contain; }
.rope .cooler.shake { animation: wob .5s; }
@keyframes wob { 25% { transform: rotate(-12deg); } 75% { transform: rotate(12deg); } }
.meta { display: flex; justify-content: space-between; align-items: center; font-size: 13px; font-weight: 600; color: var(--muted); }

/* question */
.qcard { display: flex; flex-direction: column; gap: 12px; flex: 1; }
.cat { display: flex; align-items: center; gap: 10px; }
.cat img { width: 52px; height: 52px; object-fit: contain; flex: none; }
.cat b { font: 20px/1 var(--display); letter-spacing: .3px; padding-top: 4px; color: var(--aqua-dark); }
.cat .sp { flex: 1; }
.qtext { font-size: 20px; font-weight: 800; line-height: 1.25; min-height: 50px; }
.timer { height: 10px; border-radius: 6px; background: var(--line); overflow: hidden; border: 2px solid var(--ink); }
.timer i { display: block; height: 100%; width: 100%; background: var(--aqua); transform-origin: left; }
.timer i.low { background: var(--red); }
.opts { display: grid; gap: 10px; }
.opt { text-align: left; border: 3px solid var(--ink); border-radius: 14px; background: #fff; padding: 13px 14px; font-weight: 600; font-size: 17px; box-shadow: 0 4px 0 var(--ink); display: flex; align-items: center; gap: 10px; transition: transform .08s, box-shadow .08s; }
.opt:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--ink); }
.opt .k { flex: none; width: 28px; height: 28px; border-radius: 8px; background: var(--bg); display: grid; place-items: center; font-weight: 800; font-size: 14px; }
.opt .tx { flex: 1; }
.opt .who { flex: none; display: flex; gap: 4px; }
.opt .who i { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--ink); }
.opt .who i.me { background: var(--me); } .opt .who i.them { background: var(--them); }
.opt.mine { background: #e3f6fd; border-color: var(--aqua-dark); }
.opt.right { background: #d5f5e7; border-color: var(--green); }
.opt.wrong { background: #fde1e0; border-color: var(--red); }
.opt[disabled] { pointer-events: none; box-shadow: none; transform: translateY(3px); }
.double { display: flex; align-items: center; gap: 10px; border: 3px dashed var(--ink); border-radius: 14px; background: #fff8dc; padding: 8px 12px; font-weight: 800; }
.double img { width: 38px; height: 38px; object-fit: contain; }
.double small { display: block; font-weight: 600; color: var(--muted); }
.double.on { border-style: solid; background: var(--yellow); }
.double[disabled] { opacity: .45; pointer-events: none; }
.result { font-weight: 800; text-align: center; min-height: 24px; }
.result .up { color: var(--green); } .result .down { color: var(--red); }
.bigcat { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 26px 10px; flex: 1; justify-content: center; }
.bigcat img { width: 150px; height: 150px; object-fit: contain; animation: pop .45s cubic-bezier(.3,1.6,.5,1); }
.bigcat b { font: 34px/1 var(--display); color: var(--aqua-dark); padding-top: 6px; }
@keyframes pop { 0% { transform: scale(.3) rotate(-20deg); opacity: 0; } }
.count { font: 96px/1 var(--display); text-align: center; color: var(--orange); text-shadow: 0 5px 0 var(--orange-dark); }
.banner { font: 36px/1.05 var(--display); text-align: center; color: var(--aqua-dark); padding-top: 6px; }
.prize { width: 170px; height: 170px; object-fit: contain; margin: 0 auto; display: block; }
.toast { position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%); background: var(--ink); color: #fff; font-weight: 600; padding: 10px 16px; border-radius: 999px; z-index: 9; }
dialog { border: 3px solid var(--ink); border-radius: 22px; background: var(--paper); color: var(--ink); padding: 22px 20px 18px; width: min(460px, calc(100vw - 28px)); }
dialog::backdrop { background: rgba(18, 48, 74, .55); }
dialog ol { margin: 8px 0 14px; padding-left: 22px; } dialog li { margin: 4px 0; }
@media (max-height: 700px) { h1 { font-size: 34px; } .rope { height: 62px; } .rope .cooler { width: 50px; height: 50px; margin-left: -25px; } .qtext { font-size: 18px; } .opt { padding: 10px 12px; } }
@media (prefers-reduced-motion: reduce) { .rope .cooler { transition: none; } .bigcat img, .rope .cooler.shake { animation: none; } }

/* keep everything inside a phone's width */
.screen { min-width: 0; max-width: 100%; }
.screen > *, .card > * { min-width: 0; max-width: 100%; }
.opts { grid-template-columns: minmax(0, 1fr); }
.names span, .meta span { min-width: 0; }
.chip { white-space: nowrap; }
.logo { white-space: nowrap; font-size: 20px; }
.qtext, .opt .tx { overflow-wrap: anywhere; }


/* ---------- Grid Strike: palette, the duel bar and the two floors of desks ---------- */
:root { --bg: #e6f1e4; --paper: #fffdf8; --ink: #24303a; --muted: #68767f; --line: #c9d8c6; --aqua: #1f9d8a; --aqua-dark: #14695c; --orange: #f0702b; --orange-dark: #a84512; --yellow: #ffd23f; --a: #1f9d8a; --b: #f0702b; --tin: #ffd98a; }
body { background-image: linear-gradient(rgba(36, 48, 58, .05) 1px, transparent 1px), linear-gradient(90deg, rgba(36, 48, 58, .05) 1px, transparent 1px); background-size: 26px 26px; }
.logo { font-size: 26px; }
h3 { font: 19px/1 var(--display); letter-spacing: .3px; margin: 0; padding-top: 3px; }
button:focus-visible, a:focus-visible { outline: 3px solid var(--aqua-dark); outline-offset: 2px; }
.duelbar { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 8px; padding: 8px 10px; }
.mgr { display: flex; align-items: center; gap: 8px; min-width: 0; border-radius: 14px; padding: 4px 6px; border: 3px solid transparent; }
.mgr.b { flex-direction: row-reverse; text-align: right; }
.mgr img { width: 42px; height: 42px; object-fit: contain; flex: none; }
.mgr.b img { transform: scaleX(-1); }
.mgr .who { min-width: 0; }
.mgr .who b { display: block; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mgr .who span { font: 24px/1 var(--display); padding-top: 4px; display: block; }
.mgr.a .who span { color: var(--a); } .mgr.b .who span { color: var(--orange-dark); }
.mgr.turn { border-color: var(--ink); background: #fff7d1; }
.vs { font: 20px/1 var(--display); color: var(--muted); }
.status { text-align: center; font-weight: 800; min-height: 24px; }
.status.mine { color: var(--aqua-dark); }
.lastline { font-weight: 600; min-height: 23px; }
.stickers { display: flex; justify-content: center; align-items: center; gap: 12px; min-height: 64px; }
.stickers img { width: 64px; height: 64px; object-fit: contain; }
.stickers.big { min-height: 0; } .stickers.big img { width: 130px; height: 130px; }
.row2 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr); gap: 10px; }

.floor { display: grid; grid-template-columns: repeat(var(--n), minmax(0, 1fr)); gap: 4px; background: #fff; border: 3px solid var(--ink); border-radius: 18px; padding: 8px; box-shadow: 0 6px 0 rgba(36, 48, 58, .2); touch-action: manipulation; user-select: none; }
.floor.big { width: 100%; }
.floor.small { width: 190px; flex: none; border-radius: 14px; padding: 6px; gap: 3px; box-shadow: 0 4px 0 rgba(36, 48, 58, .2); }
.desk { position: relative; aspect-ratio: 1; min-width: 0; margin: 0; padding: 0; display: grid; place-items: center; border: 2px solid var(--line); border-radius: 10px; background: #f6f3ea; font: inherit; color: var(--ink); }
.small .desk { border-radius: 6px; }
.desk > * { position: relative; z-index: 1; }
button.desk { cursor: pointer; }
button.desk.open { border-color: var(--ink); background: #fff; box-shadow: 0 3px 0 var(--ink); transition: transform .08s, box-shadow .08s, background .08s; }
button.desk.open:active, button.desk.thrown { transform: translateY(3px); box-shadow: 0 0 0 var(--ink); background: #fff3a8; }
@media (hover: hover) { .floor:not(.locked) button.desk.open:hover { background: #fff3a8; } }
.floor.locked button.desk.open { pointer-events: none; }
.target.locked .desk:not(.miss):not(.hit):not(.found) { opacity: .75; }
.desk.miss { background: #e3edf6; border-style: dashed; border-color: #9db4c8; }
.desk.hit { background: #fff1c9; border-color: var(--ink); }
/* a tin is drawn behind its desks as one long shape: each desk's piece reaches across the gap to the next */
.desk.tin { border-color: transparent; background: transparent; }
.desk.tin::before { content: ''; position: absolute; inset: -2px; border: 3px solid var(--ink); border-radius: 10px; background: repeating-linear-gradient(45deg, var(--tin) 0 7px, #ffc95c 7px 14px); }
.small .desk.tin::before { border-width: 2px; border-radius: 6px; }
.desk.tin.ju::before { top: -4px; border-top: 0; border-top-left-radius: 0; border-top-right-radius: 0; }
.desk.tin.jd::before { bottom: -4px; border-bottom: 0; border-bottom-left-radius: 0; border-bottom-right-radius: 0; }
.desk.tin.jl::before { left: -4px; border-left: 0; border-top-left-radius: 0; border-bottom-left-radius: 0; }
.desk.tin.jr::before { right: -4px; border-right: 0; border-top-right-radius: 0; border-bottom-right-radius: 0; }
.desk.tin.found::before { background: #b9ecd2; }
.desk.tin.hit::before { background: #ffb38a; }
.lid { width: 34%; height: 34%; border-radius: 50%; border: 3px solid var(--ink); background: #fff7d1; }
.small .lid { border-width: 2px; }
.pic { width: 80%; height: 80%; object-fit: contain; }
.pic.mark { display: grid; place-items: center; font-weight: 800; font-size: 22px; line-height: 1; }
.small .pic.mark { font-size: 13px; }
.tick { position: absolute !important; right: 1px; top: 1px; width: 17px; height: 17px; border-radius: 50%; background: var(--aqua-dark); color: #fff; font-size: 11px; font-weight: 800; display: grid; place-items: center; }
.small .tick { width: 12px; height: 12px; font-size: 8px; }
.desk.last { outline: 3px dashed var(--orange); outline-offset: -1px; }
.desk.hit .pic, .desk.miss .pic, .desk.found .pic { animation: land .3s cubic-bezier(.3, 1.5, .5, 1); }
@keyframes land { 0% { transform: scale(.3); opacity: 0; } }
.minewrap { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.minewrap > div:first-child { min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.pairfloors { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 10px; }
.pairfloors > div { min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.pairfloors .floor.small { width: 100%; }
@media (max-width: 350px) { .floor.small { width: 160px; } }
@media (prefers-reduced-motion: reduce) { .desk .pic { animation: none !important; } button.desk.open, .btn { transition: none; } }

/* setup: drag tins */
.floor.setup { touch-action: none; }
.floor.setup button.desk.tin { cursor: grab; }
.floor.setup button.desk.tin:active { cursor: grabbing; }
.desk.lift::before { opacity: .35; }
.desk.lift .lid { opacity: .35; }
.desk.drop-ok { background: #c9f3dc; border-color: var(--ink); border-style: solid; }
.desk.drop-bad { background: #ffd0cc; border-color: #c0392b; border-style: dashed; }
.desk.drop-ok::after, .desk.drop-bad::after { content: ''; position: absolute; inset: 3px; border-radius: 7px; border: 3px solid currentColor; opacity: .5; z-index: 2; pointer-events: none; }
.desk.drop-ok { color: #17805d; } .desk.drop-bad { color: #c0392b; }
