html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: #87CEEB;
  overflow: hidden;
  overscroll-behavior: none;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', monospace;
  color: #FFFFFF;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

#game {
  display: block;
  width: 100vw;
  height: 100vh;
  touch-action: none;
}

#hud {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 10;
}

#hud-top-left, #hud-top-right {
  position: absolute;
  top: 12px;
  font-size: 14px;
  font-weight: 700;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6);
}

#hud-top-left .score {
  font-size: 22px;
  letter-spacing: 0.04em;
}
#hud-top-left .score .label {
  color: rgba(255, 255, 255, 0.65);
  font-size: 12px;
  letter-spacing: 0.15em;
  margin-right: 6px;
}
#hud-top-left .distance {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.7);
  margin-top: 2px;
}
#hud-top-left .phase {
  color: #60C0F0;
  letter-spacing: 0.1em;
}
#hud-top-left .combo {
  display: inline-block;
  margin-top: 4px;
  padding: 3px 10px;
  background: rgba(216, 84, 24, 0.9);
  color: #fff;
  border-radius: 4px;
  font-size: 13px;
  letter-spacing: 0.1em;
  text-shadow: none;
  animation: comboPulse 0.4s ease-out;
}
@keyframes comboPulse {
  0% { transform: scale(0.7); }
  60% { transform: scale(1.15); }
  100% { transform: scale(1); }
}

#floating {
  position: absolute;
  top: 35%;
  left: 50%;
  transform: translate(-50%, 0);
  pointer-events: none;
  text-align: center;
}
#floating .float-text {
  font-size: 40px;
  font-weight: 800;
  letter-spacing: 0.06em;
  color: #FFD53E;
  text-shadow: 0 4px 12px rgba(0, 0, 0, 0.8), 0 0 2px rgba(0, 0, 0, 0.9);
  animation: floatUp 1.3s ease-out forwards;
  white-space: nowrap;
}
#floating .float-text.miss { color: #FF6B6B; }
#floating .float-text.hit {
  color: #FF3A3A;
  font-size: clamp(44px, 7vw, 64px);
  text-shadow: 0 6px 16px rgba(0, 0, 0, 0.85), 0 0 8px rgba(255, 30, 30, 0.7);
}
@keyframes floatUp {
  0% { opacity: 0; transform: translateY(10px) scale(0.8); }
  20% { opacity: 1; transform: translateY(-10px) scale(1.15); }
  100% { opacity: 0; transform: translateY(-80px) scale(1); }
}

#overlay .final-stats {
  display: flex;
  gap: 48px;
  font-size: 18px;
  letter-spacing: 0.06em;
  color: #fff;
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.6);
}
#overlay .final-stats .label {
  display: block;
  color: rgba(255, 255, 255, 0.55);
  font-size: 11px;
  letter-spacing: 0.18em;
  margin-bottom: 4px;
}
#overlay .final-stats strong {
  font-size: 36px;
  color: #FFD53E;
}

#submit-form {
  display: flex;
  gap: 10px;
  align-items: stretch;
}
#submit-form input,
#overlay button {
  font-family: inherit;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.12em;
  padding: 10px 18px;
  border: 1px solid rgba(255, 255, 255, 0.4);
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  border-radius: 4px;
  outline: none;
  cursor: pointer;
  text-transform: uppercase;
}
#submit-form input {
  letter-spacing: 0.2em;
  text-transform: uppercase;
  min-width: 200px;
  cursor: text;
}
#submit-form input:focus {
  border-color: #FFD53E;
  background: rgba(255, 213, 62, 0.1);
}
#overlay button:hover {
  background: rgba(255, 255, 255, 0.18);
  border-color: #fff;
}
#overlay button.ghost {
  background: transparent;
  border-color: rgba(255, 255, 255, 0.3);
  color: rgba(255, 255, 255, 0.7);
}
#overlay button.ghost:hover {
  color: #fff;
  border-color: #fff;
}
#overlay .hint {
  font-size: 11px;
  letter-spacing: 0.2em;
  color: rgba(255, 255, 255, 0.4);
}

#overlay .leaderboard {
  width: min(520px, 90vw);
  border-collapse: collapse;
  color: #fff;
  font-size: 14px;
  letter-spacing: 0.05em;
}
#overlay .leaderboard th {
  text-align: left;
  padding: 6px 10px;
  font-size: 11px;
  letter-spacing: 0.2em;
  color: rgba(255, 255, 255, 0.5);
  border-bottom: 1px solid rgba(255, 255, 255, 0.2);
}
#overlay .leaderboard td {
  padding: 6px 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}
#overlay .leaderboard td.rank {
  color: rgba(255, 255, 255, 0.55);
  width: 40px;
}
#overlay .leaderboard td.score { text-align: right; color: #FFD53E; font-weight: 700; }
#overlay .leaderboard td.dist { text-align: right; color: rgba(255, 255, 255, 0.65); font-size: 12px; }
#overlay .leaderboard tr.me td { background: rgba(216, 84, 24, 0.18); }
#overlay .leaderboard tr.me td.rank { color: #D85418; font-weight: 700; }
#overlay .leaderboard td.empty {
  text-align: center;
  padding: 18px;
  color: rgba(255, 255, 255, 0.5);
}

#overlay .share-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
}
#overlay #share-btn {
  background: #D85418;
  color: #fff;
  border-color: #FF7033;
  font-weight: 800;
}
#overlay #share-btn:hover {
  background: #F06A2C;
  border-color: #fff;
}

#toast {
  position: fixed;
  bottom: 120px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.9);
  color: #fff;
  padding: 12px 24px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.08em;
  z-index: 60;
  pointer-events: none;
  animation: toastIn 0.18s ease-out, toastOut 0.3s ease-in 1.6s forwards;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
}
@keyframes toastIn {
  from { opacity: 0; transform: translate(-50%, 14px); }
  to   { opacity: 1; transform: translate(-50%, 0); }
}
@keyframes toastOut {
  from { opacity: 1; transform: translate(-50%, 0); }
  to   { opacity: 0; transform: translate(-50%, -10px); }
}

#hud-top-left { left: 12px; }
#hud-top-right { right: 12px; }

#hud-top-right .hearts {
  font-size: 28px;
  letter-spacing: 4px;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.75), 0 0 2px rgba(0, 0, 0, 0.9);
}
#hud-top-right .hearts .alive { color: #E84040; }
#hud-top-right .hearts .spent { color: #FFFFFF; }

#hud-top-right .shield-icon {
  display: inline-block;
  margin-right: 12px;
  font-size: 22px;
  color: #60C0F0;
  text-shadow: 0 0 10px rgba(96, 192, 240, 0.9), 0 0 4px rgba(255, 255, 255, 0.9);
  animation: shieldPulse 1.6s ease-in-out infinite;
}
@keyframes shieldPulse {
  0%, 100% { transform: scale(1); opacity: 0.85; }
  50% { transform: scale(1.2); opacity: 1; }
}

#overlay {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 24px;
  padding: 24px;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  pointer-events: auto;
  overflow-y: auto;
}

#overlay.visible { display: flex; }

#overlay h1 {
  font-size: clamp(48px, 9vw, 96px);
  margin: 0;
  letter-spacing: 0.05em;
  text-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
}

#overlay h1 .accent { color: #E84040; }

#overlay .prompt {
  font-size: clamp(14px, 2.2vw, 20px);
  margin: 0;
  opacity: 0.9;
  animation: blink 1.2s steps(2, end) infinite;
}

#overlay .character-picker {
  display: flex;
  align-items: center;
  gap: 20px;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 10px;
  padding: 14px 16px;
  min-width: 320px;
}
#overlay .char-nav {
  font-family: inherit;
  font-size: 24px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.4);
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  cursor: pointer;
  padding: 0;
  line-height: 1;
  -webkit-tap-highlight-color: transparent;
}
#overlay .char-nav:hover {
  background: rgba(255, 255, 255, 0.22);
  border-color: #fff;
}
#overlay .char-nav:active { transform: scale(0.95); }
#overlay .char-info {
  flex: 1;
  text-align: center;
  color: #fff;
}
#overlay .char-label {
  font-size: 10px;
  letter-spacing: 0.25em;
  color: rgba(255, 255, 255, 0.5);
  margin-bottom: 4px;
}
#overlay .char-name {
  font-size: 20px;
  font-weight: 800;
  letter-spacing: 0.06em;
  color: #FFD53E;
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.6);
}
#overlay .char-tagline {
  font-size: 12px;
  letter-spacing: 0.1em;
  color: rgba(255, 255, 255, 0.75);
  margin-top: 2px;
  min-height: 16px;
}
#overlay .char-count {
  font-size: 10px;
  letter-spacing: 0.2em;
  color: rgba(255, 255, 255, 0.4);
  margin-top: 8px;
}

#overlay #start-btn {
  font-family: inherit;
  font-size: clamp(18px, 3vw, 26px);
  font-weight: 800;
  letter-spacing: 0.25em;
  padding: 14px 56px;
  border-radius: 6px;
  background: #D85418;
  color: #fff;
  border: 2px solid rgba(255, 255, 255, 0.85);
  cursor: pointer;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.35), 0 0 40px rgba(216, 84, 24, 0.35);
  transition: transform 0.1s ease-out;
  -webkit-tap-highlight-color: transparent;
}
#overlay #start-btn:active { transform: translateY(2px); }
#overlay #start-btn:hover { background: #F06A2C; }

#overlay .hint {
  font-size: clamp(11px, 1.5vw, 13px);
  letter-spacing: 0.15em;
  color: rgba(255, 255, 255, 0.55);
  margin: 0;
}
#overlay .touch-hint { display: none; }
@media (hover: none) and (pointer: coarse) {
  #overlay .desktop-hint { display: none; }
  #overlay .touch-hint { display: block; }
}

#mute-btn {
  position: fixed;
  top: max(16px, env(safe-area-inset-top, 0px));
  right: 50%;
  transform: translateX(50%);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.35);
  background: rgba(0, 0, 0, 0.35);
  color: #fff;
  font-size: 16px;
  cursor: pointer;
  z-index: 30;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  padding: 0;
  line-height: 1;
}
#mute-btn:hover { background: rgba(0, 0, 0, 0.55); }

#jump-btn {
  position: fixed;
  bottom: max(24px, env(safe-area-inset-bottom, 0px));
  right: max(24px, env(safe-area-inset-right, 0px));
  width: 96px;
  height: 96px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.7);
  background: rgba(216, 84, 24, 0.9);
  color: #fff;
  font-family: inherit;
  font-weight: 800;
  font-size: 14px;
  letter-spacing: 0.18em;
  z-index: 25;
  display: none;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.35);
  user-select: none;
  cursor: pointer;
}
#jump-btn:active,
#jump-btn.pressed {
  background: #F06A2C;
  transform: scale(0.94);
}
@media (hover: none) and (pointer: coarse) {
  #jump-btn { display: block; }
}

#trick-pad {
  position: fixed;
  bottom: max(24px, env(safe-area-inset-bottom, 0px));
  left: max(24px, env(safe-area-inset-left, 0px));
  width: 220px;
  height: 220px;
  z-index: 25;
  display: none;
  pointer-events: none;
}
#trick-pad.visible { display: block; animation: trickPadIn 0.25s ease-out; }
@keyframes trickPadIn {
  from { opacity: 0; transform: scale(0.85); }
  to   { opacity: 1; transform: scale(1); }
}

.trick-btn {
  position: absolute;
  width: 78px;
  height: 78px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.75);
  background: rgba(20, 40, 80, 0.85);
  color: #fff;
  font-family: inherit;
  z-index: 25;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.4), 0 0 18px rgba(96, 192, 240, 0.3);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  line-height: 1;
  cursor: pointer;
  pointer-events: auto;
  padding: 0;
}
.trick-btn .arrow {
  font-size: 28px;
  font-weight: 700;
  line-height: 1;
}
.trick-btn .label {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.12em;
  margin-top: 3px;
  opacity: 0.85;
}
.trick-btn .pts {
  font-size: 10px;
  font-weight: 800;
  color: #FFD53E;
  margin-top: 1px;
  letter-spacing: 0.06em;
}
.trick-btn.up    { top: 0;    left: 50%; transform: translateX(-50%); }
.trick-btn.down  { bottom: 0; left: 50%; transform: translateX(-50%); }
.trick-btn.left  { left: 0;   top: 50%;  transform: translateY(-50%); }
.trick-btn.right { right: 0;  top: 50%;  transform: translateY(-50%); }
.trick-btn:active,
.trick-btn.pressed {
  background: #D85418;
  border-color: #FFD53E;
}
.trick-btn.up:active,    .trick-btn.up.pressed    { transform: translateX(-50%) scale(0.92); }
.trick-btn.down:active,  .trick-btn.down.pressed  { transform: translateX(-50%) scale(0.92); }
.trick-btn.left:active,  .trick-btn.left.pressed  { transform: translateY(-50%) scale(0.92); }
.trick-btn.right:active, .trick-btn.right.pressed { transform: translateY(-50%) scale(0.92); }
.trick-btn.used {
  opacity: 0.3;
  pointer-events: none;
  box-shadow: none;
  border-color: rgba(255, 255, 255, 0.2);
}
.trick-btn.used .pts { color: rgba(255, 213, 62, 0.3); }

@keyframes blink {
  0%, 49% { opacity: 0.9; }
  50%, 100% { opacity: 0.2; }
}
