:root {
  --bg: #f4f6f8;
  --panel: #ffffff;
  --ink: #17212b;
  --muted: #64727f;
  --line: #d9e1e8;
  --accent: #187083;
  --accent-dark: #0f5665;
  --warn: #a95d00;
  --bad: #b93232;
  --good: #19734f;
  --shadow: 0 16px 38px rgba(24, 36, 48, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: system-ui, -apple-system, "Microsoft YaHei", "PingFang SC", sans-serif;
}

button,
input {
  font: inherit;
}

.shell,
.admin-shell {
  width: min(1160px, calc(100vw - 28px));
  margin: 0 auto;
  padding: 26px 0;
}

.screen {
  display: none;
}

.screen.is-active {
  display: block;
}

.brand-block,
.topline,
.test-header {
  margin-bottom: 18px;
}

.brand-block {
  max-width: 760px;
}

.brand-block p,
.message,
.loading-msg,
.result-message,
.rank-label {
  color: var(--muted);
  line-height: 1.65;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent-dark);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: 30px;
  line-height: 1.18;
}

h2 {
  font-size: 24px;
}

.panel,
.image-card,
.answer-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.form-panel {
  max-width: 460px;
  padding: 20px;
  display: grid;
  gap: 14px;
}

label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-weight: 700;
}

input {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 12px;
  background: #fbfcfd;
  color: var(--ink);
}

.primary-btn,
.ghost-btn,
.ghost-link {
  min-height: 44px;
  border-radius: 6px;
  border: 1px solid transparent;
  padding: 0 16px;
  font-weight: 800;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.primary-btn {
  background: var(--accent);
  color: #fff;
}

.primary-btn:hover {
  background: var(--accent-dark);
}

.primary-btn:disabled,
.ghost-btn:disabled {
  opacity: .46;
  cursor: not-allowed;
}

.ghost-btn,
.ghost-link {
  color: var(--accent-dark);
  background: #eef8fa;
  border-color: #c8e3e9;
}

.topline,
.test-header,
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.test-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 380px;
  gap: 18px;
  align-items: start;
}

.image-card {
  margin: 0;
  min-height: 420px;
  padding: 14px;
  display: grid;
  place-items: center;
}

.image-card img {
  width: 100%;
  max-height: min(72vh, 690px);
  object-fit: contain;
  display: block;
}

.answer-card {
  padding: 14px;
  position: sticky;
  top: 16px;
}

.option-grid {
  display: grid;
  gap: 8px;
}

.option-btn {
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fbfcfd;
  color: var(--ink);
  text-align: left;
  padding: 10px 12px;
  cursor: pointer;
  font-weight: 800;
}

.option-btn:hover {
  border-color: var(--accent);
}

.option-btn.is-selected {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 2px var(--accent);
}

.option-btn:disabled {
  opacity: .58;
  cursor: not-allowed;
}

.action-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 14px;
}

.inline-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 0;
}

.timer-box {
  min-width: 92px;
  min-height: 70px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  display: grid;
  place-items: center;
  box-shadow: var(--shadow);
}

.timer-box span {
  font-size: 30px;
  font-weight: 900;
  line-height: 1;
}

.timer-box.is-warning span {
  color: var(--warn);
}

.timer-box.is-critical span {
  color: var(--bad);
}

.timer-box small {
  color: var(--muted);
  font-size: 12px;
}

.progress-track {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: #dbe5eb;
  margin: 0 0 14px;
}

#timerBar {
  width: 0%;
  height: 100%;
  background: var(--accent);
  transition: width .2s linear;
}

.loading-msg {
  min-height: 24px;
  margin: 0 0 12px;
}

.feedback {
  margin-top: 12px;
  padding: 12px;
  border-radius: 6px;
  background: #f3f6f8;
  color: var(--muted);
  display: none;
}

.feedback.is-good {
  color: var(--good);
  background: #e9f6ef;
}

.feedback.is-bad {
  color: var(--bad);
  background: #faecec;
}

.result-hero {
  max-width: 620px;
  padding: 28px;
}

.score-number {
  font-size: 76px;
  font-weight: 900;
  line-height: 1;
  margin: 18px 0 10px;
  color: var(--accent-dark);
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(130px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.stat-card {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.stat-card strong {
  display: block;
  font-size: 28px;
}

.stat-card span {
  color: var(--muted);
  font-size: 13px;
}

.admin-panel {
  padding: 16px;
  margin-bottom: 16px;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 9px 8px;
  text-align: left;
  white-space: nowrap;
}

th {
  color: var(--muted);
  font-size: 12px;
}

.mini-btn {
  min-height: 30px;
  padding: 0 10px;
  border-radius: 5px;
  border: 1px solid var(--line);
  background: #fbfcfd;
  cursor: pointer;
}

.detail-box {
  display: grid;
  gap: 10px;
}

.detail-item {
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fbfcfd;
}

.code-output {
  min-height: 70px;
  padding: 12px;
  border-radius: 6px;
  background: #111b24;
  color: #e9f2f8;
  white-space: pre-wrap;
}

.message.is-error {
  color: var(--bad);
}

.message.is-ok {
  color: var(--good);
}

@media (max-width: 900px) {
  .test-layout,
  .stat-grid {
    grid-template-columns: 1fr;
  }

  .answer-card {
    position: static;
  }
}

@media (max-width: 560px) {
  .shell,
  .admin-shell {
    width: min(100vw - 18px, 1160px);
    padding: 16px 0;
  }

  h1 {
    font-size: 24px;
  }

  h2 {
    font-size: 21px;
  }

  .topline,
  .test-header,
  .panel-head {
    align-items: stretch;
    flex-direction: column;
  }

  .image-card {
    min-height: 260px;
  }

  .action-row {
    grid-template-columns: 1fr;
  }
}
