/* ===== Theme Variables ===== */
:root {
  --bg-deep: #0a0a0f;
  --bg-surface: #14141f;
  --bg-elevated: #1e1e2e;
  --bg-overlay: rgba(10, 10, 15, 0.85);
  --text-primary: #f0f0f5;
  --text-secondary: #a0a0b5;
  --text-muted: #6b6b80;
  --accent: #f59e0b;
  --accent-dim: #d97706;
  --accent-glow: rgba(245, 158, 11, 0.15);
  --border: rgba(255, 255, 255, 0.08);
  --border-hover: rgba(255, 255, 255, 0.15);
  --success: #10b981;
  --info: #3b82f6;
  --danger: #ef4444;
  --radius: 12px;
  --radius-lg: 20px;
  --radius-xl: 28px;
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 16px 64px rgba(0, 0, 0, 0.6);
  --transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

html[data-theme="light"] {
  --bg-deep: #f8f7f4;
  --bg-surface: #ffffff;
  --bg-elevated: #f0eeeb;
  --bg-overlay: rgba(248, 247, 244, 0.9);
  --text-primary: #1a1a2e;
  --text-secondary: #4a4a5e;
  --text-muted: #8a8a9e;
  --accent: #d97706;
  --accent-dim: #b45309;
  --accent-glow: rgba(217, 119, 6, 0.1);
  --border: rgba(0, 0, 0, 0.08);
  --border-hover: rgba(0, 0, 0, 0.15);
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 16px 64px rgba(0, 0, 0, 0.12);
}

/* ===== Reset & Base ===== */
html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  min-height: 100%;
  overflow: hidden;
  touch-action: manipulation;
  background: var(--bg-deep);
  color: var(--text-primary);
  font-family: 'Kenney Future', 'Segoe UI', system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

#app {
  position: relative;
  width: 100%;
  height: 100%;
  min-height: 100%;
  overflow: hidden;
}

/* ===== Screen System ===== */
.screen {
  position: absolute;
  top: 0; left: 0;
  width: 100%;
  height: 100%;
  min-height: 100%;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.5s ease, visibility 0.5s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.screen.active {
  opacity: 1;
  visibility: visible;
}

.screen-overlay {
  z-index: 100;
  background: var(--bg-deep);
}

/* ===== Title Screen ===== */
#screen-title {
  background: linear-gradient(180deg, var(--bg-deep) 0%, #0f0f1a 100%);
}

.title-content {
  text-align: center;
  max-width: 600px;
  padding: 2rem;
  animation: fadeInUp 0.8s ease;
}

.title-main {
  font-size: clamp(2.5rem, 8vw, 4.5rem);
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--text-primary);
  margin: 0 0 0.5rem;
  line-height: 1.1;
}

.title-main::after {
  content: '';
  display: block;
  width: 60px;
  height: 3px;
  background: var(--accent);
  margin: 1rem auto;
  border-radius: 2px;
}

.title-sub {
  font-size: clamp(0.9rem, 3vw, 1.2rem);
  color: var(--text-secondary);
  font-weight: 400;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  margin: 0 0 2rem;
}

.title-divider {
  width: 40px;
  height: 1px;
  background: var(--border);
  margin: 0 auto 2rem;
}

.title-desc {
  font-size: clamp(0.95rem, 2.5vw, 1.1rem);
  color: var(--text-secondary);
  line-height: 1.7;
  margin-bottom: 2.5rem;
  max-width: 480px;
  margin-left: auto;
  margin-right: auto;
}

/* ===== Buttons ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.85rem 2rem;
  border: none;
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  text-decoration: none;
  touch-action: manipulation;
}

.btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.btn-primary {
  background: var(--accent);
  color: #000;
  box-shadow: 0 4px 20px var(--accent-glow);
}

.btn-primary:hover {
  background: var(--accent-dim);
  transform: translateY(-1px);
  box-shadow: 0 6px 28px rgba(245, 158, 11, 0.25);
}

.btn-primary:active {
  transform: translateY(0);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border);
  margin-top: 0.75rem;
}

.btn-ghost:hover {
  border-color: var(--border-hover);
  color: var(--text-primary);
  background: var(--accent-glow);
}

.btn-choice {
  display: block;
  width: 100%;
  text-align: left;
  padding: 1rem 1.25rem;
  background: var(--bg-surface);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.95rem;
  line-height: 1.5;
  margin-bottom: 0.6rem;
  transition: all var(--transition);
}

.btn-choice:hover {
  border-color: var(--accent);
  background: var(--accent-glow);
  transform: translateX(4px);
}

.btn-choice:active {
  transform: translateX(2px);
}

.btn-choice::before {
  content: '›';
  display: inline-block;
  margin-right: 0.75rem;
  color: var(--accent);
  font-weight: 700;
  font-size: 1.2em;
}

/* Icon buttons */
.btn-icon {
  position: absolute;
  top: 1rem;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-overlay);
  border: 1px solid var(--border);
  border-radius: 50%;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition);
  z-index: 10;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.btn-icon:hover {
  border-color: var(--border-hover);
  color: var(--text-primary);
  background: var(--bg-elevated);
}

.btn-map {
  right: 1rem;
}

.btn-back {
  left: 1rem;
  display: none;
}

/* ===== Story Screen ===== */
#screen-story {
  position: relative;
  align-items: flex-end;
  justify-content: flex-end;
}

.scene-bg {
  position: absolute;
  top: 0; left: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
}

.scene-bg img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  filter: brightness(0.35) saturate(1.1);
  transition: transform 8s ease;
}

.screen.active .scene-bg img {
  transform: scale(1.05);
}

.scene-overlay {
  position: absolute;
  top: 0; left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(180deg, 
    rgba(10, 10, 15, 0.3) 0%,
    rgba(10, 10, 15, 0.1) 40%,
    rgba(10, 10, 15, 0.5) 70%,
    rgba(10, 10, 15, 0.95) 100%
  );
}

.scene-content {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 640px;
  padding: 5rem 1.5rem 2.5rem;
  animation: fadeInUp 0.6s ease;
  overflow-y: auto;
  max-height: 100%;
  padding-bottom: 4rem;
}

.location-tag {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--accent);
  background: var(--accent-glow);
  padding: 0.35rem 0.75rem;
  border-radius: 4px;
  margin-bottom: 1rem;
}

.scene-heading {
  font-size: clamp(1.8rem, 6vw, 2.8rem);
  font-weight: 700;
  line-height: 1.15;
  margin: 0 0 1.25rem;
  color: var(--text-primary);
  letter-spacing: -0.02em;
}

.scene-text p {
  font-size: clamp(0.9rem, 2.5vw, 1.05rem);
  line-height: 1.8;
  color: var(--text-secondary);
  margin: 0 0 1rem;
}

.scene-text p:last-child {
  margin-bottom: 2rem;
}

.scene-choices {
  margin-top: 1.5rem;
}

.scene-choices .btn-choice {
  animation: fadeInUp 0.4s ease both;
}

/* ===== Ending Screen ===== */
#screen-ending {
  background: var(--bg-deep);
}

.ending-content {
  text-align: center;
  max-width: 560px;
  padding: 2rem;
  animation: fadeInUp 0.8s ease;
}

.ending-badge {
  display: inline-block;
  padding: 0.4rem 1rem;
  background: var(--accent-glow);
  border: 1px solid var(--accent);
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 1.5rem;
}

.ending-title {
  font-size: clamp(2rem, 7vw, 3rem);
  font-weight: 700;
  margin: 0 0 1.5rem;
  color: var(--text-primary);
  letter-spacing: -0.02em;
}

.ending-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  margin: 2rem 0;
  padding: 1.5rem;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}

.stat-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border);
}

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

.stat-row span {
  color: var(--text-secondary);
  font-size: 0.85rem;
}

.stat-row strong {
  color: var(--text-primary);
  font-size: 0.95rem;
}

.ending-actions {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-top: 1rem;
}

/* ===== Map Overlay ===== */
#screen-map {
  align-items: flex-end;
  justify-content: flex-end;
}

.map-panel {
  width: 100%;
  max-width: 600px;
  max-height: 80vh;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-bottom: none;
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  padding: 1.5rem;
  overflow-y: auto;
  animation: slideUp 0.4s ease;
}

.map-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
}

.map-header h3 {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 700;
}

.map-visual {
  margin-bottom: 1.5rem;
  background: var(--bg-deep);
  border-radius: var(--radius);
  padding: 1rem;
  overflow: hidden;
}

.map-svg {
  width: 100%;
  height: auto;
}

.map-log {
  max-height: 30vh;
  overflow-y: auto;
}

.map-log h4 {
  margin: 0 0 0.75rem;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
}

.log-entry {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 0;
  border-bottom: 1px solid var(--border);
}

.log-entry:last-child {
  border-bottom: none;
}

.log-num {
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--accent-glow);
  color: var(--accent);
  font-size: 0.7rem;
  font-weight: 700;
  flex-shrink: 0;
}

.log-loc {
  font-size: 0.75rem;
  color: var(--text-muted);
  flex-shrink: 0;
  min-width: 80px;
}

.log-title {
  font-size: 0.9rem;
  color: var(--text-primary);
}

/* ===== Animations ===== */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(40px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ===== Scrollbar ===== */
::-webkit-scrollbar {
  width: 4px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 2px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--border-hover);
}

/* ===== Responsive ===== */
@media (max-width: 480px) {
  .scene-content {
    padding: 4.5rem 1rem 2rem;
  }

  .map-panel {
    padding: 1rem;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  }

  .ending-stats {
    padding: 1rem;
    gap: 0.5rem;
  }
}

@media (min-width: 768px) {
  .scene-content {
    padding: 6rem 2rem 3rem;
  }

  .map-panel {
    max-height: 70vh;
    border-radius: var(--radius-xl);
    margin: auto;
  }
}

/* ===== Hidden images ===== */
img[data-gen-asset] {
  display: none;
}

/* ===== Utility ===== */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

