:root {
  color-scheme: dark;
  --bg: #14130f;
  --panel: #1e1f1b;
  --panel-2: #292a24;
  --ink: #f7f1df;
  --muted: #b9b39f;
  --green: #44d39e;
  --coral: #ff6f59;
  --amber: #ffd166;
  --violet: #9b8cff;
  --line: rgba(255, 255, 255, 0.14);
  --shadow: 0 18px 46px rgba(0, 0, 0, 0.34);
}

* {
  box-sizing: border-box;
}

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

body {
  min-height: 100svh;
  background:
    linear-gradient(120deg, rgba(68, 211, 158, 0.12), transparent 36%),
    linear-gradient(300deg, rgba(255, 111, 89, 0.13), transparent 34%),
    var(--bg);
}

button,
a {
  font: inherit;
}

.pr-bar {
  padding: 7px 12px;
  background: #0f0f0c;
  color: #d4cfbe;
  font-size: 12px;
  text-align: center;
  border-bottom: 1px solid var(--line);
}

.app {
  width: min(100%, 920px);
  min-height: calc(100svh - 31px);
  margin: 0 auto;
  padding: 18px clamp(12px, 3vw, 28px) 22px;
  display: grid;
  grid-template-rows: auto auto 1fr auto auto;
  gap: 14px;
}

.topline,
.scoreboard,
.stage,
.controls,
.support-strip,
.result {
  border: 1px solid var(--line);
  background: rgba(20, 19, 15, 0.86);
  box-shadow: var(--shadow);
}

.topline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 16px;
  border-radius: 8px;
}

.eyebrow {
  margin: 0 0 5px;
  color: var(--amber);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: 34px;
  line-height: 1;
}

.hub-link,
.support-strip a {
  color: var(--ink);
  text-decoration: none;
}

.hub-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 64px;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
  font-weight: 800;
}

.scoreboard {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1px;
  overflow: hidden;
  border-radius: 8px;
}

.scoreboard div {
  min-width: 0;
  padding: 10px;
  background: var(--panel);
}

.scoreboard span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.scoreboard strong {
  display: block;
  margin-top: 3px;
  font-size: 22px;
  line-height: 1;
}

.stage {
  min-height: 0;
  border-radius: 8px;
  padding: clamp(12px, 3vw, 20px);
  display: grid;
  grid-template-columns: minmax(180px, 0.78fr) minmax(290px, 1.22fr);
  grid-template-rows: minmax(0, 1fr) auto auto;
  gap: 16px;
  align-items: stretch;
}

.target-card,
.lane-panel {
  min-width: 0;
}

.target-card {
  display: grid;
  align-content: center;
  gap: 10px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.panel-label {
  color: var(--amber);
  font-size: 12px;
  font-weight: 900;
}

.target-card strong {
  min-height: 40px;
  font-size: 32px;
  line-height: 1;
}

.target-card p {
  min-height: 42px;
  margin: 0;
  color: var(--muted);
  font-weight: 700;
}

.hearts {
  color: var(--coral);
  font-size: 22px;
  letter-spacing: 4px;
}

.lane-panel {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 12px;
}

.timer-bar {
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: #37352c;
}

.timer-bar span {
  display: block;
  width: 100%;
  height: 100%;
  transform-origin: left center;
  background: linear-gradient(90deg, var(--green), var(--amber), var(--coral));
}

.lane-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  min-height: 240px;
}

.lane-card {
  min-width: 0;
  min-height: 210px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
  color: var(--ink);
  cursor: pointer;
  display: grid;
  grid-template-rows: auto 1fr auto;
  align-items: center;
  justify-items: center;
  gap: 10px;
  text-align: center;
  transition: transform 120ms ease, border-color 120ms ease, background 120ms ease;
}

.lane-card:enabled:hover,
.lane-card:enabled:focus-visible {
  transform: translateY(-3px);
  outline: 2px solid var(--violet);
  outline-offset: 2px;
}

.lane-card:disabled {
  cursor: default;
  opacity: 0.78;
}

.lane-name {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.lane-icon {
  display: grid;
  place-items: center;
  width: min(84px, 70%);
  aspect-ratio: 1;
  border-radius: 8px;
  color: #15130f;
  font-size: 34px;
  font-weight: 1000;
}

.lane-label {
  min-height: 44px;
  font-weight: 900;
  line-height: 1.15;
}

.lane-card.correct-flash {
  border-color: rgba(68, 211, 158, 0.9);
  background: rgba(68, 211, 158, 0.18);
}

.lane-card.wrong-flash {
  border-color: rgba(255, 111, 89, 0.9);
  background: rgba(255, 111, 89, 0.18);
}

.feedback,
.viewport-state {
  grid-column: 1 / -1;
  min-height: 24px;
  margin: 0;
  color: var(--muted);
  font-weight: 700;
  text-align: center;
}

.viewport-state {
  min-height: 18px;
  font-size: 12px;
  color: #8f8a7d;
}

.controls {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  padding: 10px;
  border-radius: 8px;
}

button {
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
  color: var(--ink);
  cursor: pointer;
  font-weight: 900;
}

button.primary {
  background: var(--coral);
  border-color: rgba(255, 111, 89, 0.92);
  color: #1b0b07;
}

button:disabled {
  cursor: default;
  color: #7e7a6f;
  background: #20211c;
}

.support-strip {
  display: flex;
  justify-content: center;
  gap: 10px;
  padding: 10px;
  border-radius: 8px;
}

.support-strip a {
  display: inline-flex;
  align-items: center;
  min-height: 38px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  font-weight: 800;
}

.result {
  position: fixed;
  left: 50%;
  top: 50%;
  width: min(420px, calc(100vw - 24px));
  transform: translate(-50%, -50%);
  z-index: 10;
  padding: 22px;
  border-radius: 8px;
  text-align: center;
}

.result[hidden] {
  display: none;
}

.result-label {
  margin: 0;
  color: var(--amber);
  font-size: 12px;
  font-weight: 900;
}

.result strong {
  display: block;
  margin: 8px 0;
  font-size: 46px;
}

.result p {
  color: var(--muted);
}

.result button {
  width: 100%;
  margin-top: 8px;
}

@media (max-width: 720px) {
  .app {
    padding-top: 12px;
  }

  h1 {
    font-size: 27px;
  }

  .stage {
    grid-template-columns: 1fr;
  }

  .lane-grid {
    min-height: 190px;
  }

  .lane-card {
    min-height: 172px;
  }
}

@media (max-width: 480px) {
  .topline {
    padding: 12px;
  }

  h1 {
    font-size: 24px;
  }

  .scoreboard strong {
    font-size: 19px;
  }

  .stage {
    gap: 12px;
  }

  .lane-grid {
    gap: 7px;
  }

  .lane-card {
    min-height: 152px;
    padding: 9px 6px;
  }

  .lane-icon {
    width: 58px;
    font-size: 26px;
  }

  .lane-label {
    font-size: 13px;
  }

  .support-strip {
    flex-direction: column;
  }

  .support-strip a {
    justify-content: center;
  }
}
