/* ==========================================================================
   HEX CHAIN — Host screen. Laid out to fit a small laptop (1366 × 768)
   with no scrolling during play.
   ========================================================================== */

.host-page {
  --panel: #0f1630;
  --panel-2: #141d3d;
  --line: rgba(150, 170, 255, 0.14);
  --line-2: rgba(150, 170, 255, 0.26);
  --muted: #8d97c0;
  background: linear-gradient(160deg, #0b1230 0%, #070b1c 60%);
  min-height: 100vh;
  font-size: 14px;
  display: flex;
  flex-direction: column;
}
.muted { color: var(--muted); }

/* --------------------------------- Buttons --------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45em;
  padding: 0.55em 0.95em;
  border: 1px solid var(--line-2);
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--ink);
  font: 700 0.92rem/1.1 var(--font-ui);
  text-decoration: none;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.08s;
  white-space: nowrap;
}
.btn:hover:not(:disabled) { border-color: rgba(255, 255, 255, 0.45); background: rgba(255, 255, 255, 0.12); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn:focus-visible, .team-btn:focus-visible, .menu button:focus-visible, .seg-opt input:focus-visible + span, .swatches input:focus-visible + span {
  outline: 2px solid #8ccaff;
  outline-offset: 2px;
}
.btn-primary { background: linear-gradient(180deg, #3d8bff, #1858d6); border-color: #5ea0ff; }
.btn-primary:hover:not(:disabled) { background: linear-gradient(180deg, #5299ff, #1e64ea); }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-sm { padding: 0.42em 0.75em; font-size: 0.82rem; }
.btn-lg { padding: 0.8em 1.6em; font-size: 1.1rem; }
.btn-icon-sm { width: 36px; height: 36px; padding: 0; font-size: 1.05rem; border-radius: 9px; flex: none; }
.btn-t1 { background: var(--t1); border-color: var(--t1-hi); color: var(--t1-ink); }
.btn-t2 { background: var(--t2); border-color: var(--t2-hi); color: var(--t2-ink); }
.btn-t1:hover:not(:disabled), .btn-t2:hover:not(:disabled) { filter: brightness(1.1); }
.btn-t1:hover:not(:disabled) { background: var(--t1); }
.btn-t2:hover:not(:disabled) { background: var(--t2); }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; }

/* ---------------------------------- Top bar --------------------------------- */
.topbar {
  flex: none;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 8px 16px;
  background: #0d1430;
  border-bottom: 1px solid var(--line-2);
}
.brand { display: flex; align-items: center; gap: 10px; }
.logo-hex {
  width: 32px;
  aspect-ratio: 1.1547;
  clip-path: polygon(25% 0, 75% 0, 100% 50%, 75% 100%, 25% 100%, 0 50%);
  background: linear-gradient(135deg, #1e7bff 0 50%, var(--accent) 50% 100%);
}
.brand-title { font-family: var(--font-display); font-size: 1.5rem; letter-spacing: 0.08em; line-height: 1; color: var(--accent); }
.brand-sub { font-size: 0.72rem; color: var(--muted); font-weight: 600; }
.brand-sub .private { color: #ff9c9c; }
.topbar-mid { display: flex; gap: 8px; flex: 1; justify-content: center; }
.topbar-actions { display: flex; gap: 8px; align-items: center; }

.pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 12px;
  border-radius: 99px;
  border: 1px solid var(--line-2);
  background: rgba(255, 255, 255, 0.04);
  font-weight: 700;
  font-size: 0.78rem;
}
.conn .dot { width: 9px; height: 9px; border-radius: 50%; background: #8a8fa8; }
.conn.on { border-color: rgba(34, 197, 94, 0.6); }
.conn.on .dot { background: var(--good); }

/* Pop-up menus (⋯ and ?) */
.pop-wrap { position: relative; }
.pop {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  z-index: 30;
  min-width: 220px;
  padding: 6px;
  border-radius: 12px;
  border: 1px solid var(--line-2);
  background: #18224a;
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.5);
}
.menu button {
  display: block;
  width: 100%;
  padding: 9px 12px;
  border: 0;
  border-radius: 8px;
  background: none;
  color: var(--ink);
  font: 600 0.92rem var(--font-ui);
  text-align: left;
  cursor: pointer;
}
.menu button:hover { background: rgba(255, 255, 255, 0.1); }
.menu hr { border: 0; border-top: 1px solid var(--line); margin: 6px 0; }
.keys-pop { width: 320px; padding: 12px 14px; }
.keys-pop h4 { margin: 0 0 8px; font-size: 0.75rem; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); }
.keys-pop dl { display: grid; grid-template-columns: auto 1fr; gap: 6px 12px; margin: 0; font-size: 0.85rem; align-items: center; }
.keys-pop dt { white-space: nowrap; }
.keys-pop dd { margin: 0; color: var(--ink-dim); }

/* "Board isn't open" notice */
.notice {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 8px 16px;
  background: #4a3505;
  border-bottom: 1px solid #f59e0b;
  color: #fff2cf;
  font-size: 0.88rem;
  line-height: 1.35;
}
.notice a { color: #ffe08a; }

/* --------------------------------- Game layout --------------------------------- */
.console {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(380px, 1fr);
  gap: 12px;
  padding: 12px 16px;
  height: calc(100vh - 54px);
}
.panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  overflow: hidden;
}
.board-holder { flex: 1; min-height: 0; padding: 8px 14px; display: flex; align-items: center; justify-content: center; }
.board-holder svg { max-height: 100%; }

.turn-bar { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-top: 1px solid var(--line); background: rgba(0, 0, 0, 0.2); }
.turn-label { font-size: 0.7rem; letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); font-weight: 700; }
.team-btn {
  --c: var(--t1);
  --c-ink: var(--t1-ink);
  flex: 1;
  min-width: 0;
  display: grid;
  grid-template-columns: auto 1fr;
  column-gap: 10px;
  align-items: center;
  text-align: left;
  padding: 6px 12px;
  border-radius: 10px;
  border: 2px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.03);
  color: var(--ink);
  font-family: var(--font-ui);
  cursor: pointer;
}
.team-btn[data-team='t2'] { --c: var(--t2); --c-ink: var(--t2-ink); }
.team-btn .team-dot { grid-row: span 2; width: 18px; aspect-ratio: 1.1547; clip-path: polygon(25% 0, 75% 0, 100% 50%, 75% 100%, 25% 100%, 0 50%); background: var(--c); }
.team-btn .tname { font-weight: 800; font-size: 0.95rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.team-btn .tmeta { font-size: 0.72rem; color: var(--muted); }
.team-btn.active { border-color: var(--c); background: rgba(255, 255, 255, 0.09); }
.team-btn.active .tname::after { content: '  ● their turn'; font-size: 0.68rem; font-weight: 700; color: var(--c); }

/* ----------------------------- Question console ----------------------------- */
.q-body { flex: 1; min-height: 0; padding: 14px; display: flex; flex-direction: column; gap: 12px; overflow: auto; }
.q-empty { margin: auto 0; text-align: center; padding: 10px; display: flex; flex-direction: column; align-items: center; gap: 12px; }
.q-empty p { margin: 0; color: var(--muted); max-width: 40ch; line-height: 1.5; }
.q-empty .lead { font-size: 1.15rem; color: var(--ink); font-weight: 600; }
.big-turn { font-size: 1.5rem; }
.q-empty.won h3 { margin: 0; font-size: 1.5rem; }
.q-empty .tally { font-size: 1rem; color: var(--ink); font-weight: 800; }
.trophy { font-size: 2.6rem; line-height: 1; }
.after-links { display: flex; flex-direction: column; align-items: center; gap: 10px; margin-top: 6px; }
.after-links:empty { display: none; }
.tip-link { color: var(--muted); font-size: 0.82rem; }
.tip-link:hover { color: var(--ink); }

.chip { display: inline-block; max-width: 100%; padding: 3px 12px; border-radius: 99px; font-weight: 800; font-size: 0.95em; background: rgba(255, 255, 255, 0.1); border: 1px solid var(--line-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; vertical-align: middle; }
.chip-t1 { background: var(--t1); border-color: var(--t1-hi); color: var(--t1-ink); }
.chip-t2 { background: var(--t2); border-color: var(--t2-hi); color: var(--t2-ink); }

.q-head { display: flex; align-items: center; gap: 12px; }
.q-key {
  flex: none;
  width: 68px;
  aspect-ratio: 1.1547;
  display: grid;
  place-items: center;
  clip-path: polygon(25% 0, 75% 0, 100% 50%, 75% 100%, 25% 100%, 0 50%);
  background: linear-gradient(180deg, #4a5378, #1a1f3a);
  font-weight: 900;
  font-size: 2rem;
}
.q-key.kind-number { background: linear-gradient(180deg, #6a4a82, #2c1d3f); font-family: var(--font-display); font-weight: 400; font-size: 2.3rem; }
.q-key.len-2 { font-size: 1.6rem; }
.q-key.len-3, .q-key.len-4 { font-size: 1.15rem; }
.q-key.kind-number.len-3, .q-key.kind-number.len-4 { font-size: 1.5rem; }
.q-key.owner-t1 { background: var(--t1); color: var(--t1-ink); }
.q-key.owner-t2 { background: var(--t2); color: var(--t2-ink); }
.q-meta { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.q-for { font-size: 0.7rem; letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); font-weight: 700; }
.q-turn { font-size: 1.05rem; display: flex; align-items: center; gap: 8px; min-width: 0; }

.q-timer { display: flex; align-items: center; gap: 6px; }
.q-timer-num { min-width: 2ch; text-align: right; font-weight: 900; font-size: 1.7rem; font-variant-numeric: tabular-nums; }
.q-timer.urgent .q-timer-num { color: #fca5a5; }
.q-timer.paused .q-timer-num { opacity: 0.5; }
.q-timer svg { width: 14px; height: 14px; fill: currentColor; }

.diff-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.diff-easy { --dc: #22c55e; }
.diff-medium { --dc: #f59e0b; }
.diff-hard { --dc: #ef4444; }
.diff { border-color: var(--dc); }
.diff.on { background: var(--dc); color: #08101f; }

.badge { display: inline-block; padding: 3px 9px; border-radius: 6px; font-size: 0.68rem; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase; }
.badge-easy { background: rgba(34, 197, 94, 0.2); color: #86efac; }
.badge-medium { background: rgba(245, 158, 11, 0.2); color: #fcd34d; }
.badge-hard { background: rgba(239, 68, 68, 0.2); color: #fca5a5; }

.q-card { flex: 1; min-height: 0; border: 1px solid var(--line-2); border-radius: 12px; padding: 14px; background: rgba(0, 0, 0, 0.25); display: flex; flex-direction: column; justify-content: center; gap: 12px; overflow: auto; }
.q-card-empty { color: var(--muted); text-align: center; border-style: dashed; line-height: 1.5; }
.q-text { font-size: clamp(1.2rem, 3.2vh, 1.8rem); font-weight: 700; line-height: 1.35; overflow-wrap: anywhere; }
.answer { display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px 12px; padding: 10px 14px; border-radius: 10px; background: rgba(34, 197, 94, 0.1); border: 1px solid rgba(34, 197, 94, 0.45); }
.answer-label { font-size: 0.68rem; font-weight: 800; letter-spacing: 0.14em; text-transform: uppercase; color: #86efac; }
.answer-text { font-size: clamp(1.15rem, 2.8vh, 1.5rem); font-weight: 800; color: #dcfce7; overflow-wrap: anywhere; }
.answer-alt { font-size: 0.85rem; color: #a7f3c4; width: 100%; }
.answer.concealed .answer-text, .answer.concealed .answer-alt { filter: blur(9px); }
.answer.concealed:hover .answer-text, .answer.concealed:hover .answer-alt { filter: none; }

.mark-row { flex: none; display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.btn-correct, .btn-wrong { padding: 15px; font-size: 1.15rem; border-radius: 12px; color: #fff; }
.btn-correct .big, .btn-wrong .big { font-size: 1.4rem; }
.btn-correct { background: linear-gradient(180deg, #1fae54, #15803d); border-color: #4ade80; }
.btn-correct:hover:not(:disabled) { background: linear-gradient(180deg, #27c463, #16903f); }
.btn-wrong { background: linear-gradient(180deg, #e23c3c, #b91c1c); border-color: #f87171; }
.btn-wrong:hover:not(:disabled) { background: linear-gradient(180deg, #f25757, #c82222); }
.btn-another { flex: none; }

.edit-banner { padding: 8px 12px; border-radius: 8px; background: rgba(192, 38, 211, 0.2); border: 1px solid #e879f9; font-weight: 800; font-size: 0.85rem; color: #f5d0fe; }
.inline-field { display: flex; align-items: center; gap: 10px; font-size: 0.8rem; font-weight: 700; color: var(--muted); }
.inline-field input { width: 90px; text-transform: uppercase; font-weight: 800; font-size: 1.05rem; text-align: center; }

/* ------------------------------- Setup screen ------------------------------- */
.setup { flex: 1; display: flex; justify-content: center; align-items: flex-start; padding: 16px; overflow: auto; }
.setup-card {
  width: min(1080px, 100%);
  border: 1px solid var(--line-2);
  border-radius: 18px;
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  padding: 18px 22px;
}
.setup-head { display: flex; align-items: baseline; gap: 14px; flex-wrap: wrap; margin-bottom: 12px; }
.setup-head h1 { margin: 0; font-family: var(--font-display); font-weight: 400; font-size: 2rem; letter-spacing: 0.05em; color: var(--accent); }
.setup-head p { margin: 0; color: var(--muted); }
.setup-grid { display: grid; grid-template-columns: 1.15fr 1fr; gap: 6px 28px; }
.setup fieldset { border: 0; padding: 0; margin: 0 0 12px; min-width: 0; }
.setup legend { padding: 0; margin-bottom: 6px; font-size: 0.72rem; font-weight: 800; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); }
.hint { margin: 6px 0 0; font-size: 0.8rem; color: var(--muted); min-height: 1.2em; }

.seg { display: flex; flex-wrap: wrap; gap: 6px; }
.seg-opt { flex: 1 1 0; min-width: -webkit-max-content; min-width: max-content; position: relative; cursor: pointer; }
.seg-opt input { position: absolute; opacity: 0; pointer-events: none; }
.seg-opt span {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  height: 100%;
  padding: 8px 12px;
  border-radius: 10px;
  border: 1.5px solid var(--line-2);
  background: rgba(255, 255, 255, 0.04);
  text-align: center;
  white-space: nowrap;
}
.seg-opt b { font-weight: 700; font-size: 0.9rem; }
.seg-opt small { font-size: 0.7rem; color: var(--muted); font-weight: 600; }
.seg-opt:hover span { border-color: rgba(255, 255, 255, 0.4); }
.seg-opt input:checked + span { border-color: #6fb1ff; background: rgba(30, 123, 255, 0.28); }
.seg-opt input:checked + span small { color: #cfe4ff; }

.team-row { display: flex; gap: 12px; align-items: flex-start; padding: 10px 12px; margin-bottom: 8px; border: 1px solid var(--line); border-radius: 12px; background: rgba(0, 0, 0, 0.18); }
.team-swatch { flex: none; width: 34px; margin-top: 18px; aspect-ratio: 1.1547; clip-path: polygon(25% 0, 75% 0, 100% 50%, 75% 100%, 25% 100%, 0 50%); }
.team-fields { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.field-label { font-size: 0.78rem; font-weight: 800; }
.field-label small { font-weight: 600; color: var(--muted); }
.name-line { display: flex; gap: 6px; }
.name-line input { flex: 1; min-width: 0; }
.swatches { display: flex; gap: 8px; }
.swatches label { position: relative; cursor: pointer; }
.swatches input { position: absolute; opacity: 0; pointer-events: none; }
.swatches span { display: block; width: 28px; height: 28px; border-radius: 50%; background: var(--sw); border: 2px solid rgba(255, 255, 255, 0.25); }
.swatches input:checked + span { border-color: #fff; box-shadow: 0 0 0 3px var(--sw); }
.swatches input:disabled + span { opacity: 0.2; cursor: not-allowed; }

.more { margin-top: 4px; border: 1px solid var(--line); border-radius: 12px; padding: 8px 12px; }
.more summary { cursor: pointer; font-weight: 700; color: var(--ink-dim); }
.more[open] summary { margin-bottom: 8px; }
.check { display: flex; gap: 10px; align-items: flex-start; font-weight: 600; cursor: pointer; padding: 4px 0; line-height: 1.35; }
.check input { width: 17px; height: 17px; margin: 1px 0 0; accent-color: #1e7bff; flex: none; }

.own { margin-top: 8px; padding: 10px 12px; border: 1px dashed var(--line-2); border-radius: 10px; display: flex; flex-direction: column; gap: 8px; }
.own-summary { font-size: 0.85rem; line-height: 1.45; color: var(--ink-dim); }

.setup-foot { display: flex; align-items: center; justify-content: flex-end; gap: 16px; margin-top: 6px; }
.setup-error { flex: 1; margin: 0; padding: 8px 12px; border-radius: 8px; background: rgba(239, 68, 68, 0.15); border: 1px solid rgba(239, 68, 68, 0.6); color: #ffd0d0; font-weight: 600; }
.btn-start { padding: 14px 34px; font-size: 1.2rem; border-radius: 12px; }

/* Forms */
input, select, textarea {
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--line-2);
  background: #0a1027;
  color: var(--ink);
  font: 600 0.92rem var(--font-ui);
}
select { width: 100%; }
input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 2px solid #6fb1ff; outline-offset: 0; }
textarea { width: 100%; font-family: ui-monospace, Consolas, monospace; font-size: 0.8rem; resize: vertical; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 12px 0; }
.field { display: flex; flex-direction: column; gap: 5px; font-size: 0.75rem; font-weight: 700; color: var(--muted); }
.checks { display: flex; flex-direction: column; gap: 6px; }

/* ------------------------- Side panel (⋯ menu items) ------------------------- */
.side-panel {
  margin: 0 0 0 auto;
  width: min(480px, 100vw);
  height: 100vh;
  max-height: 100vh;
  padding: 0;
  border: 0;
  border-left: 1px solid var(--line-2);
  background: #111a3a;
  color: var(--ink);
}
.side-panel[open] { display: flex; flex-direction: column; }
.side-panel::backdrop { background: rgba(3, 6, 20, 0.55); }
.side-panel header { flex: none; display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.side-panel h2 { margin: 0; font-size: 1.05rem; }
.panel-body { flex: 1; overflow: auto; padding: 14px 16px; line-height: 1.5; }
.panel-body h4 { margin: 16px 0 8px; font-size: 0.75rem; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); }
.panel-body h4:first-child { margin-top: 0; }
.panel-body ol { padding-left: 20px; margin: 0; }

.kpis { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.kpi { padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line); background: rgba(0, 0, 0, 0.22); display: flex; flex-direction: column; }
.kpi b { font-size: 1.4rem; font-weight: 900; font-variant-numeric: tabular-nums; }
.kpi b small { font-size: 0.8rem; color: var(--muted); }
.kpi span { font-size: 0.68rem; color: var(--muted); font-weight: 700; text-transform: uppercase; }
.kpi.good b { color: #86efac; }
.kpi.bad b { color: #fca5a5; }
.control-bar { display: flex; height: 10px; border-radius: 99px; overflow: hidden; margin: 12px 0; background: rgba(255, 255, 255, 0.06); }
.control-bar i { display: block; height: 100%; }
.cb-t1 { background: var(--t1); }
.cb-t2 { background: var(--t2); }
.stat-table { width: 100%; border-collapse: collapse; font-size: 0.85rem; margin-bottom: 12px; }
.stat-table th, .stat-table td { padding: 6px 8px; text-align: left; border-bottom: 1px solid var(--line); }
.stat-table th { font-size: 0.7rem; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.c-t1 { color: var(--t1-hi) !important; }
.c-t2 { color: var(--t2-hi) !important; }
.log { list-style: none; margin: 0; padding: 0; font-size: 0.85rem; }
.log li { display: flex; gap: 10px; padding: 6px 0; border-bottom: 1px solid var(--line); overflow-wrap: anywhere; }
.log time { color: var(--muted); font-variant-numeric: tabular-nums; flex: none; }

/* --------------------------------- Toasts --------------------------------- */
.toasts { position: fixed; left: 50%; top: 8px; transform: translateX(-50%); align-items: center; z-index: 100; display: flex; flex-direction: column; gap: 8px; max-width: min(420px, calc(100vw - 32px)); }
.toast { padding: 10px 14px; border-radius: 10px; background: #18224a; border: 1px solid var(--line-2); border-left: 4px solid #1e7bff; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45); font-weight: 600; transition: opacity 0.35s; }
.toast-good { border-left-color: var(--good); }
.toast-warn { border-left-color: #f59e0b; }
.toast-bad { border-left-color: var(--bad); }
.toast.out { opacity: 0; }

/* ------------------------------- Responsive ------------------------------- */
@media (max-width: 980px) {
  .console { grid-template-columns: 1fr; height: auto; }
  .board-holder { height: 56vh; }
  .q-panel { min-height: 420px; }
  .setup-grid { grid-template-columns: 1fr; }
  .brand-sub, .topbar-mid { display: none; }
  .topbar { justify-content: space-between; }
}
@media (max-width: 560px) {
  .topbar { padding: 8px 16px; flex-wrap: wrap; }
  .setup { padding: 12px 16px; }
  .setup-card { padding: 14px; }
  .turn-bar { flex-wrap: wrap; }
  .turn-label { width: 100%; }
  .form-grid { grid-template-columns: 1fr; }
  .setup-foot { flex-direction: column; align-items: stretch; }
}
