/* VIN Games hub. Swap these tokens for VIN's design system when it's available. */
:root {
  --navy: #1b2f52;
  --steel: #4d6995;
  --mist: #dde5ed;
  --ground: #f5f7fa;
  --surface: #ffffff;
  --ink: #14213d;
  --muted: #3d4a5c;
  --line: #d5dce5;
  --field: #8a97a8;
  --error: #a4161a;
  --font: "Source Sans 3", "Source Sans Pro", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --radius: 10px;
  --space: 1rem;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 1.0625rem;
  line-height: 1.5;
  color: var(--ink);
  background: var(--ground);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
main { flex: 1; outline: none; }
img { max-width: 100%; display: block; }
h1, h2, h3 { line-height: 1.15; margin: 0 0 0.5rem; }
h1 { font-size: clamp(1.9rem, 4vw, 2.75rem); font-weight: 700; letter-spacing: -0.01em; }
h2 { font-size: 1.35rem; font-weight: 700; }
h3 { font-size: 1.15rem; font-weight: 700; }
p { margin: 0 0 0.75rem; }
a { color: var(--navy); font-weight: 600; }
a:hover { color: var(--steel); }
:focus-visible { outline: 3px solid var(--steel); outline-offset: 2px; }

.wrap { max-width: 1200px; margin: 0 auto; padding: 0 1.25rem; }
.narrow { max-width: 640px; margin: 0 auto; padding: 2rem 1.25rem 3rem; }
.lead { font-size: 1.2rem; color: var(--muted); max-width: 42rem; }
.muted { color: var(--muted); }
.center { text-align: center; }
.fine-print { font-size: 0.9rem; color: var(--muted); max-width: 52rem; }
.stack > * + * { margin-top: 1.25rem; }
.stack-sm > * + * { margin-top: 0.6rem; }
.skip-link { position: absolute; left: -999px; top: 0; background: var(--surface); padding: 0.5rem 1rem; z-index: 10; }
.skip-link:focus { left: 0.5rem; top: 0.5rem; }

/* Header */
.site-header { background: var(--surface); border-bottom: 1px solid var(--line); }
.header-row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; min-height: 64px; padding-top: 0.5rem; padding-bottom: 0.5rem; }
.brand { display: flex; align-items: center; gap: 0.6rem; font-size: 1.3rem; font-weight: 700; text-decoration: none; color: var(--ink); }
.pill { font-size: 0.8rem; font-weight: 600; background: var(--mist); color: var(--navy); padding: 0.15rem 0.6rem; border-radius: 999px; }
.main-nav { display: flex; align-items: center; gap: 1.25rem; flex-wrap: wrap; }
.main-nav a { text-decoration: none; }
.group-chip { font: inherit; font-size: 0.9rem; color: var(--muted); background: none; border: 1px solid var(--line); border-radius: 999px; padding: 0.3rem 0.8rem; cursor: pointer; min-height: 36px; }
.beta-bar { background: var(--mist); }
.beta-row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding-top: 0.6rem; padding-bottom: 0.6rem; }
.beta-row p { margin: 0; }
.text-button { font: inherit; font-weight: 600; color: var(--navy); background: none; border: 0; text-decoration: underline; cursor: pointer; min-height: 44px; }

/* Buttons */
.button {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem;
  min-height: 48px; padding: 0 1.25rem; border-radius: 8px;
  font: inherit; font-weight: 700; text-decoration: none; cursor: pointer;
  border: 2px solid transparent;
}
.button.primary { background: var(--navy); color: #fff; }
.button.primary:hover { background: #24406f; color: #fff; }
.button.outline { background: var(--surface); color: var(--ink); border-color: var(--navy); }
.button.outline[aria-pressed="true"] { background: var(--navy); color: #fff; }
.button.quiet { background: none; color: var(--navy); }
.button.light { background: #fff; color: var(--ink); }
.button.wide { width: 100%; }
.button[disabled] { opacity: 0.6; cursor: progress; }
.choice-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.6rem; }

/* Hub */
.hero { padding: 2.5rem 0 1.5rem; max-width: 46rem; }
.section-title { font-size: 1.6rem; margin-top: 0.5rem; }
.status-line { color: var(--muted); }
.game-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); gap: 1.25rem; margin-bottom: 3rem; }
.card { position: relative; display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.card:hover { border-color: var(--steel); }
.card .cover { aspect-ratio: 16 / 9; border-radius: 0; }
.card-body { padding: 1.1rem 1.2rem 1.2rem; display: flex; flex-direction: column; gap: 0.5rem; flex: 1; }
.card-title { margin: 0; font-size: 1.2rem; }
.card-title button { all: unset; cursor: pointer; }
.card-title button::after { content: ""; position: absolute; inset: 0; }
.card-title button:focus-visible::after { outline: 3px solid var(--steel); outline-offset: -3px; border-radius: 12px; }
.card p { margin: 0; color: var(--muted); }
.tags { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.tag { font-size: 0.82rem; font-weight: 600; color: var(--navy); border: 1px solid #b7c4d4; border-radius: 6px; padding: 0.05rem 0.5rem; }
.card-foot { display: flex; justify-content: space-between; align-items: center; margin-top: auto; padding-top: 0.4rem; font-size: 0.95rem; color: var(--muted); }
.card-foot strong { color: var(--navy); }
.badge { font-size: 0.8rem; font-weight: 600; color: var(--navy); background: var(--mist); border-radius: 999px; padding: 0.1rem 0.6rem; white-space: nowrap; }
.student-tile { border: 2px dashed #b7c4d4; border-radius: 12px; padding: 1.5rem; display: flex; flex-direction: column; justify-content: center; gap: 0.5rem; min-height: 280px; }
.student-tile p { color: var(--muted); margin: 0; }

.cover { background: var(--mist); border-radius: var(--radius); display: flex; align-items: center; justify-content: center; overflow: hidden; color: var(--navy); font-weight: 600; font-size: 0.95rem; }
.cover img { width: 100%; height: 100%; object-fit: cover; }

.make-band { background: var(--navy); color: #fff; border-radius: 16px; padding: clamp(1.5rem, 4vw, 2.5rem); margin-bottom: 3rem; }
.make-band > p { color: #e6ecf3; max-width: 44rem; font-size: 1.1rem; }
.make-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 1rem; margin: 1.25rem 0; }
.make-card { background: #fff; color: var(--ink); border-radius: 12px; padding: 1.25rem; display: flex; flex-direction: column; gap: 0.6rem; }
.make-card p { color: var(--muted); margin: 0; flex: 1; }
.make-card .button { align-self: flex-start; }
.make-foot { margin: 0; color: #e6ecf3; }
.make-foot a { color: #fff; }

/* Footer */
.site-footer { background: var(--surface); border-top: 1px solid var(--line); padding: 1.75rem 0 2.25rem; }
.footer-nav { display: flex; gap: 1.5rem; flex-wrap: wrap; }

/* Forms */
.field { display: flex; flex-direction: column; gap: 0.35rem; }
label { font-weight: 600; }
input[type="text"], input[type="email"], input[type="url"], input[type="password"], textarea, select {
  font: inherit; color: var(--ink); background: var(--surface);
  border: 1px solid var(--field); border-radius: 8px; padding: 0.7rem 0.8rem; width: 100%;
}
textarea { resize: vertical; }
.hint { font-size: 0.92rem; color: var(--muted); margin: 0; }
.form-error { color: var(--error); font-weight: 600; margin: 0; }
fieldset { border: 0; margin: 0; padding: 0; min-width: 0; } /* fieldsets default to min-content width, which can push past a phone screen */
legend { font-weight: 700; font-size: 1.05rem; padding: 0 0 0.4rem; float: left; width: 100%; }
legend + * { clear: both; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 1rem 1.1rem; }
.panel h2 { font-size: 1.15rem; }
.option { display: flex; align-items: flex-start; gap: 0.75rem; min-height: 44px; padding: 0.55rem 0; font-weight: 400; }
.option input { width: 20px; height: 20px; margin: 0.15rem 0 0; flex-shrink: 0; accent-color: var(--navy); }
.scale { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 0.4rem; }
.scale label { display: flex; flex-direction: column; align-items: center; gap: 0.2rem; border: 1px solid var(--line); border-radius: 8px; padding: 0.5rem 0; font-weight: 600; }
.scale input { accent-color: var(--navy); }
.done-panel { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 1.5rem; }

/* Player */
body.playing .site-header, body.playing .beta-bar, body.playing .site-footer { display: none; }
.player { display: flex; flex-direction: column; height: 100vh; height: 100dvh; }
.player-bar { display: flex; align-items: center; gap: 0.5rem; height: 52px; padding: 0 0.5rem; background: var(--surface); border-bottom: 1px solid var(--line); }
.player-title { flex: 1; margin: 0; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-actions { display: flex; gap: 0.25rem; }
.bar-button { display: inline-flex; align-items: center; gap: 0.35rem; min-height: 44px; min-width: 44px; justify-content: center; padding: 0 0.6rem; font: inherit; font-weight: 600; color: var(--navy); background: none; border: 1px solid transparent; border-radius: 8px; cursor: pointer; }
.bar-button:hover { border-color: var(--line); }
.bar-button svg, .icon-button svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.rotate-hint { margin: 0; padding: 0.5rem 1rem; background: var(--mist); text-align: center; }
.frame-host { position: relative; flex: 1; background: var(--ground); }
.frame-host iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; background: #fff; }
.frame-status { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; text-align: center; padding: 1rem; color: var(--muted); margin: 0; }
@media (max-width: 599px) { .wide-only { display: none; } }

/* Results */
.score-card { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 1.5rem; text-align: center; margin-bottom: 1.25rem; }
.score { font-size: 3.4rem; font-weight: 700; line-height: 1; margin: 0.25rem 0 0.5rem; }
.panel + .panel, .score-card + .panel { margin-top: 1rem; }
.topic-row { display: flex; justify-content: space-between; font-size: 0.98rem; }
.bar { height: 8px; background: var(--mist); border-radius: 4px; overflow: hidden; margin-top: 0.3rem; }
.bar span { display: block; height: 100%; background: var(--steel); }
.missed-list { list-style: none; margin: 0; padding: 0; }
.missed-list li { border-top: 1px solid var(--line); padding: 0.9rem 0; display: grid; grid-template-columns: 1fr auto; gap: 0.4rem 0.75rem; }
.missed-list li:first-child { border-top: 0; padding-top: 0.25rem; }
.missed-q { font-weight: 600; margin: 0; }
.missed-a { grid-column: 1 / -1; margin: 0; color: var(--muted); }
.missed-a strong { color: var(--ink); }
.missed-link { grid-column: 1 / -1; }
.icon-button { display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 44px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--navy); cursor: pointer; }
.cta-card { background: var(--navy); color: #fff; border-radius: 14px; padding: 1.25rem; margin: 1rem 0; }
.cta-card p { color: #e6ecf3; }

/* Sheets: bottom sheet on phones, centered dialog on wider screens */
dialog.sheet { border: 0; border-radius: 16px; padding: 1.25rem 1.4rem 1.5rem; width: min(560px, calc(100% - 2rem)); max-height: 90vh; overflow: auto; color: var(--ink); background: var(--surface); }
dialog.sheet.small { width: min(420px, calc(100% - 2rem)); }
dialog::backdrop { background: rgba(20, 33, 61, 0.55); }
.sheet-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; margin-bottom: 0.75rem; }
.sheet .cover { aspect-ratio: 16 / 9; max-height: 220px; margin-bottom: 1rem; }
.facts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0.5rem; margin: 1rem 0; }
.facts div { border: 1px solid var(--line); border-radius: 10px; padding: 0.55rem 0.65rem; }
.facts dt { font-size: 0.85rem; color: var(--muted); }
.facts dd { margin: 0; font-weight: 700; }
.sheet ol { margin: 0.25rem 0 1rem; padding-left: 1.3rem; color: var(--muted); }
@media (max-width: 599px) {
  dialog.sheet { width: 100%; max-width: 100%; margin: auto 0 0; border-radius: 20px 20px 0 0; }
}

.toast { position: fixed; left: 50%; bottom: 1.25rem; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 0.75rem 1.1rem; border-radius: 10px; max-width: calc(100% - 2rem); z-index: 20; font-weight: 600; }

@media (prefers-reduced-motion: no-preference) {
  dialog.sheet[open] { animation: rise 160ms ease-out; }
  @keyframes rise { from { transform: translateY(12px); opacity: 0; } to { transform: none; opacity: 1; } }
}

/* Codes and sharing */
.code-list { list-style: none; margin: 0; padding: 0; }
.code-list li { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; padding: 0.4rem 0; border-top: 1px solid var(--line); }
.code-list li:first-child { border-top: 0; }
.code-list .code { font-weight: 700; letter-spacing: 0.02em; }
.input-row { display: flex; gap: 0.5rem; align-items: stretch; }
.input-row input { flex: 1; min-width: 0; }
.input-row .button { flex-shrink: 0; min-height: 0; }
.share-box { border: 1px solid var(--line); border-radius: 10px; padding: 0.8rem; background: var(--ground); }
.option > span { display: block; }
@media (max-width: 420px) { .input-row { flex-direction: column; } .input-row .button { min-height: 44px; } }

/* Update notice */
.update-bar { background: #fff4d6; border-bottom: 1px solid #ecd9a3; }
.update-bar .button { min-height: 40px; }
body.playing .update-bar { display: none; }
.frame-status .button { margin-top: 0.75rem; }
.frame-status { flex-direction: column; }

/* Cover images */
.cover-preview { border: 1px solid var(--line); border-radius: 10px; padding: 0.6rem; background: var(--ground); }
.cover-preview img { width: 100%; max-width: 480px; aspect-ratio: 16 / 9; object-fit: cover; border-radius: 6px; background: var(--mist); }
.cover-preview-row { display: flex; justify-content: space-between; align-items: center; gap: 0.75rem; flex-wrap: wrap; margin-top: 0.4rem; }

/* Cover editor */
dialog.cover-editor { width: min(720px, calc(100% - 2rem)); }
.ce-frame { border-radius: 10px; overflow: hidden; background: var(--mist); box-shadow: 0 0 0 1px var(--line); margin: 0.5rem 0 0.75rem; }
.ce-canvas { display: block; width: 100%; aspect-ratio: 16 / 9; cursor: grab; touch-action: none; }
.ce-canvas.dragging { cursor: grabbing; }
.ce-canvas:focus-visible { outline: 3px solid var(--steel); outline-offset: -3px; }
.ce-controls { display: grid; gap: 0.6rem; }
.ce-zoom { display: grid; grid-template-columns: auto 1fr; align-items: center; gap: 0.75rem; }
.ce-zoom input { width: 100%; accent-color: var(--navy); }
.ce-buttons { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.ce-buttons .button { min-height: 40px; }
.ce-bg { border: 0; margin: 0; padding: 0; }
.ce-bg[disabled] { opacity: 0.5; }
.ce-bg legend { font-size: 0.95rem; }
.ce-chips { display: flex; flex-wrap: wrap; gap: 0.4rem; clear: both; }
.ce-chip { display: inline-flex; align-items: center; gap: 0.35rem; font-weight: 400; border: 1px solid var(--line); border-radius: 999px; padding: 0.25rem 0.7rem; cursor: pointer; }
.ce-chip input { accent-color: var(--navy); }
@media (max-width: 599px) { dialog.cover-editor { width: 100%; } }

/* Uploads and help */
.callout { background: var(--mist); border-radius: 10px; padding: 0.75rem 1rem; }
.upload-result { border: 1px solid var(--line); border-radius: 10px; padding: 0.75rem 0.9rem; background: var(--ground); }
.upload-result.ok { border-color: #8fc1a0; background: #eef7f1; }
.upload-result.bad { border-color: #e0a3a3; background: #fbefef; }
.upload-result ul { margin: 0.4rem 0 0; padding-left: 1.2rem; }
.upload-result li { margin-bottom: 0.3rem; overflow-wrap: anywhere; }
.upload-result .level { font-weight: 700; }
input[type="file"] { font: inherit; max-width: 100%; }
.steps { padding-left: 1.3rem; }
.steps li { margin-bottom: 0.4rem; }
.view-head-row { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; }
.view-head-row h2 { margin: 0; }
.prompt { white-space: pre-wrap; overflow-wrap: anywhere; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.88rem; line-height: 1.5; background: var(--ground); border: 1px solid var(--line); border-radius: 8px; padding: 0.9rem; margin: 0; max-height: 26rem; overflow: auto; }
.plain-list { padding-left: 1.2rem; }
