:root {
  --sky: #696fa7;
  --ink: #2f2f4a;
  --ink-deep: #24243b;
  --cyan: #08cfe0;
  --pink: #d935a5;
  --purple: #7c73d8;
  --panel: rgba(245, 247, 255, 0.95);
  --white: #ffffff;
  --shadow: 0 24px 70px rgba(32, 30, 62, 0.28);
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--sky);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}

button,
input {
  font: inherit;
}

button,
a {
  -webkit-user-select: none;
  user-select: none;
}

button {
  color: inherit;
}

.app-shell {
  width: 100%;
  height: 100dvh;
  display: grid;
  grid-template-columns: minmax(0, 1fr) clamp(310px, 26vw, 410px);
  background: var(--sky);
}

.game-column {
  min-width: 0;
  height: 100%;
  position: relative;
  overflow: hidden;
  isolation: isolate;
  touch-action: none;
}

#gameCanvas {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
}

.brand-link {
  position: absolute;
  z-index: 5;
  top: clamp(18px, 3vh, 34px);
  left: 50%;
  width: clamp(230px, 34vw, 470px);
  transform: translateX(-50%);
  transition: opacity 180ms ease, transform 180ms ease;
}

.brand-link img {
  display: block;
  width: 100%;
  height: auto;
}

.is-playing .brand-link {
  opacity: 0.58;
  transform: translateX(-50%) scale(0.82);
  transform-origin: top center;
}

.score-pill {
  position: absolute;
  z-index: 6;
  left: clamp(14px, 2vw, 28px);
  top: clamp(14px, 2.6vh, 28px);
  min-width: 80px;
  padding: 9px 14px;
  display: none;
  align-items: baseline;
  justify-content: center;
  gap: 9px;
  border: 2px solid rgba(47, 47, 74, 0.36);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.88);
  box-shadow: 0 8px 24px rgba(44, 43, 75, 0.16);
  backdrop-filter: blur(8px);
}

.score-pill.visible {
  display: flex;
}

.score-pill span {
  font-size: 0.69rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.score-pill strong {
  font-size: 1.45rem;
  line-height: 1;
}

.start-overlay {
  position: absolute;
  z-index: 5;
  left: 50%;
  bottom: clamp(118px, 19vh, 180px);
  width: min(92%, 460px);
  transform: translateX(-50%);
  display: grid;
  justify-items: center;
  gap: 12px;
  text-align: center;
  pointer-events: none;
}

.start-overlay p {
  margin: 0;
  padding: 7px 14px;
  border-radius: 999px;
  background: rgba(47, 47, 74, 0.72);
  color: white;
  font-size: clamp(0.78rem, 1vw, 0.94rem);
  font-weight: 700;
  letter-spacing: 0.03em;
}

.tap-button {
  pointer-events: auto;
  min-width: min(88vw, 300px);
  border: 3px solid var(--ink);
  border-radius: 22px;
  padding: 15px 30px 13px;
  background: linear-gradient(135deg, #0bd9e5 0%, #59b5e4 45%, #d845aa 100%);
  color: white;
  box-shadow: 0 8px 0 var(--ink), 0 18px 34px rgba(47, 47, 74, 0.24);
  cursor: pointer;
  text-transform: uppercase;
  transition: transform 120ms ease, box-shadow 120ms ease;
}

.tap-button:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 0 var(--ink), 0 20px 38px rgba(47, 47, 74, 0.28);
}

.tap-button:active {
  transform: translateY(6px);
  box-shadow: 0 2px 0 var(--ink), 0 8px 18px rgba(47, 47, 74, 0.22);
}

.tap-button span,
.tap-button small {
  display: block;
}

.tap-button span {
  font-size: clamp(1.3rem, 2.2vw, 2rem);
  font-weight: 950;
  letter-spacing: 0.04em;
}

.tap-button small {
  margin-top: 3px;
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.05em;
  opacity: 0.9;
}

.result-card {
  position: absolute;
  z-index: 10;
  left: 50%;
  top: 55%;
  width: min(90%, 450px);
  transform: translate(-50%, -50%);
  border: 3px solid var(--ink);
  border-radius: 26px;
  padding: clamp(24px, 4vw, 38px);
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 10px 0 var(--ink), var(--shadow);
  text-align: center;
  backdrop-filter: blur(12px);
}

.result-card h1 {
  margin: 6px 0 10px;
  font-size: clamp(2rem, 4vw, 3.4rem);
  line-height: 1;
}

.result-card > p:not(.eyebrow) {
  margin: 0 0 24px;
}

.eyebrow {
  margin: 0;
  color: #7068ca;
  font-size: 0.72rem;
  font-weight: 900;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
}

.result-card .button-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.result-rebrand-button {
  grid-column: 1 / -1;
  width: 100%;
  background: var(--ink);
  color: white;
  box-shadow: 0 5px 0 #121223;
}

.button,
.rebrand-button,
.small-action {
  border-radius: 13px;
  cursor: pointer;
  font-weight: 850;
  transition: transform 120ms ease, box-shadow 120ms ease, background 120ms ease;
}

.button {
  min-height: 48px;
  border: 2px solid var(--ink);
  padding: 11px 19px;
}

.button.primary,
.small-action.primary {
  background: linear-gradient(135deg, var(--cyan), #63b6df 50%, var(--pink));
  color: white;
  box-shadow: 0 5px 0 var(--ink);
}

.button.secondary {
  background: white;
  color: var(--ink);
  box-shadow: 0 5px 0 var(--ink);
}

.button:hover,
.rebrand-button:hover,
.small-action:hover {
  transform: translateY(-2px);
}

.button:active,
.rebrand-button:active,
.small-action:active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 var(--ink);
}

.leaderboard-panel {
  position: relative;
  z-index: 20;
  height: 100dvh;
  min-height: 0;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  gap: 18px;
  padding: 20px 20px 18px;
  border-left: 3px solid var(--ink);
  background: var(--panel);
  box-shadow: -16px 0 50px rgba(39, 37, 70, 0.16);
  backdrop-filter: blur(14px);
}

.panel-topbar {
  display: flex;
  justify-content: flex-end;
}

.rebrand-button {
  border: 2px solid var(--ink);
  padding: 10px 14px;
  background: var(--ink);
  color: white;
  box-shadow: 0 4px 0 #121223;
  font-size: 0.82rem;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.leaderboard-heading h2 {
  margin: 1px 0 4px;
  background: linear-gradient(135deg, var(--pink), var(--purple));
  background-clip: text;
  color: transparent;
  font-size: clamp(2.4rem, 4vw, 3.7rem);
  line-height: 0.95;
  -webkit-background-clip: text;
}

.leaderboard-heading p:last-child {
  margin: 8px 0 0;
  color: #5f5e78;
  font-size: 0.87rem;
  line-height: 1.45;
}

.leaderboard-list {
  min-height: 0;
  overflow: auto;
  padding-right: 3px;
  scrollbar-width: thin;
  scrollbar-color: #8b87c4 transparent;
}

.leaderboard-row {
  display: grid;
  grid-template-columns: 39px minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  min-height: 48px;
  margin-bottom: 7px;
  padding: 7px 10px 7px 7px;
  border: 1px solid rgba(47, 47, 74, 0.13);
  border-radius: 13px;
  background: rgba(255, 255, 255, 0.72);
}

.leaderboard-row.top-three {
  background: linear-gradient(110deg, rgba(11, 217, 229, 0.18), rgba(216, 69, 170, 0.14));
  border-color: rgba(47, 47, 74, 0.24);
}

.rank-badge {
  width: 33px;
  height: 33px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--ink);
  color: white;
  font-size: 0.76rem;
  font-weight: 900;
}

.leaderboard-name {
  overflow: hidden;
  font-size: 0.9rem;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.leaderboard-score {
  color: #6861c4;
  font-size: 1.1rem;
  font-weight: 950;
}

.leaderboard-loading,
.empty-board {
  padding: 30px 18px;
  border: 2px dashed rgba(47, 47, 74, 0.2);
  border-radius: 18px;
  color: #65647a;
  text-align: center;
}

.leaderboard-footer {
  display: flex;
  justify-content: space-between;
  padding-top: 10px;
  border-top: 1px solid rgba(47, 47, 74, 0.14);
  color: #77758e;
  font-size: 0.71rem;
  font-weight: 850;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.modal-backdrop {
  position: fixed;
  z-index: 100;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(28, 27, 51, 0.68);
  backdrop-filter: blur(7px);
}

.modal-card {
  position: relative;
  width: min(100%, 560px);
  max-height: calc(100dvh - 36px);
  overflow: auto;
  border: 3px solid var(--ink);
  border-radius: 26px;
  padding: clamp(24px, 4vw, 40px);
  background: #f8f9ff;
  box-shadow: 0 9px 0 var(--ink), var(--shadow);
}

.modal-card h2 {
  margin: 7px 42px 22px 0;
  font-size: clamp(1.7rem, 3.3vw, 2.65rem);
  line-height: 1.05;
}

.score-form {
  width: min(100%, 640px);
}

.score-form h2 {
  font-size: clamp(1.18rem, 6vw, 2.35rem);
  white-space: nowrap;
}

.modal-close,
.close-panel {
  width: 38px;
  height: 38px;
  border: 0;
  border-radius: 50%;
  background: var(--ink);
  color: white;
  cursor: pointer;
  font-size: 1.4rem;
  font-weight: 800;
  line-height: 1;
}

.modal-close {
  position: absolute;
  top: 16px;
  right: 16px;
}

.form-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 120px;
  gap: 14px;
}

.form-grid label,
.form-grid label span {
  display: block;
}

.form-grid label span {
  margin-bottom: 6px;
  font-size: 0.76rem;
  font-weight: 850;
}

.form-grid em {
  color: #75738b;
  font-style: normal;
  font-weight: 650;
}

.form-grid input {
  width: 100%;
  min-height: 48px;
  border: 2px solid rgba(47, 47, 74, 0.25);
  border-radius: 12px;
  padding: 9px 12px;
  outline: none;
  background: white;
}

.form-grid input:focus {
  border-color: #7169ce;
  box-shadow: 0 0 0 3px rgba(113, 105, 206, 0.14);
}

.full-width {
  grid-column: 1 / -1;
}

.checkbox-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-top: 18px;
  padding: 13px;
  border-radius: 13px;
  background: rgba(8, 207, 224, 0.1);
  font-size: 0.9rem;
  font-weight: 750;
}

.checkbox-row input {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
  margin: 1px 0 0;
  accent-color: var(--pink);
}

.privacy-note {
  margin: 12px 0 17px;
  color: #77758b;
  font-size: 0.75rem;
}

.score-offer {
  margin: -8px 0 20px;
  padding: 12px 14px;
  border: 1px solid rgba(47, 47, 74, 0.14);
  border-radius: 13px;
  background: linear-gradient(110deg, rgba(8, 207, 224, 0.13), rgba(217, 53, 165, 0.1));
  color: #55536d;
  font-size: 0.88rem;
  line-height: 1.45;
}

.form-error {
  margin: 0 0 14px;
  padding: 10px 12px;
  border-radius: 10px;
  background: #ffe3ec;
  color: #7e1743;
  font-size: 0.84rem;
  font-weight: 700;
}

.submit-button {
  width: 100%;
}

.success-card,
.rebrand-card {
  text-align: center;
}

.success-card > p:not(.eyebrow),
.rebrand-card > p:not(.eyebrow) {
  color: #626079;
  line-height: 1.55;
}

.quote-confirmation {
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(8, 207, 224, 0.12);
  color: var(--ink) !important;
  font-weight: 800;
}

.rebrand-card ul {
  margin: 18px 0;
  padding: 0;
  display: grid;
  gap: 9px;
  list-style: none;
  text-align: left;
}

.rebrand-card li {
  position: relative;
  padding: 11px 12px 11px 42px;
  border-radius: 12px;
  background: white;
  font-size: 0.88rem;
  font-weight: 720;
}

.rebrand-card li::before {
  content: "✓";
  position: absolute;
  left: 14px;
  color: #15b8c9;
  font-weight: 950;
}

.rebrand-offer {
  color: var(--ink) !important;
  font-weight: 850;
}

.link-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}

.text-button {
  display: block;
  margin: 20px auto 0;
  border: 0;
  background: transparent;
  color: #6861c4;
  cursor: pointer;
  font-weight: 800;
}

.mobile-actions,
.mobile-only {
  display: none;
}

.hidden {
  display: none !important;
}

@media (max-width: 820px) {
  .app-shell {
    display: block;
  }

  .game-column {
    width: 100%;
    height: 100dvh;
  }

  .brand-link {
    top: max(76px, calc(env(safe-area-inset-top) + 64px));
    width: min(68vw, 310px);
  }

  .is-playing .brand-link {
    opacity: 0.5;
    transform: translateX(-50%) scale(0.74);
  }

  .mobile-actions {
    position: absolute;
    z-index: 9;
    top: max(10px, env(safe-area-inset-top));
    left: 10px;
    right: 10px;
    display: flex;
    justify-content: space-between;
    gap: 8px;
  }

  .small-action {
    min-height: 40px;
    border: 2px solid var(--ink);
    padding: 7px 10px;
    background: rgba(255, 255, 255, 0.9);
    box-shadow: 0 3px 0 var(--ink);
    font-size: 0.68rem;
    text-transform: uppercase;
  }

  .score-pill {
    top: max(62px, calc(env(safe-area-inset-top) + 54px));
    left: 10px;
  }

  .start-overlay {
    bottom: max(112px, calc(env(safe-area-inset-bottom) + 94px));
  }

  .leaderboard-panel {
    position: fixed;
    z-index: 80;
    inset: 0;
    width: 100%;
    padding: max(14px, env(safe-area-inset-top)) 16px max(14px, env(safe-area-inset-bottom));
    border-left: 0;
    transform: translateX(105%);
    transition: transform 220ms ease;
  }

  .leaderboard-panel.mobile-open {
    transform: translateX(0);
  }

  .leaderboard-panel .rebrand-button {
    display: none;
  }

  .panel-topbar {
    justify-content: flex-start;
  }

  .mobile-only {
    display: grid;
    place-items: center;
  }

  .leaderboard-heading h2 {
    font-size: 3.2rem;
  }

  .result-card {
    top: 54%;
  }
}

@media (max-width: 520px) {
  .form-grid {
    grid-template-columns: minmax(0, 1fr) 92px;
  }

  .modal-card {
    border-radius: 20px;
    padding: 24px 18px;
  }

  .button-row .button {
    flex: 1 1 130px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}