:root {
  color-scheme: light;
  --ink: #17202a;
  --muted: #607080;
  --panel: rgba(255, 255, 255, 0.86);
  --panel-strong: rgba(255, 255, 255, 0.96);
  --border: rgba(23, 32, 42, 0.12);
  --sun: #f7b733;
  --yolk: #fdd85d;
  --mint: #2fbf71;
  --sky: #56a3d9;
  --coral: #f36f5f;
  --shadow: 0 18px 45px rgba(23, 32, 42, 0.18);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: #9ed8ee;
  color: var(--ink);
}

button,
input {
  font: inherit;
}

button {
  min-height: 40px;
  border: 0;
  cursor: pointer;
}

button:focus-visible,
input:focus-visible {
  outline: 3px solid rgba(47, 191, 113, 0.45);
  outline-offset: 2px;
}

.app-shell {
  position: relative;
  width: 100%;
  height: 100%;
  min-width: 320px;
  overflow: hidden;
}

.scene-root {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.scene-root canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.topbar {
  position: absolute;
  top: 16px;
  left: 16px;
  right: 16px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  pointer-events: none;
  z-index: 4;
}

.brand-block,
.hud-strip,
.auth-panel,
.start-panel,
.leaderboard-panel,
.touch-controls button {
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.brand-block {
  min-width: 210px;
  padding: 14px 16px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.78);
}

.eyebrow {
  margin: 0 0 4px;
  color: #31627e;
  font-size: 0.74rem;
  font-weight: 800;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 1.45rem;
  line-height: 1.08;
}

h2 {
  font-size: 1.55rem;
  line-height: 1.16;
}

.hud-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(78px, 1fr));
  gap: 8px;
  width: min(430px, 48vw);
  padding: 10px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.82);
}

.hud-strip div,
.run-stats span {
  min-width: 0;
  padding: 8px 10px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.62);
}

.hud-strip span,
.account-card span,
.login-form span {
  display: block;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
}

.hud-strip strong,
.account-card strong {
  display: block;
  margin-top: 2px;
  font-size: 1.25rem;
  line-height: 1.05;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.auth-panel {
  position: absolute;
  top: 116px;
  right: 16px;
  width: 300px;
  padding: 12px;
  border-radius: 8px;
  background: var(--panel);
  z-index: 5;
}

.login-form {
  display: grid;
  gap: 10px;
}

.login-form label {
  display: grid;
  gap: 5px;
}

.login-form input {
  width: 100%;
  height: 40px;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0 10px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.84);
}

.button-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.primary-button,
.quiet-button,
.icon-button {
  border-radius: 6px;
  font-weight: 800;
  transition: transform 140ms ease, filter 140ms ease, background 140ms ease;
}

.primary-button {
  color: #10151a;
  background: var(--yolk);
  padding: 0 15px;
}

.quiet-button {
  color: #183243;
  background: rgba(255, 255, 255, 0.76);
  padding: 0 14px;
}

.icon-button {
  width: 40px;
  color: #183243;
  background: rgba(255, 255, 255, 0.78);
}

.primary-button:hover,
.quiet-button:hover,
.icon-button:hover,
.touch-controls button:hover {
  transform: translateY(-1px);
  filter: brightness(1.02);
}

.account-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.account-card > div {
  min-width: 0;
}

.status-line {
  min-height: 18px;
  margin-top: 9px;
  color: #47606f;
  font-size: 0.83rem;
  line-height: 1.25;
}

.start-panel {
  position: absolute;
  left: 50%;
  bottom: 84px;
  width: min(420px, calc(100vw - 32px));
  transform: translateX(-50%);
  padding: 18px;
  border-radius: 8px;
  background: var(--panel-strong);
  z-index: 4;
}

.run-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin: 14px 0;
  color: var(--ink);
  font-size: 0.9rem;
  font-weight: 800;
}

.leaderboard-panel {
  position: absolute;
  left: 16px;
  bottom: 84px;
  width: min(360px, calc(100vw - 32px));
  max-height: 52vh;
  padding: 14px;
  border-radius: 8px;
  background: var(--panel-strong);
  z-index: 6;
  overflow: hidden;
}

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

.panel-heading h2 {
  font-size: 1.1rem;
}

.leaderboard-list {
  display: grid;
  gap: 8px;
  max-height: calc(52vh - 72px);
  margin: 0;
  padding: 0;
  list-style: none;
  overflow-y: auto;
}

.leaderboard-list li {
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  min-height: 44px;
  padding: 8px 10px;
  border: 1px solid rgba(23, 32, 42, 0.08);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.72);
}

.leaderboard-list strong,
.leaderboard-list span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.leaderboard-list small {
  color: var(--muted);
}

.touch-controls {
  position: absolute;
  left: 50%;
  bottom: 16px;
  display: grid;
  grid-template-columns: repeat(4, 56px);
  gap: 10px;
  transform: translateX(-50%);
  z-index: 5;
}

.touch-controls button {
  width: 56px;
  height: 48px;
  border-radius: 8px;
  color: #183243;
  background: rgba(255, 255, 255, 0.82);
  font-size: 1.05rem;
  font-weight: 900;
}

.hidden {
  display: none !important;
}

.auth-panel.compact-while-running .login-form,
.auth-panel.compact-while-running .status-line {
  display: none;
}

.auth-panel.guest-running {
  display: none;
}

@media (max-width: 820px) {
  .topbar {
    align-items: stretch;
  }

  .brand-block {
    min-width: 150px;
  }

  h1 {
    font-size: 1.08rem;
  }

  .hud-strip {
    grid-template-columns: repeat(3, minmax(56px, 1fr));
    width: auto;
    flex: 1;
  }

  .hud-strip div {
    padding: 7px 6px;
  }

  .hud-strip strong {
    font-size: 1rem;
  }

  .auth-panel {
    top: 106px;
    right: 16px;
    bottom: auto;
    width: min(300px, calc(100vw - 32px));
  }

  .start-panel {
    bottom: 74px;
  }
}

@media (max-width: 600px) {
  .topbar {
    left: 10px;
    right: 10px;
    top: 10px;
    gap: 8px;
  }

  .brand-block {
    min-width: 116px;
    padding: 10px;
  }

  .eyebrow {
    font-size: 0.64rem;
  }

  .hud-strip {
    gap: 5px;
    padding: 7px;
  }

  .hud-strip span {
    font-size: 0.62rem;
  }

  .auth-panel {
    left: 10px;
    right: 10px;
    width: auto;
    top: 92px;
    bottom: auto;
  }

  h2 {
    font-size: 1.25rem;
  }

  .start-panel,
  .leaderboard-panel {
    left: 10px;
    width: calc(100vw - 20px);
    transform: none;
  }

  .leaderboard-panel {
    bottom: 74px;
  }

  .touch-controls {
    bottom: 10px;
    grid-template-columns: repeat(4, 48px);
    gap: 8px;
  }

  .touch-controls button {
    width: 48px;
    height: 46px;
  }
}
