/* =====================================================================
   Classroom Escape Hub — "Friendly Classroom" theme
   Warm, accessible, human. Light + cheerful, chunky rounded shapes,
   highly legible typography. All colors are tokens so palettes (and
   per-escape themes) are easy to swap.
   ===================================================================== */

:root {
  /* palette */
  --bg: #fff7ef;
  --bg-tint: #ffedd9;
  --surface: #ffffff;
  --ink: #2b2440;
  --ink-soft: #5c5570;
  --line: #ece0cf;

  --coral: #f0533f;      /* primary */
  --coral-strong: #d8422f;
  --sun: #ffd23f;        /* accent / assist */
  --sun-deep: #f6b900;
  --teal: #17a89a;       /* secondary */
  --blue: #3f7fd6;
  --grape: #8a63d2;      /* non-linear */
  --green: #1f9d57;
  --red: #d8422f;

  /* Warm "quest" accents (from the cozy quest-board direction) */
  --amber: #c97a1b;
  --brass: #b5852a;
  --parchment: #fdf3dc;
  --parchment-edge: #e6c88f;

  --focus: #1f6feb;

  --radius: 22px;
  --radius-sm: 14px;
  --pill: 999px;
  --shadow: 0 10px 24px rgba(43, 36, 64, 0.12);
  --shadow-lg: 0 18px 40px rgba(43, 36, 64, 0.16);

  --font-body: 'Atkinson Hyperlegible', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-display: 'Fredoka', 'Atkinson Hyperlegible', system-ui, sans-serif;

  font-size: 17px;
}

/* Larger-text preference (toggle in the header) */
html.text-large { font-size: 20px; }

* { box-sizing: border-box; }

body {
  font-family: var(--font-body);
  color: var(--ink);
  margin: 0;
  padding: 24px;
  min-height: 100vh;
  line-height: 1.55;
  background:
    radial-gradient(rgba(150, 110, 60, 0.05) 1px, transparent 1.4px) 0 0 / 20px 20px,
    radial-gradient(1200px 600px at 15% -10%, var(--bg-tint), transparent 60%),
    radial-gradient(1000px 520px at 100% 0%, #ffe6cf, transparent 55%),
    var(--bg);
  background-attachment: fixed;
}

h1, h2, h3, .runner-title, .hub-title, .victory-title { font-family: var(--font-display); font-weight: 600; }

a { color: var(--blue); }

/* Accessibility: visible focus + reduced motion + skip link */
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 6px; }
.skip-link {
  position: absolute; left: 12px; top: -48px; background: var(--ink); color: #fff;
  padding: 10px 16px; border-radius: 10px; z-index: 100; transition: top 0.15s ease; text-decoration: none;
}
.skip-link:focus { top: 12px; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; scroll-behavior: auto !important; }
}

/* ---------------- Buttons ---------------- */
button { font-family: inherit; }
.btn {
  border: none;
  border-radius: var(--pill);
  padding: 13px 24px;
  font-size: 1rem;
  font-weight: 700;
  font-family: var(--font-display);
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.15s ease, background 0.2s ease, filter 0.15s ease;
  color: #fff;
  box-shadow: 0 4px 0 rgba(0,0,0,0.12);
}
.btn:hover:not(:disabled) { transform: translateY(-2px); filter: brightness(1.03); }
.btn:active:not(:disabled) { transform: translateY(1px); box-shadow: 0 2px 0 rgba(0,0,0,0.14); }
.btn:disabled { opacity: 0.5; cursor: default; box-shadow: none; }
.btn-primary { background: var(--coral); }
.btn-primary:hover:not(:disabled) { background: var(--coral-strong); }
.btn-assist { background: var(--sun); color: var(--ink); padding: 10px 18px; font-size: 0.92rem; }
.btn-ghost { background: var(--surface); color: var(--ink); border: 2px solid var(--line); box-shadow: 0 3px 0 var(--line); }
.btn-ghost:hover:not(:disabled) { background: #fffdf8; }

/* ---------------- Hub ---------------- */
.hub { max-width: 1100px; margin: 0 auto; }
.hub-header { margin-bottom: 26px; display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.hub-brand { display: flex; align-items: center; gap: 16px; }
.hub-logo { flex: none; }
.hub-logo svg { display: block; width: 68px; height: 68px; }
.hub-title { margin: 0; font-size: 2.3rem; color: var(--ink); letter-spacing: 0.2px; }
.hub-title .accent { color: var(--coral); }
.hub-tagline { margin: 4px 0 0; color: var(--ink-soft); font-size: 1.02rem; }

.settings { display: flex; gap: 8px; align-items: center; }

.hub-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 22px;
}

.escape-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow);
  border: 3px solid var(--line);
  border-top: 8px solid var(--coral);
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: transform 0.16s ease, box-shadow 0.16s ease, border-color 0.16s ease;
}
.escape-card:nth-child(3n+2) { border-top-color: var(--teal); }
.escape-card:nth-child(3n) { border-top-color: var(--blue); }
.escape-card:hover { transform: translateY(-5px); box-shadow: var(--shadow-lg); }
.escape-card-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.escape-icon { font-size: 2.4rem; line-height: 1; }
.escape-badges { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; }
.badge {
  background: var(--bg-tint);
  color: var(--ink);
  border-radius: var(--pill);
  padding: 4px 12px;
  font-size: 0.8rem;
  font-weight: 700;
  border: 2px solid transparent;
}
.badge-time { background: #ffe7c2; }
.badge-structure { background: #cdeee9; }
.badge-structure.nonlinear { background: #e7ddfa; }
.escape-title { margin: 6px 0 0; color: var(--ink); font-size: 1.4rem; }
.escape-subtitle { margin: 0; color: var(--ink-soft); font-weight: 700; font-size: 0.95rem; }
.escape-format { margin: 0; font-size: 0.85rem; color: var(--teal); font-weight: 700; }
.escape-summary { margin: 6px 0; color: var(--ink-soft); }
.escape-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tag { font-size: 0.76rem; color: var(--ink-soft); background: #f4ead9; border-radius: var(--pill); padding: 2px 10px; }
.escape-actions { margin-top: auto; display: flex; align-items: center; justify-content: space-between; gap: 10px; padding-top: 10px; }
.activity-count { font-size: 0.82rem; color: var(--ink-soft); }
.escape-teacher { margin-top: 8px; border-top: 2px dashed var(--parchment-edge); padding-top: 10px; display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.teacher-label { font-size: 0.76rem; font-weight: 800; color: var(--amber); text-transform: uppercase; letter-spacing: 0.04em; }
.dot-sep { color: var(--line); }
.link-btn { background: none; border: none; color: var(--blue); cursor: pointer; font-size: 0.86rem; font-weight: 700; padding: 4px 2px; }
.link-btn:hover { text-decoration: underline; }
.hub-footer { text-align: center; margin-top: 28px; color: var(--ink-soft); font-size: 0.9rem; }

/* ---------------- Runner ---------------- */
.runner { max-width: 820px; margin: 0 auto; }
.runner-header {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 16px 20px;
  box-shadow: var(--shadow);
  border: 3px solid var(--line);
  margin-bottom: 20px;
  position: sticky;
  top: 12px;
  z-index: 5;
}
.runner-header-row { display: flex; align-items: center; gap: 12px; }
.runner-title-wrap { flex: 1; min-width: 0; }
.runner-eyebrow { font-size: 0.74rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--ink-soft); font-weight: 700; }
.runner-title { margin: 2px 0 0; font-size: 1.3rem; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.runner-meta { display: flex; align-items: center; gap: 10px; }
.timer { font-variant-numeric: tabular-nums; font-weight: 700; font-family: var(--font-display); background: #fdeccb; color: #7a4e12; border: 1px solid var(--parchment-edge); padding: 6px 13px; border-radius: var(--pill); }
.progress-track { margin-top: 14px; height: 12px; background: #f0e5d4; border-radius: var(--pill); overflow: hidden; }
.progress-fill { height: 100%; width: 0; background: linear-gradient(90deg, var(--sun), var(--coral)); border-radius: var(--pill); transition: width 0.5s ease; }
.step-label-top { display: inline-block; margin-top: 8px; font-size: 0.84rem; color: var(--ink-soft); font-weight: 700; }

.puzzle-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 26px;
  box-shadow: var(--shadow);
  border: 3px solid var(--line);
  border-left: 8px solid var(--blue);
}
.puzzle-eyebrow { font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--ink-soft); font-weight: 700; }
.puzzle-title { color: var(--ink); font-size: 1.5rem; margin: 6px 0 14px; }
.puzzle-story {
  background: var(--parchment);
  border: 1px solid var(--parchment-edge);
  border-left: 5px solid var(--amber);
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  margin-bottom: 18px;
  color: #4a3d2a;
  font-size: 1.04rem;
}
.prompt { font-size: 1.08rem; font-weight: 700; }
.step-label { margin: 14px 0 4px; }

.field {
  width: 100%;
  padding: 13px;
  border: 2px solid var(--line);
  border-radius: var(--radius-sm);
  margin: 8px 0;
  font-size: 1rem;
  font-family: var(--font-body);
  background: #fffdf8;
  color: var(--ink);
}
.field::placeholder { color: #a79f92; }
.field:focus { border-color: var(--coral); outline: none; box-shadow: 0 0 0 3px rgba(240, 83, 63, 0.18); }
select.field { cursor: pointer; }
.field-label { display: block; margin-top: 14px; font-weight: 700; color: var(--ink); }
.member-row { display: grid; grid-template-columns: 28px 1fr 1fr; gap: 10px; align-items: center; }
.member-index { text-align: center; font-weight: 800; color: var(--coral); font-family: var(--font-display); }
.response-row { margin: 8px 0; }
.response-name { font-weight: 800; color: var(--teal); }

.options { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin: 14px 0; }
.option {
  background: #fffdf8;
  border: 2px solid var(--line);
  color: var(--ink);
  padding: 16px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 1rem;
  font-weight: 700;
  font-family: var(--font-body);
  transition: all 0.14s ease;
  text-align: center;
}
.option:hover { border-color: var(--blue); transform: translateY(-2px); }
.option.selected { border-color: var(--coral); background: #ffe9e4; box-shadow: 0 4px 0 rgba(240,83,63,0.2); }

.requirements { margin: 10px 0; padding-left: 20px; }
.requirements li { margin: 4px 0; }

.message { margin: 14px 0; padding: 14px; border-radius: var(--radius-sm); font-weight: 700; }
.message.success { background: #dff5e6; border-left: 5px solid var(--green); color: #12633a; }
.message.error { background: #fde4e0; border-left: 5px solid var(--red); color: #9a2c1e; }

.assist { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 8px; }
.hint-box { margin-top: 12px; background: #fff6d8; border-left: 5px solid var(--sun-deep); border-radius: var(--radius-sm); padding: 8px 14px; }
.hint-line { margin: 8px 0; }
.hint-mark { font-weight: 700; }
.bonus-panel { margin-top: 12px; background: #ffe9d6; border-left: 5px solid var(--coral); border-radius: var(--radius-sm); padding: 14px; }

/* ---------------- Media clues ---------------- */
.clue-media { margin: 0 0 18px; background: var(--bg-tint); border-radius: var(--radius-sm); padding: 14px; border: 2px solid var(--line); }
.clue-label { font-weight: 800; color: var(--coral); margin-bottom: 8px; font-family: var(--font-display); }
.clue-video { width: 100%; border-radius: 10px; background: #000; display: block; }
.clue-audio { width: 100%; }
.clue-text { margin-top: 10px; font-size: 1.05rem; font-weight: 700; }

/* ---------------- Cipher ---------------- */
.cipher-text {
  font-family: 'DejaVu Sans Mono', ui-monospace, monospace;
  font-size: 1.9rem;
  letter-spacing: 7px;
  text-align: center;
  background: var(--parchment);
  padding: 18px;
  border-radius: var(--radius-sm);
  margin: 10px 0;
  color: #8a3a2c;
  word-break: break-word;
  border: 2px dashed var(--brass);
  box-shadow: inset 0 0 24px rgba(150, 110, 60, 0.08);
}
.cipher-legend { font-size: 0.95rem; color: #5a4a30; margin: 8px 0; background: #fff8ea; border: 1px solid var(--parchment-edge); border-radius: var(--radius-sm); padding: 10px 14px; }
.cipher-legend p { margin: 4px 0; }
.cipher-example { font-family: 'DejaVu Sans Mono', ui-monospace, monospace; color: var(--amber); font-weight: 700; }
.cipher-symbol-legend { display: flex; flex-wrap: wrap; gap: 6px; }
.legend-pair { background: var(--bg-tint); border-radius: 6px; padding: 2px 6px; font-size: 0.85rem; }

/* ---------------- Combination lock ---------------- */
.dials { display: flex; gap: 14px; justify-content: center; margin: 18px 0; }
.dial { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.dial-btn { background: var(--ink); border: none; color: #fff; width: 58px; height: 36px; border-radius: 10px; cursor: pointer; font-size: 1.1rem; }
.dial-btn:hover { background: #453c60; }
.dial-display { width: 58px; height: 66px; display: flex; align-items: center; justify-content: center; font-size: 2rem; font-weight: 800; background: var(--bg-tint); border: 2px solid var(--sun-deep); border-radius: 12px; color: var(--ink); font-family: var(--font-display); }

/* ---------------- Sequence ---------------- */
.seq-pads { display: grid; grid-template-columns: repeat(auto-fit, minmax(90px, 1fr)); gap: 12px; margin: 14px 0; }
.seq-pad { padding: 26px 10px; border: none; border-radius: 14px; color: #fff; font-size: 1.1rem; font-weight: 800; font-family: var(--font-display); cursor: pointer; background: var(--blue); box-shadow: 0 5px 0 rgba(0,0,0,0.15); transition: transform 0.08s ease, filter 0.1s ease; }
.seq-pad:hover { transform: translateY(-2px); }
.seq-pad:active { transform: translateY(2px); box-shadow: 0 3px 0 rgba(0,0,0,0.15); filter: brightness(1.15); }
.sequence-entered { min-height: 28px; margin: 10px 0; padding: 12px 14px; background: var(--bg-tint); border-radius: var(--radius-sm); font-weight: 700; }
.sequence-hint { color: var(--ink-soft); font-size: 0.9rem; }
.sequence-controls { display: flex; gap: 10px; }

/* ---------------- Hidden clue ---------------- */
.clue-image { max-width: 100%; border-radius: var(--radius-sm); margin: 8px 0; border: 2px solid var(--line); }
.search-where { background: #dbeafe; border-left: 5px solid var(--blue); padding: 10px 14px; border-radius: var(--radius-sm); margin: 8px 0; font-weight: 700; }

/* ---------------- Geo check ---------------- */
.geo-status { margin: 12px 0; padding: 12px 14px; background: var(--bg-tint); border-radius: var(--radius-sm); }
.geo-override { font-size: 0.85rem; }

/* ---------------- Non-linear board ---------------- */
.board-intro { text-align: center; color: var(--ink-soft); margin-bottom: 16px; font-weight: 700; }
.board { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 20px; align-items: start; }
.board .puzzle-card { margin: 0; border-left-color: var(--grape); }
.puzzle-card.solved { border-color: var(--green); border-left-color: var(--green); }
.solved-badge { display: inline-block; background: #dff5e6; color: #12633a; border-left: 5px solid var(--green); padding: 6px 12px; border-radius: 8px; font-weight: 800; margin-bottom: 10px; }
.solved-note { color: var(--ink-soft); }

/* ---------------- Results dashboard ---------------- */
.results-toolbar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.results-toolbar-actions { display: flex; gap: 8px; margin-left: auto; flex-wrap: wrap; }
.results-count { color: var(--ink-soft); font-weight: 700; }
.btn.danger { background: var(--surface); color: var(--red); border: 2px solid #f3c6be; box-shadow: 0 3px 0 #f3c6be; }
.btn.danger:hover:not(:disabled) { background: #fde4e0; }
.results-table-wrap { overflow-x: auto; background: var(--surface); border-radius: var(--radius); padding: 8px; box-shadow: var(--shadow); border: 3px solid var(--line); }
.results-table { border-collapse: collapse; width: 100%; font-size: 0.9rem; }
.results-table th, .results-table td { border: 1px solid var(--line); padding: 9px 11px; text-align: left; vertical-align: top; }
.results-table th { background: var(--bg-tint); color: var(--ink); white-space: nowrap; font-family: var(--font-display); }
.results-empty { color: var(--ink-soft); }

/* ---------------- Victory ---------------- */
.victory {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 30px;
  box-shadow: var(--shadow-lg);
  text-align: center;
  border: 3px solid var(--line);
  border-top: 10px solid var(--green);
}
.victory-badge { font-size: 3.6rem; }
.victory-title { color: var(--ink); margin: 6px 0; }
.victory-message { max-width: 560px; margin: 8px auto; color: var(--ink-soft); }
.victory-time { font-weight: 800; font-size: 1.25rem; margin: 14px 0; font-family: var(--font-display); color: var(--coral); }
.victory-card { background: var(--bg-tint); border-radius: var(--radius-sm); padding: 18px; margin: 16px auto; max-width: 560px; text-align: left; }
.victory-card h3 { margin-top: 0; color: var(--ink); }
.victory-bonus-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 10px; }
.victory-bonus .btn { width: 100%; }
.results-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 10px; }
.results-line { margin: 4px 0; font-weight: 700; }
.sink-notes { display: flex; gap: 8px; flex-wrap: wrap; margin: 6px 0; }
.sink-note { font-size: 0.8rem; padding: 3px 10px; border-radius: var(--pill); background: var(--line); }
.sink-note.ok { background: #dff5e6; color: #12633a; }
.sink-note.fail { background: #fde4e0; color: #9a2c1e; }

.not-found { text-align: center; padding: 60px 20px; }

.fade-in { animation: fadeIn 0.4s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: translateY(0); } }

@media (max-width: 560px) {
  body { padding: 14px; }
  .member-row { grid-template-columns: 1fr; }
  .member-index { display: none; }
  .runner-title { white-space: normal; }
  .hub-title { font-size: 1.9rem; }
}
