/* Who is Who? — bright, high-contrast and big enough to read on a projector or TV.
   Large screens: board + side panel. Phones and portrait tablets: board, with the question
   picker in a bottom sheet. */

:root {
  --bg1: #fff6e4;
  --bg2: #e4f3ff;
  --ink: #1c2233;
  --ink2: #48526a;
  --muted: #7a849a;
  --card: #ffffff;
  --line: #dfe3ee;
  --soft: #f2f3f9;
  --brand: #5b4ff5;
  --brand-d: #4337d6;
  --brand-l: #eeecff;
  --accent: #ff8a3d;
  --yes: #15a34a;
  --yes-l: #e3f7ea;
  --no: #e0383e;
  --no-l: #fde8e8;
  --warn: #f59e0b;
  --mark: #ffe36e;
  --shadow: 0 6px 20px rgba(28, 38, 70, 0.12);
  --shadow-lg: 0 20px 60px rgba(20, 28, 60, 0.28);
  --r: 18px;
  --panel-w: clamp(330px, 28vw, 500px);
  --font: "Nunito", "Segoe UI Rounded", "SF Pro Rounded", ui-rounded, "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh; min-height: 100dvh;
  font-family: var(--font);
  font-size: clamp(15px, 0.55vw + 0.75vh + 5px, 21px);
  line-height: 1.35;
  color: var(--ink);
  background:
    radial-gradient(circle at 12% 18%, rgba(255, 138, 61, 0.16) 0 120px, transparent 121px),
    radial-gradient(circle at 88% 82%, rgba(91, 79, 245, 0.12) 0 160px, transparent 161px),
    linear-gradient(135deg, var(--bg1), var(--bg2));
  background-attachment: fixed;
  overflow-x: hidden;
}
button, input { font: inherit; color: inherit; }
button { touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 3px solid var(--brand); outline-offset: 2px; }
[hidden] { display: none !important; }
mark { background: linear-gradient(transparent 52%, var(--mark) 52%); color: inherit; padding: 0 0.08em; border-radius: 2px; }
.muted { color: var(--muted); }
.tr { color: var(--muted); font-size: 0.82em; font-style: italic; }
.loading { display: grid; place-items: center; min-height: 100vh; min-height: 100dvh; font-size: 2em; font-weight: 900; color: var(--brand); }
#sprite { position: absolute; width: 0; height: 0; overflow: hidden; }

/* ---- controls ---------------------------------------------------------------------------- */

.icon { display: inline-grid; place-items: center; flex: none; }
.icon svg { width: 1.3em; height: 1.3em; display: block; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.45em;
  min-height: 46px; padding: 0.55em 1em; border-radius: 14px;
  border: 2px solid var(--line); background: #fff; color: var(--ink);
  font-weight: 800; cursor: pointer; transition: transform 0.12s, background 0.15s, box-shadow 0.15s;
}
.btn:hover:not(:disabled) { transform: translateY(-1px); box-shadow: var(--shadow); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: 0.42; cursor: not-allowed; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover:not(:disabled) { background: var(--brand-d); }
.btn.big { font-size: 1.08em; padding: 0.6em 1.3em; }
.btn.small { min-height: 36px; padding: 0.3em 0.7em; font-size: 0.86em; border-radius: 10px; }
.btn.ghost { background: transparent; }
.btn.yes { border-color: var(--yes); color: var(--yes); }
.btn.no { border-color: var(--no); color: var(--no); }
.icon-btn {
  width: 46px; height: 46px; flex: none; display: inline-grid; place-items: center;
  border: 0; border-radius: 12px; background: transparent; color: var(--ink2); cursor: pointer;
}
.icon-btn:hover { background: rgba(28, 34, 51, 0.07); color: var(--ink); }
.seg { display: inline-flex; flex-wrap: wrap; gap: 4px; padding: 4px; border-radius: 14px; background: var(--soft); }
.seg button {
  min-height: 40px; padding: 0.35em 0.9em; border: 0; border-radius: 10px; background: transparent;
  font-weight: 800; color: var(--ink2); cursor: pointer;
}
.seg button.on { background: #fff; color: var(--brand); box-shadow: 0 2px 8px rgba(28, 38, 70, 0.14); }
.seg.big button { font-size: 1.05em; padding: 0.45em 1.1em; }
.seg.wrap { display: flex; }
.seg.wrap button { flex: 1 1 auto; }
.toggle { display: flex; align-items: center; gap: 12px; padding: 10px 2px; cursor: pointer; position: relative; }
.toggle-text { flex: 1; font-weight: 700; display: flex; flex-direction: column; }
.toggle-text small { font-weight: 600; color: var(--muted); font-style: italic; }
.toggle input { position: absolute; opacity: 0; pointer-events: none; }
.toggle-ui { width: 52px; height: 30px; border-radius: 99px; background: #cfd4e2; position: relative; transition: background 0.2s; flex: none; }
.toggle-ui::after { content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25); transition: transform 0.2s; }
.toggle input:checked + .toggle-ui { background: var(--yes); }
.toggle input:checked + .toggle-ui::after { transform: translateX(22px); }
.toggle input:focus-visible + .toggle-ui { outline: 3px solid var(--brand); outline-offset: 2px; }
input[type="text"] { width: 100%; min-height: 46px; padding: 0.4em 0.8em; border: 2px solid var(--line); border-radius: 12px; background: #fff; }
input[type="text"]:focus { border-color: var(--brand); outline: none; }
input[type="range"] { width: 100%; accent-color: var(--brand); }

/* ---- home ---------------------------------------------------------------------------------- */

.home {
  min-height: 100vh; min-height: 100dvh; max-width: 1240px; margin: 0 auto; display: flex; flex-direction: column;
  gap: clamp(10px, 2.2vh, 26px);
  padding: max(12px, env(safe-area-inset-top)) clamp(16px, 3vw, 40px) max(16px, env(safe-area-inset-bottom));
}
.home-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.home-tools { display: flex; gap: 2px; }
.logo { display: flex; align-items: center; gap: 0.35em; font-size: clamp(26px, 3.6vw, 60px); font-weight: 900; letter-spacing: -0.02em; white-space: nowrap; }
.logo em { font-style: normal; color: var(--accent); }
.logo-mark { width: 1.25em; height: 1.25em; border-radius: 0.32em; display: grid; place-items: center; background: var(--brand); color: #fff; box-shadow: var(--shadow); transform: rotate(-8deg); }
.logo-mark svg { width: 0.85em; height: 0.85em; }
.hero { display: flex; flex-direction: column; align-items: center; gap: clamp(8px, 1.6vh, 18px); }
.parade { display: flex; justify-content: center; gap: clamp(4px, 1vw, 14px); width: 100%; }
.parade-face {
  width: clamp(54px, 8.6vw, 128px); aspect-ratio: 200 / 220; border-radius: 22%; overflow: hidden;
  background: #fff; box-shadow: var(--shadow); animation: bob 3.2s ease-in-out infinite;
  animation-delay: calc(var(--i) * -0.37s);
}
.parade-face:nth-child(odd) { transform: rotate(-4deg); }
.parade-face:nth-child(even) { transform: rotate(4deg); }
.parade-face svg, .face { display: block; width: 100%; height: auto; }
@keyframes bob { 0%, 100% { translate: 0 0; } 50% { translate: 0 -8px; } }
.tagline { margin: 0; text-align: center; font-size: clamp(18px, 1.9vw, 30px); font-weight: 800; color: var(--ink2); }
.langs { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 10px 30px; }
.lang-pick { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: center; }
.lang-label { font-weight: 800; color: var(--ink2); }
.modes { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: clamp(10px, 1.4vw, 20px); }
.mode {
  display: flex; flex-direction: column; gap: 10px; padding: clamp(14px, 1.6vw, 22px); text-align: left;
  border: 0; border-top: 7px solid var(--mc); border-radius: 22px; background: #fff; box-shadow: var(--shadow);
  cursor: pointer; transition: transform 0.15s, box-shadow 0.15s;
}
.mode:hover { transform: translateY(-4px); box-shadow: var(--shadow-lg); }
.mode-icon { width: 58px; height: 58px; border-radius: 16px; display: grid; place-items: center; color: var(--mc); background: color-mix(in srgb, var(--mc) 14%, #fff); }
.mode-icon .icon svg { width: 34px; height: 34px; }
.mode-icon .robot-mini svg { width: 46px; height: 46px; }
.mode-text { display: flex; flex-direction: column; gap: 4px; }
.mode-text b { font-size: 1.25em; }
.mode-text small { font-size: 0.9em; color: var(--ink2); font-weight: 600; }
.mode-go { margin-top: auto; align-self: flex-start; display: inline-flex; align-items: center; gap: 4px; padding: 0.35em 0.6em 0.35em 1em; border-radius: 99px; background: var(--mc); color: #fff; font-weight: 800; }
.home-foot { display: flex; justify-content: center; margin-top: auto; }
.example { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 6px 14px; padding: 10px 18px; border-radius: 16px; background: rgba(255, 255, 255, 0.75); }
.ex-q { font-weight: 800; }
.ex-a b { color: var(--no); }
.ex-a.yes b { color: var(--yes); }

/* ---- dialogs ---------------------------------------------------------------------------------- */

.modal-wrap {
  position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 16px;
  background: rgba(18, 22, 40, 0.45); animation: fade 0.18s ease-out;
}
.modal-wrap.out { animation: fade 0.18s ease-in reverse forwards; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.modal {
  position: relative; width: min(640px, 100%); max-height: calc(100vh - 32px); max-height: calc(100dvh - 32px); overflow-y: auto;
  padding: clamp(18px, 2.4vw, 30px); border-radius: 24px; background: #fff; box-shadow: var(--shadow-lg);
  animation: rise 0.22s cubic-bezier(0.2, 0.9, 0.3, 1.2);
}
@keyframes rise { from { transform: translateY(18px) scale(0.97); opacity: 0; } to { transform: none; opacity: 1; } }
.modal-x { position: absolute; top: 10px; right: 10px; }
.modal-title { margin: 0 44px 14px 0; font-size: 1.45em; line-height: 1.15; }
.modal h3 { margin: 18px 0 8px; font-size: 0.95em; color: var(--ink2); text-transform: uppercase; letter-spacing: 0.04em; }
.modal-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 10px; margin-top: 20px; }
.toast-wrap, #toasts {
  position: fixed; left: 50%; bottom: max(18px, env(safe-area-inset-bottom)); transform: translateX(-50%);
  z-index: 200; display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; width: min(94vw, 640px);
}
.toast {
  padding: 12px 18px; border-radius: 16px; background: var(--ink); color: #fff; font-weight: 700; text-align: center;
  box-shadow: var(--shadow-lg); animation: rise 0.2s ease-out; pointer-events: auto;
}
.toast.warn { background: #fff7e0; color: #6b4200; border: 2px solid var(--warn); }
.toast.warn mark { background: linear-gradient(transparent 52%, #ffd25a 52%); }
.toast.good { background: var(--yes); }
.toast.bad { background: var(--no); }
.toast.out { opacity: 0; transform: translateY(8px); transition: 0.3s; }
#confetti { position: fixed; inset: 0; width: 100vw; height: 100vh; z-index: 150; pointer-events: none; display: none; }
#confetti.on { display: block; }

.setup .levels { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.level { display: flex; flex-direction: column; gap: 4px; padding: 12px; border-radius: 16px; border: 2px solid var(--line); background: #fff; text-align: left; cursor: pointer; }
.level b { font-size: 1.1em; }
.level small { color: var(--ink2); font-weight: 600; font-size: 0.82em; }
.level.on { border-color: var(--brand); background: var(--brand-l); box-shadow: 0 0 0 3px rgba(91, 79, 245, 0.15); }
.assist { display: flex; flex-direction: column; margin-top: 8px; border-top: 1px solid var(--line); }
.assist .toggle { border-bottom: 1px solid var(--line); }
.names { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; margin-top: 10px; }
.more { margin-top: 16px; }
.more summary { cursor: pointer; font-weight: 800; color: var(--ink2); }
.code-input { max-width: 200px; letter-spacing: 0.2em; font-weight: 800; }
.voice-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.help .rules { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.help .rules li { display: flex; gap: 12px; align-items: flex-start; font-weight: 700; }
.rule-em { font-size: 1.5em; line-height: 1; }
.examples { display: grid; gap: 8px; margin-top: 16px; }
.ex { display: flex; flex-direction: column; padding: 10px 14px; border-radius: 14px; background: var(--soft); }
.tips { margin: 0; padding-left: 1.2em; display: grid; gap: 6px; color: var(--ink2); }
.score-table { width: 100%; border-collapse: collapse; }
.score-table td { padding: 6px 8px; border-bottom: 1px solid var(--line); }

/* ---- the play screen --------------------------------------------------------------------- */

.play {
  height: 100vh; height: 100dvh; display: grid;
  grid-template-columns: minmax(0, 1fr) var(--panel-w);
  grid-template-rows: auto minmax(0, 1fr);
  grid-template-areas: "bar bar" "board panel";
}
.bar {
  grid-area: bar; display: flex; align-items: center; gap: 10px;
  padding: max(6px, env(safe-area-inset-top)) 12px 6px; background: rgba(255, 255, 255, 0.82);
  border-bottom: 1px solid var(--line); backdrop-filter: blur(8px); min-width: 0;
}
.bar-title { display: flex; align-items: baseline; gap: 10px; min-width: 0; overflow: hidden; white-space: nowrap; }
.bar-title b { font-size: 1.1em; overflow: hidden; text-overflow: ellipsis; }
.code { border: 0; background: var(--soft); border-radius: 8px; padding: 2px 8px; font-size: 0.8em; font-weight: 800; color: var(--muted); cursor: pointer; }
.bar-stats { display: flex; gap: 8px; margin-left: auto; }
.stat { display: inline-flex; align-items: center; gap: 5px; padding: 5px 12px; border-radius: 99px; background: var(--soft); font-weight: 800; font-variant-numeric: tabular-nums; }
.stat .icon { color: var(--brand); }
.bar-tools { display: flex; }

.board-area { grid-area: board; position: relative; min-height: 0; overflow: auto; padding: clamp(8px, 1.4vw, 20px); display: grid; place-items: center; }
.board { display: grid; grid-template-columns: repeat(var(--cols, 6), var(--cw, 120px)); gap: var(--gap, 10px); justify-content: center; align-content: center; perspective: 1400px; }
.card { position: relative; width: var(--cw, 120px); aspect-ratio: 200 / 262; padding: 0; border: 0; background: none; cursor: pointer; border-radius: calc(var(--cw, 120px) * 0.09); }
.card-inner { position: absolute; inset: 0; transform-style: preserve-3d; transition: transform 0.5s cubic-bezier(0.25, 0.8, 0.25, 1.15); }
.card.down .card-inner { transform: rotateY(180deg); }
.card-face {
  position: absolute; inset: 0; display: flex; flex-direction: column; overflow: hidden;
  border-radius: calc(var(--cw, 120px) * 0.09); background: #fff; backface-visibility: hidden; -webkit-backface-visibility: hidden;
  box-shadow: 0 3px 10px rgba(28, 38, 70, 0.16), inset 0 0 0 2px rgba(28, 38, 70, 0.06);
}
.card-face .face { flex: none; }
.name { flex: 1; display: grid; place-items: center; padding: 0 4px; font-weight: 900; font-size: max(11px, calc(var(--cw, 120px) * 0.125)); line-height: 1; letter-spacing: -0.01em; white-space: nowrap; overflow: hidden; }
.card-face.back { transform: rotateY(180deg); background: repeating-linear-gradient(-45deg, #6a5ff7 0 12px, #5b4ff5 12px 24px); }
.card-face.back .ghost { opacity: 0.2; filter: grayscale(1) brightness(1.6); }
.card-face.back .name { color: #fff; opacity: 0.85; }
.card:hover:not(.down) .card-face.front { box-shadow: 0 8px 22px rgba(28, 38, 70, 0.24), inset 0 0 0 2px var(--brand); }
.zoom-btn { position: absolute; top: 4%; right: 5%; width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; background: rgba(255, 255, 255, 0.9); color: var(--ink2); opacity: 0; transition: opacity 0.15s; box-shadow: var(--shadow); }
.zoom-btn .icon svg { width: 18px; height: 18px; }
@media (hover: hover) { .card:hover:not(.down) .zoom-btn { opacity: 1; } }
.card.down .zoom-btn { display: none; }
.board.guessing .card:not(.down) .card-face.front { box-shadow: 0 0 0 4px var(--accent), 0 8px 22px rgba(255, 138, 61, 0.35); animation: glow 1.1s ease-in-out infinite; }
.board.guessing .card:not(.down) { cursor: crosshair; }
@keyframes glow { 50% { box-shadow: 0 0 0 7px rgba(255, 138, 61, 0.55), 0 8px 22px rgba(255, 138, 61, 0.35); } }
.card.shake { animation: shake 0.45s; }
@keyframes shake { 20% { translate: -6px 0; } 40% { translate: 6px 0; } 60% { translate: -4px 0; } 80% { translate: 3px 0; } }
.card.found { z-index: 2; animation: found 0.8s ease-out; }
.card.found .card-face.front { box-shadow: 0 0 0 6px #ffd23f, 0 0 40px 8px rgba(255, 210, 63, 0.8); }
@keyframes found { 40% { transform: scale(1.18) rotate(-3deg); } 100% { transform: scale(1.08); } }
.card.chosen .card-face.front { box-shadow: 0 0 0 6px var(--brand), 0 12px 30px rgba(91, 79, 245, 0.4); }
.card.chosen { transform: scale(1.05); z-index: 2; }

/* the answer, big over the board */
.splash { position: absolute; z-index: 5; left: 50%; top: clamp(8px, 3vh, 36px); width: min(94%, 980px); transform: translate(-50%, -16px); opacity: 0; pointer-events: none; transition: opacity 0.25s, transform 0.25s; }
.splash.show { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; cursor: pointer; }
.splash-card { padding: clamp(12px, 1.6vw, 22px) clamp(16px, 2.2vw, 32px); border-radius: 24px; background: #fff; text-align: center; box-shadow: var(--shadow-lg); border: 4px solid var(--brand); }
.splash-card.banner { border-color: var(--accent); }
.splash-q { font-size: clamp(20px, 2.3vw, 44px); font-weight: 900; line-height: 1.2; }
.splash-a { margin-top: 0.4em; display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 0.3em 0.6em; font-size: clamp(18px, 2vw, 36px); font-weight: 800; transition: opacity 0.3s, transform 0.3s cubic-bezier(0.2, 0.9, 0.3, 1.4); }
.splash-a.pending { opacity: 0; transform: scale(0.7); }
.splash-a .big { padding: 0.05em 0.6em; border-radius: 99px; color: #fff; background: var(--yes); }
.splash-a.no .big { background: var(--no); }
.splash-a .say small { color: var(--muted); }
.splash .tr { margin-top: 6px; font-size: clamp(13px, 1.2vw, 20px); }

/* the side panel */
.panel { grid-area: panel; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; padding: 12px 12px max(12px, env(safe-area-inset-bottom)); background: rgba(255, 255, 255, 0.6); border-left: 1px solid var(--line); }
.panel > section { flex: none; padding: 12px 14px; border-radius: var(--r); background: #fff; box-shadow: 0 2px 10px rgba(28, 38, 70, 0.07); }
.panel > .picker { flex: 1 1 auto; min-height: 230px; overflow: hidden; }
.status-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.turn-chip { padding: 4px 12px; border-radius: 99px; background: var(--pc, var(--brand)); color: #fff; font-weight: 900; white-space: nowrap; }
.hint { margin: 0; font-weight: 700; color: var(--ink2); }
.last { margin-top: 10px; padding-top: 10px; border-top: 1px dashed var(--line); }
.last-q { font-weight: 800; }
.last-a b { color: #fff; background: var(--yes); padding: 0 8px; border-radius: 99px; margin-right: 4px; }
.last-a.no b { background: var(--no); }
.players { display: flex; flex-direction: column; gap: 6px; }
.pchip { display: flex; align-items: center; gap: 8px; padding: 6px 10px; border-radius: 14px; background: var(--soft); border: 2px solid transparent; }
.pchip.now { border-color: var(--pc); background: color-mix(in srgb, var(--pc) 10%, #fff); }
.pdot { width: 32px; height: 32px; border-radius: 50%; flex: none; display: grid; place-items: center; background: var(--pc); color: #fff; font-weight: 900; }
.pname { font-weight: 800; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pmeta, .pscore { font-size: 0.85em; font-weight: 700; color: var(--ink2); white-space: nowrap; }
.cpu-info { display: grid; grid-template-columns: auto 1fr; gap: 12px; align-items: start; }
.mine { display: flex; flex-direction: column; align-items: center; gap: 4px; border: 0; background: none; cursor: pointer; padding: 0; }
.mine-face { width: 78px; border-radius: 14px; overflow: hidden; box-shadow: 0 0 0 3px var(--accent); }
.mine span:last-child { display: flex; flex-direction: column; align-items: center; line-height: 1.1; }
.mine small, .cpu-title small { color: var(--muted); font-weight: 700; font-size: 0.75em; }
.cpu-title { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.cpu-title > span:last-child { display: flex; flex-direction: column; line-height: 1.1; }
.robot-mini svg { width: 34px; height: 34px; display: block; }
.mini { display: grid; grid-template-columns: repeat(auto-fill, minmax(26px, 1fr)); gap: 3px; }
.mini-card { border-radius: 5px; overflow: hidden; background: #fff; box-shadow: inset 0 0 0 1px var(--line); transition: opacity 0.4s, filter 0.4s; }
.mini-card.down { opacity: 0.25; filter: grayscale(1); }
.picker { display: flex; flex-direction: column; gap: 10px; min-height: 0; }
.picker .chips { flex: 1 1 auto; min-height: 50px; overflow-y: auto; padding: 2px; margin: -2px; }
.picker .preview { flex: none; }
.sheet-handle { display: none; }
.tabs { display: flex; flex-wrap: wrap; gap: 6px; flex: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab { flex: none; display: inline-flex; align-items: center; gap: 5px; min-height: 40px; padding: 0.3em 0.8em; border: 0; border-radius: 12px; background: var(--soft); color: var(--ink2); font-weight: 800; cursor: pointer; }
.tab.on { background: var(--ink); color: #fff; }
.tab-emoji { font-size: 1.05em; }
.chips { display: flex; flex-wrap: wrap; gap: 7px; align-content: flex-start; }
.chip { display: inline-flex; align-items: center; gap: 6px; min-height: 40px; padding: 0.3em 0.85em; border: 2px solid var(--line); border-radius: 99px; background: #fff; font-weight: 750; cursor: pointer; transition: transform 0.1s; }
.chip:hover:not(:disabled) { border-color: var(--brand); }
.chip.on { border-color: var(--brand); background: var(--brand-l); box-shadow: 0 0 0 3px rgba(91, 79, 245, 0.18); }
.chip:disabled { cursor: default; }
.chip.done { opacity: 0.55; }
.chip:disabled:not(.done) { opacity: 0.55; }
.chip .mark { font-weight: 900; }
.chip.done.yes .mark { color: var(--yes); }
.chip.done.no .mark { color: var(--no); }
.sw { width: 18px; height: 18px; border-radius: 50%; flex: none; box-shadow: inset 0 0 0 2px rgba(0, 0, 0, 0.18); }
.em { font-size: 1.05em; line-height: 1; }
.preview { padding: 12px; border-radius: 14px; background: var(--brand-l); }
.preview-empty { margin: 0; color: var(--muted); font-weight: 700; text-align: center; }
.preview-q { font-size: 1.25em; font-weight: 900; line-height: 1.2; }
.preview-row { display: flex; justify-content: flex-end; align-items: center; gap: 8px; margin-top: 8px; }
.preview-row .ask { flex: 1; font-size: 1.1em; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; background: none !important; box-shadow: none !important; padding: 0 !important; }
.actions .btn { flex: 1 1 auto; }
.btn.guess { border-color: var(--accent); color: #c2560f; }
.btn.guess.on { background: var(--accent); color: #fff; }
.btn.auto { border-color: var(--yes); color: var(--yes); }
.mobilebar { display: none; }
.sheet-backdrop { display: none; }
.cluebox { display: flex; flex-direction: column; gap: 8px; }
.clue-head { display: flex; justify-content: space-between; align-items: center; }
.clue-text { font-size: 1.35em; font-weight: 900; line-height: 1.2; }
.clue-text.hidden { filter: blur(9px); user-select: none; }
.clue-list { margin: 4px 0 0; padding-left: 1.4em; color: var(--ink2); font-weight: 700; display: grid; gap: 4px; }
.clue-list li.hidden { filter: blur(6px); }

/* the pick screen */
.pickwrap { height: 100vh; height: 100dvh; display: grid; grid-template-rows: auto minmax(0, 1fr) auto; }
.pickwrap .board-area { grid-area: auto; }
.pickhead { display: flex; align-items: center; gap: 10px; padding: max(8px, env(safe-area-inset-top)) 14px 8px; background: rgba(255, 255, 255, 0.82); border-bottom: 1px solid var(--line); }
.pickhead h1 { margin: 0; font-size: 1.3em; }
.pickhead p { margin: 2px 0 0; color: var(--ink2); font-weight: 700; }
.pickfoot { display: flex; justify-content: center; gap: 10px; padding: 10px 14px max(10px, env(safe-area-inset-bottom)); background: rgba(255, 255, 255, 0.82); border-top: 1px solid var(--line); }

/* curtains, the computer's turn, results, zoom */
.modal-wrap:has(> .curtain) { background: linear-gradient(135deg, #4b40e0, #8b5cf6 55%, #ff8a3d); }
.curtain .curtain-body { text-align: center; }
.curtain-dot { width: 96px; height: 96px; margin: 0 auto 10px; border-radius: 50%; display: grid; place-items: center; background: var(--pc); color: #fff; font-size: 48px; font-weight: 900; }
.curtain h2 { margin: 0; font-size: 1.6em; }
.curtain .modal-actions { justify-content: center; }
.modal.cpu-turn { width: min(880px, 100%); }
.cpu-body { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; align-items: start; }
.cpu-side { display: flex; flex-direction: column; align-items: center; gap: 12px; }
.robot-big svg { width: 110px; height: 110px; display: block; animation: bob 2.4s ease-in-out infinite; }
.bubble { position: relative; padding: 16px 20px; border-radius: 22px; background: var(--brand-l); font-size: 1.35em; font-weight: 900; text-align: center; line-height: 1.2; }
.bubble::before { content: ""; position: absolute; top: -12px; left: 50%; translate: -50% 0; border: 12px solid transparent; border-top: 0; border-bottom-color: var(--brand-l); }
.bubble .tr { font-size: 0.6em; margin-top: 6px; }
.dots { display: inline-flex; gap: 6px; }
.dots i { width: 12px; height: 12px; border-radius: 50%; background: var(--brand); animation: dot 1s infinite; }
.dots i:nth-child(2) { animation-delay: 0.15s; }
.dots i:nth-child(3) { animation-delay: 0.3s; }
@keyframes dot { 50% { transform: translateY(-6px); opacity: 0.5; } }
.cpu-you { display: flex; flex-direction: column; align-items: center; gap: 10px; }
.mine-big { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.mine-big .big-face { width: 150px; border-radius: 18px; overflow: hidden; box-shadow: 0 0 0 4px var(--accent); }
.mine-big.pulse .big-face { animation: pulse 0.8s 2; }
@keyframes pulse { 50% { box-shadow: 0 0 0 10px rgba(255, 138, 61, 0.6); transform: scale(1.04); } }
.cpu-ask { margin: 0; font-weight: 800; color: var(--ink2); }
.yn { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; width: 100%; }
.yn .btn { flex-direction: column; gap: 2px; }
.yn .btn b { font-size: 1.3em; }
.yn .btn small { font-weight: 700; font-size: 0.78em; color: var(--ink2); }
.yn .btn.picked.yes { background: var(--yes-l); }
.yn .btn.picked.no { background: var(--no-l); }
.cpu-feedback { text-align: center; font-weight: 800; min-height: 1.4em; }
.cpu-feedback .good { color: var(--yes); }
.cpu-feedback .bad { color: var(--no); }
.cpu-flipped { margin-top: 6px; color: var(--brand); }
.confirm-body { display: flex; flex-direction: column; align-items: center; gap: 10px; }
.big-face { width: min(260px, 60vw); border-radius: 22px; overflow: hidden; box-shadow: var(--shadow); }
.confirm-q { margin: 0; font-size: 1.6em; font-weight: 900; }
.modal.confirm .modal-actions, .modal.zoom .modal-actions { justify-content: center; }
.modal.zoom { text-align: center; width: min(460px, 100%); }
.modal.zoom .modal-title { margin-right: 0; font-size: 1.8em; }
.modal.zoom .big-face { margin: 0 auto; width: min(300px, 70vw); }
.zoom-desc { margin-top: 12px; text-align: left; font-weight: 700; }
.modal.result { width: min(820px, 100%); }
.result .modal-title { text-align: center; margin: 0 0 14px; font-size: 1.8em; }
.result-body { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 14px 22px; align-items: start; }
.result-body > .reveal { grid-row: span 3; flex-direction: column; }
.result-body.multi { grid-template-columns: minmax(0, 1fr); }
.result-body.multi > .reveal { grid-row: auto; flex-direction: row; }
.reveal { display: flex; justify-content: center; flex-wrap: wrap; gap: 14px; }
.reveal-card { display: flex; flex-direction: column; align-items: center; gap: 2px; border: 0; background: none; cursor: pointer; }
.reveal-card .big-face { width: clamp(110px, 16vw, 180px); }
.reveal-card small { color: var(--muted); font-weight: 800; }
.reveal-card b { font-size: 1.2em; }
.describe { padding: 12px 16px; border-radius: 16px; background: var(--soft); }
.describe p { margin: 4px 0 0; font-weight: 700; }
.describe-head { display: flex; align-items: center; justify-content: space-between; }
.scorebox { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 10px 24px; }
.stars { font-size: 2.6em; letter-spacing: 0.08em; color: #d8dbe6; }
.stars .on { color: #ffc21a; text-shadow: 0 2px 0 #e0a000; }
.breakdown { border-collapse: collapse; min-width: 240px; }
.breakdown td { padding: 4px 10px; border-bottom: 1px solid var(--line); }
.breakdown td:last-child { text-align: right; font-weight: 800; font-variant-numeric: tabular-nums; }
.breakdown .total td { border-bottom: 0; font-size: 1.25em; font-weight: 900; color: var(--brand); }
.newbest { padding: 6px 14px; border-radius: 99px; background: #fff2c2; color: #8a5a00; font-weight: 900; }
.tally { display: grid; gap: 6px; }
.tally h3 { margin: 0; }
.modal.history { width: min(720px, 100%); }
.hist { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.hist li { position: relative; padding: 10px 52px 10px 14px; border-radius: 14px; background: var(--soft); border-left: 6px solid var(--yes); }
.hist li.no { border-left-color: var(--no); }
.hist .who { display: inline-block; margin-bottom: 2px; padding: 0 8px; border-radius: 99px; background: var(--pc); color: #fff; font-size: 0.8em; font-weight: 800; }
.hist .hq { font-weight: 800; }
.hist .ha b { color: var(--yes); }
.hist li.no .ha b { color: var(--no); }
.hist .icon-btn { position: absolute; right: 6px; top: 50%; translate: 0 -50%; }

/* ---- phones and portrait tablets ------------------------------------------------------------ */

@media (max-width: 760px), (orientation: portrait) and (max-width: 1100px) {
  .hide-compact { display: none !important; }
  .play {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto auto auto auto auto minmax(0, 1fr) auto;
    grid-template-areas: "bar" "status" "players" "cpuinfo" "extra" "board" "mobile";
  }
  .bar { gap: 4px; padding-left: 4px; padding-right: 4px; }
  .bar-title .code { display: none; }
  .bar-title b { font-size: 0.95em; }
  .stat { padding: 4px 8px; font-size: 0.9em; }
  .panel { display: contents; }
  .panel > section { margin: 6px 8px 0; padding: 8px 12px; }
  .status { grid-area: status; }
  .status .hint { font-size: 0.9em; }
  .last { margin-top: 6px; padding-top: 6px; font-size: 0.92em; }
  .players { grid-area: players; flex-direction: row; overflow-x: auto; padding: 6px !important; }
  .mode-cpu .players { display: none; }
  .players .pchip { flex: none; }
  .cpu-info { grid-area: cpuinfo; grid-template-columns: auto 1fr; }
  .cpu-info .mini { display: none; }
  .mine { flex-direction: row; gap: 8px; }
  .mine-face { width: 40px; border-radius: 8px; }
  .mine span:last-child { align-items: flex-start; }
  .cluebox { grid-area: extra; }
  .clue-text { font-size: 1.15em; }
  .clue-list { display: none; }
  .tabs { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
  .actions { display: none !important; }
  .board-area { grid-area: board; padding: 8px; place-items: start center; }
  .board { align-content: start; }
  .picker {
    position: fixed; z-index: 60; left: 0; right: 0; bottom: 0; margin: 0 !important; max-height: 82vh; max-height: 82dvh; overflow-y: auto;
    padding: 6px 14px max(14px, env(safe-area-inset-bottom)) !important; border-radius: 24px 24px 0 0 !important;
    box-shadow: 0 -10px 40px rgba(20, 28, 60, 0.25) !important; transform: translateY(105%); transition: transform 0.28s cubic-bezier(0.2, 0.8, 0.2, 1);
  }
  .panel.open .picker { transform: none; }
  .sheet-handle { display: block; align-self: center; width: 60px; height: 22px; flex: none; border: 0; background: none; cursor: pointer; position: relative; }
  .sheet-handle::after { content: ""; position: absolute; left: 10px; right: 10px; top: 8px; height: 6px; border-radius: 99px; background: #cfd4e2; }
  .sheet-backdrop { display: block; position: fixed; inset: 0; z-index: 55; background: rgba(18, 22, 40, 0.35); opacity: 0; pointer-events: none; transition: opacity 0.25s; }
  .sheet-backdrop.show { opacity: 1; pointer-events: auto; }
  .preview { position: sticky; bottom: 0; box-shadow: 0 -6px 16px rgba(255, 255, 255, 0.9); }
  .picker .chips { overflow: visible; flex: none; }
  .result-body { grid-template-columns: minmax(0, 1fr); }
  .result-body > .reveal { grid-row: auto; flex-direction: row; }
  .mobilebar {
    grid-area: mobile; display: flex; gap: 8px; padding: 8px 8px max(8px, env(safe-area-inset-bottom));
    background: rgba(255, 255, 255, 0.92); border-top: 1px solid var(--line);
  }
  .mobilebar .btn { flex: 1 1 0; min-width: 0; padding-left: 0.5em; padding-right: 0.5em; white-space: nowrap; overflow: hidden; }
  .mobilebar .btn > span:last-child { overflow: hidden; text-overflow: ellipsis; }
  .splash { top: 6px; width: calc(100% - 16px); }
  .splash-card { border-width: 3px; border-radius: 18px; }
  .setup .levels { grid-template-columns: 1fr; }
  .cpu-body { grid-template-columns: 1fr; gap: 12px; }
  .robot-big svg { width: 70px; height: 70px; }
  .cpu-side { flex-direction: row; align-items: center; }
  .bubble { font-size: 1.1em; flex: 1; }
  .bubble::before { top: 50%; left: -12px; translate: 0 -50%; border: 12px solid transparent; border-left: 0; border-right-color: var(--brand-l); }
  .mine-big .big-face { width: 110px; }
  .modal-wrap { padding: 0; place-items: end center; }
  .modal { width: 100% !important; max-height: 92vh; max-height: 92dvh; border-radius: 24px 24px 0 0; padding-bottom: max(18px, env(safe-area-inset-bottom)); }
  .modal-actions { justify-content: stretch; }
  .modal-actions .btn { flex: 1 1 auto; }
  #toasts { bottom: calc(76px + env(safe-area-inset-bottom)); }
  .pickfoot .btn { flex: 1 1 0; }
}

@media (max-width: 420px) {
  .bar-stats .stat:first-child:not(.clock) { display: none; }
  .langs { gap: 8px; }
  .modes { grid-template-columns: 1fr; }
  .mode { flex-direction: row; align-items: center; flex-wrap: wrap; }
  .mode-text { flex: 1; min-width: 0; }
  .mode-go { margin-top: 0; }
}

/* short landscape screens (phones turned sideways): keep the panel, make it narrower */
@media (max-height: 520px) and (orientation: landscape) {
  :root { --panel-w: clamp(260px, 36vw, 380px); }
  body { font-size: 14px; }
  .hero .parade { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
