:root {
  color-scheme: dark;
  --bg: #101318;
  --panel: #171d24;
  --panel-2: #202832;
  --text: #f3f7fb;
  --muted: #95a3b4;
  --line: #344150;
  --accent: #58d5c9;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  color: var(--text);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

html {
  background: #101318;
}

body {
  position: relative;
  background:
    radial-gradient(circle at top left, rgba(88, 213, 201, 0.22), transparent 30rem),
    linear-gradient(135deg, rgba(9, 13, 21, 0.5), rgba(9, 13, 21, 0.78) 58%, rgba(6, 9, 15, 0.88)),
    url("../art/city_background/9.png") center / cover no-repeat fixed;
}

button {
  display: inline-grid;
  min-width: 3.4rem;
  min-height: 3.4rem;
  place-items: center;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  font: inherit;
  font-weight: 800;
  padding: 0;
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.42);
}

button:hover:not(:disabled) {
  transform: translateY(-1px);
}

button:disabled {
  cursor: not-allowed;
  filter: grayscale(0.55) brightness(0.72);
  opacity: 0.68;
}

.image-button {
  position: relative;
  width: clamp(3.25rem, 4.8vw, 4.25rem);
  aspect-ratio: 1;
  filter: drop-shadow(0 0.45rem 0.75rem rgba(0, 0, 0, 0.32));
}

.image-button img {
  display: block;
  width: 100%;
  height: 100%;
  pointer-events: none;
  transition: filter 140ms ease, transform 140ms ease;
}

.image-button:hover:not(:disabled) img {
  filter: brightness(1.16) saturate(1.08);
}

.image-button:active:not(:disabled) img {
  transform: translateY(1px) scale(0.98);
}

.image-button.muted img {
  filter: grayscale(0.85) brightness(0.72);
}

.image-button::after {
  position: absolute;
  inset: 15% 12%;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: rgba(7, 12, 19, 0.72);
  color: #f3f7fb;
  content: attr(data-tooltip);
  font-size: clamp(0.58rem, 1vw, 0.72rem);
  font-weight: 900;
  letter-spacing: 0;
  opacity: 0;
  pointer-events: none;
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.65);
  transform: scale(0.94);
  transition: opacity 140ms ease, transform 140ms ease;
}

.image-button:hover::after,
.image-button:focus-visible::after {
  opacity: 1;
  transform: scale(1);
}

.title-screen {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: clamp(1rem, 4vw, 2rem);
  background:
    radial-gradient(circle at center, rgba(88, 213, 201, 0.16), transparent 35rem),
    linear-gradient(180deg, rgba(5, 10, 18, 0.62), rgba(5, 10, 18, 0.9)),
    url("../art/city_background/9.png") center / cover no-repeat;
}

.title-screen[hidden] {
  display: none;
}

.title-panel {
  display: grid;
  justify-items: center;
  width: min(100%, 34rem);
  text-align: center;
}

.title-logo {
  width: min(70vw, 21rem);
  aspect-ratio: 1;
  border: 1px solid rgba(88, 213, 201, 0.34);
  border-radius: 8px;
  box-shadow: 0 1.4rem 3rem rgba(0, 0, 0, 0.42);
  object-fit: cover;
}

.title-panel h2 {
  margin: 0.2rem 0 1.1rem;
  font-size: clamp(2rem, 8vw, 4.6rem);
  letter-spacing: 0;
  line-height: 0.96;
  text-shadow: 0 0.35rem 1rem rgba(0, 0, 0, 0.42);
}

.title-actions {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: clamp(0.7rem, 3vw, 1rem);
}

.title-start-button {
  position: relative;
  width: clamp(5rem, 18vw, 7.4rem);
  aspect-ratio: 1;
  filter: drop-shadow(0 0.8rem 1.3rem rgba(0, 0, 0, 0.42));
}

.title-start-button img {
  display: block;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.title-start-button span {
  position: absolute;
  inset: auto 0 16%;
  color: #f3f7fb;
  font-size: clamp(0.76rem, 2.2vw, 1rem);
  font-weight: 900;
  text-align: center;
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.68);
  text-transform: uppercase;
}

.title-start-button:hover:not(:disabled) img {
  filter: brightness(1.15) saturate(1.08);
}

.title-info-button {
  width: clamp(3.85rem, 11vw, 5.25rem);
}

.shell {
  position: relative;
  z-index: 1;
  display: flex;
  min-height: 100vh;
  flex-direction: column;
  gap: 1rem;
  padding: clamp(0.75rem, 2vw, 1.5rem);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  width: min(100%, 72rem);
  margin: 0 auto;
}

.brand {
  display: flex;
  align-items: center;
  min-width: 0;
  gap: 0.8rem;
}

.logo-button {
  width: clamp(3.25rem, 7vw, 5.5rem);
  min-width: 0;
  min-height: 0;
  aspect-ratio: 1;
  flex: 0 0 auto;
  border-radius: 8px;
  filter: drop-shadow(0 0.7rem 1.4rem rgba(0, 0, 0, 0.24));
}

.logo-button:focus-visible {
  outline: 2px solid rgba(88, 213, 201, 0.86);
  outline-offset: 3px;
}

.logo-button:hover:not(:disabled) .brand-logo {
  filter: brightness(1.14) saturate(1.08);
}

.brand-logo {
  width: clamp(3.25rem, 7vw, 5.5rem);
  aspect-ratio: 1;
  flex: 0 0 auto;
  border: 1px solid rgba(88, 213, 201, 0.28);
  border-radius: 8px;
  background: #122033;
  box-shadow: 0 0.7rem 1.4rem rgba(0, 0, 0, 0.24);
  object-fit: cover;
  object-position: center;
}

.logo-button .brand-logo {
  display: block;
  width: 100%;
  height: 100%;
  transition: filter 140ms ease;
}

.eyebrow {
  margin: 0 0 0.2rem;
  color: var(--accent);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: clamp(1.35rem, 2.7vw, 2.35rem);
  letter-spacing: 0;
  line-height: 1.05;
}

.hud {
  display: flex;
  align-items: flex-end;
  flex-direction: column;
  justify-content: flex-end;
  gap: 0.45rem;
}

.hud-info,
.hud-controls {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.55rem;
}

.hud-controls {
  min-height: clamp(3.25rem, 4.8vw, 4.25rem);
}

.track-picker {
  display: inline-flex;
  min-height: 2.9rem;
  align-items: center;
  gap: 0.45rem;
  border: 1px solid rgba(88, 213, 201, 0.32);
  border-radius: 8px;
  background: rgba(12, 20, 31, 0.82);
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  padding: 0.4rem 0.55rem;
}

.track-picker select {
  max-width: min(42vw, 10rem);
  border: 1px solid rgba(88, 213, 201, 0.28);
  border-radius: 6px;
  background: #162535;
  color: #f3f7fb;
  font: inherit;
  letter-spacing: 0;
  padding: 0.35rem 0.45rem;
}

.track-picker select:focus {
  outline: 2px solid rgba(88, 213, 201, 0.72);
  outline-offset: 2px;
}

.hud-info span {
  display: inline-flex;
  min-height: 2.5rem;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(23, 29, 36, 0.86);
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
  padding: 0.55rem 0.75rem;
}

#statusLabel.complete {
  border-color: rgba(88, 213, 201, 0.8);
  color: #b9fff8;
}

#statusLabel.failed,
#movesLabel.danger,
#livesLabel.danger {
  border-color: rgba(255, 107, 138, 0.85);
  color: #ffd1dc;
}

.game-wrap {
  display: flex;
  flex: 1;
  align-items: center;
  justify-content: center;
  width: min(100%, 72rem);
  margin: 0 auto;
  border: 1px solid rgba(88, 213, 201, 0.16);
  border-radius: 8px;
  background: rgba(16, 19, 24, 0.78);
  box-shadow: 0 1rem 3rem rgba(0, 0, 0, 0.28);
  overflow: hidden;
}

#game {
  width: 100%;
  min-height: min(74vh, 48rem);
  touch-action: none;
}

canvas {
  display: block;
  touch-action: none;
}

.dialog-backdrop {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  padding: 1.5rem;
  background: rgba(4, 8, 14, 0.76);
  backdrop-filter: blur(5px);
}

.dialog-backdrop[hidden] {
  display: none;
}

.dialog-panel {
  width: min(100%, 28rem);
  border: 1px solid rgba(88, 213, 201, 0.45);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(28, 42, 58, 0.96), rgba(11, 17, 27, 0.98)),
    url("../art/city_background/9.png") center / cover no-repeat;
  box-shadow: 0 1.5rem 4rem rgba(0, 0, 0, 0.48);
  padding: clamp(1.25rem, 4vw, 2rem);
  text-align: center;
}

.dialog-panel h2 {
  margin: 0.1rem 0 0.6rem;
  font-size: clamp(2rem, 7vw, 3.35rem);
  letter-spacing: 0;
  line-height: 1;
}

.dialog-panel p {
  margin: 0 0 1.2rem;
  color: #c8d7e8;
  font-weight: 700;
}

.tutorial-backdrop {
  z-index: 30;
}

.return-title-backdrop {
  z-index: 25;
}

.tutorial-panel {
  position: relative;
  width: min(100%, 34rem);
  padding-top: clamp(1.5rem, 4vw, 2.3rem);
  text-align: left;
}

.tutorial-panel h2 {
  padding-right: 4.5rem;
}

.tutorial-close-button {
  position: absolute;
  top: 0.85rem;
  right: 0.85rem;
  width: clamp(3.1rem, 8vw, 3.8rem);
}

.tutorial-steps {
  display: grid;
  gap: 0.7rem;
}

.tutorial-steps p {
  margin: 0;
  border: 1px solid rgba(88, 213, 201, 0.22);
  border-radius: 8px;
  background: rgba(7, 13, 21, 0.58);
  color: #d7e4f0;
  line-height: 1.38;
  padding: 0.75rem 0.85rem;
}

.tutorial-steps strong {
  color: #b9fff8;
}

.dialog-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.75rem;
}

.restart-button {
  min-width: 10rem;
  min-height: 3rem;
  border: 1px solid rgba(88, 213, 201, 0.85);
  border-radius: 8px;
  background: linear-gradient(180deg, #2a9ac2, #21476e);
  padding: 0.7rem 1.1rem;
}

.restart-button.secondary {
  border-color: rgba(149, 163, 180, 0.72);
  background: linear-gradient(180deg, #34465f, #202b3d);
}

.restart-button:hover:not(:disabled) {
  filter: brightness(1.14);
}

@media (max-width: 720px) {
  .topbar {
    align-items: stretch;
    flex-direction: column;
  }

  .brand {
    align-items: center;
  }

  .hud {
    align-items: flex-start;
  }

  .hud-info,
  .hud-controls {
    justify-content: flex-start;
  }

  .track-picker {
    width: 100%;
  }

  .track-picker select {
    flex: 1;
    max-width: none;
  }

  .hud-info span,
  button {
    min-height: 2.35rem;
  }
}
