/* 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. */

:root {
  --font-main: 'Outfit', 'Pretendard', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --theme-bg-gradient: linear-gradient(180deg, #f0f4f8 0%, #ffffff 100%);
  --theme-accent: #3b82f6;
  --theme-text-color: #1e293b;
  --theme-hud-bg: rgba(255, 255, 255, 0.85);
  --theme-hud-border: rgba(0, 0, 0, 0.08);
  --theme-sprite-filter: none;
  --theme-shadow: 0 10px 30px -5px rgba(0, 0, 0, 0.1);
}

* {
  box-sizing: border-box;
}

html, body {
  padding: 0;
  margin: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: var(--font-main);
  user-select: none;
  -webkit-user-select: none;
  background-color: #f7f7f7;
  transition: background-color 1.2s ease;
}

/* ==========================================================================
   Dynamic Theme Background & FX Canvas Layers
   ========================================================================== */

.theme-bg-layer {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
  transition: opacity 1s ease;
}

.sky-gradient {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: var(--theme-bg-gradient);
  transition: background 1.2s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 1;
}

.celestial-body {
  position: absolute;
  border-radius: 50%;
  transition: all 1.5s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 2;
  pointer-events: none;
}

.landscape-layer {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  transition: all 1.2s ease;
  z-index: 3;
  pointer-events: none;
}

#fx-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 4;
  pointer-events: none;
}

/* ==========================================================================
   Theme Specific Styles
   ========================================================================== */

/* 1. 기본 (Default / Daylight) */
body.theme-default {
  --theme-bg-gradient: linear-gradient(180deg, #e8eff7 0%, #fdfdfe 50%, #f4f6f8 100%);
  --theme-accent: #3b82f6;
  --theme-text-color: #334155;
  --theme-hud-bg: rgba(255, 255, 255, 0.88);
  --theme-hud-border: rgba(0, 0, 0, 0.08);
  --theme-sprite-filter: none;
}
body.theme-default .celestial-body {
  top: 12%;
  right: 15%;
  width: 80px;
  height: 80px;
  background: radial-gradient(circle, #fff9db 0%, #ffd43b 60%, rgba(255, 212, 59, 0) 100%);
  box-shadow: 0 0 50px rgba(255, 212, 59, 0.5);
  opacity: 0.85;
}

/* 2. 노을 (Sunset / Twilight) */
body.theme-sunset {
  --theme-bg-gradient: linear-gradient(180deg, #1f1235 0%, #511c47 30%, #a8324a 60%, #e06c43 85%, #fbb05b 100%);
  --theme-accent: #f97316;
  --theme-text-color: #fff1f2;
  --theme-hud-bg: rgba(45, 15, 45, 0.75);
  --theme-hud-border: rgba(249, 115, 22, 0.3);
  --theme-sprite-filter: brightness(0.9) drop-shadow(0 0 8px rgba(251, 176, 91, 0.5));
}
body.theme-sunset .celestial-body {
  bottom: 22%;
  right: 20%;
  width: 140px;
  height: 140px;
  background: radial-gradient(circle, #fff3bf 0%, #ff8787 50%, #f03e3e 80%, rgba(240, 62, 62, 0) 100%);
  box-shadow: 0 0 80px rgba(255, 107, 107, 0.8);
  opacity: 0.95;
}
body.theme-sunset .landscape-layer.layer-far {
  height: 160px;
  background: radial-gradient(ellipse at 50% 100%, rgba(249, 115, 22, 0.2) 0%, transparent 70%);
}

/* 3. 밤 (Night / Starlight) */
body.theme-night {
  --theme-bg-gradient: linear-gradient(180deg, #020617 0%, #0f172a 50%, #1e1b4b 100%);
  --theme-accent: #60a5fa;
  --theme-text-color: #f8fafc;
  --theme-hud-bg: rgba(15, 23, 42, 0.8);
  --theme-hud-border: rgba(96, 165, 250, 0.3);
  --theme-sprite-filter: invert(1) brightness(1.2) drop-shadow(0 0 10px rgba(147, 197, 253, 0.6));
}
body.theme-night .celestial-body {
  top: 15%;
  right: 18%;
  width: 70px;
  height: 70px;
  background: #fef08a;
  box-shadow: 0 0 35px #fef08a, 0 0 70px rgba(254, 240, 138, 0.4);
  border-radius: 50%;
  opacity: 1;
}

/* 4. 도시 (City / Cyberpunk Neon Skyline) */
body.theme-city {
  --theme-bg-gradient: linear-gradient(180deg, #090014 0%, #1d0838 45%, #380d58 80%, #0d0118 100%);
  --theme-accent: #ec4899;
  --theme-text-color: #fdf4ff;
  --theme-hud-bg: rgba(29, 8, 56, 0.85);
  --theme-hud-border: rgba(236, 72, 153, 0.4);
  --theme-sprite-filter: invert(1) drop-shadow(0 0 6px #00f0ff) drop-shadow(0 0 12px #ff007f);
}
body.theme-city .celestial-body {
  top: 20%;
  left: 15%;
  width: 100px;
  height: 100px;
  background: linear-gradient(180deg, #ff007f 0%, #7928ca 100%);
  box-shadow: 0 0 60px rgba(255, 0, 127, 0.7);
  opacity: 0.9;
}
body.theme-city .landscape-layer.layer-mid {
  height: 180px;
  background: repeating-linear-gradient(90deg, #090014 0px, #090014 40px, #16042b 40px, #16042b 80px, #0d011a 80px, #0d011a 130px);
  mask-image: linear-gradient(to top, black 60%, transparent 100%);
  -webkit-mask-image: linear-gradient(to top, black 60%, transparent 100%);
  opacity: 0.6;
}

/* 5. 사막 (Desert / Golden Dunes) */
body.theme-desert {
  --theme-bg-gradient: linear-gradient(180deg, #3d1c06 0%, #873e15 35%, #ca6e23 70%, #f6ad55 100%);
  --theme-accent: #d97706;
  --theme-text-color: #fffbeb;
  --theme-hud-bg: rgba(61, 28, 6, 0.8);
  --theme-hud-border: rgba(245, 158, 11, 0.35);
  --theme-sprite-filter: sepia(0.9) hue-rotate(-25deg) brightness(0.65) contrast(1.3);
}
body.theme-desert .celestial-body {
  top: 15%;
  right: 25%;
  width: 110px;
  height: 110px;
  background: radial-gradient(circle, #fffbeb 0%, #fef3c7 40%, #f59e0b 80%, transparent 100%);
  box-shadow: 0 0 90px rgba(245, 158, 11, 0.9);
  opacity: 0.95;
}
body.theme-desert .landscape-layer.layer-far {
  height: 130px;
  background: radial-gradient(ellipse at 70% 100%, #b45309 0%, #78350f 70%, transparent 100%);
  opacity: 0.7;
}

/* 6. 우주 (Space / Galaxy Nebula) */
body.theme-space {
  --theme-bg-gradient: radial-gradient(circle at 50% 30%, #1e1035 0%, #090214 50%, #000002 100%);
  --theme-accent: #a855f7;
  --theme-text-color: #faf5ff;
  --theme-hud-bg: rgba(18, 5, 36, 0.85);
  --theme-hud-border: rgba(168, 85, 247, 0.4);
  --theme-sprite-filter: invert(1) brightness(1.2) drop-shadow(0 0 12px rgba(168, 85, 247, 0.9)) drop-shadow(0 0 4px rgba(56, 189, 248, 0.8));
}
body.theme-space .celestial-body {
  top: 12%;
  left: 20%;
  width: 90px;
  height: 90px;
  background: radial-gradient(circle, #e9d5ff 0%, #c084fc 50%, #7e22ce 100%);
  box-shadow: 0 0 50px rgba(192, 132, 252, 0.6);
  opacity: 0.95;
}

/* 7. 비 (Rain / Storm) */
body.theme-rain {
  --theme-bg-gradient: linear-gradient(180deg, #09111e 0%, #112033 45%, #1e3550 80%, #0d1825 100%);
  --theme-accent: #38bdf8;
  --theme-text-color: #f0f9ff;
  --theme-hud-bg: rgba(17, 32, 51, 0.85);
  --theme-hud-border: rgba(56, 189, 248, 0.35);
  --theme-sprite-filter: invert(0.95) brightness(1.15) drop-shadow(0 0 8px rgba(56, 189, 248, 0.5));
}
body.theme-rain .celestial-body {
  top: 15%;
  right: 15%;
  width: 120px;
  height: 60px;
  background: rgba(255, 255, 255, 0.08);
  filter: blur(20px);
  opacity: 0.5;
}

/* 8. 눈 (Snow / Winter Wonderland) */
body.theme-snow {
  --theme-bg-gradient: linear-gradient(180deg, #0f1c2e 0%, #1e334d 40%, #335377 75%, #597d9f 100%);
  --theme-accent: #7dd3fc;
  --theme-text-color: #f0fdf4;
  --theme-hud-bg: rgba(20, 36, 56, 0.85);
  --theme-hud-border: rgba(125, 211, 252, 0.4);
  --theme-sprite-filter: invert(1) brightness(1.3) drop-shadow(0 0 10px rgba(255, 255, 255, 0.95));
}
body.theme-snow .celestial-body {
  top: 10%;
  right: 22%;
  width: 65px;
  height: 65px;
  background: #f0f9ff;
  box-shadow: 0 0 40px #e0f2fe, 0 0 80px rgba(224, 242, 254, 0.5);
  opacity: 0.95;
}

/* ==========================================================================
   Header HUD & Progress Bar
   ========================================================================== */

.theme-hud {
  position: fixed;
  top: 18px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 100;
  display: flex;
  justify-content: center;
  align-items: center;
  pointer-events: auto;
}

.theme-badge-wrapper {
  background: var(--theme-hud-bg);
  border: 1px solid var(--theme-hud-border);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-radius: 9999px;
  padding: 8px 20px 8px 14px;
  display: flex;
  align-items: center;
  gap: 16px;
  box-shadow: 0 8px 24px -4px rgba(0, 0, 0, 0.15);
  transition: all 0.4s ease;
}

.theme-badge-wrapper:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 30px -4px rgba(0, 0, 0, 0.25);
}

.theme-badge {
  display: flex;
  align-items: center;
  gap: 8px;
}

.theme-icon {
  font-size: 1.4rem;
  line-height: 1;
  display: inline-block;
  animation: floatIcon 3s ease-in-out infinite;
}

@keyframes floatIcon {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-3px); }
}

.theme-name {
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--theme-text-color);
  letter-spacing: -0.01em;
  white-space: nowrap;
}

.theme-progress-container {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 140px;
}

.theme-progress-info {
  display: flex;
  justify-content: space-between;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--theme-text-color);
  opacity: 0.8;
}

.theme-progress-bar {
  width: 100%;
  height: 6px;
  background: rgba(0, 0, 0, 0.1);
  border-radius: 9999px;
  overflow: hidden;
}

.theme-progress-fill {
  width: 0%;
  height: 100%;
  background: var(--theme-accent);
  border-radius: 9999px;
  transition: width 0.25s linear;
  box-shadow: 0 0 8px var(--theme-accent);
}

/* ==========================================================================
   Theme Unlock Toast Banner
   ========================================================================== */

.theme-toast {
  position: fixed;
  top: 85px;
  left: 50%;
  transform: translateX(-50%) translateY(-20px) scale(0.9);
  z-index: 110;
  opacity: 0;
  pointer-events: none;
  transition: all 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.theme-toast.show {
  transform: translateX(-50%) translateY(0) scale(1);
  opacity: 1;
}

.toast-content {
  background: rgba(15, 23, 42, 0.9);
  border: 1px solid rgba(255, 255, 255, 0.2);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  color: #fff;
  padding: 12px 24px;
  border-radius: 16px;
  display: flex;
  align-items: center;
  gap: 14px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4), 0 0 20px rgba(255, 255, 255, 0.1);
}

.toast-icon {
  font-size: 2rem;
  line-height: 1;
}

.toast-subtitle {
  font-size: 0.68rem;
  letter-spacing: 0.1em;
  font-weight: 800;
  color: #38bdf8;
}

.toast-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: #ffffff;
}

/* ==========================================================================
   Message Box & Start Screen
   ========================================================================== */

.sendmessage {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 50;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-radius: 24px;
  padding: 30px 40px;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
  border: 1px solid rgba(255, 255, 255, 0.6);
  text-align: center;
  transition: opacity 0.3s ease, visibility 0.3s ease;
  max-width: 90%;
  width: 440px;
}

.sendmessage h1 {
  margin: 0 0 10px;
  font-size: 1.6rem;
  font-weight: 800;
  color: #0f172a;
}

.start-hint {
  font-size: 0.88rem;
  color: #64748b;
  margin-bottom: 24px;
  font-weight: 500;
}

.niokbutton {
  display: inline-block;
  background: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%);
  color: #ffffff;
  padding: 12px 32px;
  border-radius: 9999px;
  font-weight: 700;
  font-size: 1rem;
  cursor: pointer;
  box-shadow: 0 10px 20px -5px rgba(59, 130, 246, 0.5);
  transition: all 0.2s ease;
}

.niokbutton:hover {
  transform: translateY(-2px);
  box-shadow: 0 14px 24px -5px rgba(59, 130, 246, 0.6);
}

.niokbutton::after {
  content: "게임 시작 (Play)";
}

/* ==========================================================================
   T-Rex Game Runner Core Elements
   ========================================================================== */

.icon {
  -webkit-user-select: none;
  user-select: none;
  display: inline-block;
}

.icon-offline {
  content: -webkit-image-set( url(assets/default_100_percent/100-error-offline.png) 1x, url(assets/default_200_percent/200-error-offline.png) 2x);
  position: relative;
}

.hidden {
  display: none;
}

.offline .interstitial-wrapper {
  color: var(--theme-text-color);
  font-size: 1em;
  line-height: 1.55;
  margin: 0 auto;
  max-width: 600px;
  padding-top: 100px;
  width: 100%;
  position: relative;
  z-index: 10;
}

.offline .runner-container {
  height: 150px;
  max-width: 600px;
  overflow: hidden;
  position: absolute;
  top: 35px;
  width: 44px;
  z-index: 10;
}

.offline .runner-canvas {
  height: 150px;
  max-width: 600px;
  opacity: 1;
  overflow: hidden;
  position: absolute;
  top: 0;
  z-index: 10;
  filter: var(--theme-sprite-filter);
  transition: filter 0.8s ease;
}

.offline .controller {
  background: transparent;
  height: 100vh;
  left: 0;
  position: absolute;
  top: 0;
  width: 100vw;
  z-index: 5;
}

#offline-resources {
  display: none;
}

.arcade-mode,
.arcade-mode .runner-container,
.arcade-mode .runner-canvas {
  image-rendering: pixelated;
  max-width: 100%;
  overflow: hidden;
}

.arcade-mode #buttons,
.arcade-mode #main-content {
  opacity: 0;
  overflow: hidden;
}

.arcade-mode .interstitial-wrapper {
  height: 100vh;
  max-width: 100%;
  overflow: hidden;
}

.arcade-mode .runner-container {
  left: 0;
  margin: auto;
  right: 0;
  transform-origin: top center;
  transition: transform 250ms cubic-bezier(0.4, 0, 1, 1) 400ms;
  z-index: 10;
}

@media (max-width: 600px) {
  .theme-hud {
    top: 10px;
    width: 92%;
  }
  .theme-badge-wrapper {
    width: 100%;
    justify-content: space-between;
    padding: 6px 14px;
  }
  .theme-name {
    font-size: 0.82rem;
  }
  .theme-progress-container {
    min-width: 100px;
  }
  .sendmessage {
    padding: 24px 20px;
  }
  .sendmessage h1 {
    font-size: 1.3rem;
  }
}

