/* === RESET & BASE === */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --bg-dark: #0f0f1a;
  --bg-card: #1a1a2e;
  --bg-input: #16213e;
  --accent: #e94560;
  --accent-glow: rgba(233, 69, 96, 0.3);
  --gold: #ffd700;
  --text: #e0e0e0;
  --text-dim: #8892a4;
  --green: #2ecc71;
  --yellow: #f39c12;
  --red: #e74c3c;
  --radius: 8px;
}

body {
  font-family: 'Courier New', monospace;
  background: var(--bg-dark);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

/* === SCREENS === */
.screen {
  display: none;
  min-height: 100vh;
}
.screen.active {
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* === TITLE SCREEN === */
.title-container {
  text-align: center;
  padding: 80px 20px;
  max-width: 600px;
}

.title-main {
  font-size: 3.5em;
  color: var(--accent);
  text-shadow: 0 0 30px var(--accent-glow);
  margin-bottom: 8px;
  letter-spacing: 2px;
}

.title-sub {
  font-size: 1.3em;
  color: var(--text-dim);
  font-style: italic;
  margin-bottom: 30px;
}

.title-desc {
  color: var(--text-dim);
  font-size: 0.95em;
  margin-bottom: 40px;
  line-height: 1.8;
}

/* === BUTTONS === */
.btn-primary {
  background: var(--accent);
  color: #fff;
  border: none;
  padding: 14px 36px;
  font-size: 1.1em;
  font-family: inherit;
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.2s;
  text-transform: uppercase;
  letter-spacing: 1px;
}
.btn-primary:hover {
  background: #c73e54;
  box-shadow: 0 0 20px var(--accent-glow);
}

/* === SETUP SCREEN === */
.setup-container {
  max-width: 650px;
  width: 100%;
  padding: 40px 20px;
}

.setup-container h2 {
  color: var(--accent);
  font-size: 1.8em;
  margin-bottom: 30px;
  text-align: center;
}

.setup-section {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 20px;
}

.setup-section h3 {
  color: var(--text);
  font-size: 1em;
  margin-bottom: 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.budget-label {
  color: var(--text-dim);
  font-size: 0.85em;
}
.budget-over {
  color: var(--red) !important;
}

.setup-select, .setup-input {
  width: 100%;
  padding: 10px 12px;
  background: var(--bg-input);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: var(--radius);
  color: var(--text);
  font-family: inherit;
  font-size: 0.95em;
}
.setup-select:focus, .setup-input:focus {
  outline: none;
  border-color: var(--accent);
}

.setup-select-sm {
  padding: 6px 10px;
  background: var(--bg-input);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: var(--radius);
  color: var(--text);
  font-family: inherit;
}

.setup-row {
  margin-top: 12px;
  color: var(--text-dim);
}

.desc-text {
  color: var(--text-dim);
  font-size: 0.85em;
  margin-top: 8px;
  font-style: italic;
}

.error-text {
  color: var(--red);
  text-align: center;
  margin-bottom: 12px;
  min-height: 1.2em;
}

/* Traits */
.trait-grid {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.trait-option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  background: var(--bg-input);
  border-radius: var(--radius);
  cursor: pointer;
  transition: background 0.15s;
}
.trait-option:hover {
  background: rgba(233, 69, 96, 0.1);
}

.trait-option input[type="radio"] {
  accent-color: var(--accent);
}

.trait-name {
  color: var(--text);
  font-weight: bold;
  min-width: 100px;
}

.trait-desc {
  color: var(--text-dim);
  font-size: 0.85em;
}

/* Items */
.item-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.item-option {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  padding: 8px 10px;
  background: var(--bg-input);
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 0.85em;
  transition: background 0.15s;
}
.item-option:hover {
  background: rgba(233, 69, 96, 0.1);
}

.item-option input[type="checkbox"] {
  accent-color: var(--accent);
}

.item-name {
  font-weight: bold;
  color: var(--text);
}

.item-cost {
  color: var(--yellow);
  font-size: 0.8em;
}

.item-desc {
  width: 100%;
  color: var(--text-dim);
  font-size: 0.8em;
}

/* === GAME SCREEN === */
#screen-game {
  padding: 10px;
}

.game-layout {
  display: flex;
  gap: 16px;
  max-width: 1200px;
  width: 100%;
  height: calc(100vh - 20px);
}

.game-map-section {
  flex: 2;
  display: flex;
  flex-direction: column;
}

.ascii-display {
  width: 100%;
  border-radius: var(--radius) var(--radius) 0 0;
  border: 1px solid rgba(255,255,255,0.08);
  border-bottom: none;
  background: #0a0a14;
  color: #c0c8d8;
  font-family: 'Courier New', monospace;
  font-size: clamp(8px, 1.8vw, 12.5px);
  line-height: 1.25;
  padding: 10px 12px;
  margin: 0;
  overflow-x: auto;
  white-space: pre;
  user-select: none;
  -webkit-user-select: none;
}

.ascii-info-bar {
  background: var(--bg-card);
  border: 1px solid rgba(255,255,255,0.08);
  border-top: none;
  padding: 6px 12px;
  font-family: 'Courier New', monospace;
  font-size: 0.8em;
  color: var(--text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* === ASCII COLOR HIGHLIGHTS === */
.ascii-vehicle { color: #ffd700; }
.ascii-fire    { color: #e94560; }
.ascii-water   { color: #45b7d1; }
.ascii-snow    { color: #ffffff; }
.ascii-rain    { color: #6688aa; }
.ascii-road    { color: #8a8a6e; }

/* === PROGRESS MAP === */
.progress-map {
  background: var(--bg-card);
  border: 1px solid rgba(255,255,255,0.08);
  border-top: none;
  border-radius: 0 0 var(--radius) var(--radius);
  padding: 8px 12px;
  font-family: 'Courier New', monospace;
  font-size: clamp(6px, 1.2vw, 9px);
  line-height: 1.15;
  color: #4a5568;
  white-space: pre;
  overflow: hidden;
  margin: 0;
}
.map-player  { color: var(--gold); font-weight: bold; text-shadow: 0 0 4px var(--gold); }
.map-visited { color: var(--green); }
.map-route   { color: var(--accent); }

/* === DAY/NIGHT CYCLE === */
.ascii-display.time-dawn {
  color: #d4a87c;
  background: #0e0a0a;
}
.ascii-display.time-day {
  /* default palette — no override needed */
}
.ascii-display.time-dusk {
  color: #b08a6e;
  background: #0c0810;
}
.ascii-display.time-night {
  color: #6a7a9a;
  background: #06060e;
}

.game-side {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-width: 350px;
  min-width: 280px;
  overflow-y: auto;
}

/* === DASHBOARD === */
.dashboard {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 16px;
}

.resource-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}
.resource-bar:last-child {
  margin-bottom: 0;
}

.resource-label {
  display: flex;
  align-items: center;
  gap: 4px;
  min-width: 90px;
}

.resource-icon {
  font-size: 0.9em;
}

.resource-name {
  text-transform: capitalize;
  font-size: 0.8em;
  color: var(--text-dim);
}

.resource-track {
  flex: 1;
  height: 10px;
  background: rgba(255,255,255,0.08);
  border-radius: 5px;
  overflow: hidden;
}

.resource-fill {
  height: 100%;
  border-radius: 5px;
  transition: width 0.5s ease, background-color 0.5s ease;
  width: 100%;
  background-color: var(--green);
}

.resource-value {
  min-width: 28px;
  text-align: right;
  font-size: 0.8em;
  color: var(--text-dim);
}

/* === FAMILY ROSTER === */
.family-roster {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 10px 16px;
  font-size: 0.8em;
}

.roster-title {
  color: var(--text-dim);
  font-size: 0.85em;
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 6px;
}

.roster-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 12px;
}

.roster-member {
  color: var(--text);
}

.roster-member.dead {
  color: var(--text-dim);
  text-decoration: line-through;
}

.roster-leader {
  color: var(--gold);
}

/* === DEATH MESSAGE (event result) === */
.result-death {
  color: var(--red);
  font-weight: bold;
  font-size: 0.95em;
  margin-bottom: 12px;
  padding: 8px;
  background: rgba(231, 76, 60, 0.1);
  border-radius: var(--radius);
  border: 1px solid rgba(231, 76, 60, 0.3);
}

/* === EVENT PANEL === */
.event-panel {
  transition: all 0.3s;
}

.event-panel.active {
  background: var(--bg-card);
  border-radius: var(--radius);
  border: 1px solid var(--accent);
  box-shadow: 0 0 20px var(--accent-glow);
}

.event-card {
  padding: 16px;
}

.event-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.event-icon {
  font-size: 1.5em;
}

.event-name {
  color: var(--accent);
  font-size: 1.1em;
}

.event-desc {
  color: var(--text);
  font-size: 0.9em;
  line-height: 1.6;
  margin-bottom: 16px;
}

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

.choice-btn {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg-input);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: var(--radius);
  color: var(--text);
  font-family: inherit;
  font-size: 0.9em;
  cursor: pointer;
  text-align: left;
  transition: all 0.15s;
}
.choice-btn:hover {
  border-color: var(--accent);
  background: rgba(233, 69, 96, 0.1);
}

/* Result */
.result-card {
  text-align: center;
}

.result-narrative {
  color: var(--text);
  font-size: 0.9em;
  line-height: 1.7;
  margin-bottom: 16px;
  font-style: italic;
}

.result-effects {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  margin-bottom: 16px;
}

.effect-positive {
  color: var(--green);
  font-weight: bold;
}

.effect-negative {
  color: var(--red);
  font-weight: bold;
}

.btn-continue {
  padding: 10px 24px;
  background: var(--accent);
  border: none;
  border-radius: var(--radius);
  color: #fff;
  font-family: inherit;
  font-size: 0.9em;
  cursor: pointer;
  transition: background 0.2s;
}
.btn-continue:hover {
  background: #c73e54;
}

/* === JOURNAL / LOG === */
.journal-section {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 16px;
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.journal-section h3 {
  color: var(--text-dim);
  font-size: 0.85em;
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 10px;
}

.log-entries {
  overflow-y: auto;
  flex: 1;
  max-height: 300px;
  font-size: 0.8em;
}

.log-entry {
  padding: 4px 0;
  border-bottom: 1px solid rgba(255,255,255,0.04);
  color: var(--text-dim);
}

.log-event {
  color: var(--yellow);
}

.log-success {
  color: var(--green);
}

.log-danger {
  color: var(--red);
}

.journal-entry {
  padding: 4px 0;
  border-bottom: 1px solid rgba(255,255,255,0.04);
  color: var(--text-dim);
  font-size: 0.85em;
}

/* === END SCREEN === */
.end-container {
  max-width: 650px;
  width: 100%;
  padding: 60px 20px;
  text-align: center;
}

.end-win {
  color: var(--gold);
  font-size: 2em;
  margin-bottom: 20px;
  text-shadow: 0 0 20px rgba(255, 215, 0, 0.3);
}

.end-lose {
  color: var(--red);
  font-size: 2em;
  margin-bottom: 20px;
}

#end-summary {
  color: var(--text);
  font-size: 1em;
  line-height: 1.8;
  margin-bottom: 30px;
}

#end-summary strong {
  color: var(--accent);
}

#end-score {
  margin-bottom: 20px;
}

.score-breakdown {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  margin-bottom: 20px;
}

.score-line {
  color: var(--text-dim);
  font-size: 0.9em;
}

.score-total {
  color: var(--gold);
  font-size: 1.8em;
  font-weight: bold;
  margin-top: 10px;
}

.end-container .journal-section {
  text-align: left;
  margin-bottom: 20px;
  max-height: 250px;
  overflow-y: auto;
}

.end-container .btn-primary {
  margin-top: 20px;
}

/* === FEEDBACK FORM === */
.feedback-section {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 16px;
  margin-top: 20px;
  text-align: left;
}

.feedback-section h3 {
  color: var(--text-dim);
  font-size: 0.85em;
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 8px;
}

.feedback-prompt {
  color: var(--text-dim);
  font-size: 0.8em;
  margin-bottom: 10px;
}

.feedback-input {
  width: 100%;
  padding: 10px 12px;
  background: var(--bg-input);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: var(--radius);
  color: var(--text);
  font-family: inherit;
  font-size: 0.85em;
  resize: vertical;
  min-height: 60px;
}
.feedback-input:focus {
  outline: none;
  border-color: var(--accent);
}

.feedback-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 10px;
}

.btn-feedback {
  padding: 8px 18px;
  background: var(--bg-input);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: var(--radius);
  color: var(--text);
  font-family: inherit;
  font-size: 0.8em;
  cursor: pointer;
  transition: all 0.15s;
}
.btn-feedback:hover {
  border-color: var(--accent);
  background: rgba(233, 69, 96, 0.1);
}
.btn-feedback:disabled {
  opacity: 0.5;
  cursor: default;
}

.feedback-status {
  font-size: 0.8em;
  color: var(--green);
}

/* === RESPONSIVE === */
@media (max-width: 768px) {
  .game-layout {
    flex-direction: column;
    height: auto;
  }
  .game-side {
    max-width: 100%;
  }
  .ascii-display {
    font-size: clamp(6px, 2.4vw, 9px);
    padding: 6px 8px;
  }
  .ascii-info-bar {
    font-size: clamp(0.55em, 1.8vw, 0.8em);
    padding: 4px 8px;
  }
  .item-grid {
    grid-template-columns: 1fr;
  }
  .title-main {
    font-size: 2.5em;
  }
}
