/* styles.css — Wildlife Reserve: Balance of Nature
   Calm, nature-focused UI. Light + dark themes via CSS variables. */

/* ----------------------------- Theme tokens ----------------------------- */
:root {
  --font: 'Segoe UI', system-ui, -apple-system, Roboto, Helvetica, Arial, sans-serif;

  --bg: #f4f1e9;
  --bg-2: #ece7db;
  --panel: #fffdf8;
  --panel-2: #f7f4ec;
  --ink: #23302a;
  --ink-soft: #556158;
  --ink-faint: #7d8880;
  --line: #e0dacb;

  --green: #2f7d54;
  --green-deep: #205c3d;
  --green-soft: #dcefe2;
  --blue: #2f6d8f;
  --blue-soft: #dceaf1;
  --sun: #c98a2b;
  --sun-soft: #f5e7cf;
  --rare: #7a5bb0;
  --rare-soft: #ece3f7;

  --pos: #2f7d54;
  --neg: #b4562f;

  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 6px 20px rgba(40, 60, 45, 0.08);
  --shadow-lg: 0 14px 40px rgba(30, 45, 35, 0.18);
  --focus: 0 0 0 3px rgba(47, 125, 84, 0.45);
  --speed: 180ms;
}

html[data-theme='dark'] {
  --bg: #14201a;
  --bg-2: #0f1813;
  --panel: #1c2b23;
  --panel-2: #172219;
  --ink: #e8f0e9;
  --ink-soft: #adbdb2;
  --ink-faint: #7f9187;
  --line: #2c3d33;

  --green: #58b487;
  --green-deep: #7fcaa2;
  --green-soft: #21362b;
  --blue: #6fb2d1;
  --blue-soft: #1e3441;
  --sun: #e0af5f;
  --sun-soft: #3a2f1c;
  --rare: #b79ce4;
  --rare-soft: #2e2540;

  --pos: #6fce9d;
  --neg: #e39069;

  --shadow: 0 6px 20px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 16px 44px rgba(0, 0, 0, 0.5);
  --focus: 0 0 0 3px rgba(111, 206, 157, 0.5);
}

/* ----------------------------- Base ----------------------------- */
* { box-sizing: border-box; }

/* The hidden attribute must always win over component display rules. */
[hidden] { display: none !important; }

body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink);
  background: radial-gradient(1200px 700px at 80% -10%, var(--bg-2), var(--bg)) fixed;
  line-height: 1.5;
  min-height: 100vh;
}

h1, h2, h3, h4 { margin: 0; line-height: 1.2; }

.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;
}

.reduced-motion *,
.reduced-motion *::before,
.reduced-motion *::after {
  transition: none !important;
  animation: none !important;
  scroll-behavior: auto !important;
}

/* ----------------------------- Buttons ----------------------------- */
.btn {
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 0.6rem 1.15rem;
  color: var(--ink);
  background: var(--panel-2);
  transition: transform var(--speed), background var(--speed), box-shadow var(--speed);
}
.btn:hover { transform: translateY(-1px); }
.btn:focus-visible { outline: none; box-shadow: var(--focus); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

.btn--primary { background: var(--green); color: #fff; border-color: var(--green-deep); }
.btn--primary:hover { background: var(--green-deep); }
.btn--secondary { background: var(--blue-soft); color: var(--ink); }
.btn--ghost { background: transparent; border-color: var(--line); }
.btn--toggle { background: var(--panel-2); border-color: var(--line); min-width: 84px; }
.btn--large { padding: 0.8rem 1.6rem; font-size: 1.05rem; }
.btn--small { padding: 0.4rem 0.8rem; font-size: 0.85rem; }

/* ----------------------------- Screens ----------------------------- */
.screen { display: none; }
.screen--active { display: block; }

#app {
  max-width: 1240px;
  margin: 0 auto;
  padding: clamp(1rem, 2.5vw, 2rem);
}

/* ----------------------------- Menu ----------------------------- */
#screen-menu.screen--active { display: flex; min-height: 90vh; align-items: center; justify-content: center; }

.menu-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: clamp(1.5rem, 4vw, 3rem);
  max-width: 640px;
  width: 100%;
  text-align: center;
}
.menu-eyebrow { text-transform: uppercase; letter-spacing: 0.16em; font-size: 0.75rem; color: var(--green); font-weight: 700; margin: 0 0 0.5rem; }
.menu-title { font-size: clamp(2.2rem, 6vw, 3.2rem); color: var(--green-deep); }
.menu-subtitle { font-size: clamp(1.1rem, 3vw, 1.5rem); color: var(--ink-soft); font-weight: 600; margin-top: 0.15rem; }
.menu-lead { color: var(--ink-soft); max-width: 46ch; margin: 1.2rem auto 0; }

.menu-best {
  display: inline-flex; flex-direction: column; gap: 0.1rem;
  margin: 1.3rem auto 0; padding: 0.6rem 1.4rem;
  background: var(--sun-soft); border-radius: var(--radius-sm);
}
.menu-best__label { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.1em; color: var(--sun); font-weight: 700; }
.menu-best__value { font-size: 1.6rem; font-weight: 800; color: var(--ink); }

.menu-actions { display: flex; gap: 0.8rem; justify-content: center; flex-wrap: wrap; margin-top: 1.6rem; }

.how-to-play {
  text-align: left; margin-top: 1.4rem; padding: 1.1rem 1.3rem;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--radius-sm);
}
.how-to-play h2 { font-size: 1.1rem; margin-bottom: 0.6rem; color: var(--green-deep); }
.how-to-play ul { margin: 0; padding-left: 1.2rem; color: var(--ink-soft); }
.how-to-play li { margin-bottom: 0.35rem; }

.menu-prefs { display: flex; gap: 1.5rem; justify-content: center; flex-wrap: wrap; margin-top: 1.6rem; }
.pref { display: flex; align-items: center; gap: 0.55rem; }
.pref__label { font-size: 0.85rem; color: var(--ink-soft); font-weight: 600; }

/* ----------------------------- Game header ----------------------------- */
.game-header {
  display: flex; align-items: center; gap: 1.2rem; flex-wrap: wrap;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 0.9rem 1.2rem; margin-bottom: 1rem;
}
.game-header__when { display: flex; flex-direction: column; }
.game-header__season { font-size: 1.4rem; font-weight: 800; color: var(--green-deep); }
.game-header__year { font-size: 0.85rem; color: var(--ink-faint); font-weight: 600; }
.progress { flex: 1; min-width: 120px; height: 8px; background: var(--panel-2); border-radius: 999px; overflow: hidden; border: 1px solid var(--line); }
.progress__bar { height: 100%; background: linear-gradient(90deg, var(--green), var(--blue)); transition: width var(--speed); }
.game-header__stats { display: flex; align-items: center; gap: 1.2rem; }
.stat { display: flex; flex-direction: column; text-align: right; }
.stat__label { font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--ink-faint); font-weight: 700; }
.stat__value { font-size: 1.15rem; font-weight: 800; }

/* ----------------------------- Game grid ----------------------------- */
.game-grid {
  display: grid;
  grid-template-columns: 300px 1fr 300px;
  gap: 1rem;
  align-items: start;
}
.game-col { display: flex; flex-direction: column; gap: 1rem; }

.panel {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 1rem 1.1rem;
}
.panel__title {
  font-size: 0.82rem; text-transform: uppercase; letter-spacing: 0.09em;
  color: var(--ink-faint); font-weight: 700; margin-bottom: 0.8rem;
}

/* ----------------------------- Meters ----------------------------- */
.meter { margin-bottom: 0.7rem; }
.meter:last-child { margin-bottom: 0; }
.meter__head { display: flex; justify-content: space-between; font-size: 0.9rem; margin-bottom: 0.25rem; }
.meter__label { color: var(--ink-soft); font-weight: 600; }
.meter__value { font-weight: 800; }
.meter__track { height: 8px; background: var(--panel-2); border-radius: 999px; overflow: hidden; border: 1px solid var(--line); }
.meter__fill { height: 100%; background: linear-gradient(90deg, var(--green), var(--blue)); transition: width var(--speed); }
.meter--budget .meter__head { margin-bottom: 0; }

/* ----------------------------- Species ----------------------------- */
.species-list { display: flex; flex-direction: column; gap: 0.5rem; }
.species { display: flex; align-items: center; gap: 0.6rem; padding: 0.35rem 0.5rem; border-radius: var(--radius-sm); background: var(--panel-2); }
.species__icon { font-size: 1.2rem; }
.species__name { flex: 1; font-weight: 600; color: var(--ink-soft); }
.species__count { font-weight: 800; font-variant-numeric: tabular-nums; }

/* ----------------------------- Event card ----------------------------- */
.panel--event { border-top: 4px solid var(--blue); }
.event { border-radius: var(--radius-sm); padding: 0.9rem 1rem; background: var(--blue-soft); }
.event--rare { background: var(--rare-soft); border: 1px dashed var(--rare); }
.event__tag {
  display: inline-block; font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.1em;
  font-weight: 800; padding: 0.15rem 0.55rem; border-radius: 999px; margin-bottom: 0.5rem;
  background: var(--blue); color: #fff;
}
.event--rare .event__tag { background: var(--rare); }
.event__title { font-size: 1.15rem; color: var(--ink); margin-bottom: 0.3rem; }
.event__text { color: var(--ink-soft); margin: 0 0 0.6rem; }
.event__tradeoff { margin: 0.6rem 0 0; font-size: 0.88rem; color: var(--ink-soft); font-style: italic; }

/* ----------------------------- Effects lists ----------------------------- */
.effects { list-style: none; margin: 0.4rem 0 0; padding: 0; display: flex; flex-direction: column; gap: 0.25rem; }
.effects--wrap { flex-direction: row; flex-wrap: wrap; gap: 0.35rem; }
.effect {
  font-size: 0.82rem; font-weight: 700; font-variant-numeric: tabular-nums;
  padding: 0.15rem 0.5rem; border-radius: 999px; width: max-content;
}
.effect--pos { background: var(--green-soft); color: var(--pos); }
.effect--neg { background: var(--sun-soft); color: var(--neg); }
.effect--none { background: var(--panel-2); color: var(--ink-faint); }

/* ----------------------------- Decision cards ----------------------------- */
.card-deck { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.8rem; }
.dcard {
  display: flex; flex-direction: column; gap: 0.4rem; text-align: left;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 0.9rem; cursor: pointer; font: inherit; color: var(--ink);
  transition: transform var(--speed), box-shadow var(--speed), border-color var(--speed);
}
.dcard:hover:not(:disabled) { transform: translateY(-3px); box-shadow: var(--shadow-lg); border-color: var(--green); }
.dcard:focus-visible { outline: none; box-shadow: var(--focus); }
.dcard--locked { opacity: 0.55; }
.dcard__head { display: flex; justify-content: space-between; align-items: center; }
.dcard__cost {
  font-weight: 800; font-size: 1.1rem; color: var(--green-deep);
  background: var(--green-soft); border-radius: 999px; padding: 0.05rem 0.6rem;
}
.dcard__cost--changed { color: var(--sun); background: var(--sun-soft); }
.dcard__cost::before { content: '💰 '; font-size: 0.8rem; }
.dcard__title { font-size: 1rem; }
.dcard__desc { font-size: 0.85rem; color: var(--ink-soft); margin: 0; }
.dcard__drawback { font-size: 0.78rem; color: var(--neg); margin: 0.2rem 0 0; font-style: italic; }
.dcard__note { font-size: 0.78rem; color: var(--blue); margin: 0.2rem 0 0; font-weight: 600; }

.chip {
  font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.06em; font-weight: 800;
  padding: 0.12rem 0.5rem; border-radius: 999px; background: var(--panel); border: 1px solid var(--line); color: var(--ink-soft);
}
.chip--habitat { color: var(--green); }
.chip--water { color: var(--blue); }
.chip--wildlife { color: var(--sun); }
.chip--conservation { color: var(--green-deep); }
.chip--visitors { color: var(--rare); }
.chip--research { color: var(--blue); }
.chip--economy { color: var(--sun); }

.redraw-row { margin-top: 0.9rem; display: flex; align-items: center; gap: 0.9rem; justify-content: center; flex-wrap: wrap; }
.redraw-note { margin: 0; color: var(--neg); font-weight: 600; font-size: 0.9rem; }

/* ----------------------------- Journal ----------------------------- */
.panel--journal { position: sticky; top: 1rem; }
.journal { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.6rem; max-height: 60vh; overflow-y: auto; }
.journal--full { max-height: none; }
.journal__entry {
  font-size: 0.85rem; color: var(--ink-soft); line-height: 1.45;
  padding: 0.55rem 0.7rem; background: var(--panel-2); border-left: 3px solid var(--green); border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}
.journal__empty { color: var(--ink-faint); font-style: italic; font-size: 0.9rem; }
.journal--full { counter-reset: j; }

/* ----------------------------- Result overlay ----------------------------- */
.overlay {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(20, 30, 24, 0.55);
  display: flex; align-items: center; justify-content: center; padding: 1rem;
  animation: fade var(--speed) ease;
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.overlay__panel {
  background: var(--panel); border-radius: var(--radius); box-shadow: var(--shadow-lg);
  max-width: 640px; width: 100%; max-height: 90vh; overflow-y: auto; padding: 1.5rem;
  border-top: 5px solid var(--green);
}
.overlay__title { font-size: 1.5rem; color: var(--green-deep); margin-bottom: 1rem; }
.overlay__actions { margin-top: 1.2rem; display: flex; justify-content: flex-end; }

.result-lead { font-size: 0.98rem; color: var(--ink); background: var(--panel-2); padding: 0.7rem 0.9rem; border-radius: var(--radius-sm); margin: 0 0 1rem; }
.result-section { margin-bottom: 1rem; }
.result-section__title { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--ink-faint); margin-bottom: 0.4rem; }
.result-note { font-size: 0.85rem; color: var(--ink-soft); margin: 0.3rem 0; }
.notes { margin: 0.5rem 0 0; padding-left: 1.1rem; font-size: 0.85rem; color: var(--ink-soft); }
.notes li { margin-bottom: 0.2rem; }
.notes--synergy li { color: var(--green); font-weight: 600; }

/* ----------------------------- Final screen ----------------------------- */
#screen-final.screen--active { display: flex; justify-content: center; }
.final-card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow-lg); padding: clamp(1.5rem, 4vw, 2.5rem); max-width: 760px; width: 100%;
}
.final-title { font-size: 2rem; color: var(--green-deep); text-align: center; margin-bottom: 1.4rem; }

.score-hero { display: flex; align-items: center; gap: 1.6rem; flex-wrap: wrap; justify-content: center; margin-bottom: 1.6rem; }
.score-hero__ring {
  width: 140px; height: 140px; border-radius: 50%;
  background: conic-gradient(var(--green) var(--score-deg, 0deg), var(--panel-2) 0);
  display: grid; place-content: center; text-align: center;
  border: 6px solid var(--panel-2);
}
.score-hero__number { font-size: 2.6rem; font-weight: 800; color: var(--green-deep); }
.score-hero__max { font-size: 0.8rem; color: var(--ink-faint); display: block; }
.score-hero__meta { text-align: left; }
.score-hero__label { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.1em; color: var(--ink-faint); font-weight: 700; margin: 0; }
.score-hero__rating { font-size: 1.6rem; font-weight: 800; color: var(--green); margin: 0.1rem 0; }
.score-hero__best { font-size: 0.9rem; color: var(--sun); font-weight: 700; margin: 0; }

.final-strongest { background: var(--green-soft); border-radius: var(--radius-sm); padding: 1rem 1.2rem; margin-bottom: 1.4rem; text-align: center; }
.final-strongest h3 { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--green-deep); margin-bottom: 0.4rem; }
.final-strongest p { margin: 0; font-size: 1.1rem; color: var(--ink); }

.final-block { margin-bottom: 1.4rem; }
.final-block h3 { font-size: 1rem; color: var(--green-deep); margin-bottom: 0.7rem; }
.final-actions { display: flex; gap: 0.8rem; justify-content: center; margin-top: 1rem; flex-wrap: wrap; }

/* ----------------------------- Responsive ----------------------------- */
@media (max-width: 1080px) {
  .game-grid { grid-template-columns: 1fr 1fr; }
  .game-col--right { grid-column: 1 / -1; }
  .panel--journal { position: static; }
  .journal { max-height: 240px; }
}
@media (max-width: 720px) {
  .game-grid { grid-template-columns: 1fr; }
  .card-deck { grid-template-columns: 1fr; }
  .game-header { justify-content: space-between; }
  .game-header__stats { gap: 0.8rem; }
  .score-hero { flex-direction: column; }
  .score-hero__meta { text-align: center; }
}
