:root {
  color-scheme: dark;
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --bg: #191f2e;
  --panel: rgba(25, 31, 46, 0.9);
  --text: #f6f8ff;
  --muted: #aeb7c8;
  --accent: #ffd166;
  --accent-2: #47d5b2;
  --danger: #ff6b6b;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
}

html,
body,
#app {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  overscroll-behavior: none;
}

button,
input {
  font: inherit;
}

button {
  min-height: 44px;
  border: 0;
  border-radius: 8px;
  padding: 0 18px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.13);
  cursor: pointer;
}

button.primary {
  color: #171b25;
  background: var(--accent);
  font-weight: 800;
}

button:disabled {
  opacity: 0.55;
}

#game {
  display: block;
  width: 100vw;
  height: 100dvh;
  background: linear-gradient(#202940 0%, #303f68 52%, #465e86 100%);
  transform: translateZ(0);
}

.screen {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: none;
  align-items: center;
  justify-content: center;
  padding: max(16px, env(safe-area-inset-top)) 16px max(16px, env(safe-area-inset-bottom));
  background: #101725;
}

.screen.active {
  display: flex;
}

.panel {
  width: min(430px, 100%);
  max-height: 92dvh;
  overflow: auto;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  padding: 20px;
  background: var(--panel);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.32);
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 44px;
  line-height: 1;
}

h2 {
  font-size: 22px;
}

.muted {
  margin-top: 8px;
  color: var(--muted);
  line-height: 1.45;
}

label {
  display: grid;
  gap: 7px;
  margin: 18px 0 12px;
  color: var(--muted);
  font-size: 14px;
}

input {
  width: 100%;
  min-height: 48px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 8px;
  padding: 0 12px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.08);
  outline: none;
  user-select: text;
  -webkit-user-select: text;
}

.panel > button {
  width: 100%;
  margin-top: 10px;
}

.leaderboard {
  margin-top: 20px;
}

.leaderboard ol {
  min-height: 28px;
  margin: 10px 0 0;
  padding-left: 25px;
  color: var(--muted);
}

.leaderboard li {
  margin: 6px 0;
}

.row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

button.icon {
  width: 44px;
  min-width: 44px;
  padding: 0;
  font-size: 28px;
  line-height: 1;
}

.balance {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 12px 0 8px;
  color: var(--accent);
  font-weight: 700;
}

.shop-note {
  margin: 0 0 16px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

.balance img {
  width: 24px;
  height: 24px;
  object-fit: contain;
}

.shop-grid {
  display: grid;
  gap: 12px;
}

.shop-item {
  display: grid;
  grid-template-columns: 64px 1fr;
  gap: 12px;
  align-items: center;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  padding: 12px;
  background: rgba(255, 255, 255, 0.07);
}

.background-preview {
  width: 64px;
  height: 72px;
  border-radius: 8px;
  object-fit: cover;
  filter: drop-shadow(0 5px 8px rgba(0, 0, 0, 0.35));
}

.shop-item h3 {
  margin: 0 0 4px;
  font-size: 16px;
}

.shop-item p {
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 13px;
}

#hud {
  position: fixed;
  z-index: 5;
  top: max(10px, env(safe-area-inset-top));
  left: 12px;
  right: 12px;
  display: none;
  justify-content: space-between;
  gap: 10px;
  color: white;
  font-weight: 900;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.45);
  pointer-events: none;
}

#hud.active {
  display: flex;
}

#controls {
  position: fixed;
  z-index: 6;
  right: 0;
  bottom: max(14px, env(safe-area-inset-bottom));
  left: 0;
  display: none;
  justify-content: space-between;
  padding: 0 18px;
  pointer-events: none;
}

#controls.active {
  display: flex;
}

#controls button {
  width: min(31vw, 128px);
  height: 72px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  padding: 0;
  background: rgba(255, 255, 255, 0.15);
  color: white;
  font-size: 54px;
  line-height: 1;
  pointer-events: auto;
}

#gameOverScreen {
  padding: 0;
  background: #000;
}

#gameOverVideo {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.game-over-actions {
  position: fixed;
  right: 18px;
  bottom: max(24px, env(safe-area-inset-bottom));
  left: 18px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.restart {
  display: none;
}

.restart.active {
  display: block;
}

@media (min-width: 720px) {
  #controls {
    left: 50%;
    width: min(520px, 100%);
    transform: translateX(-50%);
  }
}
