/* The American Experiment — Official Minimalist Editorial Design System */
@import url('https://fonts.googleapis.com/css2?family=Instrument+Sans:ital,wght@0,400..700;1,400..700&family=Instrument+Serif:ital@0;1&display=swap');

:root {
  --bg: #0a0d13;
  --panel: #10141d;
  --panel-2: #161b27;
  --border: #1f2533;
  --text: #e9ecf3;
  --muted: #8a93a8;
  
  --dem: #3b82f6;
  --dem-deep: #1e3a8a;
  
  --rep: #ef4444;
  --rep-deep: #b91c2c;
  
  --serif: "Instrument Serif", Georgia, serif;
  --sans: "Instrument Sans", system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

html, body {
  height: 100%;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

.app {
  max-width: 1480px;
  margin: 0 auto;
  padding: 16px 24px 32px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-height: 100%;
}

/* Topbar */
.topbar {
  position: relative;
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 26px;
  padding: 10px 0;
}

.brand-block {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.seal-icon {
  font-size: 2rem;
  line-height: 1;
}

.brand {
  font-family: var(--serif);
  font-weight: 700;
  font-size: 28px;
  letter-spacing: .01em;
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-title {
  text-align: center;
}

.star-row {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--muted);
  font-size: 12px;
}

.clock {
  position: absolute;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  font-family: var(--serif);
  font-size: 13px;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 8px;
}

.live-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--rep);
  animation: blink 1.2s ease-in-out infinite;
}

@keyframes blink {
  50% { opacity: .25; }
}

/* Scoreboard Header */
.scoreboard {
  display: grid;
  grid-template-columns: 240px 1fr 240px;
  gap: 18px;
  align-items: center;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px 20px;
}

.score {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.score.rep {
  text-align: right;
}

.score-name {
  font-family: var(--serif);
  font-weight: 400;
  font-size: 20px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.score-ev {
  font-family: var(--serif);
  font-size: 38px;
  font-weight: 400;
  line-height: 1;
}

.score.dem .score-ev { color: var(--dem); }
.score.rep .score-ev { color: var(--rep); }

.score-pv {
  font-family: var(--serif);
  font-size: 13px;
  color: var(--muted);
  margin-top: 2px;
}

.ev-bar-wrap {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.ev-bar-label {
  text-align: center;
  font-family: var(--serif);
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .1em;
}

.ev-bar {
  position: relative;
  height: 26px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}

.ev-fill {
  position: absolute;
  top: 0;
  bottom: 0;
  transition: width .7s cubic-bezier(.22, 1, .36, 1);
}

.ev-fill.dem { left: 0; background: var(--dem-deep); }
.ev-fill.rep { right: 0; background: var(--rep-deep); }

.ev-270 {
  position: absolute;
  left: 50%;
  top: 0;
  bottom: 0;
  border-left: 2px dashed rgba(255, 255, 255, .55);
}

.projection {
  text-align: center;
  font-family: var(--serif);
  font-weight: 400;
  font-size: 16px;
  letter-spacing: .02em;
  margin-top: 4px;
}

.projection.dem { color: var(--dem); }
.projection.rep { color: var(--rep); }
.projection.neutral { color: var(--muted); }

/* Setup Section */
.setup {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px 20px;
}

.setup-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 20px;
}

.ticket {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.ticket + .ticket {
  border-left: 1px solid var(--border);
  padding-left: 20px;
}

.ticket-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-family: var(--serif);
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: .16em;
  color: var(--muted);
  padding-bottom: 8px;
}

.ticket.dem .ticket-head > span { color: #7aa7f8; }
.ticket.rep .ticket-head > span { color: #f48a8a; }

.gen-btn {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--muted);
  font-family: var(--serif);
  font-size: 11px;
  letter-spacing: .08em;
  text-transform: uppercase;
  padding: 3px 10px;
  cursor: pointer;
  transition: border-color .15s, color .15s;
}

.gen-btn:hover {
  border-color: #d4a929;
  color: #e7cf8f;
}

.field-name, .field-mate {
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  font-family: var(--serif);
  padding: 8px 1px;
}

.field-name {
  font-size: 22px;
}

.field-mate {
  font-size: 16px;
  color: #c6ccda;
}

.field-name:focus, .field-mate:focus {
  outline: none;
  border-bottom-color: #4a5670;
}

.ticket.dem .field-name:focus, .ticket.dem .field-mate:focus { border-bottom-color: var(--dem); }
.ticket.rep .field-name:focus, .ticket.rep .field-mate:focus { border-bottom-color: var(--rep); }

.field-desc {
  background: transparent;
  border: none;
  border-top: 1px solid var(--border);
  color: #d4d9e4;
  font-family: var(--sans);
  font-size: 13px;
  line-height: 1.55;
  padding: 10px 2px;
  resize: vertical;
  min-height: 90px;
}

.field-desc:focus {
  outline: none;
  border-top-color: #3d4a66;
}

.setup-actions {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding-top: 16px;
}

.simulate-btn {
  background: var(--text);
  border: none;
  border-radius: 9px;
  color: var(--bg);
  font-family: var(--serif);
  font-weight: 400;
  font-size: 17px;
  letter-spacing: .03em;
  padding: 11px 48px;
  cursor: pointer;
  transition: background .15s;
}

.simulate-btn:hover {
  background: #ffffff;
}

/* Board & Map Panel */
.board {
  display: grid;
  grid-template-columns: 1fr 310px;
  gap: 14px;
  flex: 1;
}

.map-panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.usa-map {
  width: 100%;
  height: auto;
}

.state {
  stroke: var(--bg);
  stroke-width: 1.5;
  cursor: pointer;
  transition: fill .45s ease;
}

.state:hover {
  filter: brightness(1.25);
}

.state.deliberating {
  animation: deliberate 1.4s ease-in-out infinite;
}

@keyframes deliberate {
  50% { fill: #4d5a85; }
}

.state.called {
  animation: callFlash .8s ease;
}

@keyframes callFlash {
  0% { filter: brightness(2.2); }
  100% { filter: brightness(1); }
}

.state-label {
  pointer-events: none;
  text-anchor: middle;
  fill: #ffffffd9;
  font-family: var(--serif);
}

.state-label .abbr {
  font-size: 13px;
  font-weight: 400;
}

.state-label .ev {
  font-size: 10.5px;
  opacity: .8;
}

.map-safe-dem { fill: #2563eb; }
.map-lean-dem { fill: #60a5fa; }
.map-safe-rep { fill: #dc2626; }
.map-lean-rep { fill: #f87171; }
.map-tossup { fill: #1f2533; }

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  font-family: var(--serif);
  font-size: 13px;
  color: var(--muted);
  padding-top: 4px;
  justify-content: center;
}

.lg {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.lg i {
  width: 13px;
  height: 13px;
  border-radius: 3px;
  display: inline-block;
}

.lg i.safe-dem { background: #2563eb; }
.lg i.lean-dem { background: #60a5fa; }
.lg i.tossup { background: #1f2533; }
.lg i.lean-rep { background: #f87171; }
.lg i.safe-rep { background: #dc2626; }

/* Sidebar: Chips & Live Feed */
.sidebar {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.chips {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  max-height: 240px;
  overflow-y: auto;
}

.chip {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-radius: 7px;
  padding: 6px 8px;
  font-family: var(--serif);
  font-size: 13px;
  color: #ffffffeb;
  cursor: pointer;
  transition: background .45s ease, filter .15s;
  background: var(--panel-2);
  border: 1px solid var(--border);
}

.chip:hover {
  filter: brightness(1.25);
}

.chip.dem { background: var(--dem-deep); }
.chip.rep { background: var(--rep-deep); }
.chip.tossup { background: var(--panel-2); }

.chip b {
  opacity: .75;
  font-weight: 500;
}

.feed {
  flex: 1;
  min-height: 220px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow: hidden;
}

.feed-title {
  font-family: var(--serif);
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: .14em;
  color: var(--muted);
}

.feed-items {
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 7px;
  max-height: 300px;
}

.feed-item {
  font-family: var(--serif);
  font-size: 13.5px;
  line-height: 1.45;
  padding: 7px 10px;
  border-radius: 7px;
  background: var(--panel-2);
}

.feed-item.call.dem { background: rgba(59, 130, 246, .15); border: 1px solid rgba(59, 130, 246, .3); }
.feed-item.call.rep { background: rgba(239, 68, 68, .15); border: 1px solid rgba(239, 68, 68, .3); }

/* State Inspection Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(5, 7, 11, .75);
  backdrop-filter: blur(5px);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.modal {
  width: 100%;
  max-width: 720px;
  max-height: calc(100vh - 48px);
  overflow-y: auto;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 26px 30px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  box-shadow: 0 24px 80px rgba(0, 0, 0, .7);
}

.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}

.modal-head h2 {
  margin: 0;
  font-family: var(--serif);
  font-weight: 400;
  font-size: 28px;
}

.modal-close {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 18px;
  cursor: pointer;
}

.modal-close:hover { color: var(--text); }

.chat-log {
  min-height: 200px;
  max-height: 40vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-right: 4px;
}

.chat-msg {
  font-size: 13px;
  line-height: 1.5;
  padding: 8px 11px;
  border-radius: 10px;
  max-width: 88%;
}

.chat-msg.user { align-self: flex-end; background: #243049; color: #e9ecf3; }
.chat-msg.assistant { align-self: flex-start; background: var(--panel-2); color: #d4d9e4; }

.chat-input {
  display: flex;
  gap: 6px;
}

.chat-input input {
  flex: 1;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-family: var(--sans);
  font-size: 13px;
  padding: 8px 10px;
}

.chat-input input:focus { outline: none; border-color: #3d4a66; }

.chat-input button {
  background: var(--text);
  border: none;
  border-radius: 8px;
  color: var(--bg);
  font-family: var(--serif);
  font-size: 14px;
  padding: 0 16px;
  cursor: pointer;
}

/* Tooltip */
.tooltip {
  position: fixed;
  z-index: 50;
  width: 340px;
  background: #0d111af7;
  border: 1px solid #2b3347;
  border-radius: 12px;
  padding: 14px 16px;
  box-shadow: 0 16px 48px rgba(0, 0, 0, .6);
  pointer-events: none;
  display: none;
}
