/* Am AI your frenemy? — light purple-and-white theme.
   Explicitly light (does NOT follow OS dark preference) per design handoff;
   visual reference: design-reference/frenemy-gameplay.html. */
:root {
  color-scheme: light;
  --fg: #162138;
  --bg: #f5f7fb;
  --panel: #ffffff;
  --muted: #526078;
  --line: #d8dfeb;
  --brand: #5135b8;
  --brand-ink: #ffffff;
  --brandfill: #eee8fc;
  --good: #17634a;
  --goodfill: #e3f6ee;
  --warn: #8a5a00;
  --warnfill: #fcf1dc;
  --danger: #a11b2b;
  --dangerfill: #fbe6e8;
  --focus: #5135b8;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font: 15px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--fg); background: var(--bg);
  overflow-wrap: anywhere;
}
a { color: var(--brand); }
.wrap { max-width: 1180px; margin: 0 auto; }

/* Header / banners */
header.app {
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; padding: 20px 24px; border-bottom: 1px solid var(--line);
  background: var(--panel); flex-wrap: wrap;
}
header.app .title-wrap { display: flex; flex-direction: column; }
header.app .kicker { color: var(--muted); font-size: 12px; letter-spacing: .08em; text-transform: uppercase; }
header.app h1 { font-size: 24px; margin: 2px 0 0; font-weight: 650; }
.header-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

.badge { display: inline-block; padding: .25rem .6rem; border-radius: 999px;
  font-size: .72rem; font-weight: 700; letter-spacing: .04em; }
.badge.demo { background: var(--warnfill); color: var(--warn); border: 1px solid #e4c488; }
.badge.live { background: var(--goodfill); color: var(--good); border: 1px solid #9bd8bf; }

.demo-banner {
  background: var(--warnfill); color: var(--warn); border: 1px solid #e4c488;
  padding: .55rem 1rem; margin: 16px 24px 0; border-radius: 10px;
  font-size: .9rem; font-weight: 600;
}

/* Cards */
.card {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 12px; padding: 20px; margin: 20px 24px;
}
h2 { font-size: 20px; margin: 0 0 10px; font-weight: 620; }
h3 { font-size: 18px; margin: 0 0 8px; font-weight: 620; }
.muted { color: var(--muted); }
p { margin: 8px 0; }

/* Forms */
label { display: block; font-weight: 550; margin: 14px 0 5px; }
input[type=text], input[type=password], textarea, select {
  width: 100%; padding: 11px 12px; border: 1px solid var(--line);
  border-radius: 8px; background: var(--bg); color: var(--fg); font: inherit;
}
textarea { min-height: 92px; resize: vertical; font-family: ui-monospace, "SF Mono", Menlo, monospace; }
button {
  font: inherit; font-weight: 600; border: 1px solid var(--line);
  border-radius: 8px; padding: 9px 14px; background: var(--panel);
  color: var(--fg); cursor: pointer;
}
button.primary { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }
button.ghost { background: transparent; color: var(--brand); border-color: var(--line); }
button:disabled { opacity: .55; cursor: not-allowed; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }

/* Attract screen */
.attract { text-align: center; padding: 40px 24px; }
.attract h2 { font-size: 30px; }
.attract .teasers { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin: 24px 0; }
.teaser { border: 1px solid var(--line); border-radius: 10px; padding: 16px; background: var(--panel); text-align: left; }
.teaser .pts { color: var(--brand); font-weight: 700; }
@media (max-width: 820px) { .attract .teasers { grid-template-columns: 1fr 1fr; } }

/* Gameplay layout: mission rail + single workspace */
.play-header {
  display: flex; gap: 18px; flex-wrap: wrap; align-items: center;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 12px; padding: 14px 18px; margin: 20px 24px;
}
.stat { display: flex; flex-direction: column; }
.stat .k { font-size: 12px; color: var(--muted); }
.stat .v { font-size: 18px; font-weight: 700; font-variant-numeric: tabular-nums; }
.timer.low .v { color: var(--danger); }

.layout { display: grid; grid-template-columns: 250px 1fr; gap: 20px; padding: 0 24px 24px; }
.rail { display: flex; flex-direction: column; gap: 10px; }
.rail button { text-align: left; padding: 12px 14px; display: block; }
.rail button[aria-pressed=true] { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }
.rail button .sub { display: block; font-size: 12px; opacity: .85; margin-top: 3px; font-weight: 500; }
.rail .solved-dot { color: var(--good); font-weight: 700; }
.rail button[aria-pressed=true] .solved-dot { color: #cdeede; }

.workspace { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 22px; min-width: 0; }
.goal { background: var(--brandfill); border-radius: 8px; padding: 14px 16px; margin: 4px 0 16px; }
.chat { margin: 12px 0; display: flex; flex-direction: column; gap: 10px; }
.msg { padding: 11px 14px; border-radius: 10px; white-space: pre-wrap; }
.msg.user { background: var(--brandfill); align-self: flex-end; max-width: 85%; }
.msg.assistant { background: var(--bg); border: 1px solid var(--line); max-width: 90%; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 10px; }

.outcome { margin: 14px 0 0; padding: 12px 14px; border-radius: 8px;
  border-left: 4px solid var(--line); background: var(--bg); }
.outcome.success { border-left-color: var(--good); background: var(--goodfill); color: var(--good); }
.outcome.refused { border-left-color: var(--warn); background: var(--warnfill); color: var(--warn); }
.outcome.error { border-left-color: var(--danger); background: var(--dangerfill); color: var(--danger); }
.outcome.stale { border-left-color: var(--muted); }

@media (max-width: 820px) {
  .layout { grid-template-columns: 1fr; }
  .rail { display: grid; grid-template-columns: 1fr 1fr; }
  .card, .play-header, .demo-banner { margin-left: 14px; margin-right: 14px; }
  .layout { padding: 0 14px 14px; }
}

/* Tables */
table { border-collapse: collapse; width: 100%; }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--line); }
th { font-size: 13px; color: var(--muted); }

/* Staff station cards (phone-friendly) */
.stations { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.station-card { border: 1px solid var(--line); border-radius: 12px; padding: 16px; background: var(--panel); }
.station-card h3 { display: flex; justify-content: space-between; align-items: center; }
.pill { font-size: 12px; padding: 2px 8px; border-radius: 999px; background: var(--bg); border: 1px solid var(--line); color: var(--muted); }
.pill.active { background: var(--goodfill); color: var(--good); border-color: #9bd8bf; }
.pill.err { background: var(--warnfill); color: var(--warn); border-color: #e4c488; }
.station-card .controls { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.station-card button { width: 100%; }
@media (max-width: 760px) { .stations { grid-template-columns: 1fr; } }

/* Live model panel (staff console) */
.live-status .controls { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.live-status .controls button { width: 100%; }
.live-status .row { margin-bottom: 6px; }

/* Toast */
.toast {
  position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%);
  background: var(--panel); border: 1px solid var(--line); padding: 11px 16px;
  border-radius: 10px; max-width: 92vw; box-shadow: 0 6px 24px rgba(20,33,56,.14);
}
.toast.err { border-color: var(--danger); color: var(--danger); }
.toast.ok { border-color: var(--good); color: var(--good); }

.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
.hidden { display: none !important; }

@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* Chat / Bot's brief tabs (presentation uplift) */
.tabs { display: flex; gap: 6px; margin: 6px 0 10px; }
.tabs .tab {
  font-size: .85rem; padding: 6px 12px; border-radius: 8px 8px 0 0;
  border: 1px solid var(--line); background: var(--bg); color: var(--muted);
}
.tabs .tab[aria-pressed="true"] {
  background: var(--brand); color: var(--brand-ink); border-color: var(--brand);
}
.brief {
  background: var(--brandfill); border: 1px solid var(--line);
  border-radius: 8px; padding: 14px 16px; margin: 4px 0 12px; line-height: 1.5;
}
/* Standings top-three emphasis */
.rank-1 td { background: #f6f0ff; font-weight: 700; }
.rank-2 td { background: #faf7ff; }
.rank-3 td { background: #fdfbff; }
.medal { font-weight: 800; }
