:root {
  --ink: #f6f4ff;
  --muted: #aaa9c4;
  --dim: #686880;
  --night: #0b0c22;
  --night-2: #111333;
  --panel: rgba(23, 24, 57, .86);
  --panel-solid: #17183c;
  --line: rgba(181, 174, 255, .17);
  --violet: #9a6dff;
  --violet-bright: #bf9dff;
  --cyan: #62e7ef;
  --amber: #ffc35f;
  --danger: #ff7991;
  --success: #72efb4;
  --shadow: 0 22px 60px rgba(0, 0, 0, .34);
  font-family: Inter, ui-rounded, "Arial Rounded MT Bold", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--night);
}

* { box-sizing: border-box; }

html { min-height: 100%; background: var(--night); }

body {
  min-height: 100vh;
  margin: 0;
  background:
    radial-gradient(circle at 10% -10%, rgba(103, 71, 180, .24), transparent 36rem),
    radial-gradient(circle at 92% 18%, rgba(32, 134, 163, .13), transparent 31rem),
    linear-gradient(160deg, #10112d 0%, #0b0c22 58%, #090a1c 100%);
  color: var(--ink);
}

button, input, textarea { font: inherit; }

button, a { -webkit-tap-highlight-color: transparent; }

a { color: inherit; text-decoration: none; }

button { cursor: pointer; }

.topbar {
  width: min(1240px, calc(100% - 32px));
  min-height: 74px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 25px;
  border-bottom: 1px solid var(--line);
}

.brand {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: #fff;
  font-weight: 900;
  font-size: .96rem;
  letter-spacing: .15em;
}

.brand-mark {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  color: #10112d;
  background: var(--amber);
  border-radius: 9px 9px 13px 13px;
  font-size: 1.55rem;
  line-height: 1;
  transform: rotate(-8deg);
  box-shadow: 0 4px 16px rgba(255, 195, 95, .28);
}

.main-nav {
  display: flex;
  align-items: stretch;
  align-self: stretch;
  gap: 3px;
}

.main-nav a {
  display: grid;
  place-items: center;
  position: relative;
  padding: 0 12px;
  color: var(--muted);
  font-size: .82rem;
  font-weight: 750;
  transition: color .18s ease;
}

.main-nav a:hover,
.main-nav a.active { color: #fff; }

.main-nav a.active::after {
  position: absolute;
  content: "";
  height: 3px;
  border-radius: 4px 4px 0 0;
  background: var(--violet-bright);
  left: 11px;
  right: 11px;
  bottom: -1px;
}

.identity-wrap {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 10px;
}

.identity {
  max-width: 190px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--muted);
  font-size: .75rem;
}

.tiny-account-link {
  display: none;
  color: var(--violet-bright);
  font-size: .77rem;
  font-weight: 800;
}

.game-layout {
  width: min(1240px, calc(100% - 32px));
  margin: 33px auto 22px;
  display: grid;
  grid-template-columns: minmax(0, 1.48fr) minmax(300px, .82fr);
  gap: 26px;
  align-items: start;
}

.game-column { min-width: 0; }

.game-frame {
  overflow: hidden;
  border: 1px solid rgba(170, 161, 255, .25);
  border-radius: 22px;
  background: #0a0c20;
  box-shadow: var(--shadow), inset 0 1px 0 rgba(255,255,255,.06);
}

.game-frame-top {
  height: 39px;
  padding: 0 11px 0 15px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: linear-gradient(90deg, rgba(34,31,78,.94), rgba(17,18,48,.94));
  border-bottom: 1px solid rgba(202, 196, 255, .13);
}

.status-dot {
  display: flex;
  align-items: center;
  gap: 7px;
  color: #cbc8e8;
  font-size: .63rem;
  font-weight: 850;
  letter-spacing: .13em;
}

.status-dot span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 11px var(--success);
}

.icon-button {
  padding: 5px 8px;
  border: 0;
  border-radius: 7px;
  color: #d8d5ed;
  background: transparent;
  font-size: .69rem;
  font-weight: 800;
}

.icon-button:hover { background: rgba(255,255,255,.09); }

.game-host {
  position: relative;
  min-height: 350px;
  aspect-ratio: 480 / 760;
  background: #0b0c20;
  touch-action: none;
}

.game-host canvas {
  width: 100% !important;
  height: auto !important;
  display: block;
  image-rendering: auto;
  touch-action: none;
}

.mobile-hint {
  display: none;
  margin: 9px 4px 0;
  color: var(--dim);
  font-size: .72rem;
  text-align: center;
}

.flight-side {
  display: grid;
  gap: 15px;
}

.panel {
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 20px;
  background: linear-gradient(135deg, rgba(31,31,71,.88), rgba(17,18,48,.9));
  box-shadow: 0 11px 28px rgba(0,0,0,.14), inset 0 1px 0 rgba(255,255,255,.035);
}

.eyebrow {
  color: var(--cyan);
  font-size: .64rem;
  font-weight: 900;
  letter-spacing: .15em;
}

.flight-brief h1 {
  max-width: 330px;
  margin: 8px 0 10px;
  font-size: clamp(1.72rem, 3vw, 2.45rem);
  line-height: 1;
  letter-spacing: -.045em;
}

.flight-brief h1 em {
  color: var(--violet-bright);
  font-style: normal;
}

.flight-brief p,
.result-panel p {
  margin: 0;
  color: var(--muted);
  font-size: .85rem;
  line-height: 1.55;
}

.control-card {
  margin: 20px 0;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border-radius: 12px;
  background: rgba(8,9,27,.48);
  border: 1px solid rgba(255,255,255,.055);
}

.keycap {
  min-width: 66px;
  padding: 8px 8px;
  border: 1px solid #77719c;
  border-bottom-width: 3px;
  border-radius: 7px;
  color: #fff;
  background: linear-gradient(#4b4975, #343357);
  font-size: .68rem;
  font-weight: 900;
  text-align: center;
  letter-spacing: .07em;
}

.control-card strong {
  display: block;
  font-size: .82rem;
}

.control-card small {
  color: var(--muted);
  font-size: .72rem;
}

.brief-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  border-top: 1px solid var(--line);
  padding-top: 15px;
}

.brief-stats div + div {
  padding-left: 16px;
  border-left: 1px solid var(--line);
}

.brief-stats span {
  display: block;
  color: #fff;
  font-size: 1.16rem;
  font-weight: 900;
  letter-spacing: -.03em;
}

.brief-stats small {
  display: block;
  margin-top: 3px;
  color: var(--dim);
  font-size: .67rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .08em;
}

.panel-heading {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

.panel-heading h2 {
  margin: 4px 0 0;
  font-size: 1rem;
  letter-spacing: -.025em;
}

.flight-badge {
  padding: 5px 7px;
  border: 1px solid rgba(98, 231, 239, .35);
  border-radius: 99px;
  color: var(--cyan);
  background: rgba(98, 231, 239, .08);
  font-size: .59rem;
  font-weight: 900;
  letter-spacing: .1em;
}

.flight-badge.error {
  border-color: rgba(255,121,145,.36);
  color: var(--danger);
  background: rgba(255,121,145,.08);
}

.flight-badge.saved {
  border-color: rgba(114,239,180,.35);
  color: var(--success);
  background: rgba(114,239,180,.08);
}

.run-score-line {
  display: flex;
  align-items: baseline;
  gap: 7px;
  margin: 15px 0 5px;
}

.run-score-line span {
  color: var(--amber);
  font-size: 2.55rem;
  font-weight: 950;
  letter-spacing: -.075em;
  line-height: 1;
}

.run-score-line small {
  color: var(--muted);
  font-size: .75rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .08em;
}

.result-actions {
  display: flex;
  gap: 8px;
  margin-top: 15px;
}

.button {
  min-height: 38px;
  padding: 9px 13px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid transparent;
  border-radius: 9px;
  font-size: .75rem;
  font-weight: 900;
  text-align: center;
  transition: transform .16s ease, background .16s ease, border .16s ease;
}

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

.button.primary {
  color: #17102b;
  background: linear-gradient(135deg, #d2b5ff, #9d70ff);
  box-shadow: 0 7px 17px rgba(123, 84, 225, .22);
}

.button.ghost {
  color: #dedaf6;
  border-color: rgba(194,189,244,.25);
  background: rgba(255,255,255,.03);
}

.button.danger {
  color: #ffb6c3;
  border-color: rgba(255,121,145,.3);
  background: rgba(255,121,145,.08);
}

.text-button {
  padding: 3px 0;
  border: 0;
  color: var(--violet-bright);
  background: transparent;
  font-size: .72rem;
  font-weight: 850;
}

.text-button:hover { color: #fff; }

.leaderboard-list {
  list-style: none;
  margin: 13px 0 5px;
  padding: 0;
  counter-reset: score-rank;
}

.leaderboard-list li {
  min-height: 31px;
  padding: 6px 0;
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  border-bottom: 1px solid rgba(255,255,255,.055);
  counter-increment: score-rank;
}

.leaderboard-list li::before {
  content: counter(score-rank);
  color: #7f7c9d;
  font-size: .72rem;
  font-weight: 900;
  text-align: center;
}

.leaderboard-list li:first-child::before { color: var(--amber); }
.leaderboard-list li:nth-child(2)::before { color: #d5dff1; }
.leaderboard-list li:nth-child(3)::before { color: #d89b75; }

.leaderboard-list .leaderboard-empty {
  display: block;
  color: var(--muted);
  font-size: .78rem;
  line-height: 1.4;
}

.leaderboard-list .leaderboard-empty::before { content: none; }

.board-name {
  overflow: hidden;
  color: #e9e6fa;
  font-size: .78rem;
  font-weight: 760;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.board-score {
  color: var(--amber);
  font-size: .78rem;
  font-weight: 900;
}

.microcopy {
  margin: 10px 0 0;
  color: var(--dim);
  font-size: .67rem;
  line-height: 1.42;
}

.site-footer {
  width: min(1240px, calc(100% - 32px));
  margin: 20px auto 27px;
  padding-top: 16px;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  border-top: 1px solid var(--line);
  color: var(--dim);
  font-size: .65rem;
  font-weight: 780;
  letter-spacing: .07em;
}

.site-footer a {
  color: var(--muted);
  letter-spacing: 0;
  text-transform: none;
}

.site-footer a:hover { color: var(--violet-bright); }

/* Shared inner pages */
.page-main {
  width: min(1000px, calc(100% - 32px));
  margin: 48px auto 36px;
}

.page-hero {
  max-width: 700px;
  margin-bottom: 27px;
}

.page-hero h1 {
  margin: 8px 0 9px;
  font-size: clamp(2rem, 5vw, 3.5rem);
  line-height: .98;
  letter-spacing: -.065em;
}

.page-hero h1 .accent { color: var(--violet-bright); }

.page-hero p {
  margin: 0;
  max-width: 610px;
  color: var(--muted);
  font-size: .96rem;
  line-height: 1.6;
}

.account-grid,
.score-grid,
.contact-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(270px, .7fr);
  gap: 20px;
  align-items: start;
}

.wide-panel { min-width: 0; }

.form-panel h2,
.info-panel h2,
.data-panel h2 {
  margin: 5px 0 8px;
  font-size: 1.24rem;
  letter-spacing: -.035em;
}

.form-panel > p,
.info-panel > p,
.data-panel > p {
  margin: 0;
  color: var(--muted);
  font-size: .84rem;
  line-height: 1.55;
}

.auth-tabs {
  display: flex;
  gap: 7px;
  margin: 21px 0 16px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
}

.auth-tab {
  padding: 6px 9px;
  border: 0;
  border-radius: 7px;
  color: var(--muted);
  background: transparent;
  font-size: .75rem;
  font-weight: 850;
}

.auth-tab.active {
  color: #fff;
  background: rgba(154,109,255,.19);
}

.auth-form {
  display: grid;
  gap: 13px;
}

.field-label {
  display: grid;
  gap: 6px;
  color: #d8d5eb;
  font-size: .74rem;
  font-weight: 800;
}

.text-input,
.text-area {
  width: 100%;
  border: 1px solid rgba(198,193,245,.2);
  border-radius: 9px;
  outline: 0;
  color: #fff;
  background: rgba(6,7,22,.42);
  font-size: .88rem;
  transition: border .16s ease, box-shadow .16s ease;
}

.text-input {
  min-height: 42px;
  padding: 9px 11px;
}

.text-area {
  min-height: 136px;
  padding: 11px;
  resize: vertical;
}

.text-input:focus,
.text-area:focus {
  border-color: rgba(190,156,255,.75);
  box-shadow: 0 0 0 3px rgba(154,109,255,.13);
}

.form-submit-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 3px;
}

.form-status {
  min-height: 18px;
  margin: 0;
  color: var(--muted);
  font-size: .73rem;
  line-height: 1.35;
}

.form-status.success { color: var(--success); }
.form-status.error { color: var(--danger); }
.form-status.pending { color: var(--cyan); }

.account-state {
  display: grid;
  gap: 15px;
}

.account-email {
  overflow-wrap: anywhere;
  color: var(--amber);
  font-size: 1.05rem;
  font-weight: 850;
}

.account-pill {
  width: max-content;
  max-width: 100%;
  padding: 6px 8px;
  border: 1px solid rgba(114,239,180,.24);
  border-radius: 99px;
  color: var(--success);
  background: rgba(114,239,180,.07);
  font-size: .66rem;
  font-weight: 900;
  letter-spacing: .08em;
}

.list-bullets {
  display: grid;
  gap: 11px;
  margin: 18px 0 0;
  padding: 0;
  list-style: none;
}

.list-bullets li {
  position: relative;
  padding-left: 18px;
  color: var(--muted);
  font-size: .8rem;
  line-height: 1.45;
}

.list-bullets li::before {
  position: absolute;
  left: 0;
  top: .5em;
  width: 7px;
  height: 7px;
  content: "";
  border-radius: 50%;
  background: var(--violet);
  box-shadow: 0 0 10px rgba(154,109,255,.7);
}

.callout {
  margin-top: 15px;
  padding: 12px;
  border-left: 3px solid var(--cyan);
  border-radius: 0 9px 9px 0;
  color: #c6c4db;
  background: rgba(98,231,239,.07);
  font-size: .78rem;
  line-height: 1.45;
}

.callout.warning {
  border-left-color: var(--amber);
  background: rgba(255,195,95,.07);
}

.callout.error {
  border-left-color: var(--danger);
  background: rgba(255,121,145,.07);
}

.score-summary {
  display: grid;
  grid-template-columns: repeat(2, minmax(0,1fr));
  gap: 10px;
  margin: 17px 0;
}

.score-tile {
  padding: 14px;
  border: 1px solid rgba(255,255,255,.06);
  border-radius: 11px;
  background: rgba(7,8,23,.32);
}

.score-tile span {
  display: block;
  color: var(--amber);
  font-size: 1.45rem;
  font-weight: 950;
  letter-spacing: -.05em;
}

.score-tile small {
  display: block;
  margin-top: 4px;
  color: var(--dim);
  font-size: .66rem;
  font-weight: 800;
  letter-spacing: .06em;
  text-transform: uppercase;
}

.record-list {
  display: grid;
  gap: 8px;
  margin-top: 16px;
}

.record-row {
  min-height: 59px;
  padding: 10px 11px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 10px;
  background: rgba(6,7,21,.3);
}

.record-row strong {
  display: block;
  color: #fff;
  font-size: .82rem;
}

.record-row small {
  display: block;
  margin-top: 3px;
  color: var(--dim);
  font-size: .68rem;
}

.delete-record {
  padding: 6px 8px;
  border: 1px solid rgba(255,121,145,.25);
  border-radius: 7px;
  color: #ffacba;
  background: rgba(255,121,145,.06);
  font-size: .66rem;
  font-weight: 850;
}

.empty-records {
  margin: 16px 0 0;
  padding: 14px;
  border: 1px dashed rgba(200,195,247,.2);
  border-radius: 10px;
  color: var(--muted);
  font-size: .8rem;
  line-height: 1.45;
}

.shared-board {
  margin-top: 16px;
  display: grid;
  gap: 7px;
}

.shared-board-row {
  display: grid;
  grid-template-columns: 25px minmax(0,1fr) auto;
  align-items: center;
  gap: 8px;
  min-height: 29px;
  border-bottom: 1px solid rgba(255,255,255,.06);
  color: #dad7ee;
  font-size: .77rem;
}

.shared-board-row .rank { color: var(--dim); font-weight: 900; }
.shared-board-row strong { color: var(--amber); font-size: .76rem; }

.contact-note {
  margin-top: 15px;
  color: var(--dim);
  font-size: .7rem;
  line-height: 1.45;
}

.loading-line {
  margin: 16px 0 0;
  color: var(--cyan);
  font-size: .77rem;
}

.hidden { display: none !important; }

@media (max-width: 900px) {
  .game-layout {
    grid-template-columns: minmax(0, 1fr);
    max-width: 660px;
  }
  .flight-side {
    grid-template-columns: repeat(2, minmax(0,1fr));
  }
  .flight-brief { grid-column: 1 / -1; }
  .flight-brief h1 { font-size: 2rem; }
  .account-grid,
  .score-grid,
  .contact-grid { grid-template-columns: 1fr; }
}

@media (max-width: 620px) {
  .topbar {
    width: min(100% - 22px, 1240px);
    min-height: 64px;
    gap: 10px;
  }
  .brand { font-size: .8rem; letter-spacing: .1em; }
  .brand-mark { width: 24px; height: 24px; }
  .main-nav { margin-left: auto; gap: 0; }
  .main-nav a { padding: 0 7px; font-size: .68rem; }
  .identity-wrap { margin-left: 0; }
  .identity { display: none; }
  .tiny-account-link { display: none; }
  .game-layout {
    width: min(100% - 18px, 660px);
    margin-top: 16px;
    gap: 15px;
  }
  .game-frame { border-radius: 16px; }
  .game-host { min-height: 0; }
  .mobile-hint { display: block; }
  .flight-side { grid-template-columns: 1fr; gap: 12px; }
  .flight-brief { grid-column: auto; }
  .panel { border-radius: 14px; padding: 16px; }
  .flight-brief h1 { font-size: 1.75rem; }
  .control-card { margin: 14px 0; }
  .site-footer {
    width: min(100% - 22px, 1240px);
    margin-top: 22px;
    flex-direction: column;
    gap: 7px;
  }
  .page-main {
    width: min(100% - 22px, 1000px);
    margin-top: 31px;
  }
  .page-hero { margin-bottom: 20px; }
  .page-hero h1 { font-size: 2.18rem; }
  .form-submit-row { align-items: flex-start; flex-direction: column; }
}

@media (max-width: 370px) {
  .main-nav a { padding: 0 5px; font-size: .62rem; }
  .brand { font-size: .73rem; }
  .flight-side { gap: 10px; }
}