* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #0f0f1a;
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  touch-action: none;
}

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

#gameCanvas {
  display: block;
  width: 100%;
  height: 100%;
}

.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 24px;
  background: rgba(15, 15, 26, 0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  z-index: 10;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.logo {
  font-size: clamp(2rem, 8vw, 3rem);
  font-weight: 900;
  letter-spacing: 4px;
  background: linear-gradient(135deg, #ff6b6b, #feca57, #48dbfb);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  text-align: center;
}

.subtitle {
  color: #a0a0c0;
  font-size: 1rem;
  text-align: center;
}

.hint {
  color: #606080;
  font-size: 0.75rem;
  margin-top: 8px;
}

.btn {
  border: none;
  border-radius: 50px;
  padding: 14px 40px;
  font-size: 1.1rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
  min-width: 220px;
}

.btn:active {
  transform: scale(0.95);
}

.btn.primary {
  background: linear-gradient(135deg, #ff6b6b, #ee5a24);
  color: white;
  box-shadow: 0 4px 20px rgba(255, 107, 107, 0.4);
}

.btn.secondary {
  background: rgba(255, 255, 255, 0.1);
  color: #e0e0f0;
  border: 1px solid rgba(255, 255, 255, 0.15);
}

.btn.danger {
  background: transparent;
  color: #ff6b6b;
  border: 1px solid rgba(255, 107, 107, 0.3);
  font-size: 0.85rem;
  padding: 10px 24px;
  min-width: auto;
}

h2 {
  color: #f0f0ff;
  font-size: 1.8rem;
}

#scoreList {
  list-style: none;
  width: 100%;
  max-width: 320px;
  max-height: 50vh;
  overflow-y: auto;
}

#scoreList li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  margin-bottom: 8px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 12px;
  color: #e0e0f0;
  font-size: 0.95rem;
}

#scoreList li:first-child {
  background: linear-gradient(135deg, rgba(255, 215, 0, 0.2), rgba(255, 107, 107, 0.15));
  border: 1px solid rgba(255, 215, 0, 0.3);
}

#scoreList .rank {
  font-weight: 800;
  color: #feca57;
  min-width: 28px;
}

#scoreList .name {
  flex: 1;
  margin: 0 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#scoreList .pts {
  font-weight: 700;
  color: #48dbfb;
}

.empty {
  color: #606080;
  font-style: italic;
}

.hidden {
  display: none !important;
}

.final-score {
  font-size: 1.5rem;
  color: #48dbfb;
  font-weight: 700;
}

.best-label {
  color: #a0a0c0;
  font-size: 0.95rem;
}

#playerName {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 12px;
  padding: 12px 20px;
  color: white;
  font-size: 1rem;
  text-align: center;
  width: 100%;
  max-width: 280px;
  outline: none;
}

#playerName:focus {
  border-color: #48dbfb;
}

.btn.icon-btn {
  background: transparent;
  color: #a0a0c0;
  border: 1px solid rgba(255, 255, 255, 0.1);
  font-size: 0.9rem;
  padding: 10px 24px;
  min-width: auto;
}

.btn.icon-btn.muted {
  color: #606080;
  opacity: 0.7;
}

.hud {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: max(16px, env(safe-area-inset-top)) 20px 0;
  z-index: 5;
  pointer-events: none;
}

.hud-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
}

.phase-badge {
  font-size: 0.7rem !important;
  font-weight: 600 !important;
  color: #ff9ff3 !important;
  background: rgba(255, 159, 243, 0.15);
  padding: 2px 10px;
  border-radius: 20px;
  letter-spacing: 1px;
  text-transform: uppercase;
}

.milestone-toast {
  position: absolute;
  top: 18%;
  left: 50%;
  transform: translateX(-50%) scale(0.8);
  z-index: 8;
  padding: 12px 28px;
  border-radius: 50px;
  background: linear-gradient(135deg, rgba(254, 202, 87, 0.9), rgba(255, 107, 107, 0.9));
  color: #1a1a2e;
  font-weight: 900;
  font-size: 1.1rem;
  letter-spacing: 2px;
  opacity: 0;
  transition: opacity 0.3s, transform 0.3s;
  pointer-events: none;
  white-space: nowrap;
}

.milestone-toast.show {
  opacity: 1;
  transform: translateX(-50%) scale(1);
}

.hud span {
  font-size: 1.4rem;
  font-weight: 800;
  color: white;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
}

#speedDisplay {
  color: #feca57;
  font-size: 1.1rem;
}

.touch-zones {
  position: absolute;
  inset: 0;
  display: flex;
  z-index: 3;
}

.touch-zones .zone {
  flex: 1;
}

.touch-zones .zone.left {
  border-right: 1px dashed rgba(255, 255, 255, 0.05);
}

.section-label {
  color: #707090;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-top: 2px;
}

.diff-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  max-width: 340px;
}

.diff-chip {
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.05);
  color: #b0b0d0;
  border-radius: 20px;
  padding: 8px 14px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
}

.diff-chip.active {
  background: linear-gradient(135deg, rgba(255, 107, 107, 0.25), rgba(72, 219, 251, 0.2));
  color: #fff;
  border-color: rgba(72, 219, 251, 0.4);
}

.diff-chip[data-diff="extreme"].active {
  background: linear-gradient(135deg, rgba(255, 71, 87, 0.35), rgba(95, 39, 205, 0.3));
  border-color: rgba(255, 107, 107, 0.5);
}

.diff-badge {
  font-size: 0.65rem !important;
  font-weight: 700 !important;
  color: #feca57 !important;
  background: rgba(254, 202, 87, 0.12);
  padding: 2px 10px;
  border-radius: 20px;
  letter-spacing: 0.5px;
}

.gameover-diff {
  color: #feca57;
  font-size: 0.9rem;
  font-weight: 700;
  letter-spacing: 1px;
}

.lb-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 4px;
}

.lb-tab {
  border: 1px solid rgba(255, 255, 255, 0.15);
  background: rgba(255, 255, 255, 0.06);
  color: #a0a0c0;
  border-radius: 20px;
  padding: 8px 20px;
  font-weight: 700;
  font-size: 0.9rem;
  cursor: pointer;
}

.lb-tab.active {
  background: linear-gradient(135deg, rgba(72, 219, 251, 0.25), rgba(255, 107, 107, 0.2));
  color: #f0f0ff;
  border-color: rgba(72, 219, 251, 0.4);
}

.lb-status {
  color: #a0a0c0;
  font-size: 0.85rem;
  text-align: center;
}

.privacy-note {
  color: #606080;
  font-size: 0.72rem;
  text-align: center;
  line-height: 1.4;
  max-width: 300px;
}

.privacy-note a {
  color: #48dbfb;
  text-decoration: none;
}

.consent-label {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  color: #c0c0d8;
  font-size: 0.85rem;
  max-width: 300px;
  cursor: pointer;
  text-align: left;
}

.consent-label input {
  margin-top: 3px;
  accent-color: #48dbfb;
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.consent-label small {
  display: block;
  color: #707090;
  font-size: 0.75rem;
  margin-top: 2px;
}

.hp-field {
  position: absolute;
  left: -9999px;
  opacity: 0;
  height: 0;
  width: 0;
  pointer-events: none;
}

.version-tag {
  color: #404060;
  font-size: 0.65rem;
  margin-top: 4px;
  letter-spacing: 1px;
}

.update-banner {
  position: fixed;
  bottom: max(16px, env(safe-area-inset-bottom));
  left: 16px;
  right: 16px;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  background: linear-gradient(135deg, #1a1a2e, #16213e);
  border: 1px solid rgba(72, 219, 251, 0.4);
  border-radius: 14px;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
  color: #e0e0f0;
  font-size: 0.9rem;
}

.update-banner button {
  border: none;
  border-radius: 20px;
  padding: 8px 16px;
  background: #48dbfb;
  color: #1a1a2e;
  font-weight: 700;
  font-size: 0.85rem;
  white-space: nowrap;
  cursor: pointer;
}

.overlay.scrollable {
  overflow-y: auto;
  justify-content: flex-start;
  padding-top: max(20px, env(safe-area-inset-top));
  padding-bottom: max(24px, env(safe-area-inset-bottom));
}

.privacy-link {
  border: none;
  background: none;
  padding: 0;
  color: #48dbfb;
  font: inherit;
  font-size: inherit;
  cursor: pointer;
  text-decoration: underline;
}

.privacy-content {
  width: 100%;
  max-width: 340px;
  text-align: left;
}

.privacy-lead {
  color: #a0a0c0;
  font-size: 0.9rem;
  margin-bottom: 12px;
  text-align: center;
}

.privacy-card {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  padding: 14px 16px;
  margin-bottom: 10px;
}

.privacy-card h3 {
  color: #48dbfb;
  font-size: 0.95rem;
  margin-bottom: 8px;
}

.privacy-card p,
.privacy-card li {
  color: #c0c0d8;
  font-size: 0.85rem;
  line-height: 1.5;
}

.privacy-card ul {
  padding-left: 20px;
  margin-top: 6px;
}