@import url('https://fonts.googleapis.com/css2?family=DM+Mono:wght@400;500&family=Manrope:wght@400;500;600;700;800&display=swap');

/* The visual system: warm orange actions, mint status accents, and deep blue
  surfaces that stay readable on both a monitor and a phone screen. */
:root {
  --ink: #f4f5ef;
  --muted: #91a0a9;
  --line: rgba(211, 226, 222, 0.14);
  --surface: #111f2b;
  --surface-raised: #172936;
  --page: #09131d;
  --accent: #f2a65a;
  --accent-strong: #e88039;
  --mint: #9bd4c3;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.24);
  --radius-panel: 18px;
  --radius-control: 10px;
}

/* Base page and typography. */
* { box-sizing: border-box; }
html { min-height: 100%; background: var(--page); }
body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  font-family: 'Manrope', sans-serif;
  background:
    radial-gradient(circle at 80% -10%, rgba(242, 166, 90, 0.14), transparent 34rem),
    linear-gradient(135deg, #09131d 0%, #0d1c28 52%, #0a171f 100%);
}
button, input, select { font: inherit; }
button { cursor: pointer; }
button:disabled, input:disabled, select:disabled { cursor: not-allowed; opacity: 0.42; }
button:focus-visible, input:focus-visible, select:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}
[hidden] { display: none !important; }

/* Main game layout. */
.app-shell { width: min(1320px, calc(100% - 40px)); margin: 0 auto; padding: 36px 0 48px; }
.topbar { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; margin-bottom: 24px; }
.eyebrow, .section-kicker { margin: 0 0 8px; color: var(--accent); font: 500 0.72rem 'DM Mono', monospace; letter-spacing: 0.08em; text-transform: uppercase; }
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: clamp(2rem, 5vw, 3.5rem); line-height: 0.98; letter-spacing: -0.045em; }
h2 { margin: 0; font-size: 1.35rem; }
.deck-pill, .mode-chip { border: 1px solid var(--line); border-radius: 999px; color: var(--mint); background: rgba(155, 212, 195, 0.07); font: 500 0.75rem 'DM Mono', monospace; }
.deck-pill { padding: 11px 15px; white-space: nowrap; }
.mode-chip { padding: 6px 10px; white-space: nowrap; }
.game-layout { display: grid; grid-template-columns: minmax(0, 1.65fr) minmax(320px, 0.78fr); gap: 18px; align-items: start; }
.stage-panel, .control-panel { border: 1px solid var(--line); border-radius: var(--radius-panel); background: linear-gradient(145deg, rgba(20, 38, 51, 0.96), rgba(14, 27, 39, 0.96)); box-shadow: var(--shadow); }
.stage-panel { min-width: 0; padding: 22px; }
.control-panel { display: flex; flex-direction: column; gap: 19px; padding: 20px; }
.multiplayer-panel { display: grid; gap: 10px; padding: 16px; border: 1px solid rgba(155,212,195,0.2); border-radius: 14px; background: rgba(155,212,195,0.04); }
.multiplayer-heading h2 { margin: 0 0 2px; font-size: 1.05rem; }
.multiplayer-heading .section-kicker { margin-bottom: 6px; }
.multiplayer-panel > input, .join-room-row input { padding: 10px 11px; }
.join-room-row { display: flex; gap: 8px; }
.join-room-row input { flex: 1; min-width: 0; text-transform: uppercase; }
.room-view { display: grid; gap: 7px; }
.room-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.room-toolbar > div { display: flex; gap: 6px; }
.room-toolbar .icon-button { width: auto; height: auto; padding: 6px 9px; font-size: 0.68rem; }
.room-toolbar strong { color: var(--mint); font: 700 0.9rem 'DM Mono', monospace; letter-spacing: 0.1em; }
.room-players { display: grid; gap: 5px; margin: 0; padding: 0; list-style: none; }
.room-players li { display: flex; justify-content: space-between; gap: 10px; padding: 8px 10px; border-radius: 8px; background: rgba(255,255,255,0.04); color: var(--muted); font-size: 0.75rem; }
.room-players strong { color: var(--accent); font-family: 'DM Mono', monospace; }
.stage-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 52px; margin-bottom: 12px; }
.status { min-height: 1.4em; margin-bottom: 0; color: var(--muted); font-size: 0.88rem; }
.image-stage { display: grid; place-items: center; aspect-ratio: 16 / 9; overflow: hidden; border: 1px solid rgba(255,255,255,0.08); border-radius: 12px; background: radial-gradient(ellipse at center, #102433 0%, #071019 72%); }
.image-stage img { display: block; width: 100%; height: 100%; object-fit: contain; }
.stage-placeholder { display: grid; justify-items: center; gap: 12px; color: var(--muted); font-size: 0.84rem; }
.image-stage [hidden] { display: none !important; }
.placeholder-mark { display: grid; place-items: center; width: 58px; height: 58px; border: 1px solid rgba(242,166,90,0.45); border-radius: 18px; color: var(--accent); background: rgba(242,166,90,0.06); font-size: 2rem; }
.control-block { display: grid; gap: 10px; }
label, .search-label { color: var(--ink); font-size: 0.78rem; font-weight: 700; }
select, input { width: 100%; border: 1px solid var(--line); border-radius: var(--radius-control); outline: none; color: var(--ink); background: rgba(7, 19, 29, 0.78); }
select { padding: 12px 13px; }
input { min-width: 0; padding: 12px 13px; }
select:focus, input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(242,166,90,0.12); }
.guess-row { display: flex; gap: 8px; }
.guess-row input { flex: 1; }
button { border: 0; border-radius: var(--radius-control); padding: 11px 14px; color: var(--ink); font-weight: 700; transition: transform 160ms ease, background 160ms ease, border-color 160ms ease; }
button:not(:disabled):hover { transform: translateY(-1px); }
.primary-button { background: var(--accent-strong); color: #21140a; }
.primary-button:not(:disabled):hover { background: var(--accent); }
.secondary-button { border: 1px solid var(--line); background: rgba(255,255,255,0.045); }
.secondary-button:not(:disabled):hover { border-color: rgba(242,166,90,0.5); }
.library-button { width: 100%; border: 1px solid rgba(155,212,195,0.35); background: rgba(155,212,195,0.08); color: var(--mint); text-align: left; }
.library-button span { float: right; font-size: 1.1rem; }
.wide { width: 100%; }
.actions { display: grid; gap: 9px; margin-top: auto; }
.small-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.helper-text { margin: 0; color: var(--muted); font-size: 0.72rem; }
.network-note { margin: 0; padding-top: 14px; border-top: 1px solid var(--line); color: var(--muted); font-size: 0.72rem; line-height: 1.6; }

/* Searchable video-library dialog. */
.picker-dialog { width: min(560px, calc(100% - 28px)); max-height: min(680px, calc(100dvh - 28px)); padding: 22px; border: 1px solid var(--line); border-radius: 16px; color: var(--ink); background: #101f2b; box-shadow: var(--shadow); }
.picker-dialog::backdrop { background: rgba(3, 8, 13, 0.78); backdrop-filter: blur(5px); }
.picker-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 20px; }
.icon-button { width: 38px; height: 38px; padding: 0; border: 1px solid var(--line); background: transparent; color: var(--muted); font-size: 1.6rem; line-height: 1; }
.search-label { display: block; margin-bottom: 8px; }
.search-input { margin-bottom: 8px; }
.video-list { display: grid; gap: 5px; max-height: min(430px, 50dvh); margin-top: 12px; overflow-y: auto; padding-right: 4px; }
.video-item { width: 100%; padding: 12px 13px; border: 1px solid transparent; border-radius: 9px; background: rgba(255,255,255,0.035); color: var(--ink); text-align: left; font-weight: 500; }
.video-item:hover, .video-item:focus { border-color: rgba(242,166,90,0.55); background: rgba(242,166,90,0.1); outline: none; }
.series-dialog { width: min(560px, calc(100% - 28px)); }
.series-tools { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.series-tools .helper-text { margin-left: auto; }
.series-list { display: grid; gap: 5px; max-height: min(430px, 50dvh); margin: 12px 0 16px; overflow-y: auto; padding-right: 4px; }
.creator-back { margin: 0 0 8px; }
.creator-item { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 52px; padding: 11px 13px; border: 1px solid var(--line); border-radius: 9px; background: rgba(255,255,255,0.035); text-align: left; }
.creator-item:not(:disabled):hover { border-color: rgba(242,166,90,0.5); background: rgba(242,166,90,0.1); }
.creator-name { font-weight: 700; }
.series-item { display: flex; align-items: center; gap: 12px; min-height: 46px; padding: 9px 12px; border: 1px solid var(--line); border-radius: 9px; background: rgba(255,255,255,0.035); cursor: pointer; }
.series-item input { flex: 0 0 18px; width: 18px; height: 18px; margin: 0; padding: 0; accent-color: var(--accent); }
.series-name { flex: 1; font-weight: 600; }
.series-count { color: var(--muted); font-size: 0.75rem; white-space: nowrap; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; padding-top: 14px; border-top: 1px solid var(--line); }
.empty-list { padding: 24px 0; color: var(--muted); text-align: center; }
.toast { position: fixed; right: 20px; bottom: 20px; max-width: min(360px, calc(100% - 40px)); padding: 13px 16px; border: 1px solid var(--line); border-radius: 5px; background: var(--surface-raised); box-shadow: var(--shadow); opacity: 0; pointer-events: none; transform: translateY(10px); transition: opacity 180ms ease, transform 180ms ease; }
.toast.visible { opacity: 1; transform: translateY(0); }

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

/* Stack the image and controls on smaller screens, including iPhone. */
@media (max-width: 820px) {
  .app-shell { width: min(100% - 24px, 680px); padding-top: 24px; }
  .topbar { align-items: flex-start; flex-direction: column; gap: 14px; margin-bottom: 18px; }
  .deck-pill { align-self: flex-start; }
  .game-layout { grid-template-columns: 1fr; }
  .control-panel { gap: 18px; padding: 16px; }
  .network-note { margin-top: 2px; }
}

@media (max-width: 460px) {
  .app-shell { width: min(100% - 20px, 680px); padding-top: 20px; }
  .stage-panel { padding: 12px; }
  .stage-heading { min-height: 58px; }
  .guess-row { display: grid; grid-template-columns: 1fr; }
  .guess-row .primary-button { width: 100%; }
  .small-actions { grid-template-columns: 1fr; }
  .picker-dialog { padding: 17px; }
  .dialog-actions > button { flex: 1; }
}
