/* ===== QAMUTIK — Arctic Settlement Sim =====
   Stylesheet v2
   =========================================== */

:root {
  --bg-deep: #080b12;
  --bg-panel: #0d1117;
  --bg-card: #141a24;
  --bg-card-hover: #1a2230;
  --bg-card-active: #1e2a3d;
  --border: #1c2535;
  --border-light: #2a3a4f;
  --ice-blue: #7ec8e3;
  --ice-bright: #a8e0f5;
  --aurora-green: #4ade80;
  --amber: #f59e0b;
  --red: #ef4444;
  --green-dim: rgba(74, 222, 128, 0.12);
  --red-dim: rgba(239, 68, 68, 0.12);
  --amber-dim: rgba(245, 158, 11, 0.12);
  --blue-dim: rgba(126, 200, 227, 0.12);
  --text-primary: #e2e8f0;
  --text-secondary: #8899aa;
  --text-muted: #4a5568;
  --summer-gold: #fbbf24;
  --winter-blue: #3b82f6;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  background: var(--bg-deep);
  color: var(--text-primary);
  font-family: 'Outfit', sans-serif;
  min-height: 100vh;
  overflow-x: hidden;
}

/* ===== SKY & STARS ===== */

.sky {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 350px;
  z-index: 0;
  transition: background 1.2s ease;
  pointer-events: none;
}
.sky.winter { background: linear-gradient(180deg, #030610 0%, #0a0f1f 50%, var(--bg-deep) 100%); }
.sky.spring { background: linear-gradient(180deg, #0c1530 0%, #152244 50%, var(--bg-deep) 100%); }
.sky.summer { background: linear-gradient(180deg, #14253d 0%, #1e3a55 50%, var(--bg-deep) 100%); }
.sky.fall   { background: linear-gradient(180deg, #0e1420 0%, #171f30 50%, var(--bg-deep) 100%); }

canvas.stars {
  position: fixed;
  top: 0; left: 0;
  z-index: 0;
  pointer-events: none;
  opacity: 0.6;
}

.container {
  position: relative;
  z-index: 1;
  max-width: 960px;
  margin: 0 auto;
  padding: 16px 16px 60px;
}

/* ===== TITLE SCREEN ===== */

.title-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 92vh;
  text-align: center;
  animation: fadeIn 1.2s ease;
}

.title-screen h1 {
  font-family: 'Chakra Petch', sans-serif;
  font-size: clamp(2.8rem, 9vw, 5rem);
  font-weight: 700;
  letter-spacing: 8px;
  text-transform: uppercase;
  color: var(--ice-bright);
  text-shadow: 0 0 60px rgba(126, 200, 227, 0.25), 0 0 120px rgba(126, 200, 227, 0.1);
  margin-bottom: 4px;
}

.title-screen .subtitle {
  font-family: 'DM Serif Text', serif;
  font-style: italic;
  font-size: 1.15rem;
  color: var(--text-secondary);
  letter-spacing: 1px;
  margin-bottom: 52px;
}

.title-screen .flavor {
  max-width: 440px;
  color: var(--text-muted);
  font-size: 0.88rem;
  line-height: 1.8;
  margin-bottom: 52px;
}

/* ===== BUTTONS ===== */

.btn-primary {
  font-family: 'Chakra Petch', sans-serif;
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: 3px;
  text-transform: uppercase;
  color: var(--bg-deep);
  background: var(--ice-blue);
  border: none;
  padding: 15px 44px;
  cursor: pointer;
  transition: all 0.3s ease;
}

.btn-primary:hover {
  background: var(--ice-bright);
  transform: translateY(-2px);
  box-shadow: 0 8px 32px rgba(126, 200, 227, 0.3);
}

.btn-advance {
  font-family: 'Chakra Petch', sans-serif;
  font-size: 0.9rem;
  font-weight: 600;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--bg-deep);
  background: var(--aurora-green);
  border: none;
  padding: 13px 36px;
  cursor: pointer;
  transition: all 0.3s ease;
}

.btn-advance:hover {
  background: #6ee7a0;
  transform: translateY(-1px);
  box-shadow: 0 6px 24px rgba(74, 222, 128, 0.2);
}

/* ===== HEADER ===== */

.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0 14px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 14px;
}

.header-left {
  display: flex;
  align-items: baseline;
  gap: 12px;
}

.header-title {
  font-family: 'Chakra Petch', sans-serif;
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: 3px;
  text-transform: uppercase;
  color: var(--ice-blue);
}

.header-pop {
  font-size: 0.78rem;
  color: var(--text-muted);
}
.header-pop strong { color: var(--text-secondary); }

.header-date {
  display: flex;
  align-items: center;
  gap: 8px;
}

.season-badge {
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  padding: 3px 10px;
  border-radius: 2px;
}
.season-badge.winter { background: rgba(59, 130, 246, 0.15); color: var(--winter-blue); }
.season-badge.spring { background: rgba(74, 222, 128, 0.12); color: #6ee7a0; }
.season-badge.summer { background: rgba(251, 191, 36, 0.15); color: var(--summer-gold); }
.season-badge.fall   { background: rgba(245, 158, 11, 0.12); color: #f59e0b; }

.date-text {
  font-family: 'Chakra Petch', sans-serif;
  font-size: 0.85rem;
  color: var(--text-secondary);
}

/* ===== NARRATIVE LOG ===== */

.narrative {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  margin-bottom: 14px;
  overflow: hidden;
}

.narrative-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}

.narrative-header h3 {
  font-family: 'DM Serif Text', serif;
  font-size: 1rem;
  font-weight: 400;
}

.narrative-toggle {
  font-size: 0.7rem;
  color: var(--text-muted);
  cursor: pointer;
  background: none;
  border: 1px solid var(--border);
  padding: 3px 10px;
  font-family: 'Outfit', sans-serif;
  transition: all 0.2s;
}
.narrative-toggle:hover {
  border-color: var(--text-secondary);
  color: var(--text-secondary);
}

.narrative-feed {
  max-height: 280px;
  overflow-y: auto;
  scroll-behavior: smooth;
}
.narrative-feed::-webkit-scrollbar { width: 4px; }
.narrative-feed::-webkit-scrollbar-track { background: transparent; }
.narrative-feed::-webkit-scrollbar-thumb { background: var(--border); }

.n-entry {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  gap: 12px;
  animation: entrySlide 0.4s ease;
  transition: background 0.2s;
}
.n-entry:hover { background: var(--bg-card); }
.n-entry:last-child { border-bottom: none; }

.n-icon {
  width: 32px;
  height: 32px;
  min-width: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  border-radius: 2px;
  margin-top: 2px;
}
.n-icon.good    { background: var(--green-dim); }
.n-icon.bad     { background: var(--red-dim); }
.n-icon.warning { background: var(--amber-dim); }
.n-icon.neutral { background: var(--blue-dim); }
.n-icon.system  { background: rgba(100, 100, 130, 0.12); }

.n-body { flex: 1; }
.n-title { font-weight: 600; font-size: 0.82rem; margin-bottom: 3px; }
.n-text  { font-size: 0.78rem; color: var(--text-secondary); line-height: 1.55; }
.n-meta  { font-size: 0.65rem; color: var(--text-muted); margin-top: 5px; font-family: 'Chakra Petch', sans-serif; letter-spacing: 0.5px; }
.n-impact { display: inline-flex; gap: 6px; margin-top: 5px; flex-wrap: wrap; }

.impact-tag {
  font-size: 0.62rem;
  padding: 1px 6px;
  font-family: 'Chakra Petch', sans-serif;
  letter-spacing: 0.5px;
  font-weight: 600;
}
.impact-tag.pos  { background: var(--green-dim); color: var(--aurora-green); }
.impact-tag.neg  { background: var(--red-dim); color: var(--red); }
.impact-tag.info { background: var(--blue-dim); color: var(--ice-blue); }

/* ===== RESOURCES ===== */

.resources {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  margin-bottom: 14px;
}
@media (max-width: 600px) { .resources { grid-template-columns: repeat(2, 1fr); } }

.resource {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  padding: 10px 12px;
  overflow: hidden;
}

.resource-top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}

.resource-label {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--text-muted);
}

.resource-value {
  font-family: 'Chakra Petch', sans-serif;
  font-size: 1.2rem;
  font-weight: 700;
}
.resource-value.good { color: var(--aurora-green); }
.resource-value.warn { color: var(--amber); }
.resource-value.bad  { color: var(--red); }

.resource-detail {
  font-size: 0.68rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.resource-trend {
  font-size: 0.62rem;
  font-family: 'Chakra Petch', sans-serif;
  margin-left: 4px;
}
.resource-trend.up   { color: var(--aurora-green); }
.resource-trend.down { color: var(--red); }

.bar-track {
  height: 3px;
  background: var(--border);
  margin-top: 6px;
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  transition: width 0.6s ease, background 0.4s;
}
.bar-fill.good { background: var(--aurora-green); }
.bar-fill.warn { background: var(--amber); }
.bar-fill.bad  { background: var(--red); }

/* ===== SETTLEMENT BAR ===== */

.settlement-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 14px;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.s-label {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--text-muted);
  margin-right: 6px;
}

.b-icon {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  transition: all 0.15s;
  cursor: default;
  position: relative;
}
.b-icon:hover {
  border-color: var(--border-light);
  transform: scale(1.08);
}

.b-tip {
  display: none;
  position: absolute;
  bottom: 110%;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  padding: 4px 8px;
  font-size: 0.62rem;
  white-space: nowrap;
  color: var(--text-secondary);
  z-index: 10;
  pointer-events: none;
}
.b-icon:hover .b-tip { display: block; }

/* ===== ACTIONS PANEL ===== */

.actions-panel {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  margin-bottom: 14px;
}

.actions-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}

.actions-header h3 {
  font-family: 'DM Serif Text', serif;
  font-size: 1rem;
  font-weight: 400;
}

.actions-hint {
  font-size: 0.7rem;
  color: var(--text-muted);
  font-style: italic;
}

.tab-row {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border);
}

.tab-btn {
  flex: 1;
  padding: 10px 8px;
  font-family: 'Outfit', sans-serif;
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--text-muted);
  background: transparent;
  border: none;
  cursor: pointer;
  transition: all 0.2s;
  border-bottom: 2px solid transparent;
  text-align: center;
}
.tab-btn:hover { color: var(--text-secondary); background: var(--bg-card); }
.tab-btn.active { color: var(--ice-blue); border-bottom-color: var(--ice-blue); }

.actions-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1px;
  background: var(--border);
}
@media (max-width: 600px) { .actions-grid { grid-template-columns: 1fr; } }

.action-card {
  background: var(--bg-panel);
  padding: 14px 16px;
  cursor: pointer;
  transition: all 0.2s;
  position: relative;
}
.action-card:hover { background: var(--bg-card-hover); }
.action-card:active { background: var(--bg-card-active); }
.action-card.disabled {
  opacity: 0.3;
  cursor: not-allowed;
  pointer-events: none;
}

.a-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 6px;
}

.action-card h4 {
  font-size: 0.82rem;
  font-weight: 600;
}

.a-cost {
  font-size: 0.72rem;
  font-family: 'Chakra Petch', sans-serif;
  color: var(--amber);
  white-space: nowrap;
}

.action-card p {
  font-size: 0.73rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

.a-effects {
  display: flex;
  gap: 5px;
  margin-top: 8px;
  flex-wrap: wrap;
}

.effect {
  font-size: 0.6rem;
  padding: 2px 6px;
  font-family: 'Chakra Petch', sans-serif;
  letter-spacing: 0.5px;
  font-weight: 600;
}
.effect.pos  { background: var(--green-dim); color: var(--aurora-green); }
.effect.neg  { background: var(--red-dim); color: var(--red); }
.effect.info { background: var(--blue-dim); color: var(--ice-blue); }
.effect.lock { background: rgba(100, 100, 130, 0.1); color: var(--text-muted); }

.a-tag {
  font-size: 0.58rem;
  padding: 2px 7px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  background: rgba(251, 191, 36, 0.15);
  color: var(--summer-gold);
}

/* ===== ADVANCE ROW ===== */

.advance-row {
  display: flex;
  justify-content: center;
  gap: 12px;
  align-items: center;
  margin: 20px 0;
}

.month-hint {
  font-size: 0.72rem;
  color: var(--text-muted);
  font-style: italic;
}

/* ===== EVENT POPUP ===== */

.event-popup {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.75);
  animation: fadeIn 0.25s ease;
  padding: 16px;
}

.event-popup-inner {
  background: var(--bg-panel);
  border: 1px solid var(--border-light);
  max-width: 500px;
  width: 100%;
  padding: 28px 24px;
}

.ep-icon { font-size: 2rem; margin-bottom: 12px; }

.event-popup-inner h3 {
  font-family: 'Chakra Petch', sans-serif;
  font-size: 1.1rem;
  letter-spacing: 1px;
  margin-bottom: 10px;
}
.event-popup-inner h3.good    { color: var(--aurora-green); }
.event-popup-inner h3.bad     { color: var(--red); }
.event-popup-inner h3.warning { color: var(--amber); }
.event-popup-inner h3.neutral { color: var(--ice-blue); }

.ep-text {
  font-size: 0.85rem;
  color: var(--text-secondary);
  line-height: 1.7;
  margin-bottom: 20px;
}

.ep-choices {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.ep-choice {
  background: var(--bg-card);
  border: 1px solid var(--border);
  padding: 12px 14px;
  cursor: pointer;
  transition: all 0.2s;
  text-align: left;
}
.ep-choice:hover {
  border-color: var(--ice-blue);
  background: var(--bg-card-hover);
}

.ep-choice h5 {
  font-size: 0.8rem;
  font-weight: 600;
  margin-bottom: 3px;
}

.ep-choice p {
  font-size: 0.7rem;
  color: var(--text-muted);
  line-height: 1.4;
}

.ep-c-effects {
  display: flex;
  gap: 4px;
  margin-top: 6px;
  flex-wrap: wrap;
}

/* ===== END SCREEN ===== */

.end-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 75vh;
  text-align: center;
  animation: fadeIn 0.6s ease;
}

.end-screen h2 {
  font-family: 'Chakra Petch', sans-serif;
  font-size: 2rem;
  letter-spacing: 3px;
  margin-bottom: 16px;
}
.end-screen h2.lose { color: var(--red); }
.end-screen h2.win  { color: var(--aurora-green); }

.end-screen .reason {
  color: var(--text-secondary);
  max-width: 420px;
  line-height: 1.7;
  margin-bottom: 24px;
  font-size: 0.92rem;
}

.final-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 36px;
}

.final-stat { text-align: center; }
.fs-val {
  font-family: 'Chakra Petch', sans-serif;
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--ice-blue);
}
.fs-label {
  font-size: 0.65rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-top: 2px;
}

/* ===== ANIMATIONS ===== */

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

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

/* ===== SCROLLBAR ===== */

::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg-deep); }
::-webkit-scrollbar-thumb { background: var(--border); }

/* ===== TIER BADGE (in header) ===== */

.tier-badge {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 1px;
  color: var(--aurora-green);
  background: var(--green-dim);
  padding: 2px 8px;
  border-radius: 2px;
}

/* ===== TIER PROGRESS BAR ===== */

.tier-progress {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  padding: 8px 14px;
  margin-bottom: 14px;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.tier-progress-label {
  font-size: 0.68rem;
  color: var(--text-secondary);
  font-family: 'Chakra Petch', sans-serif;
  letter-spacing: 0.5px;
}

.tier-progress-track {
  height: 4px;
  background: var(--border);
  overflow: hidden;
}

.tier-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--ice-blue), var(--aurora-green));
  transition: width 0.8s ease;
}

/* ===== MILESTONES PANEL ===== */

.milestones-panel {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  margin-bottom: 14px;
  overflow: hidden;
}

.milestones-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
}

.milestones-header h3 {
  font-family: 'DM Serif Text', serif;
  font-size: 1rem;
  font-weight: 400;
}

.m-count {
  font-family: 'Chakra Petch', sans-serif;
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-left: 8px;
  letter-spacing: 0.5px;
}

.milestones-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1px;
  background: var(--border);
  border-top: 1px solid var(--border);
}

.milestone-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: var(--bg-panel);
  transition: background 0.2s;
}

.milestone-card:hover { background: var(--bg-card); }

.milestone-card .m-icon {
  font-size: 1.1rem;
  min-width: 24px;
  text-align: center;
}

.milestone-card .m-info {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.milestone-card .m-title {
  font-size: 0.78rem;
  font-weight: 600;
}

.milestone-card .m-desc {
  font-size: 0.65rem;
  color: var(--text-muted);
}

.milestone-card.unlocked .m-title { color: var(--aurora-green); }

.milestone-card.locked {
  opacity: 0.35;
}

.milestone-card.locked .m-title {
  color: var(--text-muted);
}

/* ===== END SCREEN MILESTONES ===== */

.milestones-recap {
  margin-bottom: 28px;
  width: 100%;
  max-width: 500px;
}

.milestones-recap h3 {
  font-family: 'Chakra Petch', sans-serif;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 2px;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.milestones-recap .milestones-grid {
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  border-top: none;
}

.milestones-recap .milestone-card {
  padding: 8px 10px;
  gap: 6px;
}

.milestones-recap .milestone-card .m-title {
  font-size: 0.72rem;
}
