/* Copyright 2013 The Chromium Authors. All rights reserved.
 * Use of this source code is governed by a BSD-style license that can be
 * found in the LICENSE file. */

html, body {
  padding: 0;
  margin: 0;
  width: 100%;
  height: 100%;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  overflow: hidden;
  transition: background 1.2s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
  box-sizing: border-box;
}

/* ==========================================================================
   Hidden Resources (Sprites are drawn via JS Canvas, MUST NOT be displayed in DOM)
   ========================================================================== */
#offline-resources,
#main-content,
.icon,
.icon-offline,
.hidden {
  display: none !important;
}

/* ==========================================================================
   Game Layout & Canvas Centering
   ========================================================================== */
.offline .interstitial-wrapper {
  color: #2b2b2b;
  font-size: 1em;
  line-height: 1.55;
  margin: 0 auto;
  max-width: 600px;
  width: 100%;
  height: 100vh;
  position: relative;
  display: flex;
  justify-content: center;
  align-items: center;
}

.offline .runner-container {
  height: 150px;
  max-width: 600px;
  width: 100%;
  overflow: hidden;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  transform-origin: center center;
}

.offline .runner-canvas {
  height: 150px;
  max-width: 600px;
  width: 100%;
  opacity: 1;
  overflow: hidden;
  position: absolute;
  top: 0;
  left: 0;
  z-index: 2;
  transition: filter 0.5s ease;
}

.offline .controller {
  background: transparent;
  height: 100vh;
  left: 0;
  position: fixed;
  top: 0;
  width: 100vw;
  z-index: 1;
}

#main-frame-error {
  margin: auto;
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 100vh;
}

/* ==========================================================================
   Start Hint Banner
   ========================================================================== */
.start-hint-banner {
  position: fixed;
  top: 100px;
  left: 0;
  width: 100%;
  display: flex;
  justify-content: center;
  z-index: 15;
  pointer-events: none;
  animation: fadeInHint 0.5s ease;
}

@keyframes fadeInHint {
  from { opacity: 0; transform: translateY(-10px); }
  to { opacity: 1; transform: translateY(0); }
}

.hint-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 22px;
  border-radius: 9999px;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
  font-size: 0.88rem;
  font-weight: 700;
  color: #1e293b;
  border: 1px solid rgba(226, 232, 240, 0.8);
  animation: pulseHint 2s infinite;
}

@keyframes pulseHint {
  0%, 100% { transform: scale(1); opacity: 0.95; }
  50% { transform: scale(1.03); opacity: 1; }
}

body.bg-theme-1 .hint-pill,
body.bg-theme-2 .hint-pill,
body.bg-theme-3 .hint-pill,
body.bg-theme-5 .hint-pill,
body.bg-theme-6 .hint-pill {
  background: rgba(15, 23, 42, 0.85);
  color: #f8fafc;
  border-color: rgba(255, 255, 255, 0.15);
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
}

/* ==========================================================================
   Game Toast
   ========================================================================== */
.game-toast {
  position: fixed;
  top: 76px;
  left: 50%;
  transform: translateX(-50%) translateY(-20px);
  background: rgba(15, 23, 42, 0.92);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #f8fafc;
  padding: 10px 24px;
  border-radius: 9999px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
  font-size: 0.9rem;
  font-weight: 600;
  z-index: 999;
  opacity: 0;
  pointer-events: none;
  transition: all 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

.game-toast.active {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
  pointer-events: auto;
}

/* ==========================================================================
   Top App Navigation HUD Bar
   ========================================================================== */
.app-hud-bar {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 60px;
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid rgba(226, 232, 240, 0.8);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.05);
  z-index: 100;
  transition: background 0.3s ease, border-color 0.3s ease;
}

body.bg-theme-1 .app-hud-bar,
body.bg-theme-2 .app-hud-bar,
body.bg-theme-3 .app-hud-bar,
body.bg-theme-5 .app-hud-bar,
body.bg-theme-6 .app-hud-bar {
  background: rgba(15, 23, 42, 0.8);
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
}

.hud-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.hud-home-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 14px;
  border-radius: 10px;
  background: #0f172a;
  color: #ffffff;
  font-weight: 700;
  font-size: 0.85rem;
  text-decoration: none;
  transition: all 0.2s ease;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.2);
}

.hud-home-btn:hover {
  transform: translateY(-1px);
  background: #1e293b;
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.3);
}

.hud-badge-title {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: 'Orbitron', sans-serif;
  font-weight: 800;
  font-size: 0.92rem;
  color: #334155;
  letter-spacing: 0.04em;
}

body.bg-theme-1 .hud-badge-title,
body.bg-theme-2 .hud-badge-title,
body.bg-theme-3 .hud-badge-title,
body.bg-theme-5 .hud-badge-title,
body.bg-theme-6 .hud-badge-title {
  color: #f1f5f9;
}

.hud-center {
  display: flex;
  align-items: center;
}

.theme-status-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  border-radius: 9999px;
  background: rgba(241, 245, 249, 0.9);
  border: 1px solid rgba(203, 213, 225, 0.8);
  font-size: 0.85rem;
  font-weight: 600;
  color: #334155;
}

body.bg-theme-1 .theme-status-pill,
body.bg-theme-2 .theme-status-pill,
body.bg-theme-3 .theme-status-pill,
body.bg-theme-5 .theme-status-pill,
body.bg-theme-6 .theme-status-pill {
  background: rgba(30, 41, 59, 0.85);
  border-color: rgba(255, 255, 255, 0.15);
  color: #e2e8f0;
}

.theme-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #10b981;
  box-shadow: 0 0 8px #10b981;
  animation: pulseDot 2s infinite;
}

@keyframes pulseDot {
  0%, 100% { transform: scale(1); opacity: 0.8; }
  50% { transform: scale(1.3); opacity: 1; }
}

.hud-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.user-profile-badge {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 12px 4px 6px;
  border-radius: 12px;
  background: rgba(241, 245, 249, 0.9);
  border: 1px solid rgba(203, 213, 225, 0.8);
}

body.bg-theme-1 .user-profile-badge,
body.bg-theme-2 .user-profile-badge,
body.bg-theme-3 .user-profile-badge,
body.bg-theme-5 .user-profile-badge,
body.bg-theme-6 .user-profile-badge {
  background: rgba(30, 41, 59, 0.85);
  border-color: rgba(255, 255, 255, 0.15);
}

.user-avatar {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: linear-gradient(135deg, #3b82f6, #1d4ed8);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
}

.user-meta {
  display: flex;
  flex-direction: column;
  text-align: left;
}

.user-name {
  font-size: 0.82rem;
  font-weight: 700;
  color: #0f172a;
}

body.bg-theme-1 .user-name,
body.bg-theme-2 .user-name,
body.bg-theme-3 .user-name,
body.bg-theme-5 .user-name,
body.bg-theme-6 .user-name {
  color: #f8fafc;
}

.user-score {
  font-size: 0.72rem;
  color: #64748b;
  font-family: 'JetBrains Mono', monospace;
}

.user-score strong {
  color: #2563eb;
  font-weight: 800;
}

body.bg-theme-1 .user-score strong,
body.bg-theme-2 .user-score strong,
body.bg-theme-3 .user-score strong,
body.bg-theme-5 .user-score strong,
body.bg-theme-6 .user-score strong {
  color: #60a5fa;
}

.hud-btn-login {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: 10px;
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  color: #ffffff;
  font-weight: 700;
  font-size: 0.82rem;
  text-decoration: none;
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.3);
  transition: all 0.2s ease;
}

.hud-btn-login:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(37, 99, 235, 0.45);
}

/* ==========================================================================
   8-Stage Background Themes (Every 100 Points)
   ========================================================================== */
/* 0. 기본 (0~99점) */
body.bg-theme-0 {
  background: #f8fafc;
}

/* 1. 노을 (100~199점) */
body.bg-theme-1 {
  background: linear-gradient(180deg, #1e0936 0%, #581c87 30%, #be185d 65%, #ea580c 85%, #fde047 100%);
}
body.bg-theme-1 .runner-canvas { filter: invert(1) drop-shadow(0 2px 8px rgba(255,255,255,0.4)); }

/* 2. 밤 (200~299점) */
body.bg-theme-2 {
  background: linear-gradient(180deg, #020617 0%, #0f172a 45%, #1e1b4b 100%);
}
body.bg-theme-2 .runner-canvas { filter: invert(1) drop-shadow(0 2px 10px rgba(147, 197, 253, 0.5)); }

/* 3. 도시 (300~399점) */
body.bg-theme-3 {
  background: linear-gradient(180deg, #090014 0%, #1f0836 40%, #701a75 75%, #be185d 100%);
}
body.bg-theme-3 .runner-canvas { filter: invert(1) hue-rotate(280deg) brightness(1.2); }

/* 4. 사막 (400~499점) */
body.bg-theme-4 {
  background: linear-gradient(180deg, #fffbeb 0%, #fed7aa 35%, #f97316 75%, #9a3412 100%);
}

/* 5. 우주 (500~599점) */
body.bg-theme-5 {
  background: radial-gradient(circle at top, #1e1035 0%, #030014 60%, #000000 100%);
}
body.bg-theme-5 .runner-canvas { filter: invert(1) drop-shadow(0 0 12px rgba(168, 85, 247, 0.7)); }

/* 6. 비 (600~699점) */
body.bg-theme-6 {
  background: linear-gradient(180deg, #090d16 0%, #1e293b 50%, #334155 100%);
}
body.bg-theme-6 .runner-canvas { filter: invert(1) drop-shadow(0 2px 8px rgba(148, 163, 184, 0.6)); }

/* 7. 눈 (700~799점) */
body.bg-theme-7 {
  background: linear-gradient(180deg, #0284c7 0%, #38bdf8 35%, #bae6fd 70%, #ffffff 100%);
}

@media (max-width: 640px) {
  .app-hud-bar {
    padding: 0 12px;
  }
  .hud-badge-title {
    display: none;
  }
  .user-score {
    display: none;
  }
}
