:root {
  --bg: #05060a;
  --bg-panel: #141522;
  --bg-panel-soft: #0b0c16;
  --accent: #1f8cff;
  --accent-soft: rgba(31, 140, 255, 0.25);
  --accent-strong: #4ea3ff;
  --text-main: #f5f7ff;
  --text-muted: #9ca2be;
  --border-subtle: #262840;
  --good: #37e28a;
  --bad: #ff4f6b;
  --shadow-soft: 0 20px 50px rgba(0, 0, 0, 0.75);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: radial-gradient(circle at top, #202542 0, #05060a 55%, #010207 100%);
  color: var(--text-main);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    Helvetica, Arial, sans-serif;
}

#appRoot {
  width: 100%;
  height: 100vh;
  display: flex;
  align-items: stretch;
  justify-content: center;
}

/* Screens */

.screen {
  display: none;
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  padding: 16px;
}

.screen.active {
  display: flex;
  flex-direction: column;
}

/* HOME */

.home-inner {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
}

.app-title {
  font-size: 30px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  margin: 0;
  text-align: center;
}

.subtitle {
  margin: 0;
  color: var(--text-muted);
  font-size: 13px;
}

.home-status {
  margin-top: 4px;
  font-size: 12px;
  color: var(--text-muted);
}

.home-buttons {
  width: 100%;
  max-width: 260px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 6px;
}

/* Plates */

.plate {
  position: relative;
  margin: 0 auto;
  background: #f7f7ff;
  border-radius: 10px;
  border: 3px solid #d2d5ea;
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.6);
  overflow: hidden;
  text-align: center;
  color: #16234d;
  text-transform: uppercase;
}

.plate-large {
  width: 270px;
  height: 140px;
}

.plate-preview {
  width: 260px;
  height: 130px;
  margin-bottom: 14px;
}

.plate-small {
  width: 180px;
  height: 90px;
}

.plate-top {
  background: linear-gradient(90deg, #d62839, #ff7a59);
  color: #fff;
  font-size: 11px;
  letter-spacing: 0.16em;
  padding: 4px 8px;
}

.plate-main {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  font-weight: 700;
  letter-spacing: 0.16em;
  padding: 8px;
}

.plate-small .plate-main {
  font-size: 18px;
}

.plate-bottom {
  background: #1d3a76;
  color: #f7f7ff;
  font-size: 9px;
  letter-spacing: 0.22em;
  padding: 3px 6px;
}

/* Panels */

.panel {
  width: 100%;
  margin: auto;
  background: linear-gradient(160deg, #17192a, #05060f);
  border-radius: 18px;
  border: 1px solid var(--border-subtle);
  padding: 16px 16px 18px;
  box-shadow: var(--shadow-soft);
}

.panel h2 {
  margin: 0 0 6px;
}

.panel-text {
  font-size: 13px;
  color: var(--text-muted);
  margin: 0 0 12px;
}

.panel-text.small {
  font-size: 12px;
}

/* Fields */

.field-row {
  margin-bottom: 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.field-row label {
  font-size: 11px;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.field-row input,
.field-row select {
  border-radius: 10px;
  border: 1px solid var(--border-subtle);
  background: var(--bg-panel-soft);
  color: var(--text-main);
  padding: 7px 10px;
  font-size: 14px;
}

/* Buttons */

.button-row {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

.btn {
  border-radius: 999px;
  border: 1px solid transparent;
  padding: 9px 14px;
  font-size: 14px;
  cursor: pointer;
  transition: background 0.15s, box-shadow 0.15s, transform 0.1s,
    border-color 0.15s;
}

.btn.big {
  padding: 12px 24px;
  font-size: 15px;
  width: 100%;
}

.btn.primary {
  background: var(--accent);
  border-color: var(--accent-soft);
  color: #fff;
}

.btn.primary:hover {
  background: var(--accent-strong);
  box-shadow: 0 0 18px var(--accent-soft);
  transform: translateY(-1px);
}

.btn.ghost {
  background: var(--bg-panel-soft);
  border-color: var(--border-subtle);
  color: var(--text-main);
}

.btn.ghost:hover {
  background: #181828;
}

.btn.small {
  padding: 6px 10px;
  font-size: 11px;
}

/* Error */

.error-text {
  min-height: 14px;
  font-size: 11px;
  color: var(--bad);
}

/* Mode buttons */

.section-block {
  margin: 8px 0;
}

.section-block h3 {
  margin: 8px 0 4px;
  font-size: 13px;
}

.mode-buttons {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
}

.mode-btn {
  border-radius: 12px;
  border: 1px solid var(--border-subtle);
  background: var(--bg-panel-soft);
  padding: 10px 8px;
  text-align: center;
  color: var(--text-main);
  font-size: 13px;
  cursor: pointer;
}

.mode-btn span {
  display: block;
  font-size: 11px;
  color: var(--text-muted);
}

.mode-btn.active {
  border-color: var(--accent);
  background: rgba(31, 140, 255, 0.16);
}

/* Toggle switches list */

.toggle-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-panel-soft);
  border-radius: 999px;
  padding: 6px 10px;
  border: 1px solid var(--border-subtle);
  font-size: 13px;
}

.toggle-label {
  font-size: 13px;
}

.toggle-sub {
  font-size: 11px;
  color: var(--text-muted);
}

/* Switch */

.switch {
  position: relative;
  display: inline-block;
  width: 46px;
  height: 24px;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #666;
  transition: 0.3s;
  border-radius: 24px;
}

.slider:before {
  position: absolute;
  content: "";
  height: 20px;
  width: 20px;
  left: 2px;
  bottom: 2px;
  background-color: #fff;
  transition: 0.3s;
  border-radius: 50%;
}

.switch input:checked + .slider {
  background-color: #33c27d;
}

.switch input:checked + .slider:before {
  transform: translateX(22px);
}

/* Game header */

.game-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 4px 4px;
}

.game-metrics {
  display: flex;
  gap: 6px;
}

.metric {
  background: rgba(5, 6, 14, 0.96);
  border-radius: 10px;
  padding: 4px 7px;
  border: 1px solid rgba(255, 255, 255, 0.05);
  display: flex;
  flex-direction: column;
  min-width: 60px;
}

.metric-label {
  font-size: 9px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.metric-value {
  font-size: 14px;
  font-weight: 600;
}

/* Game main */

.game-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 4px 0 0;
}

/* Image */

.image-wrapper {
  position: relative;
  flex: 1;
  border-radius: 18px;
  overflow: hidden;
  background: radial-gradient(circle at top, #32385c 0, #05070f 55%);
  display: flex;
  align-items: center;
  justify-content: center;
}

.image-wrapper img {
  max-width: 100%;
  max-height: 100%;
  object-fit: cover;
  transition: transform 0.3s ease, object-position 0.3s ease, opacity 0.2s ease;
  opacity: 0;
}

.image-wrapper.crop img {
  transform: scale(1.7);
}

.image-gradient {
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.7), transparent 55%);
  display: flex;
  align-items: flex-end;
  padding: 8px 10px;
}

.round-status {
  font-size: 12px;
  color: var(--text-muted);
}

/* Timer */

.timer-pill {
  position: absolute;
  top: 6px;
  right: 6px;
  padding: 3px 9px;
  border-radius: 999px;
  background: rgba(5, 6, 14, 0.96);
  border: 1px solid var(--border-subtle);
  font-size: 11px;
}

/* Progress */

.game-progress-row {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text-muted);
  padding: 0 2px;
}

/* Answers */

.answer-buttons {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 4px;
}

.answer-btn {
  width: 100%;
  padding: 10px 12px;
  font-size: 15px;
  border-radius: 10px;
  border: 1px solid var(--border-subtle);
  background: var(--bg-panel-soft);
  color: var(--text-main);
  text-align: left;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
}

.answer-btn:active {
  transform: translateY(1px);
}

.answer-btn.correct {
  background: rgba(55, 226, 138, 0.18);
  border-color: var(--good);
}

.answer-btn.wrong {
  background: rgba(255, 79, 107, 0.16);
  border-color: var(--bad);
}

/* Expert inputs */

.expert-inputs {
  display: none;
  flex-direction: column;
  gap: 6px;
  margin-top: 6px;
}

.expert-inputs select,
.expert-inputs input {
  border-radius: 10px;
  border: 1px solid var(--border-subtle);
  background: var(--bg-panel-soft);
  color: var(--text-main);
  padding: 8px 10px;
  font-size: 14px;
}

/* Game controls */

.game-controls-row {
  margin-top: 8px;
  display: flex;
  gap: 6px;
}

.game-controls-row .btn {
  flex: 1;
}

/* Answer / hint text */

.answer-display {
  min-height: 18px;
  margin-top: 4px;
  font-size: 14px;
}

.hint-display {
  min-height: 16px;
  margin-top: 2px;
  font-size: 12px;
  color: var(--text-muted);
}

/* Game footer */

.game-footer {
  margin-top: 6px;
  display: flex;
  justify-content: space-between;
}

/* Overlay */

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.82);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 20;
}

.overlay.hidden {
  display: none;
}

.overlay-panel {
  max-width: 380px;
}

/* Animations */

.game-main.correct-anim {
  animation: correctPulse 0.45s ease-out;
}

.game-main.wrong-anim {
  animation: wrongShake 0.35s ease-out;
}

@keyframes correctPulse {
  0% {
    transform: scale(1);
  }
  40% {
    transform: scale(1.02);
    box-shadow: 0 0 26px rgba(55, 226, 138, 0.9);
  }
  100% {
    transform: scale(1);
    box-shadow: none;
  }
}

@keyframes wrongShake {
  0% {
    transform: translateX(0);
  }
  25% {
    transform: translateX(-6px);
  }
  50% {
    transform: translateX(6px);
  }
  75% {
    transform: translateX(-4px);
  }
  100% {
    transform: translateX(0);
  }
}

/* Small screens */

@media (max-width: 480px) {
  .screen {
    padding: 10px;
  }

  .game-metrics {
    gap: 4px;
  }
}
