@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;600;800;900&display=swap');

:root {
  --primary-color: #00f2fe;
  --secondary-color: #4facfe;
  --accent-color: #ff007f;
  --gold-color: #ffd700;
  --danger-color: #ff3b30;
  --success-color: #34c759;
  --bg-dark: rgba(10, 14, 26, 0.85);
  --glass-bg: rgba(255, 255, 255, 0.08);
  --glass-border: rgba(255, 255, 255, 0.18);
  --glass-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
  --text-main: #ffffff;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  touch-action: manipulation;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: #070913;
  font-family: 'Outfit', -apple-system, BlinkMacSystemFont, sans-serif;
  color: var(--text-main);
}

#canvas-container {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
}

#game-canvas {
  width: 100%;
  height: 100%;
  display: block;
}

/* UI Overlay Container */
#ui-container {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 10;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 20px;
}

#ui-container * {
  pointer-events: auto;
}

/* Top HUD Bar */
.hud-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  max-width: 600px;
  margin: 0 auto;
  gap: 15px;
}

.hud-card {
  background: var(--glass-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--glass-border);
  box-shadow: var(--glass-shadow);
  border-radius: 16px;
  padding: 10px 18px;
  text-align: center;
}

.hud-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: rgba(255, 255, 255, 0.6);
  font-weight: 600;
}

.hud-value {
  font-size: 22px;
  font-weight: 800;
  background: linear-gradient(135deg, #fff, var(--primary-color));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

/* Balance Meter */
.balance-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.balance-track {
  width: 100%;
  height: 14px;
  background: rgba(0, 0, 0, 0.4);
  border-radius: 10px;
  border: 1px solid var(--glass-border);
  position: relative;
  overflow: hidden;
}

.balance-center-zone {
  position: absolute;
  left: 40%;
  width: 20%;
  height: 100%;
  background: rgba(52, 199, 89, 0.3);
  border-left: 1px dashed rgba(255, 255, 255, 0.4);
  border-right: 1px dashed rgba(255, 255, 255, 0.4);
}

.balance-indicator {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 16px;
  height: 24px;
  background: linear-gradient(180deg, var(--gold-color), #ff9500);
  border-radius: 4px;
  box-shadow: 0 0 12px var(--gold-color);
  transition: transform 0.05s ease-out;
}

.balance-warning {
  background: linear-gradient(180deg, var(--danger-color), #ff0055) !important;
  box-shadow: 0 0 16px var(--danger-color) !important;
  animation: pulse 0.3s infinite alternate;
}

@keyframes pulse {
  0% { transform: translate(-50%, -50%) scale(1); }
  100% { transform: translate(-50%, -50%) scale(1.25); }
}

/* Combo Popup Banner */
#combo-banner {
  position: absolute;
  top: 25%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.5);
  opacity: 0;
  pointer-events: none;
  transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  text-align: center;
  z-index: 20;
}

#combo-banner.active {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}

.trick-name {
  font-size: 32px;
  font-weight: 900;
  font-style: italic;
  text-transform: uppercase;
  background: linear-gradient(135deg, #fff 0%, var(--gold-color) 50%, var(--accent-color) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  text-shadow: 0 10px 20px rgba(0,0,0,0.5);
}

.trick-points {
  font-size: 22px;
  font-weight: 800;
  color: var(--primary-color);
}

/* Wind Warning */
#wind-indicator {
  position: absolute;
  top: 18%;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(255, 59, 48, 0.2);
  border: 1px solid var(--danger-color);
  padding: 6px 16px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 1px;
  color: #ff8888;
  display: flex;
  align-items: center;
  gap: 8px;
  opacity: 0;
  transition: opacity 0.3s ease;
}

#wind-indicator.active {
  opacity: 1;
}

.wind-arrow {
  display: inline-block;
  font-size: 16px;
  transition: transform 0.3s ease;
}

/* Bottom Controls Overlay */
.controls-bottom {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  width: 100%;
  max-width: 600px;
  margin: 0 auto;
}

.btn-action {
  background: var(--glass-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--glass-border);
  box-shadow: var(--glass-shadow);
  border-radius: 50%;
  width: 72px;
  height: 72px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  cursor: pointer;
  transition: all 0.15s ease;
  color: #fff;
  touch-action: manipulation;
}

.btn-action:active {
  transform: scale(0.92);
  background: rgba(255, 255, 255, 0.2);
}

.btn-action svg {
  width: 26px;
  height: 26px;
  fill: currentColor;
}

.btn-action span {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  margin-top: 2px;
  letter-spacing: 0.5px;
}

.tilt-touch-zone {
  display: flex;
  gap: 12px;
}

.btn-tilt {
  width: 64px;
  height: 64px;
  border-radius: 18px;
}

/* Modals & Screens */
.modal-screen {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: var(--bg-dark);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  z-index: 999;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 30px;
  text-align: center;
  pointer-events: auto;
  transition: opacity 0.3s ease;
}

.modal-screen * {
  pointer-events: auto;
}

.modal-screen.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none !important;
  display: none !important;
}

.game-title {
  font-size: 44px;
  font-weight: 900;
  letter-spacing: -1px;
  margin-bottom: 8px;
  background: linear-gradient(135deg, #00f2fe 0%, #4facfe 50%, #ff007f 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  text-transform: uppercase;
}

.game-subtitle {
  font-size: 15px;
  color: rgba(255, 255, 255, 0.7);
  margin-bottom: 28px;
  max-width: 320px;
  line-height: 1.4;
}

.btn-primary {
  background: linear-gradient(135deg, #00f2fe 0%, #4facfe 100%);
  color: #040914;
  font-family: inherit;
  font-size: 18px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 1px;
  padding: 16px 42px;
  border-radius: 40px;
  border: none;
  cursor: pointer;
  box-shadow: 0 10px 25px rgba(0, 242, 254, 0.4);
  transition: all 0.2s ease;
  margin-top: 10px;
  pointer-events: auto !important;
  touch-action: manipulation;
}

.btn-primary:hover {
  transform: translateY(-2px) scale(1.03);
  box-shadow: 0 15px 30px rgba(0, 242, 254, 0.6);
}

.btn-primary:active {
  transform: translateY(1px) scale(0.98);
}

.control-tips {
  margin-top: 24px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--glass-border);
  border-radius: 16px;
  padding: 16px;
  max-width: 340px;
  width: 100%;
}

.tip-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
  font-size: 13px;
  color: rgba(255, 255, 255, 0.85);
}

.tip-row:last-child {
  margin-bottom: 0;
}

.key-badge {
  background: rgba(255, 255, 255, 0.15);
  padding: 4px 10px;
  border-radius: 6px;
  font-family: monospace;
  font-weight: 700;
  font-size: 12px;
  border: 1px solid rgba(255, 255, 255, 0.2);
}

/* Stats Summary Box on Game Over */
.stats-box {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--glass-border);
  border-radius: 20px;
  padding: 20px;
  width: 100%;
  max-width: 340px;
  margin-bottom: 24px;
}

.stat-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.stat-item:last-child {
  border-bottom: none;
}

.stat-title {
  font-size: 14px;
  color: rgba(255, 255, 255, 0.65);
}

.stat-val {
  font-size: 20px;
  font-weight: 800;
  color: var(--primary-color);
}

/* Permission Banner for Motion Sensor on iOS */
#sensor-banner {
  position: absolute;
  bottom: 100px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(12px);
  border: 1px solid var(--gold-color);
  padding: 12px 20px;
  border-radius: 30px;
  display: flex;
  align-items: center;
  gap: 12px;
  z-index: 40;
  box-shadow: 0 0 20px rgba(255, 215, 0, 0.3);
}

#sensor-banner.hidden {
  display: none;
}

.btn-sensor {
  background: var(--gold-color);
  color: #000;
  border: none;
  font-weight: 800;
  font-size: 12px;
  padding: 6px 14px;
  border-radius: 20px;
  cursor: pointer;
}

/* Calibration Button */
#btn-calibrate {
  position: absolute;
  top: 75px;
  right: 20px;
  background: var(--glass-bg);
  backdrop-filter: blur(10px);
  border: 1px solid var(--glass-border);
  border-radius: 20px;
  color: rgba(255, 255, 255, 0.8);
  font-size: 11px;
  font-weight: 700;
  padding: 6px 12px;
  cursor: pointer;
  z-index: 15;
}

#btn-calibrate:active {
  background: rgba(255, 255, 255, 0.2);
}

/* 3D Model Creative Commons Attribution Credit */
.model-credit {
  margin-top: 24px;
  font-size: 11px;
  color: rgba(255, 255, 255, 0.45);
  text-align: center;
  line-height: 1.5;
  max-width: 90%;
}

.model-credit a {
  color: var(--accent-color);
  text-decoration: underline;
  word-break: break-word;
}

/* ================================================== */
/* HIGHSCORE / LEADERBOARD UI                         */
/* ================================================== */

.leaderboard-panel {
  width: 100%;
  max-width: 340px;
  margin-top: 18px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--glass-border);
  border-radius: 20px;
  overflow: hidden;
}

.lb-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  background: rgba(255, 215, 0, 0.12);
  border-bottom: 1px solid rgba(255, 215, 0, 0.25);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--gold-color);
}

.lb-trophy { font-size: 16px; }

.lb-list {
  max-height: 220px;
  overflow-y: auto;
  padding: 6px 0;
}

.lb-list::-webkit-scrollbar { width: 4px; }
.lb-list::-webkit-scrollbar-track { background: transparent; }
.lb-list::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.2);
  border-radius: 4px;
}

.lb-row {
  display: grid;
  grid-template-columns: 28px 1fr auto;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  transition: background 0.15s ease;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.lb-row:last-child { border-bottom: none; }
.lb-row:hover { background: rgba(255, 255, 255, 0.06); }

.lb-row.rank-1 { background: rgba(255, 215, 0, 0.10); }
.lb-row.rank-2 { background: rgba(200, 200, 200, 0.07); }
.lb-row.rank-3 { background: rgba(205, 127, 50, 0.07); }
.lb-row.highlight { background: rgba(0, 242, 254, 0.12) !important; }

.lb-rank {
  font-size: 13px;
  font-weight: 800;
  color: rgba(255, 255, 255, 0.5);
  text-align: center;
}

.lb-row.rank-1 .lb-rank { color: var(--gold-color); }
.lb-row.rank-2 .lb-rank { color: #c8c8c8; }
.lb-row.rank-3 .lb-rank { color: #cd7f32; }

.lb-name {
  font-size: 14px;
  font-weight: 600;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.lb-score-val {
  font-size: 15px;
  font-weight: 800;
  background: linear-gradient(135deg, #fff, var(--primary-color));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  white-space: nowrap;
}

.lb-loading, .lb-empty {
  padding: 18px;
  text-align: center;
  color: rgba(255, 255, 255, 0.4);
  font-size: 13px;
}

/* Name Entry Form */
.name-entry {
  width: 100%;
  max-width: 340px;
  margin-top: 6px;
}

.name-entry-label {
  font-size: 13px;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.75);
  margin-bottom: 10px;
  text-align: center;
}

.name-entry-row {
  display: flex;
  gap: 10px;
  align-items: center;
}

.name-input {
  flex: 1;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(0, 242, 254, 0.4);
  border-radius: 14px;
  color: #fff;
  font-family: inherit;
  font-size: 15px;
  font-weight: 600;
  padding: 12px 16px;
  outline: none;
  transition: all 0.2s ease;
  user-select: text;
  -webkit-user-select: text;
  touch-action: manipulation;
}

.name-input::placeholder { color: rgba(255, 255, 255, 0.35); }

.name-input:focus {
  border-color: var(--primary-color);
  background: rgba(0, 242, 254, 0.08);
  box-shadow: 0 0 0 3px rgba(0, 242, 254, 0.15);
}

.btn-submit-score {
  background: linear-gradient(135deg, #ffd700, #ff9500);
  color: #000;
  border: none;
  border-radius: 14px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 800;
  padding: 12px 16px;
  cursor: pointer;
  white-space: nowrap;
  box-shadow: 0 6px 18px rgba(255, 215, 0, 0.35);
  transition: all 0.2s ease;
  touch-action: manipulation;
}

.btn-submit-score:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 24px rgba(255, 215, 0, 0.5);
}

.btn-submit-score:active { transform: scale(0.96); }

.btn-submit-score:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.score-status {
  margin-top: 8px;
  font-size: 12px;
  font-weight: 700;
  text-align: center;
  min-height: 18px;
}

.score-status.success { color: var(--success-color); }
.score-status.error   { color: var(--danger-color); }
.score-status.loading { color: var(--primary-color); }


