:root {
  color-scheme: dark;
  --ink: #f7fbff;
  --muted: #a8b3c8;
  --line: rgba(167, 185, 214, 0.2);
  --panel: rgba(16, 20, 31, 0.92);
  --panel-strong: #151b2a;
  --paper: #090b10;
  --accent: #00d9ff;
  --accent-dark: #0098ff;
  --accent-soft: rgba(0, 217, 255, 0.14);
  --pink: #ff3d8f;
  --yellow: #ffe156;
  --mint: #26e6a3;
  --soft-warm: rgba(255, 225, 86, 0.14);
  --danger: #ff355d;
  --ok: #26e6a3;
  --shadow: 0 22px 60px rgba(0, 0, 0, 0.38);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    repeating-linear-gradient(135deg, rgba(255, 255, 255, 0.035) 0 2px, transparent 2px 24px),
    linear-gradient(115deg, rgba(0, 217, 255, 0.22), transparent 32%),
    linear-gradient(72deg, transparent 48%, rgba(255, 61, 143, 0.2) 72%, rgba(255, 225, 86, 0.12)),
    var(--paper);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

a {
  color: inherit;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  min-height: 44px;
  border: 0;
  border-radius: 8px;
  padding: 0 14px;
  color: #071018;
  background: linear-gradient(135deg, var(--accent), var(--yellow));
  cursor: pointer;
  font-weight: 800;
  letter-spacing: 0;
  box-shadow: 0 10px 24px rgba(0, 217, 255, 0.24);
  transition: transform 140ms ease, background 140ms ease, box-shadow 140ms ease;
}

button:hover {
  background: linear-gradient(135deg, var(--accent-dark), var(--pink));
  color: #ffffff;
  transform: translateY(-1px);
  box-shadow: 0 14px 32px rgba(255, 61, 143, 0.28);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
  transform: none;
}

.button-link {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  padding: 0 14px;
  color: #071018;
  background: linear-gradient(135deg, var(--accent), var(--yellow));
  text-decoration: none;
  font-weight: 800;
}

.button-link:hover {
  background: linear-gradient(135deg, var(--accent-dark), var(--pink));
  color: #fff;
}

button.secondary {
  color: var(--ink);
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--line);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.04);
}

button.secondary:hover {
  background: rgba(0, 217, 255, 0.14);
  color: var(--ink);
}

button.danger {
  background: linear-gradient(135deg, var(--danger), #ff6b35);
  color: #fff;
}

input,
select,
textarea {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  background: rgba(255, 255, 255, 0.07);
  color: var(--ink);
}

input:focus,
select:focus,
textarea:focus {
  outline: 3px solid rgba(0, 217, 255, 0.22);
  border-color: rgba(0, 217, 255, 0.65);
}

input::placeholder,
textarea::placeholder {
  color: rgba(247, 251, 255, 0.48);
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.9rem;
}

.topbar {
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  color: #ffffff;
  background: rgba(6, 8, 14, 0.94);
  border-bottom: 1px solid rgba(0, 163, 255, 0.32);
  box-shadow: 0 10px 35px rgba(0, 0, 0, 0.28);
  backdrop-filter: blur(14px);
}

.brand {
  font-size: 1.35rem;
  font-weight: 800;
  text-decoration: none;
  color: #fff;
  letter-spacing: 0;
}

.brand::after {
  content: "";
  display: inline-block;
  width: 34px;
  height: 4px;
  margin-left: 10px;
  vertical-align: middle;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent), var(--pink), var(--yellow));
}

.topbar nav {
  display: flex;
  gap: 16px;
}

.topbar nav a {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 0 12px;
  color: rgba(255, 255, 255, 0.82);
  text-decoration: none;
  transition: background 140ms ease, color 140ms ease;
}

.topbar nav a:hover {
  color: #071018;
  background: var(--yellow);
}

.shell {
  width: min(1180px, calc(100vw - 32px));
  margin: 28px auto;
}

.start-screen {
  position: fixed;
  inset: 60px 0 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 20px;
  background:
    linear-gradient(135deg, rgba(0, 163, 255, 0.28), rgba(255, 61, 113, 0.18) 52%, rgba(255, 209, 102, 0.2)),
    rgba(10, 13, 22, 0.86);
  backdrop-filter: blur(12px);
}

.start-card {
  width: min(420px, 100%);
  display: grid;
  gap: 16px;
  padding: 24px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  border-top: 6px solid var(--pink);
  box-shadow: var(--shadow);
}

.start-card h1 {
  font-size: 3.4rem;
}

.quiz-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 380px;
  gap: 22px;
}

.quiz-panel,
.result-panel,
.toolbar,
.list-panel,
.editor-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}

.quiz-panel {
  padding: 22px;
  border-top: 6px solid var(--pink);
}

.quiz-header {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

h1 {
  margin: 0;
  font-size: 4.6rem;
  letter-spacing: 0;
  line-height: 0.92;
  color: var(--ink);
  text-shadow: 0 10px 28px rgba(0, 0, 0, 0.34);
}

.quiz-controls {
  display: grid;
  grid-template-columns: repeat(2, minmax(130px, 1fr));
  gap: 10px;
  width: min(520px, 100%);
}

.quiz-controls label {
  color: var(--muted);
  font-weight: 700;
}

.brand-filter {
  margin: 0 0 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.06);
}

.brand-filter summary {
  cursor: pointer;
  color: var(--muted);
}

.brand-options {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.brand-options label {
  display: inline-flex;
  grid-template-columns: none;
  align-items: center;
  gap: 6px;
  min-height: 34px;
  padding: 6px 9px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.06);
}

.brand-options input {
  width: auto;
  min-height: auto;
}

.qcm-panel {
  display: grid;
  gap: 10px;
  margin-top: 16px;
}

.qcm-panel h2 {
  margin: 0;
  font-size: 1.2rem;
}

.qcm-options {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.qcm-options button {
  min-height: 56px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.07);
  text-align: left;
  border: 1px solid var(--line);
  box-shadow: none;
}

.qcm-options button:hover {
  background: var(--accent-soft);
  border-color: rgba(0, 163, 255, 0.45);
  color: var(--ink);
}

.qcm-options button.active {
  outline: 3px solid rgba(0, 163, 255, 0.34);
  background: var(--accent-soft);
  border-color: var(--accent);
}

.crop-frame {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  display: grid;
  place-items: center;
  background: #0b1020;
  border-radius: 8px;
  border: 1px solid rgba(0, 217, 255, 0.24);
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.05),
    0 18px 42px rgba(3, 7, 18, 0.32);
}

.crop-frame img {
  position: absolute;
  max-width: none;
  max-height: none;
  cursor: zoom-in;
}

.crop-frame img.full-image {
  position: static;
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.hint-panel {
  display: grid;
  gap: 8px;
  margin-top: 14px;
  padding: 12px;
  border: 1px solid rgba(255, 225, 86, 0.52);
  border-radius: 8px;
  background: var(--soft-warm);
}

.hint-panel p {
  margin: 0;
  color: #ffeaa0;
  font-weight: 650;
}

.scoreline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 16px;
  color: var(--muted);
}

.scoreline span {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  padding: 0 10px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--ink);
  font-weight: 750;
}

.quiz-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.result-panel {
  padding: 14px;
  align-self: start;
  border-top: 6px solid var(--yellow);
}

.result-panel img {
  width: 100%;
  border-radius: 8px;
  display: block;
  background: #111;
  cursor: zoom-in;
}

.image-lightbox {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 64px 18px 18px;
  background: rgba(8, 11, 24, 0.88);
}

.image-lightbox.hidden {
  display: none;
}

.image-lightbox img {
  max-width: min(1200px, 96vw);
  max-height: 86vh;
  object-fit: contain;
  border-radius: 8px;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.45);
  background: #0b1020;
}

.lightbox-close {
  position: fixed;
  top: 16px;
  right: 16px;
  background: #ffffff;
  color: #101828;
}

.waiting-panel {
  display: grid;
  align-content: center;
  min-height: 260px;
  background: var(--panel);
}

.result-panel h2 {
  margin: 12px 0 4px;
  font-size: 1.35rem;
}

.side-stack {
  display: grid;
  gap: 16px;
  align-content: start;
}

.score-card {
  padding: 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  border-top: 6px solid var(--mint);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}

.score-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}

.player-field {
  margin-bottom: 12px;
}

.score-card h2 {
  margin: 0;
  font-size: 1.35rem;
}

.score-card-head button {
  min-height: 34px;
  padding: 0 10px;
  font-size: 0.86rem;
}

.score-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 12px;
}

.score-stats div {
  display: grid;
  gap: 2px;
  padding: 10px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid var(--line);
}

.score-stats span {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
}

.score-stats strong {
  font-size: 1.35rem;
}

.score-stats small {
  color: var(--muted);
  font-weight: 700;
}

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

.score-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.84rem;
}

.score-table th,
.score-table td {
  padding: 9px 8px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

.score-table th {
  color: var(--muted);
  font-size: 0.78rem;
  text-transform: uppercase;
}

.score-table tbody tr:hover {
  background: rgba(255, 255, 255, 0.04);
}

.score-ok,
.score-ko {
  display: inline-flex;
  min-height: 24px;
  align-items: center;
  border-radius: 999px;
  padding: 0 8px;
  font-size: 0.78rem;
  font-weight: 800;
}

.score-ok {
  color: #05130e;
  background: var(--mint);
}

.score-ko {
  color: #ffffff;
  background: var(--danger);
}

.hidden {
  display: none;
}

.meta {
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.45;
}

.admin-title-row {
  margin-bottom: 14px;
}

.admin-title-row h1 {
  font-size: 3rem;
  color: #ffffff;
  text-shadow: 0 10px 28px rgba(0, 0, 0, 0.28);
}

.admin-sections {
  display: grid;
  grid-template-columns: minmax(320px, 1.4fr) minmax(280px, 1fr) minmax(180px, 0.55fr);
  gap: 16px;
  margin-bottom: 18px;
}

.admin-card {
  display: grid;
  gap: 12px;
  align-content: start;
  padding: 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}

.admin-card:nth-child(1) {
  border-top: 6px solid var(--accent);
}

.admin-card:nth-child(2) {
  border-top: 6px solid var(--pink);
}

.admin-card:nth-child(3) {
  border-top: 6px solid var(--yellow);
}

.admin-card h2 {
  margin: 0;
  font-size: 1.15rem;
}

.admin-card-grid {
  display: grid;
  grid-template-columns: 140px minmax(220px, 1fr);
  gap: 12px;
  align-items: end;
}

.admin-button-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
}

.admin-button-grid button,
.admin-card-grid button {
  width: 100%;
  min-width: 0;
  white-space: normal;
}

.admin-card-grid button {
  grid-column: 1 / -1;
  justify-self: start;
  width: min(220px, 100%);
}

@media (min-width: 1550px) {
  .admin-card-grid {
    grid-template-columns: 140px minmax(220px, 1fr) 190px;
  }

  .admin-card-grid button {
    grid-column: auto;
    width: 100%;
  }
}

@media (max-width: 1450px) {
  .admin-button-grid {
    grid-template-columns: 1fr;
  }
}

.message {
  min-height: 24px;
  color: var(--muted);
}

.settings-panel {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) minmax(240px, 1.2fr) 180px auto auto;
  gap: 12px;
  align-items: end;
  margin-bottom: 18px;
  padding: 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  border-top: 6px solid var(--mint);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}

.settings-panel h2 {
  margin: 0 0 4px;
  font-size: 1.25rem;
}

.admin-grid {
  display: grid;
  grid-template-columns: 360px minmax(0, 1fr);
  gap: 18px;
}

.list-panel {
  min-height: 620px;
  overflow: hidden;
}

.cars-list {
  max-height: 72vh;
  overflow: auto;
}

.cars-list::-webkit-scrollbar,
.score-table-wrap::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

.cars-list::-webkit-scrollbar-thumb,
.score-table-wrap::-webkit-scrollbar-thumb {
  background: rgba(0, 217, 255, 0.28);
  border-radius: 999px;
}

.car-row {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  align-items: center;
  gap: 4px;
  width: 100%;
  padding: 12px;
  border-bottom: 1px solid var(--line);
}

.car-row:hover,
.car-row.active {
  background: rgba(0, 217, 255, 0.12);
}

.car-select {
  width: 18px;
  min-height: 18px;
}

.car-open {
  display: grid;
  gap: 4px;
  min-height: auto;
  padding: 0;
  color: var(--ink);
  background: transparent;
  text-align: left;
  box-shadow: none;
}

.car-open:hover {
  background: transparent;
  color: var(--ink);
  transform: none;
  box-shadow: none;
}

.car-row strong {
  font-size: 0.98rem;
}

.car-row span {
  color: var(--muted);
  font-size: 0.85rem;
}

.editor-panel {
  min-height: 620px;
  padding: 16px;
}

.empty {
  color: var(--muted);
}

.editor-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.editor-form label.wide,
.crop-tools,
.image-editor,
.chatgpt-tools {
  grid-column: 1 / -1;
}

.chatgpt-tools {
  display: grid;
  grid-template-columns: auto auto auto 1fr;
  gap: 10px;
  align-items: end;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(0, 217, 255, 0.08);
}

.chatgpt-tools textarea {
  min-height: 78px;
}

.actions {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.image-editor {
  display: grid;
  gap: 12px;
  margin-top: 8px;
}

.image-editor img {
  max-width: 100%;
  max-height: 460px;
  display: block;
}

.crop-tools {
  display: grid;
  grid-template-columns: 180px repeat(2, auto);
  gap: 10px;
  align-items: end;
}

@media (max-width: 900px) {
  .quiz-shell,
  .admin-grid,
  .admin-sections,
  .admin-card-grid,
  .admin-button-grid,
  .settings-panel,
  .editor-form,
  .crop-tools,
  .chatgpt-tools {
    grid-template-columns: 1fr;
  }

  .quiz-header {
    align-items: stretch;
    flex-direction: column;
  }

  .shell {
    width: min(100% - 20px, 1180px);
    margin: 14px auto;
  }

  .topbar {
    height: auto;
    min-height: 58px;
    padding: 12px 14px;
  }

  .start-screen {
    inset: 58px 0 0;
    padding: 14px;
  }

  .start-card {
    padding: 18px;
  }

  h1 {
    font-size: 2.8rem;
  }

  .quiz-panel,
  .result-panel,
  .score-card {
    border-radius: 8px;
  }

  .quiz-controls,
  .qcm-options {
    grid-template-columns: 1fr;
  }

  input,
  select,
  textarea,
  button,
  .button-link {
    min-height: 48px;
  }

  .scoreline {
    align-items: stretch;
    flex-direction: column;
  }

  .quiz-actions {
    justify-content: stretch;
  }

  .quiz-actions button {
    flex: 1;
  }

  .score-stats {
    grid-template-columns: 1fr;
  }

  .list-panel,
  .editor-panel {
    min-height: auto;
  }
}
