:root {
  --navy: #062c43;
  --navy-soft: #0a4255;
  --cream: #eef7f4;
  --paper: #ffffff;
  --ink: #17313f;
  --muted: #657684;
  --line: #d8e7e2;
  --teal: #006b68;
  --teal-light: #dff2ee;
  --orange: #f2a51a;
  --coral: #df4d2f;
  --shadow: 0 20px 50px rgba(0, 75, 83, 0.1);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, .72), rgba(238, 247, 244, .96)),
    var(--cream);
  color: var(--ink);
  font-family: "DM Sans", Arial, sans-serif;
}
button { font: inherit; cursor: pointer; }
.hidden { display: none !important; }

.topbar {
  align-items: center;
  background: var(--paper);
  border-bottom: 4px solid var(--orange);
  color: var(--ink);
  display: flex;
  justify-content: space-between;
  padding: 16px max(24px, calc((100vw - 1240px) / 2));
}
.brand { align-items: center; color: inherit; display: flex; gap: 12px; text-decoration: none; }
.brand-mark {
  align-items: center; background: var(--paper); border: 1px solid var(--line); border-radius: 8px; display: flex; font-family: "Space Grotesk";
  font-size: 13px; font-weight: 700; height: 46px; justify-content: center; letter-spacing: 0; overflow: hidden; width: 60px;
}
.brand-mark img { display: block; height: 100%; object-fit: contain; padding: 4px; width: 100%; }
.brand strong, .brand small { display: block; }
.brand strong { font-family: "Space Grotesk"; font-size: 16px; letter-spacing: 0; }
.brand small { color: var(--muted); font-size: 11px; margin-top: 2px; text-transform: uppercase; letter-spacing: 1px; }
.ghost-button { background: transparent; border: 1px solid var(--line); border-radius: 8px; color: var(--teal); padding: 8px 12px; text-decoration: none; }
.ghost-button:hover { border-color: var(--teal); }
.header-actions { display: flex; gap: 8px; }
.player-badge { color: var(--teal); font-size: 11px; font-weight: 700; letter-spacing: 1px; text-transform: uppercase; }

.page-shell { margin: auto; max-width: 1240px; padding: 52px 24px 72px; }
.login-shell { display: grid; min-height: calc(100vh - 70px); place-items: center; }
.login-panel { box-shadow: var(--shadow); max-width: 480px; }
.login-panel h1 { font-size: 38px; letter-spacing: 0; }
.hero { align-items: end; display: flex; justify-content: space-between; margin-bottom: 26px; }
.eyebrow, .card-label { color: var(--teal); font-size: 11px; font-weight: 700; letter-spacing: 1.5px; margin: 0 0 8px; text-transform: uppercase; }
h1, h2 { font-family: "Space Grotesk"; margin: 0; }
h1 { font-size: clamp(31px, 4vw, 48px); letter-spacing: 0; max-width: 730px; }
h2 { font-size: 20px; letter-spacing: 0; }
.question-counter { color: var(--orange); font-family: "Space Grotesk"; }
.question-counter span { font-size: 49px; font-weight: 700; letter-spacing: 0; }
.question-counter small { color: var(--muted); font-size: 16px; font-weight: 600; }

.quiz-layout { align-items: start; display: grid; gap: 22px; grid-template-columns: minmax(0, 1fr) 310px; }
.main-column { display: grid; gap: 20px; }
.scenario-card, .decision-card, .results-card, .status-card {
  background: var(--paper); border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--shadow);
}
.scenario-card { border-left: 5px solid var(--orange); padding: 24px 27px; }
.scenario-card p { font-size: 17px; line-height: 1.65; margin: 0; white-space: pre-line; }
.scenario-grid { align-items: start; display: grid; gap: 24px; grid-template-columns: minmax(0, 1fr) 150px; }
.clock-panel {
  align-self: start; background: #f6fbf9; border: 1px solid var(--line); border-radius: 8px; margin: 0;
  overflow: hidden; padding: 10px; text-align: center;
}
.clock-panel img { display: block; height: auto; width: 100%; }
.clock-panel figcaption { display: grid; gap: 2px; padding: 2px 0 4px; }
.clock-panel strong { color: var(--teal); font-family: "Space Grotesk"; font-size: 20px; }
.clock-panel span { color: var(--muted); font-size: 13px; font-weight: 700; }
.decision-card, .results-card { padding: 26px; }
.section-heading { align-items: center; display: flex; gap: 16px; justify-content: space-between; }
.text-button { background: transparent; border: 0; color: var(--teal); font-weight: 700; padding: 4px; }
.text-button:hover { text-decoration: underline; }

.options-list { display: grid; gap: 11px; margin-top: 22px; }
.option {
  align-items: flex-start; background: #fff; border: 1px solid var(--line); border-radius: 10px; color: var(--ink);
  display: flex; gap: 14px; padding: 15px; text-align: left; transition: border-color .15s, transform .15s, background .15s;
}
.option:hover { border-color: var(--teal); transform: translateY(-1px); }
.option.selected { background: var(--teal-light); border-color: var(--teal); }
.option-marker {
  align-items: center; border: 1px solid #c7c9c4; border-radius: 50%; display: flex; flex: 0 0 auto; font-size: 12px;
  font-weight: 700; height: 26px; justify-content: center; width: 26px;
}
.option.selected .option-marker { background: var(--teal); border-color: var(--teal); color: white; }
.submit-row { align-items: center; display: flex; gap: 16px; justify-content: space-between; margin-top: 18px; }
.helper-text { color: var(--muted); font-size: 13px; margin: 0; }
.custom-answer { display: grid; gap: 8px; margin-top: 14px; }
.custom-answer span { color: var(--muted); font-size: 12px; font-weight: 700; text-transform: uppercase; }
.custom-answer textarea {
  background: #fff; border: 1px solid var(--line); border-radius: 8px; color: var(--ink); font: inherit;
  line-height: 1.45; padding: 12px; resize: vertical; width: 100%;
}
.custom-answer textarea:focus { border-color: var(--teal); outline: 3px solid var(--teal-light); }
.primary-button {
  background: var(--teal); border: 0; border-radius: 8px; color: white; font-weight: 700; padding: 12px 18px;
}
.primary-button:hover { background: var(--navy-soft); }
.primary-button:disabled { cursor: not-allowed; opacity: .45; }
.secondary-button {
  background: #fff; border: 1px solid var(--line); border-radius: 8px; color: var(--ink); font-weight: 700; padding: 11px 15px;
}
.secondary-button:hover { border-color: var(--teal); color: var(--teal); }
.waiting-panel { padding: 44px 20px 32px; text-align: center; }
.waiting-icon {
  align-items: center; background: var(--teal-light); border-radius: 50%; color: var(--teal); display: flex; font-size: 28px;
  height: 58px; justify-content: center; margin: 0 auto 15px; width: 58px;
}
.waiting-panel h3 { font-family: "Space Grotesk"; margin: 0 0 6px; }
.waiting-panel p { color: var(--muted); margin: 0; }
.waiting-panel .primary-button, .waiting-panel .secondary-button { margin-top: 18px; }
.waiting-panel .primary-button + .secondary-button { margin-left: 10px; }
.analysis-actions { display: grid; gap: 9px; grid-template-columns: repeat(3, minmax(0, 1fr)); margin-top: 18px; }
.analysis-actions .secondary-button { margin-top: 0; width: 100%; }

.status-card { padding: 22px; position: sticky; top: 20px; }
.status-count { color: var(--coral); font-family: "Space Grotesk"; font-size: 20px; }
.progress-track { background: #ebe7de; border-radius: 9px; height: 6px; margin: 18px 0; overflow: hidden; }
.progress-track span { background: var(--teal); display: block; height: 100%; transition: width .25s; width: 0; }
.role-status-list { display: grid; gap: 6px; }
.role-status {
  align-items: center; border-radius: 8px; display: flex; gap: 10px; padding: 8px 6px; transition: background .2s;
}
.role-status.answered { background: #f0f7f3; }
.status-dot { background: #d6d4ce; border-radius: 50%; height: 9px; width: 9px; }
.answered .status-dot { background: var(--teal); }
.role-status strong { font-size: 13px; width: 58px; }
.role-status small { color: var(--muted); font-size: 11px; }

.results-intro { color: var(--muted); font-size: 14px; margin: 8px 0 20px; }
.results-grid { display: grid; gap: 10px; grid-template-columns: repeat(3, minmax(0, 1fr)); }
.result-item { background: #f8f7f2; border: 1px solid var(--line); border-radius: 9px; padding: 14px; }
.result-item strong { color: var(--teal); display: block; font-family: "Space Grotesk"; font-size: 14px; margin-bottom: 5px; }
.result-item p { font-size: 12px; line-height: 1.45; margin: 0; }
.result-item small { color: var(--orange); display: block; font-size: 10px; font-weight: 700; margin-top: 8px; text-transform: uppercase; }
.complete-pill { background: var(--teal-light); border-radius: 20px; color: var(--teal); font-size: 12px; font-weight: 700; padding: 7px 11px; }
.next-button { display: block; margin: 20px 0 0 auto; }
.next-button span { font-size: 19px; margin-left: 6px; }
.admin-controls { align-items: center; display: flex; gap: 10px; justify-content: flex-end; margin-top: 20px; }
.admin-controls .next-button { margin: 0; }
.question-reset { align-items: center; display: flex; gap: 8px; }
.question-reset span { color: var(--muted); font-size: 11px; font-weight: 700; text-transform: uppercase; }
.question-reset select {
  background: #fff; border: 1px solid var(--line); border-radius: 8px; color: var(--ink); font: inherit;
  min-height: 41px; padding: 8px 10px;
}
.question-reset select:focus { border-color: var(--teal); outline: 3px solid var(--teal-light); }

.modal-backdrop {
  align-items: center; background: rgba(11, 19, 36, .72); display: flex; inset: 0; justify-content: center;
  padding: 18px; position: fixed; z-index: 5;
}
.role-modal, .analysis-modal { background: var(--paper); border-radius: 8px; max-width: 760px; padding: 28px; width: 100%; }
.role-modal h2 { font-size: 28px; }
.role-modal > p { color: var(--muted); line-height: 1.5; margin: 8px 0 22px; }
.analysis-modal { max-height: calc(100vh - 36px); overflow-y: auto; }
.analysis-output {
  background: #f8fbfa; border: 1px solid var(--line); border-radius: 8px; color: var(--ink);
  line-height: 1.55; margin-top: 18px; padding: 16px; white-space: pre-wrap;
}
.role-grid { display: grid; gap: 10px; grid-template-columns: repeat(3, 1fr); }
.auth-form { display: grid; gap: 13px; margin-top: 20px; }
.auth-form label { display: grid; gap: 6px; }
.auth-form label span { color: var(--muted); font-size: 12px; font-weight: 700; text-transform: uppercase; }
.auth-form input {
  background: #fff; border: 1px solid var(--line); border-radius: 8px; color: var(--ink); font: inherit; padding: 12px;
}
.auth-form input:focus { border-color: var(--teal); outline: 3px solid var(--teal-light); }
.role-button { background: white; border: 1px solid var(--line); border-radius: 10px; padding: 13px; text-align: left; }
.role-button:hover { border-color: var(--teal); }
.role-button strong, .role-button small { display: block; }
.role-button strong { color: var(--teal); font-family: "Space Grotesk"; font-size: 16px; }
.role-button small { color: var(--muted); font-size: 11px; line-height: 1.3; margin-top: 3px; }
.role-button.taken { background: #f3f1ec; }
.role-button.taken::after { color: var(--orange); content: "Answered"; display: block; font-size: 10px; font-weight: 700; margin-top: 7px; text-transform: uppercase; }
.toast {
  background: var(--navy); border-radius: 8px; bottom: 18px; color: white; font-size: 14px; left: 50%; opacity: 0;
  padding: 11px 15px; pointer-events: none; position: fixed; transform: translate(-50%, 15px); transition: .2s; z-index: 10;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 850px) {
  .page-shell { padding: 35px 18px 55px; }
  .quiz-layout { grid-template-columns: 1fr; }
  .status-card { position: static; }
  .role-status-list { grid-template-columns: repeat(3, 1fr); }
  .scenario-grid { grid-template-columns: 1fr; }
  .clock-panel { max-width: 180px; }
  .role-status small { display: none; }
  .results-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 520px) {
  .topbar { padding: 13px 16px; }
  .header-actions { align-items: flex-end; flex-direction: column; }
  .brand small { display: none; }
  .ghost-button { font-size: 12px; }
  .hero { align-items: start; gap: 10px; }
  h1 { font-size: 30px; letter-spacing: 0; }
  .question-counter span { font-size: 37px; }
  .scenario-card { padding: 19px; }
  .scenario-card p { font-size: 15px; }
  .clock-panel { max-width: 150px; }
  .decision-card, .results-card { padding: 19px; }
  .submit-row { align-items: stretch; flex-direction: column; }
  .primary-button { width: 100%; }
  .waiting-panel .primary-button + .secondary-button { margin-left: 0; }
  .admin-controls { align-items: stretch; flex-direction: column; }
  .question-reset { align-items: stretch; flex-direction: column; gap: 6px; }
  .secondary-button { width: 100%; }
  .analysis-actions { grid-template-columns: 1fr; }
  .role-grid { grid-template-columns: repeat(2, 1fr); }
  .role-modal { max-height: calc(100vh - 30px); overflow-y: auto; padding: 21px; }
  .role-modal h2 { font-size: 24px; }
  .results-grid { grid-template-columns: 1fr; }
}
