@font-face { font-family: "Lilita One"; src: url("../assets/fonts/lilita-one.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Nunito"; src: url("../assets/fonts/nunito-700.woff2") format("woff2"); font-weight: 700; font-display: swap; }
@font-face { font-family: "Nunito"; src: url("../assets/fonts/nunito-800.woff2") format("woff2"); font-weight: 800; font-display: swap; }
@font-face { font-family: "Nunito"; src: url("../assets/fonts/nunito-900.woff2") format("woff2"); font-weight: 900; font-display: swap; }

:root {
  --ink: #23264a;
  --ink-2: #1b1d3a;
  --bg: #f6f5f2;
  --white: #ffffff;
  --coral: #ff6b6b;   --coral-d: #e04e4e;
  --yellow: #ffc83d;  --yellow-d: #e6a817;
  --blue: #4a90ff;    --blue-d: #2f6fd6;
  --green: #5bd16b;   --green-d: #36a948;
  --muted: #8b8fa8;
  --ok: #5bd16b; --bad: #ff6b6b;
  --display: "Lilita One", "Arial Rounded MT Bold", "Trebuchet MS", sans-serif;
  --body: "Nunito", ui-rounded, "Segoe UI", system-ui, sans-serif;
}
* { box-sizing: border-box; }
.hidden { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100vh; font-family: var(--body); font-weight: 800; color: var(--ink);
  background-color: var(--bg);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220' viewBox='0 0 220 220'%3E%3Cg fill='none' stroke='%2323264a' stroke-opacity='.07' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 50l26-26 8 8-26 26-11 3z'/%3E%3Cpath d='M150 20l5 11 11 5-11 5-5 11-5-11-11-5 11-5z'/%3E%3Crect x='120' y='120' width='38' height='30' rx='4'/%3E%3Cpath d='M126 144l9-10 7 7 5-5 6 8'/%3E%3Cpath d='M30 140c8-14 18-14 22 0s14 14 22 0'/%3E%3Cpath d='M180 90a9 9 0 1 1 9 9v6M189 114v1'/%3E%3Ccircle cx='80' cy='95' r='9'/%3E%3Cpath d='M60 190h30M75 175v30'/%3E%3Cpath d='M190 180l12 12M202 180l-12 12'/%3E%3C/g%3E%3C/svg%3E");
  background-size: 220px 220px;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
h1, h2, h3 { font-family: var(--display); font-weight: 400; margin: 0; letter-spacing: .01em; }
button { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--blue); outline-offset: 3px; }

/* ---------- top bar ---------- */
.top { display: flex; align-items: center; gap: 10px; max-width: 980px; margin: 0 auto; padding: 14px 16px 0; min-height: 60px; }
.lang { margin-left: auto; display: flex; background: var(--white); border: 3px solid var(--ink); border-radius: 999px; padding: 3px; box-shadow: 0 3px 0 var(--ink); }
.lang button { border: 0; background: transparent; font-family: var(--display); font-size: 1rem; padding: 4px 12px; border-radius: 999px; cursor: pointer; color: var(--ink); }
.lang button.on { background: var(--ink); color: var(--white); }
.round-btn { width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; background: var(--white); border: 3px solid var(--ink); box-shadow: 0 3px 0 var(--ink); cursor: pointer; padding: 0; }
.round-btn:active { transform: translateY(3px); box-shadow: 0 0 0 var(--ink); }
.mini-logo { font-family: var(--display); font-size: 1.35rem; color: var(--ink); }
.mini-logo span { color: var(--coral); }

main { max-width: 980px; margin: 0 auto; padding: 8px 16px 110px; }
.screen { display: flex; flex-direction: column; gap: 14px; max-width: 520px; margin: 0 auto; }
#screen-home { max-width: none; }

/* ---------- logo ---------- */
.logo { position: relative; display: flex; flex-direction: column; align-items: center; line-height: .86; margin: 6px auto 0; width: max-content; }
.logo .w1, .logo .w2 { display: block; font-size: clamp(3.6rem, 17vw, 5.4rem); }
.logo .w1 { color: var(--ink); text-shadow: 0 5px 0 rgba(35,38,74,.18); }
.logo .w2 { color: var(--coral); -webkit-text-stroke: 2px var(--ink); paint-order: stroke fill; text-shadow: 0 5px 0 var(--ink); transform: rotate(-2deg); margin-top: 2px; }
.ticks { position: absolute; top: 50%; display: flex; flex-direction: column; gap: 7px; }
.ticks i { display: block; height: 7px; border-radius: 99px; background: var(--coral); border: 2px solid var(--ink); }
.ticks.l { left: -38px; transform: translateY(-50%) rotate(-8deg); align-items: flex-end; }
.ticks.r { right: -38px; transform: translateY(-50%) rotate(8deg); }
.ticks i:nth-child(1) { width: 18px; } .ticks i:nth-child(2) { width: 28px; } .ticks i:nth-child(3) { width: 18px; }
.tagline { text-align: center; margin: 10px 0 2px; color: var(--muted); font-weight: 800; font-size: 1.05rem; }

/* ---------- home layout ---------- */
.home-grid { display: grid; gap: 10px; align-items: center; }
.menu { display: flex; flex-direction: column; gap: 14px; width: 100%; max-width: 440px; margin: 0 auto; }
.mascot { order: -1; display: flex; justify-content: center; }
.mascot-svg { width: min(200px, 52vw); height: auto; }
@media (min-width: 900px) {
  .home-grid { grid-template-columns: 440px 1fr; gap: 40px; margin-top: 20px; }
  .mascot { order: 0; }
  .mascot-svg { width: min(460px, 100%); }
  .menu { margin: 0; }
}

/* ---------- panels & inputs ---------- */
.panel { background: var(--white); border: 3px solid var(--ink); border-radius: 22px; box-shadow: 0 5px 0 var(--ink); padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.panel h3 { font-size: 1.3rem; }
label, .label { font-family: var(--display); font-size: 1.05rem; margin: 0; }
input, select {
  font-family: var(--body); font-weight: 800; font-size: 1.05rem; padding: 12px 16px; width: 100%;
  border: 3px solid var(--ink); border-radius: 16px; background: #fbfaf7; color: var(--ink);
  box-shadow: inset 0 3px 0 rgba(35,38,74,.08);
}
input::placeholder { color: #a9acc0; font-weight: 700; }
.swatches, .palette { display: grid; grid-template-columns: repeat(8, 1fr); gap: 8px; }
.sw {
  aspect-ratio: 1; width: 100%; max-width: 42px; justify-self: center; border-radius: 50%; cursor: pointer; padding: 0;
  background: var(--c); border: 3px solid var(--ink); box-shadow: 0 3px 0 var(--ink); transition: transform .1s;
}
.sw.on { transform: translateY(-3px); box-shadow: 0 6px 0 var(--ink), inset 0 0 0 4px var(--white); }

/* ---------- chunky buttons ---------- */
.btn {
  position: relative; display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  font-family: var(--display); font-size: 1.25rem; letter-spacing: .02em; text-transform: uppercase;
  padding: 12px 22px; border-radius: 999px; cursor: pointer; color: var(--ink);
  background: var(--white); border: 3px solid var(--ink);
  box-shadow: inset 0 -6px 0 rgba(0,0,0,.14), 0 5px 0 var(--ink);
  transition: transform .08s, box-shadow .08s; user-select: none; -webkit-tap-highlight-color: transparent;
}
.btn::after { content: ""; position: absolute; left: 18px; right: 40%; top: 6px; height: 6px; border-radius: 99px; background: rgba(255,255,255,.5); pointer-events: none; }
.btn:active:not(:disabled) { transform: translateY(5px); box-shadow: inset 0 -3px 0 rgba(0,0,0,.14), 0 0 0 var(--ink); }
.btn:disabled { filter: grayscale(.7); opacity: .55; cursor: not-allowed; }
.btn .ico { width: 1.25em; height: 1.25em; flex: none; }
.btn.big { font-size: 1.7rem; padding: 14px 26px; }
.btn.coral { background: var(--coral); color: var(--white); text-shadow: 0 2px 0 rgba(0,0,0,.18); }
.btn.blue { background: var(--blue); color: var(--white); text-shadow: 0 2px 0 rgba(0,0,0,.18); }
.btn.green { background: var(--green); color: var(--white); text-shadow: 0 2px 0 rgba(0,0,0,.2); }
.btn.yellow { background: var(--yellow); color: var(--ink); }
.btn.white { background: var(--white); }
.btn.small-pill { font-size: 1rem; padding: 9px 18px; align-self: center; }
.btn.center { align-self: center; }
.q { width: 26px; height: 26px; border-radius: 50%; background: var(--white); border: 2.5px solid var(--ink); display: grid; place-items: center; font-size: .95rem; }
.join-row { display: grid; grid-template-columns: 1fr auto; gap: 10px; }
.code-in { text-transform: uppercase; letter-spacing: .35em; text-align: center; font-family: var(--display); font-size: 1.5rem; padding: 8px 10px; }
.code-in:placeholder-shown { letter-spacing: normal; text-transform: none; font-family: var(--body); font-size: 1.05rem; }

/* ---------- lobby ---------- */
.title { font-size: 2.1rem; text-align: center; }
.title.center { text-align: center; }
.hint { margin: 0; text-align: center; color: var(--muted); font-weight: 800; }
.roomcode {
  align-self: center; font-family: var(--display); font-size: clamp(3.4rem, 17vw, 4.8rem); letter-spacing: .14em;
  padding: 4px 22px 4px calc(22px + .14em); background: var(--yellow); border: 3px solid var(--ink); border-radius: 22px;
  box-shadow: inset 0 -8px 0 rgba(0,0,0,.12), 0 6px 0 var(--ink); transform: rotate(-2deg);
}
.plist, .scores { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.plist li, .scores li {
  display: flex; align-items: center; gap: 10px; padding: 8px 12px; border: 3px solid var(--ink); border-radius: 999px;
  background: #fbfaf7; font-weight: 900;
}
.dot { width: 26px; height: 26px; border-radius: 50%; border: 3px solid var(--ink); background: var(--c); flex: none; }
.tag { margin-left: auto; font-family: var(--display); font-size: .85rem; background: var(--yellow); border: 2.5px solid var(--ink); border-radius: 999px; padding: 1px 10px; }
.seg { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.seg button { font-family: var(--display); font-size: 1.3rem; padding: 8px 0; border-radius: 14px; border: 3px solid var(--ink); background: var(--white); box-shadow: 0 3px 0 var(--ink); cursor: pointer; }
.seg button.on { background: var(--blue); color: var(--white); }
.seg button:active { transform: translateY(3px); box-shadow: none; }

/* ---------- stage (dark game panel) ---------- */
.stage { background: var(--ink); border: 3px solid var(--ink-2); border-radius: 24px; padding: 12px; box-shadow: 0 6px 0 var(--ink-2); display: flex; flex-direction: column; gap: 10px; color: var(--white); }
.stage-bar { display: flex; align-items: center; gap: 8px; }
.pill-label { font-family: var(--display); font-size: 1rem; background: rgba(255,255,255,.12); border-radius: 999px; padding: 4px 12px; }
.pill-label.soft { background: transparent; color: #b7bad6; padding: 4px 4px; }
.timer {
  margin-left: auto; font-family: var(--display); font-size: 1.5rem; min-width: 64px; text-align: center; line-height: 1.3;
  background: var(--coral); color: var(--white); border: 3px solid var(--ink-2); border-radius: 999px; padding: 0 12px;
  box-shadow: inset 0 -4px 0 rgba(0,0,0,.15); font-variant-numeric: tabular-nums;
}
.timer.low { animation: pulse .5s infinite alternate; }
@keyframes pulse { to { transform: scale(1.12) rotate(-4deg); } }
.prompt { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 2px; }
.prompt-k { color: #b7bad6; font-size: .95rem; }
.prompt strong { font-family: var(--display); font-weight: 400; font-size: clamp(1.6rem, 7vw, 2.2rem); color: var(--yellow); line-height: 1.05; }
.canvas-wrap, .frame { border-radius: 16px; overflow: hidden; background: var(--white); border: 3px solid var(--ink-2); }
#canvas { display: block; width: 100%; height: auto; aspect-ratio: 1; touch-action: none; cursor: crosshair; }
.frame img { display: block; width: 100%; aspect-ratio: 1; object-fit: contain; background: var(--white); }
.stage-q { margin: 2px 0 0; text-align: center; font-family: var(--display); font-size: 1.35rem; color: var(--yellow); }
.stage-wait { margin: 0; padding: 40px 10px; text-align: center; font-family: var(--display); font-size: 1.3rem; color: var(--white); }

/* ---------- tools ---------- */
.tools { display: flex; flex-direction: column; gap: 10px; }
.tool-row { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.sizes { display: flex; gap: 6px; }
.tpill {
  font-family: var(--display); font-size: .85rem; text-transform: uppercase; letter-spacing: .02em; min-height: 40px;
  padding: 6px 11px; border-radius: 999px; border: 2.5px solid var(--ink); background: var(--white); color: var(--ink);
  box-shadow: 0 3px 0 var(--ink); cursor: pointer; display: inline-flex; align-items: center; justify-content: center;
}
.tpill:active { transform: translateY(3px); box-shadow: none; }
.tpill.on { background: var(--yellow); }
.tpill.size { width: 40px; padding: 0; }
.ico-pill { width: 52px; padding: 0; }
.ico-pill svg { width: 22px; height: 22px; }
.tool-row .sizes { margin-right: 6px; }
.tpill.size i { width: var(--s); height: var(--s); border-radius: 50%; background: var(--ink); display: block; }

/* ---------- guessing ---------- */
.options { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.opt {
  font-family: var(--display); font-size: 1.05rem; line-height: 1.15; padding: 12px 10px; min-height: 56px;
  border-radius: 18px; border: 3px solid var(--ink); background: var(--white); color: var(--ink); cursor: pointer;
  box-shadow: inset 0 -5px 0 rgba(0,0,0,.08), 0 4px 0 var(--ink);
}
.opt:active:not(:disabled) { transform: translateY(4px); box-shadow: none; }
.opt:hover:not(:disabled) { background: #fff6dc; }
.opt.picked { background: var(--yellow); }
.opt:last-child:nth-child(odd) { grid-column: 1 / -1; }
.opt:disabled { opacity: .6; }

/* ---------- results ---------- */
.head-row { display: flex; align-items: center; gap: 10px; }
.head-row .title { text-align: left; }
.reslist { display: grid; gap: 14px; grid-template-columns: 1fr; }
.rescard { background: var(--white); border: 3px solid var(--ink); border-radius: 22px; box-shadow: 0 5px 0 var(--ink); overflow: hidden; display: grid; grid-template-columns: 128px 1fr; }
.rescard img { display: block; width: 100%; height: 100%; aspect-ratio: 1; object-fit: contain; background: var(--white); border-right: 3px solid var(--ink); }
.rescard .body { align-content: center; }
.rescard .body { padding: 10px 14px 14px; display: grid; gap: 6px; }
.rescard .word { font-family: var(--display); font-size: 1.3rem; line-height: 1.1; color: var(--ink); }
.rescard .by { font-size: .92rem; color: var(--muted); }
.guessers { display: flex; flex-wrap: wrap; gap: 6px; }
.g { font-size: .88rem; font-weight: 900; border: 2.5px solid var(--ink); border-radius: 999px; padding: 2px 10px; background: #fbfaf7; }
.g.ok { background: #c9f3cf; }
.g.no { background: #ffd3d3; }
.scores .pts { margin-left: auto; font-family: var(--display); font-size: 1.15rem; font-variant-numeric: tabular-nums; }
.scores .delta { display: inline-block; margin-left: 8px; font-size: .85rem; color: var(--white); background: var(--green); border: 2px solid var(--ink); border-radius: 999px; padding: 0 8px; }
.scores.big li { padding: 12px 14px; font-size: 1.1rem; }
.scores.big li:first-child { background: var(--yellow); }
.medal { font-family: var(--display); width: 30px; text-align: center; }
.trophy { display: flex; justify-content: center; margin-top: 6px; }
.winner { font-family: var(--display); font-size: clamp(1.8rem, 8vw, 2.6rem); text-align: center; color: var(--coral); -webkit-text-stroke: 1.5px var(--ink); text-shadow: 0 4px 0 var(--ink); transform: rotate(-2deg); }

/* ---------- modal & toast ---------- */
.modal { position: fixed; inset: 0; z-index: 20; display: grid; place-items: center; padding: 20px; background: rgba(35,38,74,.55); }
.modal-card { width: min(460px, 100%); background: var(--white); border: 3px solid var(--ink); border-radius: 26px; box-shadow: 0 8px 0 var(--ink); padding: 22px 20px; display: flex; flex-direction: column; gap: 16px; animation: pop .18s ease-out; }
@keyframes pop { from { transform: scale(.9); opacity: 0; } }
.steps { list-style: none; margin: 0; padding: 0; display: grid; gap: 14px; }
.steps li { display: flex; gap: 12px; align-items: flex-start; line-height: 1.35; }
.step-ico { flex: none; width: 40px; height: 40px; border-radius: 50%; border: 3px solid var(--ink); display: grid; place-items: center; font-family: var(--display); font-size: 1.2rem; box-shadow: 0 3px 0 var(--ink); }
.step-ico.yellow { background: var(--yellow); } .step-ico.blue { background: var(--blue); color: #fff; } .step-ico.green { background: var(--green); color: #fff; }
.modal-card .btn { align-self: center; }
.toast {
  position: fixed; left: 50%; bottom: calc(96px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 30;
  background: var(--ink); color: var(--white); font-weight: 800; padding: 12px 18px; border-radius: 999px;
  border: 3px solid var(--white); box-shadow: 0 4px 0 rgba(0,0,0,.2); width: max-content; max-width: calc(100% - 32px); text-align: center;
}

@media (min-width: 720px) {
  .options { grid-template-columns: 1fr 1fr 1fr; }
  .opt:last-child:nth-child(odd) { grid-column: auto; }
  .rescard { grid-template-columns: 170px 1fr; }
}
@media (prefers-reduced-motion: reduce) {
  .timer.low, .modal-card { animation: none; }
  .btn, .sw { transition: none; }
}
