:root {
  color-scheme: dark;
  --page: #1e3141;
  --page-2: #2a3e4f;
  --panel: rgba(11, 20, 30, 0.66);
  --panel-2: rgba(18, 31, 44, 0.72);
  --ink: #f7fbff;
  --muted: #c2d6e7;
  --line: rgba(255, 255, 255, 0.16);
  --red: #ee2222;
  --gold: #ffdc50;
  --green: #77b255;
  --blue: #2d8cff;
  --radius: 8px;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

html {
  overscroll-behavior: none;
}

body {
  margin: 0;
  min-width: 320px;
  overflow: hidden;
  overscroll-behavior: none;
  background:
    radial-gradient(circle at 10% 9%, rgba(176, 221, 47, 0.16), transparent 26%),
    radial-gradient(circle at 88% 18%, rgba(255, 220, 80, 0.09), transparent 22%),
    linear-gradient(135deg, var(--page), var(--page-2));
  color: var(--ink);
}

button {
  font: inherit;
}

.parking-app {
  position: relative;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  margin: 0 auto;
  padding: 0;
  overflow: hidden;
}

.hud {
  position: absolute;
  z-index: 5;
  inset: 0;
  max-width: none;
  margin: 0;
  min-width: 0;
  display: block;
  pointer-events: none;
}

.brand,
.readouts,
.hud-actions {
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: var(--radius);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.06), transparent 38%),
    linear-gradient(180deg, var(--panel-2), var(--panel));
  backdrop-filter: blur(8px);
  box-shadow:
    0 12px 28px rgba(0, 0, 0, 0.25),
    inset 0 1px 0 rgba(255, 255, 255, 0.12);
  pointer-events: auto;
}

.brand {
  position: absolute;
  left: clamp(10px, 1.6vw, 20px);
  top: clamp(10px, 1.6vw, 20px);
  width: min(330px, calc(100vw - 168px));
  min-height: 58px;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px clamp(12px, 1.5vw, 20px);
}

.brand > div {
  min-width: 0;
}

.brand-mark {
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
  border-radius: 8px;
  position: relative;
  background:
    linear-gradient(90deg, transparent 45%, rgba(255, 255, 255, 0.82) 46%, rgba(255, 255, 255, 0.82) 54%, transparent 55%),
    linear-gradient(180deg, #3e4d5d, #1d2a38);
  box-shadow:
    inset 0 0 0 2px rgba(255, 255, 255, 0.16),
    0 0 0 2px rgba(238, 34, 34, 0.28),
    0 12px 18px rgba(0, 0, 0, 0.26);
}

.brand-mark::after {
  content: "";
  position: absolute;
  width: 22px;
  height: 12px;
  left: 8px;
  top: 14px;
  border-radius: 7px 9px 9px 7px;
  background: linear-gradient(180deg, #ff6b5d, var(--red));
  box-shadow: 0 0 15px rgba(238, 34, 34, 0.56);
}

.brand strong {
  display: block;
  max-width: 100%;
  font-size: clamp(20px, 2vw, 31px);
  line-height: 0.95;
  letter-spacing: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.brand span:last-child {
  display: block;
  max-width: 100%;
  margin-top: 5px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.readouts {
  position: absolute;
  left: clamp(10px, 1.6vw, 20px);
  bottom: clamp(10px, 1.6vw, 20px);
  width: min(520px, calc(100vw - 32px));
  min-height: 62px;
  min-width: 0;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin: 0;
  overflow: hidden;
}

.readouts > div {
  min-width: 0;
  display: grid;
  align-content: center;
  padding: 8px clamp(9px, 1vw, 18px);
  border-left: 1px solid rgba(255, 255, 255, 0.11);
}

.readouts > div:first-child {
  border-left: 0;
}

.readouts dt {
  color: var(--muted);
  font-size: 9px;
  font-weight: 900;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.readouts dd {
  margin: 2px 0 0;
  color: var(--ink);
  font-size: clamp(20px, 2vw, 30px);
  font-weight: 900;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.readouts span {
  margin-top: 4px;
  color: #c7d5df;
  font-size: 10px;
  font-weight: 750;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.hud-actions {
  position: absolute;
  top: clamp(10px, 1.6vw, 20px);
  right: clamp(10px, 1.6vw, 20px);
  min-height: 58px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 12px;
}

.icon-button {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--ink);
  cursor: pointer;
  transition:
    transform 140ms ease,
    background 140ms ease,
    border-color 140ms ease,
    opacity 140ms ease;
}

.icon-button:hover:not(:disabled) {
  transform: translateY(-1px);
  background: rgba(255, 255, 255, 0.14);
  border-color: rgba(255, 255, 255, 0.34);
}

.icon-button:active:not(:disabled) {
  transform: translateY(1px);
}

.icon-button:disabled {
  opacity: 0.35;
  cursor: default;
}

.icon-button svg {
  width: 23px;
  height: 23px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.15;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.icon-button.accent {
  color: var(--gold);
  border-color: rgba(247, 201, 72, 0.38);
}

.icon-button.danger {
  color: #ff7a6f;
  border-color: rgba(238, 34, 34, 0.36);
}

.stage {
  position: absolute;
  inset: 0;
  min-height: 0;
  display: grid;
  place-items: center;
  overflow: hidden;
  border-radius: 0;
  border: 0;
  background:
    radial-gradient(circle at 16% 14%, rgba(177, 220, 48, 0.18), transparent 27%),
    radial-gradient(circle at 86% 16%, rgba(255, 220, 80, 0.08), transparent 23%),
    #172532;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

canvas {
  width: 100%;
  height: 100%;
  aspect-ratio: 16 / 9;
  display: block;
  touch-action: none;
  cursor: grab;
}

canvas.is-dragging {
  cursor: grabbing;
}

.coach-line {
  position: absolute;
  right: clamp(10px, 1.6vw, 20px);
  bottom: clamp(8px, 1.6vw, 18px);
  transform: none;
  width: min(390px, calc(100vw - 560px));
  min-height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 7px 14px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 999px;
  background: rgba(10, 16, 24, 0.58);
  color: rgba(247, 251, 255, 0.9);
  font-size: clamp(11px, 1.2vw, 14px);
  font-weight: 800;
  text-align: center;
  backdrop-filter: blur(8px);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.28);
  pointer-events: none;
}

html.capture-clean .hud,
html.capture-clean .coach-line,
html.capture-clean .state-overlay {
  display: none;
}

.state-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(14px, 3vw, 36px);
  background: rgba(9, 15, 23, 0.42);
  backdrop-filter: blur(4px);
  z-index: 4;
}

.state-overlay[hidden] {
  display: none;
}

.state-panel {
  width: min(94vw, 620px);
  max-height: min(90vh, 650px);
  overflow: auto;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: var(--radius);
  padding: clamp(18px, 3vw, 30px);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.09), transparent 34%),
    linear-gradient(135deg, rgba(22, 37, 53, 0.97), rgba(8, 14, 23, 0.98));
  box-shadow:
    0 28px 80px rgba(0, 0, 0, 0.46),
    inset 0 1px 0 rgba(255, 255, 255, 0.13);
}

.state-kicker {
  color: var(--gold);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.state-panel h1 {
  margin: 6px 0 0;
  font-size: clamp(34px, 6vw, 58px);
  line-height: 0.95;
  letter-spacing: 0;
}

.state-panel p {
  margin: 12px 0 0;
  color: #c7d5df;
  font-size: clamp(14px, 2.2vw, 17px);
  line-height: 1.55;
  font-weight: 650;
}

.result-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-top: 18px;
}

.result-stats:empty {
  display: none;
}

.result-stats span {
  min-width: 0;
  padding: 10px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.07);
  color: var(--ink);
  text-align: center;
  font-size: 13px;
  font-weight: 850;
}

.level-select {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 8px;
  margin-top: 20px;
}

.level-select button {
  min-width: 0;
  min-height: 42px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.07);
  color: var(--ink);
  cursor: pointer;
  font-weight: 900;
}

.level-select button:hover:not(:disabled),
.level-select button.active {
  background: rgba(238, 34, 34, 0.9);
  border-color: rgba(255, 255, 255, 0.28);
}

.level-select button:disabled {
  color: rgba(255, 255, 255, 0.35);
  cursor: default;
}

.level-select small {
  display: block;
  margin-top: 2px;
  color: rgba(255, 255, 255, 0.7);
  font-size: 10px;
  font-weight: 850;
}

.how-to {
  margin-top: 18px;
  padding: 14px 16px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.13);
  background: rgba(255, 255, 255, 0.06);
}

.how-to strong,
.how-to span {
  display: block;
}

.how-to strong {
  font-size: 12px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.how-to span {
  margin-top: 5px;
  color: #c7d5df;
  font-size: 14px;
  line-height: 1.45;
  font-weight: 650;
}

.menu-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 20px;
}

.play-button,
.secondary-button {
  min-height: 46px;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 950;
}

.play-button {
  flex: 1 1 220px;
  border: 0;
  background: linear-gradient(135deg, #ff5a4d, var(--red));
  color: #fff;
  box-shadow: 0 14px 28px rgba(238, 34, 34, 0.28);
}

.secondary-button {
  flex: 1 1 150px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(255, 255, 255, 0.08);
  color: var(--ink);
}

@media (max-width: 1080px) {
  body {
    overflow: auto;
  }

  .parking-app {
    height: 100dvh;
    min-height: 100dvh;
  }

  .hud {
    position: absolute;
  }

  .brand {
    min-height: 58px;
    width: min(236px, calc(100vw - 168px));
    padding-inline: 10px;
    gap: 9px;
  }

  .brand strong {
    font-size: clamp(18px, 4vw, 24px);
  }

  .brand span:last-child {
    font-size: 9px;
  }

  .readouts {
    width: min(470px, calc(100vw - 24px));
  }

  .hud-actions {
    min-height: 58px;
  }

  .stage {
    min-height: 100dvh;
  }

  canvas {
    width: 100%;
  }
}

@media (max-width: 560px) {
  .parking-app {
    padding: 6px;
    gap: 6px;
  }

  .hud {
    inset: 0;
  }

  .brand {
    min-height: 54px;
    width: calc(100vw - 20px);
  }

  .brand-mark {
    width: 36px;
    height: 36px;
  }

  .brand-mark::after {
    width: 21px;
    height: 12px;
    left: 7px;
    top: 13px;
  }

  .hud-actions {
    top: auto;
    bottom: 84px;
    left: 10px;
    right: auto;
    min-height: 48px;
    padding: 6px;
  }

  .icon-button {
    width: 38px;
    height: 38px;
  }

  .readouts {
    left: 6px;
    right: 6px;
    bottom: 8px;
    width: auto;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .readouts > div:nth-child(odd) {
    border-left: 0;
  }

  .brand strong {
    white-space: normal;
  }

  .level-select {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

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

  .coach-line {
    display: none;
  }
}

@media (max-width: 760px) and (max-height: 520px) {
  .parking-app {
    grid-template-rows: minmax(0, 1fr);
    padding: 0;
  }

  .hud {
    position: absolute;
    left: 8px;
    right: 8px;
    top: 8px;
    z-index: 5;
    display: flex;
    align-items: stretch;
    gap: 6px;
    pointer-events: none;
  }

  .brand,
  .readouts,
  .hud-actions {
    position: static;
    pointer-events: auto;
    background:
      linear-gradient(180deg, rgba(255, 255, 255, 0.07), transparent 38%),
      rgba(8, 15, 24, 0.88);
    backdrop-filter: blur(6px);
  }

  .brand {
    width: 144px;
    min-height: 48px;
    padding: 0 8px;
    gap: 8px;
  }

  .brand-mark {
    width: 32px;
    height: 32px;
  }

  .brand-mark::after {
    width: 19px;
    height: 11px;
    left: 6px;
    top: 11px;
  }

  .brand strong {
    max-width: 88px;
    font-size: 17px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .brand span:last-child {
    margin-top: 2px;
    max-width: 88px;
    font-size: 8px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .readouts {
    flex: 1 1 auto;
    grid-column: auto;
    min-height: 48px;
  }

  .readouts > div {
    padding: 5px 8px;
  }

  .readouts dt {
    font-size: 8px;
  }

  .readouts dd {
    font-size: 20px;
  }

  .readouts span {
    margin-top: 1px;
    font-size: 9px;
  }

  .hud-actions {
    min-height: 48px;
    padding: 4px;
    gap: 4px;
  }

  .icon-button {
    width: 38px;
    height: 38px;
  }

  .stage {
    min-height: 100%;
    border: 0;
  }

  canvas {
    width: 100%;
    max-height: none;
  }

  .state-panel {
    width: min(92vw, 620px);
    max-height: 82vh;
    padding: 16px 20px;
  }

  .state-panel h1 {
    font-size: clamp(34px, 7vw, 48px);
  }

  .result-stats,
  .how-to {
    margin-top: 12px;
  }

  .level-select {
    margin-top: 14px;
  }

  .menu-actions {
    margin-top: 14px;
  }

  .coach-line {
    bottom: 8px;
    width: min(88%, 580px);
  }
}

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