*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  background:
    radial-gradient(ellipse at 20% 0%, #5a2d7a 0%, transparent 50%),
    radial-gradient(ellipse at 90% 10%, #2a6b5a 0%, transparent 42%),
    linear-gradient(180deg, #1b1230 0%, #2c1848 45%, #1a2a28 100%);
  color: #fff8ee;
  font-family: "Trebuchet MS", "Segoe UI", "Comic Sans MS", sans-serif;
}

body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100%;
}

#game-root {
  position: relative;
  width: min(100vw, calc(100vh * 0.675));
  height: min(100vh, calc(100vw / 0.675));
  max-width: 560px;
  max-height: 860px;
  border-radius: 28px;
  overflow: hidden;
  box-shadow:
    0 0 0 6px #3d2060,
    0 0 0 10px #f4d35e,
    0 22px 50px rgba(0, 0, 0, 0.45);
  background: #1c1630;
}

#game {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  cursor: pointer;
}

#hud {
  position: absolute;
  inset: 0 0 auto 0;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 14px 14px 0;
  pointer-events: none;
  z-index: 3;
}

#hud.hidden {
  display: none;
}

.hud-cluster {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.hud-right {
  align-items: flex-end;
}

.hud-stat {
  padding: 8px 14px;
  border-radius: 999px;
  background: rgba(20, 10, 36, 0.72);
  border: 3px solid #f4d35e;
  font-size: 18px;
  letter-spacing: 0.02em;
  text-shadow: 0 2px 0 #2a1040;
}

.hud-stat strong {
  font-size: 22px;
  color: #fff4a8;
}

.hud-letters strong {
  letter-spacing: 0.12em;
}

.hud-btn,
.ghost-btn,
.big-btn {
  font-family: inherit;
  font-weight: 800;
  border: none;
  cursor: pointer;
}

.hud-btn {
  pointer-events: auto;
  min-height: 48px;
  padding: 8px 16px;
  border-radius: 16px;
  background: #fff8ee;
  color: #3b1460;
  font-size: 18px;
  box-shadow: 0 4px 0 #c9a227;
}

.hud-btn:hover,
.ghost-btn:hover,
.big-btn:hover {
  filter: brightness(1.06);
}

.hud-btn:active,
.ghost-btn:active,
.big-btn:active {
  transform: translateY(2px);
  box-shadow: none;
}

.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 12px 14px 18px;
  background: linear-gradient(180deg, rgba(16, 8, 28, 0.02) 0%, rgba(16, 8, 28, 0.08) 48%, rgba(16, 8, 28, 0.72) 100%);
  z-index: 4;
}

.overlay-split {
  flex-direction: column;
  justify-content: space-between;
  align-items: center;
  padding-top: 18px;
  pointer-events: none;
}

.overlay-split .overlay-card,
.overlay-split .hub-dock {
  pointer-events: auto;
}

.overlay.hidden {
  display: none;
  pointer-events: none;
}

.overlay-card {
  width: min(100%, 420px);
  text-align: center;
  padding: 12px 16px 14px;
  border-radius: 24px;
  background: rgba(28, 14, 48, 0.9);
  border: 4px solid #f4d35e;
  box-shadow: 0 10px 0 rgba(0, 0, 0, 0.28);
  max-height: 92%;
}

.overlay-scroll {
  overflow: auto;
}

.title-card {
  padding: 8px 14px 10px;
  background: rgba(28, 14, 48, 0.78);
}

.hub-dock {
  width: min(100%, 420px);
  text-align: center;
  padding: 10px 10px 6px;
  border-radius: 24px;
  background: rgba(28, 14, 48, 0.88);
  border: 4px solid #f4d35e;
}

.hub-row {
  display: flex;
  gap: 8px;
  justify-content: center;
}

.hub-row .ghost-btn {
  min-width: 0;
  flex: 1;
}

.game-dock {
  padding-top: 12px;
}

.game-pick-btn {
  display: block;
  width: 100%;
  min-height: 108px;
  margin: 0 0 12px;
  padding: 16px 18px;
  border: none;
  border-radius: 22px;
  text-align: left;
  cursor: pointer;
  font-family: inherit;
  font-weight: 800;
  background: linear-gradient(180deg, #ffe36a 0%, #f4b942 100%);
  color: #3b1460;
  box-shadow: 0 7px 0 #b88614;
}

.game-pick-cart {
  background: linear-gradient(180deg, #d7b3ff 0%, #9a62e0 100%);
  color: #fff8ee;
  box-shadow: 0 7px 0 #5a2d8a;
}

.game-pick-btn strong {
  display: block;
  font-size: clamp(28px, 6vw, 34px);
  line-height: 1;
  margin-bottom: 8px;
}

.game-pick-btn span {
  display: block;
  font-size: 17px;
  line-height: 1.25;
  font-weight: 700;
}

.game-pick-btn:hover {
  filter: brightness(1.06);
}

.game-pick-btn:active {
  transform: translateY(2px);
  box-shadow: none;
}

.skin-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 10px 0 12px;
}

.skin-btn {
  min-height: 56px;
  margin: 0;
  padding: 8px 10px;
  border: none;
  border-radius: 16px;
  background: rgba(16, 8, 28, 0.55);
  color: #fff8ee;
  font-family: inherit;
  font-size: 17px;
  font-weight: 800;
  border: 3px solid #c9a6ff;
  cursor: pointer;
}

.skin-btn.picked {
  background: linear-gradient(180deg, #ffe36a 0%, #f4b942 100%);
  color: #3b1460;
  border-color: #f4d35e;
}

.vehicle-heading {
  margin: 4px 0 0;
  color: #ffb3e0;
  font-size: 16px;
  font-weight: 800;
}

.vehicle-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 8px 0 12px;
}

.vehicle-btn {
  min-height: 92px;
  margin: 0;
  padding: 6px 8px 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  border: none;
  border-radius: 16px;
  background: rgba(16, 8, 28, 0.55);
  color: #fff8ee;
  font-family: inherit;
  font-size: 16px;
  font-weight: 800;
  border: 3px solid #c9a6ff;
  cursor: pointer;
}

.vehicle-btn.picked {
  background: linear-gradient(180deg, #d7b3ff 0%, #9a62e0 100%);
  color: #fff8ee;
  border-color: #f4d35e;
}

.vehicle-btn canvas,
.vehicle-preview {
  display: block;
  width: 72px;
  height: 54px;
  pointer-events: none;
}

.standings {
  text-align: left;
  margin: 8px 0 14px;
}

.stand-row {
  display: flex;
  gap: 10px;
  align-items: center;
  margin: 0 0 8px;
  padding: 8px 10px;
  border-radius: 14px;
  background: rgba(16, 8, 28, 0.45);
  font-size: 20px;
  font-weight: 800;
}

.stand-row.me {
  border: 3px solid #f4d35e;
}

.stand-row span:first-child {
  min-width: 42px;
  color: #ffe36a;
}

#cart-hud {
  position: absolute;
  inset: 0 0 auto 0;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 14px 14px 0;
  pointer-events: none;
  z-index: 3;
}

#cart-hud.hidden {
  display: none;
}

.cart-hud-left {
  margin-top: 214px;
}

#cart-hud .hud-btn {
  pointer-events: auto;
}

.eyebrow {
  margin: 0 0 4px;
  color: #ffb3e0;
  font-size: 18px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0 0 10px;
  line-height: 0.95;
  text-shadow: 0 4px 0 #2a1040;
}

h1 {
  font-size: clamp(28px, 6vw, 40px);
  color: #e9b4ff;
}

h2 {
  font-size: clamp(32px, 7vw, 48px);
  color: #ffd76a;
}

.blurb,
.howto,
.best-line,
.score-line {
  margin: 0 0 8px;
}

.blurb {
  font-size: 18px;
  line-height: 1.3;
}

.howto {
  font-size: 18px;
  color: #ffe7b0;
}

.best-line,
.score-line {
  font-size: 20px;
}

.score-line strong,
.best-line strong {
  color: #fff4a8;
  font-size: 26px;
}

.big-btn {
  display: inline-block;
  min-width: 200px;
  min-height: 64px;
  margin: 6px 0 8px;
  padding: 10px 26px;
  border-radius: 999px;
  background: linear-gradient(180deg, #ffe36a 0%, #f4b942 100%);
  color: #3b1460;
  font-size: 32px;
  box-shadow: 0 7px 0 #b88614;
}

.ghost-btn {
  display: inline-block;
  min-height: 48px;
  margin: 0 0 8px;
  padding: 8px 18px;
  border-radius: 999px;
  background: transparent;
  color: #fff8ee;
  font-size: 18px;
  border: 3px solid #c9a6ff;
}

.level-list,
.shop-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 8px 0 12px;
}

.level-btn,
.shop-btn {
  min-width: 0;
  width: 100%;
  font-size: 22px;
  min-height: 56px;
}

.level-btn:disabled,
.shop-btn:disabled,
.big-btn:disabled {
  opacity: 0.45;
  filter: none;
  cursor: default;
}

.shop-row {
  display: flex;
  gap: 10px;
  align-items: center;
  text-align: left;
  padding: 8px;
  border-radius: 16px;
  background: rgba(16, 8, 28, 0.45);
}

.shop-info {
  flex: 1;
  min-width: 0;
}

.shop-info strong {
  display: block;
  font-size: 20px;
  color: #ffe36a;
}

.shop-info span {
  font-size: 16px;
  color: #fff8ee;
}

.shop-btn {
  flex: 0 0 120px;
  min-width: 120px;
  font-size: 20px;
}

.collect-stats p {
  margin: 6px 0;
  font-size: 20px;
}

.gold-wrap {
  margin: 12px 0;
}

.gold-bar {
  height: 22px;
  border-radius: 999px;
  background: rgba(16, 8, 28, 0.7);
  border: 3px solid #f4d35e;
  overflow: hidden;
}

.gold-fill {
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, #ffe36a, #f4b942);
}

.tutorial {
  position: absolute;
  left: 12px;
  right: 12px;
  top: 210px;
  z-index: 5;
  padding: 14px 16px;
  border-radius: 18px;
  background: rgba(28, 14, 48, 0.9);
  border: 4px solid #c6f000;
  font-size: 22px;
  font-weight: 800;
  text-align: center;
  pointer-events: none;
}

.tutorial.hidden {
  display: none;
}

.toast {
  position: absolute;
  left: 16px;
  right: 16px;
  bottom: 18px;
  z-index: 8;
  padding: 16px 18px;
  border-radius: 18px;
  background: rgba(28, 14, 48, 0.94);
  border: 4px solid #ff7a14;
  font-size: 22px;
  font-weight: 800;
  text-align: center;
}

.toast.hidden {
  display: none;
}

#toast-line {
  margin: 0;
}

@media (max-height: 740px) {
  h1 {
    font-size: 32px;
  }

  .big-btn {
    min-height: 56px;
    font-size: 26px;
  }

  .blurb,
  .howto {
    font-size: 16px;
  }
}
