:root {
  --bg_deep: #0b1a33;
  --bg_glow: #1a3a6b;
  --accent: #ff6a00;
  --accent_hot: #ffd400;
  --panel: rgba(8, 18, 40, 0.92);
  --text: #f5f7ff;
  --muted: #9db0d0;
  --danger: #ff3b5c;
  --ok: #2ee59d;
  --btn_shadow: 0 8px 0 #b34a00;
  --safe_top: env(safe-area-inset-top, 0px);
  --safe_right: env(safe-area-inset-right, 0px);
  --safe_bottom: env(safe-area-inset-bottom, 0px);
  --safe_left: env(safe-area-inset-left, 0px);
}

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

html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: radial-gradient(ellipse at top, var(--bg_glow), var(--bg_deep) 70%);
  color: var(--text);
  font-family: "Trebuchet MS", "Segoe UI", sans-serif;
  touch-action: manipulation;
  user-select: none;
}

#app {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

#game_canvas {
  display: block;
  width: 100%;
  height: 100%;
  background: #102548;
}

.hidden {
  display: none !important;
}

.hud {
  position: absolute;
  top: calc(12px + var(--safe_top));
  left: calc(12px + var(--safe_left));
  right: calc(96px + var(--safe_right));
  z-index: 5;
  pointer-events: none;
}

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

.hud_lives {
  display: flex;
  gap: 4px;
  font-size: 22px;
  letter-spacing: 1px;
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.45);
}

.hud_coins {
  font-size: 22px;
  font-weight: 700;
  background: rgba(0, 0, 0, 0.35);
  border: 2px solid rgba(255, 212, 0, 0.55);
  border-radius: 999px;
  padding: 4px 12px;
}

.hud_progress_wrap {
  height: 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.15);
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.hud_progress {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent), var(--accent_hot));
  transition: width 0.08s linear;
}

.lane_controls {
  position: absolute;
  right: calc(12px + var(--safe_right));
  bottom: calc(24px + var(--safe_bottom));
  top: auto;
  transform: none;
  z-index: 6;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.lane_row {
  display: flex;
  flex-direction: row;
  gap: 14px;
}

.lane_btn {
  width: 72px;
  height: 72px;
  border: 3px solid #fff3;
  border-radius: 18px;
  background: linear-gradient(180deg, #ff8a2b, var(--accent));
  color: #fff;
  font-size: 28px;
  font-weight: 800;
  box-shadow: var(--btn_shadow);
  touch-action: none;
  cursor: pointer;
  -webkit-user-select: none;
  user-select: none;
}

.lane_btn_jump {
  width: 84px;
  height: 64px;
  background: linear-gradient(180deg, #7dffb0, #1faf5c);
  box-shadow: 0 8px 0 #0f6b35;
}

.lane_btn_jump:active {
  transform: translateY(4px);
  box-shadow: 0 4px 0 #0f6b35;
}

.lane_btn_boost {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  font-size: 22px;
  background: linear-gradient(180deg, #ff5a5a, #c41010);
  box-shadow: 0 8px 0 #7a0808;
}

.lane_btn_boost.is_active,
.lane_btn_boost:active {
  transform: translateY(4px);
  box-shadow: 0 4px 0 #7a0808;
  filter: brightness(1.1);
}

.lane_btn:active {
  transform: translateY(4px);
  box-shadow: 0 4px 0 #b34a00;
}

.brand_small {
  font-size: clamp(22px, 6vw, 30px);
}

.help_table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 14px;
  margin: 8px 0 12px;
}

.help_table th,
.help_table td {
  padding: 8px 6px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.help_table th {
  color: var(--muted);
  font-weight: 700;
  font-size: 12px;
  text-transform: uppercase;
}

.help_table kbd {
  display: inline-block;
  min-width: 1.6em;
  padding: 3px 7px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.22);
  text-align: center;
  font-family: inherit;
}

.help_boost {
  color: #ff6b6b;
  font-weight: 800;
}

.help_note {
  text-align: left;
  font-size: 13px;
  margin: 0 0 8px;
}

.panel_help {
  text-align: center;
}

.coin_icon {
  display: inline-block;
  width: 1.05em;
  height: 1.05em;
  border-radius: 50%;
  vertical-align: -0.15em;
  background:
    radial-gradient(circle at 30% 28%, #fff8c0 0%, #ffd400 38%, #f0a000 72%, #b86a00 100%);
  box-shadow:
    inset 0 0 0 1.5px #a86800,
    inset -2px -2px 0 rgba(255, 255, 255, 0.35),
    0 1px 2px rgba(0, 0, 0, 0.35);
  position: relative;
}

.coin_icon::after {
  content: "$";
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.62em;
  font-weight: 800;
  color: #8a4f00;
  line-height: 1;
}

.screen {
  position: absolute;
  inset: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: calc(16px + var(--safe_top)) calc(16px + var(--safe_right)) calc(16px + var(--safe_bottom)) calc(16px + var(--safe_left));
  background: rgba(4, 10, 24, 0.55);
  backdrop-filter: blur(4px);
  overflow: auto;
}

.panel {
  width: min(420px, 100%);
  background: var(--panel);
  border: 2px solid rgba(255, 255, 255, 0.14);
  border-radius: 24px;
  padding: 22px 20px 20px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.45);
  text-align: center;
}

.brand {
  margin: 0 0 6px;
  font-size: clamp(28px, 8vw, 40px);
  letter-spacing: 0.04em;
  color: var(--accent_hot);
  text-shadow: 0 3px 0 #c45a00, 0 0 24px rgba(255, 106, 0, 0.45);
}

.subtitle {
  margin: 0 0 18px;
  color: var(--muted);
  font-size: 15px;
}

.field_label {
  display: block;
  text-align: left;
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 6px;
}

.field_input {
  width: 100%;
  border: 2px solid rgba(255, 255, 255, 0.18);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  border-radius: 14px;
  padding: 14px 14px;
  font-size: 18px;
  margin-bottom: 14px;
  outline: none;
}

.field_input:focus {
  border-color: var(--accent);
}

.btn {
  width: 100%;
  border: none;
  border-radius: 16px;
  padding: 16px 14px;
  font-size: 18px;
  font-weight: 800;
  cursor: pointer;
  touch-action: manipulation;
  margin-top: 10px;
}

.btn_primary {
  background: linear-gradient(180deg, #ff922e, var(--accent));
  color: #fff;
  box-shadow: var(--btn_shadow);
}

.btn_primary:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  box-shadow: none;
}

.btn_primary:not(:disabled):active {
  transform: translateY(3px);
  box-shadow: 0 5px 0 #b34a00;
}

.btn_secondary {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  border: 2px solid rgba(255, 255, 255, 0.18);
}

.result_coins {
  font-size: 28px;
  font-weight: 800;
  color: var(--accent_hot);
  margin: 8px 0 4px;
}

.board_block {
  margin-top: 16px;
  text-align: left;
}

.board_block h2 {
  margin: 0 0 8px;
  font-size: 15px;
  color: var(--muted);
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.board_list {
  margin: 0;
  padding: 0;
  list-style: none;
  max-height: 180px;
  overflow: auto;
}

.board_list li {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.04);
  margin-bottom: 6px;
  font-size: 14px;
}

.board_list .rank {
  color: var(--muted);
  min-width: 1.5em;
}

.board_list .name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.board_list .badge {
  font-size: 11px;
  margin-left: 6px;
}

.board_list .badge_ok {
  color: var(--ok);
}

.board_list .badge_fail {
  color: #ff8fa3;
}

.board_list .coins {
  color: var(--accent_hot);
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.muted {
  color: var(--muted);
}
