:root {
  --bg: #f6f8f9;
  --panel: #ffffff;
  --ink: #152024;
  --muted: #5f6f75;
  --line: #d8e1e4;
  --accent: #0f766e;
  --accent-dark: #0b5f59;
  --accent-soft: #e6f4f1;
  --input: #ffffff;
  --hover: #fbfefd;
  --sticky: rgba(255, 255, 255, 0.96);
  --warning: #b45309;
  --danger: #b91c1c;
  --shadow: 0 18px 45px rgba(18, 38, 45, 0.08);
}

:root[data-theme="dark"] {
  --bg: #101617;
  --panel: #172123;
  --ink: #edf4f3;
  --muted: #a6b7b6;
  --line: #2a3a3d;
  --accent: #5dd3c4;
  --accent-dark: #87e3d8;
  --accent-soft: #173934;
  --input: #101819;
  --hover: #122425;
  --sticky: rgba(23, 33, 35, 0.96);
  --warning: #f6b44b;
  --danger: #ff8c8c;
  --shadow: 0 18px 45px rgba(0, 0, 0, 0.28);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    --bg: #101617;
    --panel: #172123;
    --ink: #edf4f3;
    --muted: #a6b7b6;
    --line: #2a3a3d;
    --accent: #5dd3c4;
    --accent-dark: #87e3d8;
    --accent-soft: #173934;
    --input: #101819;
    --hover: #122425;
    --sticky: rgba(23, 33, 35, 0.96);
    --warning: #f6b44b;
    --danger: #ff8c8c;
    --shadow: 0 18px 45px rgba(0, 0, 0, 0.28);
  }
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
}

body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.5 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  transition: background 180ms ease, color 180ms ease;
}

button,
input {
  font: inherit;
}

button {
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  font-weight: 700;
  padding: 0.85rem 1rem;
  transition: background 160ms ease, color 160ms ease, border-color 160ms ease, transform 160ms ease;
}

button:hover {
  background: var(--accent-dark);
  transform: translateY(-1px);
}

button:disabled {
  background: #93a4a8;
  cursor: not-allowed;
}

.ghost-button,
.link-button {
  border: 1px solid var(--line);
  background: transparent;
  color: var(--accent-dark);
}

.ghost-button:hover,
.link-button:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-dark);
}

.link-button {
  padding: 0;
  border: 0;
  border-radius: 0;
  font-weight: 800;
}

.link-button:hover {
  background: transparent;
  text-decoration: underline;
  transform: none;
}

.shell {
  width: min(980px, calc(100% - 28px));
  margin: 0 auto;
  padding: 24px 0 42px;
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
}

.top-actions {
  display: grid;
  justify-items: end;
  gap: 10px;
}

.theme-toggle {
  display: inline-grid;
  width: 36px;
  height: 36px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
  color: var(--muted);
  padding: 0;
  font-size: 1rem;
  line-height: 1;
}

.theme-toggle:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-dark);
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--accent);
  font-size: 0.82rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: clamp(1.55rem, 3vw, 2.35rem);
  line-height: 1.12;
  letter-spacing: 0;
}

.subtitle {
  margin: 8px 0 0;
  color: var(--muted);
  max-width: 720px;
}

.window-info {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.timer {
  min-width: 148px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  padding: 12px 14px;
  text-align: right;
}

.timer-label {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
}

.timer strong {
  display: block;
  font-size: 1.8rem;
  line-height: 1.1;
}

.timer.late {
  border-color: #f59e0b;
  color: var(--warning);
}

.timer.closed {
  border-color: #ef4444;
  color: var(--danger);
}

.panel,
.notice,
.result-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  animation: rise 220ms ease both;
}

.panel {
  padding: 22px;
}

.notice {
  margin-bottom: 16px;
  padding: 14px 16px;
  color: var(--muted);
}

.notice.error {
  border-color: #fca5a5;
  background: #fff7f7;
  color: var(--danger);
}

:root[data-theme="dark"] .notice.error {
  background: #321a1a;
}

.notice.success {
  border-color: #99d8c9;
  background: var(--accent-soft);
  color: var(--accent-dark);
}

.result-panel {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: center;
  margin-bottom: 16px;
  padding: 14px 16px;
}

.result-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.result-panel p {
  margin: 3px 0 0;
  color: var(--muted);
}

.report-button {
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  padding: 0.72rem 0.9rem;
  text-decoration: none;
  font-weight: 800;
  white-space: nowrap;
}

.report-button:hover {
  background: var(--accent-dark);
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 20;
  max-width: min(360px, calc(100vw - 36px));
  border: 1px solid #99d8c9;
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  color: var(--ink);
  padding: 12px 14px;
  font-weight: 800;
  animation: toast-in 180ms ease both;
}

.toast.success {
  background: var(--accent-soft);
  color: var(--accent-dark);
}

.toast.error {
  border-color: #fca5a5;
  color: var(--danger);
}

.login-form label {
  display: block;
  margin-bottom: 8px;
  font-weight: 800;
}

.login-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
}

input[type="text"] {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--input);
  color: var(--ink);
  padding: 0.82rem 0.9rem;
}

input[type="text"]:focus,
input[type="radio"]:focus-visible,
button:focus-visible {
  outline: 3px solid rgba(15, 118, 110, 0.22);
  outline-offset: 2px;
}

.hint,
#submitHint {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 0.94rem;
}

.remembered {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 12px;
  color: var(--muted);
  font-size: 0.92rem;
}

.quiz-meta {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.quiz-meta > div {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 11px 12px;
}

.label {
  display: block;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 800;
  text-transform: uppercase;
}

.instructions {
  display: grid;
  gap: 8px;
  margin-bottom: 16px;
  color: var(--muted);
}

.instructions p {
  margin: 0;
}

.resources {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 18px;
}

.resources a {
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--accent-dark);
  padding: 0.35rem 0.7rem;
  text-decoration: none;
  transition: background 160ms ease, border-color 160ms ease;
}

.resources a:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.question {
  border-top: 1px solid var(--line);
  padding: 20px 0;
}

.question:first-child {
  border-top: 0;
  padding-top: 0;
}

.question h2 {
  margin: 0 0 14px;
  font-size: 1.05rem;
  line-height: 1.45;
}

.points {
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 700;
}

.options {
  display: grid;
  gap: 10px;
}

.option {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 10px;
  align-items: start;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  cursor: pointer;
  transition: background 160ms ease, border-color 160ms ease, transform 160ms ease;
}

.option:hover {
  border-color: #9fc9c3;
  background: var(--hover);
  transform: translateY(-1px);
}

.option:has(input:checked) {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.option.correct {
  border-color: #0f766e;
}

.option.wrong {
  border-color: #ef4444;
}

.option input {
  margin-top: 0.25rem;
}

.solution {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 0.94rem;
}

.solution.ok {
  color: var(--accent-dark);
}

.solution.no {
  color: var(--danger);
}

.submit-row {
  position: sticky;
  bottom: 0;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 14px;
  align-items: center;
  border-top: 1px solid var(--line);
  background: var(--sticky);
  padding: 16px 0 0;
}

.site-footer {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-top: 18px;
  color: var(--muted);
  font-size: 0.86rem;
}

.site-footer a {
  color: var(--accent-dark);
  text-decoration: none;
}

.site-footer a:hover {
  text-decoration: underline;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.session-list {
  margin: 12px 0 0;
  padding-left: 1.2rem;
}

.session-list span {
  color: var(--muted);
}

@media (max-width: 720px) {
  .shell {
    width: min(100% - 20px, 980px);
    padding-top: 14px;
  }

  .topbar,
  .top-actions,
  .login-row,
  .quiz-meta,
  .result-panel,
  .submit-row {
    grid-template-columns: 1fr;
  }

  .topbar {
    display: grid;
  }

  .timer {
    width: 100%;
    text-align: left;
  }

  .top-actions {
    justify-items: stretch;
  }

  .panel {
    padding: 16px;
  }

  .submit-row {
    position: static;
  }

  .site-footer {
    display: grid;
    text-align: center;
  }

  .result-panel {
    display: grid;
  }

  .result-actions {
    display: grid;
    justify-content: stretch;
  }

  .report-button,
  .ghost-button {
    text-align: center;
  }

  .toast {
    right: 10px;
    bottom: 10px;
    max-width: calc(100vw - 20px);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}
