/* ==========================================================================
   GyroMarble - Mobile-First Modern Theme & Responsive Layout
   ========================================================================== */

:root {
  --bg-primary: #090d16;
  --bg-surface: rgba(30, 41, 59, 0.75);
  --bg-surface-hover: rgba(51, 65, 85, 0.85);
  --border-glass: rgba(255, 255, 255, 0.12);
  --accent-cyan: #38bdf8;
  --accent-indigo: #6366f1;
  --accent-glow: rgba(56, 189, 248, 0.35);
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --danger: #ef4444;
  --success: #10b981;
  --font-sans: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

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

html, body {
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  background-color: var(--bg-primary);
  color: var(--text-main);
  font-family: var(--font-sans);
  user-select: none;
  -webkit-user-select: none;
  overscroll-behavior: none;
  touch-action: none;
}

#app {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
  position: relative;
  background: radial-gradient(circle at 50% 20%, #1e1b4b 0%, #090d16 80%);
}

/* ==========================================================================
   Header & HUD
   ========================================================================== */

.hud-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  background: var(--bg-surface);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border-glass);
  z-index: 10;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.hud-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.brand-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(99, 102, 241, 0.2);
  border: 1px solid rgba(99, 102, 241, 0.4);
  padding: 4px 8px;
  border-radius: 8px;
  font-weight: 700;
  font-size: 0.85rem;
  letter-spacing: 0.5px;
  color: #c7d2fe;
}

.logo-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, #fff, #6366f1);
  box-shadow: 0 0 6px #6366f1;
}

.timer-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  background: rgba(15, 23, 42, 0.6);
  padding: 2px 10px;
  border-radius: 8px;
  border: 1px solid var(--border-glass);
}

.timer-label {
  font-size: 0.65rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.timer-value {
  font-family: var(--font-mono);
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--accent-cyan);
  min-width: 48px;
  text-align: center;
}

.hud-select {
  background: var(--bg-surface);
  color: var(--text-main);
  border: 1px solid var(--border-glass);
  padding: 6px 8px;
  border-radius: 8px;
  font-size: 0.8rem;
  font-weight: 600;
  outline: none;
  cursor: pointer;
}

.sensor-badge {
  display: flex;
  align-items: center;
  gap: 5px;
  background: var(--bg-surface);
  border: 1px solid var(--border-glass);
  color: var(--text-main);
  padding: 6px 9px;
  border-radius: 8px;
  font-size: 0.72rem;
  font-weight: 600;
  cursor: pointer;
  letter-spacing: 0.3px;
  transition: all 0.2s ease;
}

.sensor-badge:active {
  transform: scale(0.94);
}

.sensor-badge.active {
  border-color: rgba(56, 189, 248, 0.5);
  background: rgba(56, 189, 248, 0.15);
  color: #7dd3fc;
}

.sensor-badge.warning {
  border-color: rgba(245, 158, 11, 0.5);
  background: rgba(245, 158, 11, 0.15);
  color: #fcd34d;
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #94a3b8;
  transition: background 0.2s ease, box-shadow 0.2s ease;
}

.sensor-badge.active .status-dot {
  background: #38bdf8;
  box-shadow: 0 0 6px #38bdf8;
}

.sensor-badge.warning .status-dot {
  background: #f59e0b;
  box-shadow: 0 0 6px #f59e0b;
}

.hud-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-surface);
  border: 1px solid var(--border-glass);
  color: var(--text-main);
  width: 36px;
  height: 36px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 1rem;
  transition: background 0.15s ease, transform 0.1s ease;
}

.hud-btn:active {
  transform: scale(0.92);
  background: var(--bg-surface-hover);
}

/* ==========================================================================
   Game Canvas Area
   ========================================================================== */

.canvas-container {
  flex: 1;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
}

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

/* ==========================================================================
   Virtual Touch Tilt Pad (Fallback on Screen)
   ========================================================================== */

.virtual-tilt-container {
  position: absolute;
  bottom: 20px;
  left: 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  z-index: 5;
  opacity: 0.45;
  transition: opacity 0.2s ease;
}

.virtual-tilt-container:hover,
.virtual-tilt-container:active {
  opacity: 0.9;
}

.virtual-tilt-pad {
  width: 90px;
  height: 90px;
  border-radius: 50%;
  background: rgba(15, 23, 42, 0.7);
  border: 2px solid rgba(255, 255, 255, 0.18);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  touch-action: none;
}

.tilt-knob {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #ffffff, #38bdf8);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
  pointer-events: none;
}

.pad-hint {
  font-size: 0.65rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* ==========================================================================
   Modals & Overlays
   ========================================================================== */

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(3, 7, 18, 0.82);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 100;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.modal-backdrop.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.modal-card {
  background: rgba(30, 41, 59, 0.9);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 24px;
  padding: 28px 24px;
  max-width: 380px;
  width: 100%;
  text-align: center;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.6), 0 0 30px var(--accent-glow);
  animation: modalPop 0.35s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes modalPop {
  0% { transform: scale(0.85); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

.modal-icon {
  width: 72px;
  height: 72px;
  margin: 0 auto 16px;
  filter: drop-shadow(0 0 16px var(--accent-cyan));
}

.modal-title {
  font-size: 1.6rem;
  font-weight: 800;
  background: linear-gradient(135deg, #ffffff, var(--accent-cyan));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-bottom: 8px;
}

.modal-subtitle {
  font-size: 0.9rem;
  color: var(--text-muted);
  line-height: 1.4;
  margin-bottom: 20px;
}

.instructions-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  text-align: left;
  background: rgba(15, 23, 42, 0.6);
  padding: 14px 16px;
  border-radius: 14px;
  margin-bottom: 18px;
  border: 1px solid var(--border-glass);
}

.inst-item {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.85rem;
  color: #e2e8f0;
}

.inst-icon {
  font-size: 1.1rem;
}

.http-notice {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  background: rgba(245, 158, 11, 0.12);
  border: 1px solid rgba(245, 158, 11, 0.35);
  border-radius: 12px;
  padding: 10px 12px;
  font-size: 0.78rem;
  color: #fde68a;
  text-align: left;
  line-height: 1.35;
  margin-bottom: 18px;
}

.http-notice.hidden {
  display: none;
}

.notice-icon {
  font-size: 1rem;
  flex-shrink: 0;
}

.troubleshoot-box {
  display: flex;
  flex-direction: column;
  gap: 12px;
  text-align: left;
  background: rgba(15, 23, 42, 0.6);
  padding: 16px;
  border-radius: 16px;
  margin-bottom: 22px;
  border: 1px solid var(--border-glass);
}

.troubleshoot-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.tb-title {
  font-size: 0.85rem;
  font-weight: 700;
  color: #38bdf8;
}

.tb-desc {
  font-size: 0.8rem;
  color: #cbd5e1;
  line-height: 1.4;
}

.tb-desc code {
  background: rgba(0, 0, 0, 0.4);
  color: #f472b6;
  padding: 2px 6px;
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 0.76rem;
  display: inline-block;
  margin-top: 2px;
}

.primary-btn {
  width: 100%;
  padding: 14px 20px;
  background: linear-gradient(135deg, #38bdf8, #6366f1);
  border: none;
  border-radius: 14px;
  color: #ffffff;
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: 0.5px;
  cursor: pointer;
  box-shadow: 0 4px 18px rgba(99, 102, 241, 0.45);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.primary-btn:active {
  transform: scale(0.96);
  box-shadow: 0 2px 10px rgba(99, 102, 241, 0.3);
}

.secondary-btn {
  width: 100%;
  padding: 12px 18px;
  background: transparent;
  border: 1px solid var(--border-glass);
  border-radius: 14px;
  color: var(--text-muted);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  margin-top: 10px;
  transition: background 0.15s ease, color 0.15s ease;
}

.secondary-btn:active {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-main);
}

/* ==========================================================================
   Victory Stats
   ========================================================================== */

.victory-stats {
  display: flex;
  justify-content: space-around;
  background: rgba(15, 23, 42, 0.6);
  padding: 14px;
  border-radius: 14px;
  margin-bottom: 20px;
  border: 1px solid var(--border-glass);
}

.stat-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.stat-label {
  font-size: 0.7rem;
  color: var(--text-muted);
  text-transform: uppercase;
}

.stat-val {
  font-family: var(--font-mono);
  font-size: 1.25rem;
  font-weight: 700;
  color: #38bdf8;
}

/* ==========================================================================
   Toast Notification
   ========================================================================== */

.toast {
  position: absolute;
  top: 70px;
  left: 50%;
  transform: translateX(-50%) translateY(-20px);
  background: rgba(15, 23, 42, 0.92);
  border: 1px solid rgba(56, 189, 248, 0.4);
  color: #f8fafc;
  padding: 8px 18px;
  border-radius: 20px;
  font-size: 0.85rem;
  font-weight: 600;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4);
  opacity: 0;
  visibility: hidden;
  transition: all 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  pointer-events: none;
  z-index: 200;
  white-space: nowrap;
}

.toast.visible {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
  visibility: visible;
}
