@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.28);
}

/* 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; }

/* Main game layout. */
.app-shell { width: min(1280px, calc(100% - 40px)); margin: 0 auto; padding: 42px 0 50px; }
.topbar { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; margin-bottom: 28px; }
.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, 4rem); line-height: 0.98; letter-spacing: -0.04em; }
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(300px, 0.7fr); gap: 20px; align-items: stretch; }
.stage-panel, .control-panel { border: 1px solid var(--line); background: rgba(17, 31, 43, 0.88); box-shadow: var(--shadow); }
.stage-panel { min-width: 0; padding: 20px; }
.control-panel { display: flex; flex-direction: column; gap: 26px; padding: 24px; }
.stage-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; min-height: 52px; }
.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; background: #071019; border: 1px solid rgba(255,255,255,0.08); }
.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.55); border-radius: 50%; color: var(--accent); 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: 5px; outline: none; color: var(--ink); background: #0b1924; }
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: 5px; padding: 12px 15px; color: var(--ink); font-weight: 700; transition: transform 160ms ease, background 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: var(--surface-raised); }
.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: auto 0 0; padding-top: 16px; 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: 10px; 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: 5px; 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; }
.series-item { display: flex; align-items: center; gap: 12px; min-height: 46px; padding: 9px 12px; border: 1px solid var(--line); border-radius: 5px; 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); }

/* 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: 20px; padding: 18px; }
  .network-note { margin-top: 2px; }
}

@media (max-width: 460px) {
  .stage-panel { padding: 12px; }
  .stage-heading { min-height: 68px; }
  .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; }
}
