/* ==========================================
   Ciudad Serena — style.css
   ------------------------------------------
   Paleta:
     --night-deep:   #081423
     --night-mid:    #0d1f35
     --night-panel:  #0f2136
     --night-card:   #132844
     --accent-blue:  #1a3a5c
     --teal:         #8fb7c8
     --lavender:     #a79ac7
     --peach:        #f0b9a7
     --coral:        #e8a090
     --rosegold:     #d4a08a
     --text:         #e8dfd5
     --text-muted:   #8a9ab5
   ========================================== */

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --night-deep: #081423;
  --night-mid: #0d1f35;
  --night-panel: #0f2136;
  --night-card: #132844;
  --accent-blue: #1a3a5c;
  --teal: #8fb7c8;
  --lavender: #a79ac7;
  --peach: #f0b9a7;
  --coral: #e8a090;
  --rosegold: #d4a08a;
  --text: #e8dfd5;
  --text-muted: #8a9ab5;

  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 22px;
  --radius-xl: 32px;

  --ease-out: cubic-bezier(.22, 1, .36, 1);
  --ease-in-out: cubic-bezier(.65, 0, .35, 1);
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: 'Nunito', sans-serif;
  background: var(--night-deep);
  color: var(--text);
  min-height: 100dvh;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

/* ---- Utility ---- */

.eyebrow {
  font-size: .75rem;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--teal);
  opacity: .8;
}

h1 {
  font-size: clamp(2rem, 5vw, 3.2rem);
  font-weight: 800;
  line-height: 1.1;
  background: linear-gradient(135deg, var(--teal), var(--lavender), var(--peach));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

h2 {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text);
}

/* ---- App Shell ---- */

.app {
  position: relative;
  width: 100%;
  height: 100dvh;
  overflow: hidden;
}

.ambient {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 0;
}

.ambient--left {
  background: radial-gradient(ellipse at 10% 80%, rgba(143,183,200,.07) 0%, transparent 60%);
}

.ambient--right {
  background: radial-gradient(ellipse at 90% 20%, rgba(167,154,199,.06) 0%, transparent 55%);
}

/* ---- Screens ---- */

.screen {
  position: absolute;
  inset: 0;
  display: flex;
  opacity: 0;
  pointer-events: none;
  transition: opacity .6s var(--ease-out);
  z-index: 1;
}

.screen.is-visible {
  opacity: 1;
  pointer-events: auto;
}

/* ---- MENU SCREEN ---- */

.screen--menu {
  align-items: center;
  justify-content: center;
  z-index: 10;
  padding: 1.5rem;
  overflow-y: auto;
}

.menu-shell {
  max-width: 720px;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

.menu-copy {
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: .5rem;
}

.menu-lead {
  font-size: .95rem;
  color: var(--text-muted);
  max-width: 500px;
  margin: 0 auto;
  line-height: 1.55;
}

.menu-grid {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.menu-panel {
  background: var(--night-panel);
  border: 1px solid rgba(143,183,200,.08);
  border-radius: var(--radius-lg);
  padding: 1.25rem 1.5rem;
  display: flex;
  flex-direction: column;
  gap: .85rem;
}

.menu-note {
  font-size: .78rem;
  color: var(--text-muted);
  opacity: .65;
}

/* Scene options */

.scene-options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .75rem;
}

.scene-option {
  display: flex;
  flex-direction: column;
  gap: .5rem;
  background: var(--night-card);
  border: 2px solid transparent;
  border-radius: var(--radius-md);
  padding: .85rem;
  cursor: pointer;
  transition: border-color .3s var(--ease-out), background .3s;
  text-align: left;
  color: var(--text);
  font-family: inherit;
}

.scene-option.is-selected {
  border-color: var(--teal);
  background: rgba(143,183,200,.08);
}

.scene-option:hover:not(.is-selected) {
  border-color: rgba(143,183,200,.25);
}

.scene-option__preview {
  width: 100%;
  height: 80px;
  border-radius: var(--radius-sm);
  display: block;
}

.scene-option__preview--neighborhood {
  background: linear-gradient(180deg, #0d1f35 0%, #132844 60%, #1a3a5c 100%);
}

.scene-option__preview--station {
  background: linear-gradient(180deg, #0d1f35 0%, #1a2844 60%, #2a3050 100%);
}

.scene-option__title {
  font-size: .88rem;
  font-weight: 700;
}

.scene-option__text {
  font-size: .78rem;
  color: var(--text-muted);
  line-height: 1.4;
}

/* Duration chips */

.chip-group {
  display: flex;
  gap: .5rem;
}

.duration-chip {
  flex: 1;
  padding: .6rem 1rem;
  border: 2px solid rgba(143,183,200,.12);
  border-radius: var(--radius-md);
  background: var(--night-card);
  color: var(--text);
  font-family: inherit;
  font-size: .88rem;
  font-weight: 600;
  cursor: pointer;
  transition: border-color .3s, background .3s, color .3s;
}

.duration-chip.is-selected {
  border-color: var(--lavender);
  background: rgba(167,154,199,.12);
  color: var(--lavender);
}

.duration-chip:hover:not(.is-selected) {
  border-color: rgba(167,154,199,.3);
}

/* Toggle pills */

.toggle-list {
  display: flex;
  flex-direction: column;
  gap: .5rem;
}

.toggle-pill {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .65rem 1rem;
  border: 1px solid rgba(143,183,200,.1);
  border-radius: var(--radius-md);
  background: var(--night-card);
  color: var(--text);
  font-family: inherit;
  font-size: .88rem;
  cursor: pointer;
  transition: border-color .3s, background .3s;
}

.toggle-pill__label {
  font-weight: 600;
}

.toggle-pill__status {
  font-size: .78rem;
  color: var(--text-muted);
  transition: color .3s;
}

.toggle-pill.is-on {
  border-color: rgba(143,183,200,.2);
}

.toggle-pill.is-on .toggle-pill__status {
  color: var(--teal);
}

/* Start button */

.start-button {
  display: block;
  width: 100%;
  max-width: 340px;
  margin: 0 auto;
  padding: .95rem 2rem;
  border: none;
  border-radius: var(--radius-xl);
  background: linear-gradient(135deg, var(--teal), var(--lavender));
  color: var(--night-deep);
  font-family: inherit;
  font-size: 1.05rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform .25s var(--ease-out), box-shadow .3s;
  box-shadow: 0 4px 24px rgba(143,183,200,.2);
}

.start-button:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 32px rgba(143,183,200,.3);
}

.start-button:active {
  transform: translateY(0);
}

.start-button--secondary {
  background: linear-gradient(135deg, var(--lavender), var(--peach));
}

.start-button--ghost {
  background: transparent;
  border: 2px solid rgba(143,183,200,.2);
  color: var(--text);
  box-shadow: none;
}

.start-button--ghost:hover {
  border-color: rgba(143,183,200,.4);
  box-shadow: none;
}

/* ---- GAME SCREEN ---- */

.screen--game {
  display: flex;
  flex-direction: column;
}

/* Breathing panel */

.breathing-panel {
  flex: 0 0 auto;
  padding: 1rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: .75rem;
  background: var(--night-mid);
  border-bottom: 1px solid rgba(143,183,200,.06);
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.timer-pill {
  font-size: .85rem;
  font-weight: 700;
  padding: .35rem .85rem;
  border-radius: 100px;
  background: var(--night-card);
  color: var(--teal);
  font-variant-numeric: tabular-nums;
}

.breath-stage {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .5rem;
}

.breath-gauge {
  position: relative;
  width: 280px;
  max-width: 100%;
  aspect-ratio: 320 / 180;
}

.breath-fill {
  display: none;
}

.breath-arc {
  width: 100%;
  height: 100%;
}

.breath-track {
  fill: none;
  stroke: rgba(143,183,200,.08);
  stroke-width: 18;
  stroke-linecap: round;
}

.breath-progress {
  fill: none;
  stroke: url(#arcGradient);
  stroke-width: 18;
  stroke-linecap: round;
  stroke-dasharray: 100;
  stroke-dashoffset: 100;
  transition: stroke-dashoffset .1s linear;
}

.breath-core {
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: .15rem;
}

.breath-phase {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--text);
  transition: opacity .35s var(--ease-out);
}

.breath-phase.fade-out {
  opacity: 0;
}

.breath-subphase {
  font-size: .72rem;
  color: var(--text-muted);
  letter-spacing: .08em;
}

.breath-hint {
  font-size: .75rem;
  color: var(--text-muted);
  opacity: .5;
  text-align: center;
}

/* ---- Scene Panel ---- */

.scene-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}

.scene-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .75rem 1.25rem;
  flex-wrap: wrap;
  gap: .5rem;
}

.scene-actions {
  display: flex;
  gap: .4rem;
  flex-wrap: wrap;
}

.mini-pill {
  padding: .3rem .7rem;
  border-radius: 100px;
  border: 1px solid rgba(143,183,200,.12);
  background: var(--night-card);
  color: var(--text-muted);
  font-family: inherit;
  font-size: .72rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: .3rem;
  transition: border-color .3s, background .3s;
}

.mini-pill strong {
  color: var(--text-muted);
  font-weight: 600;
}

.mini-pill.is-on strong {
  color: var(--teal);
}

.mini-pill:hover {
  border-color: rgba(143,183,200,.3);
}

/* ---- City Frame ---- */

.city-frame {
  flex: 1;
  position: relative;
  overflow: hidden;
  background: linear-gradient(180deg, #081423 0%, #0d1f35 40%, #132844 100%);
}

.city-sky {
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at 50% 0%, rgba(26,58,92,.3) 0%, transparent 70%);
}

.city-stars,
.city-roads,
.city-buildings,
.city-trees,
.city-traffic,
.city-station,
.city-people,
.city-owls,
.city-train-layer {
  position: absolute;
  inset: 0;
}

.city-fog {
  position: absolute;
  inset: 0;
  background: linear-gradient(0deg, rgba(8,20,35,.6) 0%, transparent 30%);
  pointer-events: none;
}

.city-vignette {
  position: absolute;
  inset: 0;
  box-shadow: inset 0 0 80px 30px rgba(8,20,35,.5);
  pointer-events: none;
}

.scene-caption {
  position: absolute;
  bottom: .75rem;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(8,20,35,.7);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  padding: .4rem 1rem;
  border-radius: 100px;
  font-size: .72rem;
  color: var(--text-muted);
  white-space: nowrap;
  max-width: 90%;
  overflow: hidden;
  text-overflow: ellipsis;
  z-index: 5;
}

/* ---- Stars ---- */

.star {
  position: absolute;
  width: 2px;
  height: 2px;
  background: var(--text);
  border-radius: 50%;
  opacity: 0;
  animation: starTwinkle 3s ease-in-out infinite;
}

@keyframes starTwinkle {
  0%, 100% { opacity: .15; }
  50% { opacity: .7; }
}

/* ---- Buildings ---- */

.building {
  position: absolute;
  border-radius: 2px 2px 0 0;
  image-rendering: pixelated;
}

.building-window {
  position: absolute;
  width: 4px;
  height: 4px;
  border-radius: 1px;
  opacity: 0;
  animation: windowGlow 6s ease-in-out infinite;
}

@keyframes windowGlow {
  0%, 100% { opacity: .15; }
  50% { opacity: .85; }
}

/* ---- Roads ---- */

.road {
  position: absolute;
  background: rgba(143,183,200,.04);
}

.road--h {
  height: 8px;
}

.road--v {
  width: 8px;
}

/* ---- Trees ---- */

.tree {
  position: absolute;
  width: 14px;
  height: 20px;
}

.tree__trunk {
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 4px;
  height: 8px;
  background: #2a3a2a;
  border-radius: 1px;
}

.tree__canopy {
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 12px;
  height: 12px;
  background: radial-gradient(circle, #1a3a2a, #0d2a1a);
  border-radius: 50%;
  animation: canopySway 6s ease-in-out infinite;
}

@keyframes canopySway {
  0%, 100% { transform: translateX(-50%) rotate(0deg); }
  50% { transform: translateX(-50%) rotate(1.5deg); }
}

/* ---- Traffic Lights ---- */

.traffic-light {
  position: absolute;
  width: 6px;
  height: 14px;
  background: #1a2a3a;
  border-radius: 2px;
}

.traffic-light__dot {
  position: absolute;
  width: 4px;
  height: 4px;
  left: 1px;
  border-radius: 50%;
  animation: trafficPulse 8s ease-in-out infinite;
}

.traffic-light__dot--top { top: 1px; background: #e85050; }
.traffic-light__dot--mid { top: 5px; background: #e8c050; }
.traffic-light__dot--bot { top: 9px; background: #50c870; }

@keyframes trafficPulse {
  0%, 40% { opacity: .2; }
  45%, 55% { opacity: 1; }
  60%, 100% { opacity: .2; }
}

/* ---- Station ---- */

.station-platform {
  position: absolute;
  background: rgba(143,183,200,.06);
  border: 1px solid rgba(143,183,200,.08);
  border-radius: 3px;
}

.station-roof {
  position: absolute;
  background: rgba(167,154,199,.08);
  border-radius: 2px 2px 0 0;
}

/* ---- People ---- */

.person {
  position: absolute;
  width: 6px;
  height: 10px;
  border-radius: 3px 3px 1px 1px;
  cursor: default;
  transition: left 2.5s var(--ease-out), bottom 2.5s var(--ease-out);
  will-change: left, bottom;
}

.person__head {
  position: absolute;
  top: -3px;
  left: 50%;
  transform: translateX(-50%);
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: inherit;
  filter: brightness(1.2);
}

/* ---- Owls ---- */

.owl {
  position: absolute;
  width: 16px;
  height: 14px;
  cursor: pointer;
  transition: left 1.8s var(--ease-out), bottom 1.8s var(--ease-out), transform .4s var(--ease-out);
  will-change: left, bottom, transform;
  z-index: 3;
}

.owl:hover {
  transform: scale(1.15);
}

.owl__body {
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 12px;
  height: 10px;
  border-radius: 5px 5px 3px 3px;
  background: #4a3a2a;
}

.owl__eye {
  position: absolute;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: #f0d070;
  top: 2px;
  animation: owlBlink 5s ease-in-out infinite;
}

.owl__eye--left { left: 2px; }
.owl__eye--right { right: 2px; }

@keyframes owlBlink {
  0%, 90%, 100% { transform: scaleY(1); }
  95% { transform: scaleY(.1); }
}

.owl__beak {
  position: absolute;
  top: 5px;
  left: 50%;
  transform: translateX(-50%);
  width: 3px;
  height: 2px;
  background: #c8a050;
  border-radius: 0 0 2px 2px;
}

.owl__wing {
  position: absolute;
  bottom: 2px;
  width: 5px;
  height: 7px;
  border-radius: 50%;
  background: #3a2a1a;
}

.owl__wing--left { left: 0; }
.owl__wing--right { right: 0; }

.owl.is-hooting {
  animation: owlHoot .5s var(--ease-out);
}

@keyframes owlHoot {
  0%, 100% { transform: scale(1); }
  30% { transform: scale(1.2) translateY(-2px); }
  60% { transform: scale(1.08); }
}

/* ---- Train ---- */

.train {
  position: absolute;
  display: flex;
  will-change: left;
}

.train__car {
  width: 36px;
  height: 14px;
  border-radius: 3px;
  margin-right: 2px;
  position: relative;
  flex-shrink: 0;
}

.train__car--engine {
  background: linear-gradient(90deg, #3a5060, #4a6070);
  border-radius: 3px 6px 3px 3px;
}

.train__car--wagon {
  background: linear-gradient(90deg, #2a3a4a, #344858);
}

.train__window {
  position: absolute;
  width: 6px;
  height: 5px;
  top: 3px;
  background: rgba(240,185,167,.25);
  border-radius: 1px;
}

.train__light {
  position: absolute;
  right: -2px;
  top: 4px;
  width: 4px;
  height: 4px;
  background: #f0d070;
  border-radius: 50%;
  box-shadow: 0 0 8px 2px rgba(240,208,112,.5);
}

/* ---- Session Complete Overlay ---- */

.session-complete {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(8,20,35,.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  z-index: 20;
  opacity: 0;
  pointer-events: none;
  transition: opacity .6s var(--ease-out);
  padding: 1.5rem;
}

.session-complete[aria-hidden="false"] {
  opacity: 1;
  pointer-events: auto;
}

.session-complete__card {
  background: var(--night-panel);
  border: 1px solid rgba(143,183,200,.1);
  border-radius: var(--radius-xl);
  padding: 2.5rem 2rem;
  max-width: 440px;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.session-complete__card h2 {
  font-size: 1.2rem;
  line-height: 1.4;
  background: linear-gradient(135deg, var(--teal), var(--lavender));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.session-complete__card p {
  font-size: .88rem;
  color: var(--text-muted);
  line-height: 1.5;
}

.session-complete__actions {
  display: flex;
  gap: .75rem;
  flex-direction: column;
  margin-top: .5rem;
}

/* ---- Fireflies (for station ambiance) ---- */

.firefly {
  position: absolute;
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: rgba(240,208,112,.6);
  box-shadow: 0 0 6px 2px rgba(240,208,112,.3);
  opacity: 0;
  animation: fireflyFloat 8s ease-in-out infinite;
  pointer-events: none;
}

@keyframes fireflyFloat {
  0%   { opacity: 0; transform: translate(0, 0); }
  15%  { opacity: .7; }
  50%  { opacity: .4; transform: translate(15px, -20px); }
  85%  { opacity: .6; }
  100% { opacity: 0; transform: translate(-10px, 10px); }
}

/* ---- RESPONSIVE: Desktop ---- */

@media (min-width: 768px) {
  .screen--game {
    flex-direction: row;
  }

  .breathing-panel {
    flex: 0 0 380px;
    border-bottom: none;
    border-right: 1px solid rgba(143,183,200,.06);
    justify-content: center;
    padding: 2rem;
  }

  .breath-gauge {
    width: 320px;
  }

  .scene-panel {
    flex: 1;
  }

  .scene-topbar {
    padding: 1rem 1.5rem;
  }

  .session-complete__actions {
    flex-direction: row;
    justify-content: center;
  }

  .session-complete__actions .start-button {
    max-width: 200px;
  }
}

/* ---- Small mobile tweaks ---- */

@media (max-width: 400px) {
  .scene-options {
    grid-template-columns: 1fr;
  }

  .scene-option__preview {
    height: 60px;
  }

  .breath-gauge {
    width: 220px;
  }

  .breath-phase {
    font-size: 1.15rem;
  }
}
