@import url('https://fonts.googleapis.com/css2?family=Press+Start+2P&family=Inter:wght@400;500;600&display=swap');

:root {
  --bg: #0c0f16;
  --panel: #141821;
  --panel-hover: #1a1f2b;
  --border: #252a36;
  --border-light: #2d3344;
  --accent: #d4a74a;
  --accent-dim: #a08030;
  --crisis: #a04040;
  --safe: #4a8a5a;
  --warn: #b08030;
  --text: #c8c8d0;
  --text-bright: #e8e8f0;
  --dim: #606878;
  --font-pixel: 'Press Start 2P', monospace;
  --font-body: 'Inter', -apple-system, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
img, canvas, svg { max-width: 100%; height: auto; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 13px;
  min-height: 100vh;
  overflow-x: hidden;
}

/* Subtle noise texture */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image:
    repeating-linear-gradient(0deg, transparent, transparent 2px, rgba(255,255,255,0.005) 2px, rgba(255,255,255,0.005) 4px),
    repeating-linear-gradient(90deg, transparent, transparent 2px, rgba(255,255,255,0.003) 2px, rgba(255,255,255,0.003) 4px);
  pointer-events: none;
  z-index: 0;
}

/* Scanline effect — very subtle */
body::after {
  content: '';
  position: fixed;
  inset: 0;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 2px,
    rgba(0,0,0,0.03) 2px,
    rgba(0,0,0,0.03) 4px
  );
  pointer-events: none;
  z-index: 9999;
}

#game-container {
  max-width: 1280px;
  margin: 0 auto;
  padding: 8px;
  position: relative;
  z-index: 1;
}

/* ── HEADER ── */
#header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: linear-gradient(135deg, #141821 0%, #1a1f2b 100%);
  border-bottom: 1px solid var(--accent-dim);
  padding: 8px 16px;
  margin-bottom: 8px;
}

.header-brand {
  font-family: var(--font-pixel);
  font-size: 11px;
  color: var(--accent);
  letter-spacing: 2px;
  white-space: nowrap;
}

.header-info {
  font-size: 9px;
  color: var(--dim);
  font-family: var(--font-body);
  display: flex;
  gap: 6px;
  align-items: center;
}

.header-sep { color: var(--border-light); }

.header-stats {
  display: flex;
  gap: 20px;
  align-items: center;
}

.header-stat {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
}

.stat-label {
  color: var(--dim);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.stat-value {
  color: var(--text-bright);
  font-family: var(--font-pixel);
  font-size: 10px;
}

/* ── MAIN LAYOUT ── */
#main-layout {
  display: grid;
  grid-template-columns: 240px 1fr 220px;
  gap: 8px;
  align-items: start;
}

/* ── PANELS ── */
aside, main {
  background: var(--panel);
  border: 1px solid var(--border);
  padding: 10px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.03), 0 2px 8px rgba(0,0,0,0.3);
}

h3 {
  font-family: var(--font-pixel);
  font-size: 7px;
  color: var(--accent);
  border-bottom: 1px solid var(--border);
  padding-bottom: 5px;
  margin-bottom: 8px;
  letter-spacing: 1px;
}

/* ── INDICATORS ── */
#indicators-list { display: flex; flex-direction: column; gap: 7px; }

.indicator {
  display: flex;
  flex-direction: column;
  gap: 3px;
  border-left: 3px solid var(--border);
  padding-left: 6px;
}

.indicator-label {
  font-size: 11px;
  color: var(--dim);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-family: var(--font-body);
}

.indicator-label span:last-child {
  color: var(--text-bright);
  font-family: var(--font-pixel);
  font-size: 8px;
}

.indicator-bar-bg {
  height: 4px;
  background: #1a1d26;
  position: relative;
}

.indicator-bar-fill {
  height: 100%;
  transition: width 0.4s steps(10);
}

.bar-green  { background: var(--safe); }
.bar-yellow { background: var(--accent); }
.bar-red    { background: var(--crisis); }
.bar-blue   { background: #5a6aaa; }
.bar-orange { background: var(--warn); }
.bar-purple { background: #7a5aaa; }

/* ── DPR BAR ── */
#dpr-section { margin-top: 12px; }

#dpr-bar {
  height: 16px;
  display: flex;
  margin: 6px 0;
  overflow: hidden;
  border-radius: 2px;
}

.dpr-segment {
  height: 100%;
  transition: width 0.3s;
}

#coalition-info {
  font-size: 11px;
  color: var(--dim);
  margin-top: 4px;
  font-family: var(--font-body);
}

/* ── FISCAL PANEL ── */
#fiscal-section { margin-top: 12px; }

#fiscal-indicators { display: flex; flex-direction: column; gap: 7px; }

.fiscal-item {
  display: flex;
  flex-direction: column;
  gap: 3px;
  border-left: 3px solid var(--border);
  padding-left: 6px;
}

.fiscal-label {
  font-size: 11px;
  color: var(--dim);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-family: var(--font-body);
}

.fiscal-label span:last-child {
  color: var(--text-bright);
  font-family: var(--font-pixel);
  font-size: 8px;
}

.fiscal-bar-bg {
  height: 4px;
  background: #1a1d26;
}

.fiscal-bar-fill {
  height: 100%;
  transition: width 0.4s steps(10);
}

.fiscal-value-text {
  font-size: 12px;
  font-family: var(--font-pixel);
  color: var(--accent);
  padding: 2px 0;
}

.fiscal-tag {
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 2px;
  display: inline-block;
  margin-top: 2px;
  font-family: var(--font-body);
}

.tag-safe   { color: var(--safe);  background: rgba(74,138,90,0.12); }
.tag-warn   { color: var(--warn);  background: rgba(176,128,48,0.12); }
.tag-crit   { color: var(--crisis); background: rgba(160,64,64,0.15); animation: blink 1s steps(1) infinite; }

@keyframes blink { 0%,100%{opacity:1} 50%{opacity:0.4} }

/* ── EVENT BANNER ── */
#event-banner {
  background: rgba(160,64,64,0.08);
  border-left: 3px solid var(--crisis);
  padding: 10px 12px;
  margin-bottom: 8px;
  animation: borderPulse 2s ease-in-out infinite;
}

@keyframes borderPulse {
  0%, 100% { border-left-color: var(--crisis); }
  50% { border-left-color: rgba(160,64,64,0.4); }
}

#event-icon { font-size: 18px; line-height: 1; display: inline; }
#event-title {
  font-family: var(--font-pixel);
  font-size: 8px;
  color: var(--crisis);
  display: inline;
  margin-left: 6px;
}

#event-desc {
  font-size: 12px;
  color: var(--dim);
  line-height: 1.6;
  margin-top: 6px;
  font-family: var(--font-body);
}

/* ── POLICY CARDS ── */
#policy-section h3 { color: var(--accent); }

#policy-cards {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 8px;
}

.policy-card {
  background: #0f1219;
  border: 1px solid var(--border);
  border-left: 8px solid var(--border);
  padding: 10px 12px;
  cursor: pointer;
  transition: all 0.15s ease;
  position: relative;
}

.policy-card:hover {
  border-color: var(--accent);
  border-left-color: var(--accent);
  transform: translateY(-2px);
  background: #151a24;
}

.policy-card.needs-dpr { border-left-color: var(--warn); }
.policy-card.disabled { opacity: 0.35; cursor: not-allowed; pointer-events: none; }

.card-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

/* .card-icon removed — no emoji icons */

.card-name {
  font-family: var(--font-pixel);
  font-size: 8px;
  color: var(--text-bright);
  line-height: 1.5;
}

.card-category {
  font-size: 9px;
  padding: 1px 6px;
  border-radius: 2px;
  color: var(--text);
  font-family: var(--font-body);
  opacity: 0.8;
}

.card-desc {
  font-size: 12px;
  color: var(--dim);
  line-height: 1.5;
  margin-bottom: 8px;
  font-family: var(--font-body);
}

.card-effects {
  display: flex;
  flex-direction: column;
  gap: 3px;
  margin-bottom: 4px;
}

.effect-group {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  align-items: center;
}

.effect-group-label {
  font-size: 10px;
  margin-right: 2px;
  font-family: var(--font-body);
}

.effect-group-label.group-benefit { color: var(--safe); }
.effect-group-label.group-cost { color: var(--crisis); }
.effect-group-label.group-risk { color: var(--warn); }

.effect-tag {
  font-size: 9px;
  padding: 1px 5px;
  font-family: var(--font-body);
  border-radius: 2px;
}

.effect-pos { background: rgba(74,138,90,0.12); color: var(--safe); }
.effect-neg { background: rgba(160,64,64,0.12); color: var(--crisis); }
.effect-risk { background: rgba(176,128,48,0.12); color: var(--warn); }

.card-satirical {
  font-size: 11px;
  color: var(--dim);
  font-style: italic;
  margin-top: 6px;
  font-family: var(--font-body);
  opacity: 0.7;
}

.dpr-badge {
  position: absolute;
  top: 8px; right: 8px;
  font-size: 9px;
  background: rgba(176,128,48,0.2);
  color: var(--warn);
  padding: 2px 6px;
  border-radius: 10px;
  font-family: var(--font-body);
}

/* ── NEXT MONTH BTN ── */
#next-month-btn {
  display: block;
  width: 100%;
  margin-top: 12px;
  padding: 12px;
  background: rgba(12,15,22,0.8);
  border: 1px solid var(--accent);
  color: var(--accent);
  font-family: var(--font-pixel);
  font-size: 9px;
  cursor: pointer;
  letter-spacing: 1px;
  transition: all 0.2s;
}

#next-month-btn:hover {
  background: rgba(212,167,74,0.08);
  box-shadow: 0 0 12px rgba(212,167,74,0.15);
}

/* ── LOG ── */
#log-panel {
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 80px);
}

#log-panel h3 {
  flex-shrink: 0;
}

#log-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  overflow-y: auto;
  flex: 1;
}

.log-entry {
  font-size: 10px;
  color: var(--dim);
  border-left: 2px solid var(--border);
  padding-left: 6px;
  line-height: 1.6;
  font-family: var(--font-body);
}

.log-entry.log-policy { border-color: var(--safe); color: var(--text); }
.log-entry.log-event  { border-color: var(--crisis); color: var(--warn); }
.log-entry.log-vote   { border-color: var(--accent); color: var(--accent); }

.log-type-badge {
  font-size: 8px;
  font-family: var(--font-pixel);
  padding: 0 4px;
  opacity: 0.6;
  display: inline;
}

/* ── VOTING MODAL ── */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.8);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

#voting-content {
  background: var(--panel);
  border: 1px solid var(--accent-dim);
  padding: 24px;
  max-width: 480px;
  width: 90%;
  text-align: center;
  box-shadow: 0 8px 32px rgba(0,0,0,0.6);
}

#voting-content h3 {
  font-size: 10px;
  color: var(--accent);
  border: none;
  padding-bottom: 0;
}

#voting-policy-name {
  font-family: var(--font-pixel);
  font-size: 8px;
  color: var(--text-bright);
  margin: 12px 0;
  line-height: 1.6;
}

#voting-bar {
  height: 20px;
  display: flex;
  margin: 14px 0 8px;
  overflow: hidden;
  border-radius: 2px;
}

#voting-yes {
  background: var(--safe);
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 9px;
  font-family: var(--font-pixel);
  color: #fff;
  transition: width 0.8s ease;
  min-width: 0;
}

#voting-no {
  background: var(--crisis);
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 9px;
  font-family: var(--font-pixel);
  color: #fff;
  transition: width 0.8s ease;
  min-width: 0;
}

#voting-parties {
  display: flex;
  flex-direction: column;
  gap: 4px;
  text-align: left;
  margin: 12px 0;
}

.party-vote-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11px;
  font-family: var(--font-body);
  padding: 4px 0;
  border-bottom: 1px solid var(--border);
}

.vote-yes { color: var(--safe); }
.vote-no  { color: var(--crisis); }
.vote-abs { color: var(--dim); }

#voting-result {
  font-family: var(--font-pixel);
  font-size: 9px;
  padding: 10px;
  margin: 12px 0;
}

#voting-result.result-pass { color: var(--safe); background: rgba(74,138,90,0.1); }
#voting-result.result-fail { color: var(--crisis); background: rgba(160,64,64,0.1); }

#voting-ok {
  font-family: var(--font-pixel);
  font-size: 8px;
  padding: 10px 20px;
  background: rgba(12,15,22,0.8);
  border: 1px solid var(--accent);
  color: var(--accent);
  cursor: pointer;
  margin-top: 8px;
  transition: all 0.15s;
}

#voting-ok:hover {
  background: rgba(212,167,74,0.08);
}

/* ── OVERLAY ── */
#overlay {
  position: fixed;
  inset: 0;
  background: radial-gradient(ellipse at center, rgba(12,15,22,0.95) 0%, rgba(0,0,0,0.98) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
}

#overlay-content {
  background: var(--panel);
  border: 1px solid var(--accent-dim);
  padding: 40px;
  text-align: center;
  max-width: 480px;
  box-shadow: 0 8px 40px rgba(0,0,0,0.5);
}

#overlay-title {
  font-family: var(--font-pixel);
  font-size: 14px;
  margin-bottom: 16px;
}

#overlay-desc {
  font-family: var(--font-body);
  font-size: 13px;
  color: var(--dim);
  line-height: 1.8;
  margin-bottom: 24px;
}

#overlay-content button {
  font-family: var(--font-pixel);
  font-size: 9px;
  padding: 12px 24px;
  background: rgba(12,15,22,0.8);
  border: 1px solid var(--accent);
  color: var(--accent);
  cursor: pointer;
  transition: all 0.15s;
}

#overlay-content button:hover {
  background: rgba(212,167,74,0.08);
}

/* ── DELTA FLASH ── */
.delta-flash {
  position: fixed;
  font-family: var(--font-pixel);
  font-size: 9px;
  pointer-events: none;
  z-index: 5000;
  animation: floatUp 1.5s ease-out forwards;
  text-shadow: 0 0 6px currentColor;
}

@keyframes floatUp {
  0%   { opacity: 1; transform: translateY(0); }
  70%  { opacity: 0.6; }
  100% { opacity: 0; transform: translateY(-30px); }
}

/* ── HELPERS ── */
.hidden { display: none !important; }

/* Scrollbar */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border-light); }
::-webkit-scrollbar-thumb:hover { background: var(--dim); }

/* ── SETUP SCREEN ── */
#setup-screen {
  position: fixed; inset: 0;
  background: var(--bg);
  display: flex; align-items: center; justify-content: center;
  z-index: 3000;
}

#setup-box {
  background: var(--panel);
  border: 1px solid var(--border);
  padding: 32px;
  max-width: 480px; width: 90%;
}

#setup-brand {
  font-family: var(--font-pixel);
  font-size: 16px;
  color: var(--accent);
  text-align: center;
  margin-bottom: 4px;
}

#setup-subtitle {
  font-size: 11px;
  color: var(--dim);
  text-align: center;
  margin-bottom: 24px;
  font-family: var(--font-body);
}

.setup-field {
  margin-bottom: 14px;
}

.setup-field label {
  display: block;
  font-size: 10px;
  color: var(--dim);
  margin-bottom: 4px;
  font-family: var(--font-pixel);
  letter-spacing: 0;
}

.setup-field input, .setup-field select {
  width: 100%;
  background: #0c0f16;
  border: 1px solid var(--border);
  color: var(--text-bright);
  padding: 8px 10px;
  font-family: var(--font-body);
  font-size: 13px;
  outline: none;
}

.setup-field input:focus, .setup-field select:focus {
  border-color: var(--accent-dim);
}

#start-btn {
  display: block;
  width: 100%;
  margin-top: 20px;
  padding: 12px;
  background: transparent;
  border: 2px solid var(--accent);
  color: var(--accent);
  font-family: var(--font-pixel);
  font-size: 10px;
  cursor: pointer;
  letter-spacing: 1px;
  transition: all 0.2s;
}

#start-btn:hover {
  background: var(--accent);
  color: var(--bg);
}

/* ── RESET BUTTON ── */
#reset-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--dim);
  font-size: 14px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 3px;
  transition: all 0.15s;
  flex-shrink: 0;
}

#reset-btn:hover {
  border-color: var(--crisis);
  color: var(--crisis);
  background: rgba(160,64,64,0.1);
}

/* ═══════════════════════════════════════════
   RESPONSIVE — Tablet (768px–1023px)
   ═══════════════════════════════════════════ */
@media (max-width: 1023px) {
  #main-layout {
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }

  #log-panel {
    grid-column: 1 / -1;
    max-height: 200px;
  }

  .header-stats {
    gap: 12px;
  }

  #game-container {
    max-width: 100%;
    padding: 8px;
  }
}

/* ═══════════════════════════════════════════
   RESPONSIVE — Mobile (<=767px)
   ═══════════════════════════════════════════ */
@media (max-width: 767px) {
  body {
    font-size: 14px;
    padding: 0;
  }

  #game-container {
    padding: 12px;
    max-width: 100%;
  }

  /* Header → vertical stack */
  #header {
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
    padding: 10px 12px;
  }

  .header-brand {
    font-size: 9px;
    text-align: center;
  }

  .header-info {
    text-align: center;
    justify-content: center;
    font-size: 10px;
  }

  .header-stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
    width: 100%;
  }

  .header-stat {
    background: rgba(255,255,255,0.02);
    padding: 4px 8px;
    border-radius: 3px;
    justify-content: center;
  }

  /* Main layout → single column */
  #main-layout {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  /* All panels full width */
  aside, main {
    padding: 12px;
    width: 100%;
    max-width: 100%;
  }

  #indicators-panel {
    order: 1;
  }

  #center-panel {
    order: 2;
  }

  #log-panel {
    order: 3;
    max-height: 250px;
  }

  /* Policy cards single column */
  #policy-cards {
    gap: 10px;
  }

  .policy-card {
    padding: 12px;
    border-left-width: 6px;
  }

  .card-name {
    font-size: 9px;
  }

  .card-desc {
    font-size: 13px;
  }

  /* DPR bar */
  #dpr-bar {
    height: 20px;
  }

  /* Buttons — min 44px touch target */
  #next-month-btn {
    padding: 14px;
    font-size: 10px;
    min-height: 44px;
  }

  #voting-ok {
    padding: 12px 24px;
    min-height: 44px;
    font-size: 9px;
  }

  #overlay-content button {
    padding: 14px 28px;
    min-height: 44px;
    font-size: 10px;
  }

  /* Voting modal */
  #voting-content {
    width: 95%;
    padding: 16px;
  }

  /* Overlay */
  #overlay-content {
    width: 95%;
    padding: 24px;
  }

  #overlay-title {
    font-size: 12px;
  }

  #overlay-desc {
    font-size: 12px;
  }

  /* Setup screen */
  #setup-box {
    width: 95%;
    padding: 20px;
  }

  #setup-brand {
    font-size: 13px;
  }

  .setup-field input,
  .setup-field select {
    font-size: 16px; /* prevents iOS zoom */
    padding: 10px;
  }

  #start-btn {
    padding: 14px;
    font-size: 10px;
    min-height: 44px;
  }
}

/* ═══════════════════════════════════════════
   RESPONSIVE — Small Mobile (<=480px)
   ═══════════════════════════════════════════ */
@media (max-width: 480px) {
  #game-container {
    padding: 8px;
  }

  #header {
    padding: 8px;
  }

  .header-brand {
    font-size: 8px;
    letter-spacing: 1px;
  }

  .header-info {
    font-size: 9px;
    gap: 4px;
  }

  .header-stats {
    grid-template-columns: 1fr 1fr;
    gap: 4px;
  }

  .header-stat {
    font-size: 11px;
    padding: 3px 6px;
  }

  .stat-label {
    font-size: 9px;
  }

  .stat-value {
    font-size: 9px;
  }

  aside, main {
    padding: 10px;
  }

  h3 {
    font-size: 8px;
    padding-bottom: 4px;
    margin-bottom: 6px;
  }

  .policy-card {
    padding: 10px;
  }

  .card-name {
    font-size: 8px;
  }

  .card-desc {
    font-size: 12px;
    line-height: 1.4;
  }

  .effect-tag {
    font-size: 8px;
    padding: 1px 4px;
  }

  .card-satirical {
    font-size: 10px;
  }

  .dpr-badge {
    font-size: 8px;
    padding: 1px 4px;
  }

  /* Setup screen small */
  #setup-box {
    padding: 16px;
  }

  #setup-brand {
    font-size: 11px;
  }

  #setup-subtitle {
    font-size: 10px;
    margin-bottom: 16px;
  }

  .setup-field {
    margin-bottom: 10px;
  }

  .setup-field label {
    font-size: 8px;
  }
}

/* ── BADGE LABELS (pixel-style, no emoji) ── */
.badge-risk {
  display: inline-block;
  padding: 1px 5px;
  font-family: var(--font-pixel);
  font-size: 7px;
  letter-spacing: 1px;
  background: var(--danger);
  color: #000;
  border-radius: 2px;
  vertical-align: middle;
  margin-right: 4px;
}
.badge-apbn {
  display: inline-block;
  padding: 1px 5px;
  font-family: var(--font-pixel);
  font-size: 7px;
  letter-spacing: 1px;
  background: var(--accent);
  color: #000;
  border-radius: 2px;
  vertical-align: middle;
  margin-right: 4px;
}
.badge-dpr {
  display: inline-block;
  padding: 1px 5px;
  font-family: var(--font-pixel);
  font-size: 7px;
  letter-spacing: 1px;
  background: var(--safe);
  color: #000;
  border-radius: 2px;
  vertical-align: middle;
  margin-right: 4px;
}
.badge-crisis {
  display: inline-block;
  padding: 1px 6px;
  font-family: var(--font-pixel);
  font-size: 7px;
  letter-spacing: 1px;
  background: var(--danger);
  color: #fff;
  border-radius: 2px;
  vertical-align: middle;
  margin-right: 6px;
  animation: blink-badge 1s step-end infinite;
}
@keyframes blink-badge {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}
.badge-policy {
  display: inline-block;
  padding: 1px 5px;
  font-family: var(--font-pixel);
  font-size: 7px;
  letter-spacing: 1px;
  background: var(--dim);
  color: var(--text-bright);
  border-radius: 2px;
  vertical-align: middle;
  margin-right: 4px;
}

