/* ── Mini Diplomacy Arena — 19th Century Parchment Theme ── */

:root {
  --bg: #2a2218;
  --parchment: #e8dcc8;
  --parchment-dk: #d4c8b0;
  --parchment-lt: #f0e8d8;
  --ink: #2a2018;
  --ink-dim: #5a5040;
  --ink-muted: #8a7a68;
  --border: rgba(80, 60, 30, 0.3);
  --border-heavy: rgba(80, 60, 30, 0.5);
  --france: #2e5a8a;
  --france-lt: #4a80b8;
  --france-bg: rgba(46, 90, 138, 0.06);
  --prussia: #8a7a28;
  --prussia-lt: #b8a830;
  --prussia-bg: rgba(138, 122, 40, 0.06);
  --russia: #8a3030;
  --russia-lt: #b84848;
  --russia-bg: rgba(138, 48, 48, 0.06);
  --gold: #9a7a20;
  --gold-dim: rgba(154, 122, 32, 0.3);
}

* { box-sizing: border-box; margin: 0; }
body {
  color: var(--ink);
  font-family: "Playfair Display", Georgia, serif;
  background: var(--bg);
  height: 100vh; overflow: hidden;
}
#app { height: 100vh; display: flex; flex-direction: column; }

/* ═══ Score Strip + Controls ═══ */
.score-strip {
  display: flex; align-items: center; justify-content: space-between;
  padding: 3px 12px; gap: 6px; flex-shrink: 0; z-index: 5;
  background: var(--parchment-dk); border-bottom: 2px solid var(--border-heavy);
  font-family: "Space Grotesk", sans-serif;
}
.faction { display: flex; align-items: center; gap: 5px; font-weight: 700; }
.faction .pts { font-size: 18px; min-width: 22px; text-align: center; background: rgba(0,0,0,0.06); border-radius: 3px; padding: 0 3px; }
.faction .name { font-size: 9px; text-transform: uppercase; letter-spacing: 0.12em; }
.faction.france { color: var(--france); }
.faction.prussia { color: var(--prussia); }
.faction.russia { color: var(--russia); }

.strip-center { display: flex; align-items: center; gap: 5px; }
.turn-pill { font-size: 10px; color: var(--gold); background: rgba(154,122,32,0.08); border: 1px solid rgba(154,122,32,0.2); border-radius: 12px; padding: 1px 8px; }
.status-badge { font-size: 8px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; padding: 1px 6px; border-radius: 3px; background: rgba(40,120,60,0.1); color: #3a8a4a; border: 1px solid rgba(40,120,60,0.2); }
.status-badge.thinking { background: rgba(154,122,32,0.1); color: var(--gold); border-color: var(--gold-dim); animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 0%,100% { opacity: 0.6; } 50% { opacity: 1; } }

.ctrl-btn { border-radius: 4px; border: 1px solid var(--border); padding: 4px 12px; background: rgba(255,255,255,0.3); color: var(--ink-dim); font-family: inherit; font-size: 11px; cursor: pointer; font-weight: 600; }
.ctrl-btn:hover { background: rgba(255,255,255,0.5); color: var(--ink); }
.ctrl-btn.primary { background: rgba(46,90,138,0.25); color: var(--france); border-color: rgba(46,90,138,0.4); font-weight: 700; font-size: 12px; }
.gear-btn { background: none; border: 1px solid var(--border); border-radius: 3px; padding: 2px 6px; font-size: 12px; cursor: pointer; color: var(--ink-dim); }

.control-bar-wrap { height: 3px; display: flex; flex-shrink: 0; }
.control-bar-wrap .f-fill { background: var(--france); transition: flex 0.8s ease; }
.control-bar-wrap .p-fill { background: var(--prussia); transition: flex 0.8s ease; }
.control-bar-wrap .r-fill { background: var(--russia); transition: flex 0.8s ease; }

/* ═══ Arena Layout ═══ */
.arena-layout { flex: 1; display: flex; overflow: hidden; }
.left-col { display: flex; flex-direction: column; transition: flex 0.5s ease; }
.right-col { display: flex; flex-direction: column; overflow: hidden; transition: flex 0.5s ease; }

/* Phase: deliberation — grid dominant but map still visible */
.arena-layout[data-phase="deliberation"] .left-col { flex: 0.3; }
.arena-layout[data-phase="deliberation"] .right-col { flex: 0.7; }
/* Phase: resolution — map+narrator only, grid HIDDEN */
.arena-layout[data-phase="resolution"] .left-col { flex: 1; }
.arena-layout[data-phase="resolution"] .right-col { flex: 0; max-width: 0; overflow: hidden; }
/* Phase: idle — balanced */
.arena-layout[data-phase="idle"] .left-col { flex: 0.45; }
.arena-layout[data-phase="idle"] .right-col { flex: 0.55; }

/* ═══ Map ═══ */
.map-stage {
  flex-shrink: 0; position: relative; overflow: hidden; background: #0c1520;
}
.map-stage > svg { position: absolute; inset: 0; width: 100%; height: 100%; }

/* ═══ Narrator fills remaining space ═══ */

/* ═══ Narrator Panel (fills remaining space below map) ═══ */
.narrator-panel {
  flex: 1; min-height: 80px;
  display: flex; flex-direction: column;
  background: var(--parchment-lt); border-top: 2px solid var(--border-heavy);
  overflow: hidden;
}
.narrator-header {
  font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.1em;
  color: var(--gold); padding: 4px 10px; border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.narrator-feed {
  flex: 1; overflow-y: auto; padding: 6px 10px;
  display: flex; flex-direction: column; gap: 8px;
}
.narrator-feed::-webkit-scrollbar { width: 3px; }
.narrator-feed::-webkit-scrollbar-thumb { background: rgba(80,60,30,0.3); }
.narrator-entry {
  font-style: italic; font-size: 12px; line-height: 1.6; color: var(--ink-dim);
  padding: 6px 10px; border-left: 3px solid var(--gold-dim);
  background: rgba(154,122,32,0.04); border-radius: 0 4px 4px 0;
}
.narrator-entry .narrator-turn {
  font-style: normal; font-weight: 700; color: var(--gold);
  font-size: 9px; text-transform: uppercase; margin-right: 6px;
  display: inline-block; background: rgba(154,122,32,0.1);
  padding: 0 4px; border-radius: 2px;
}

/* ═══ 3x3 Channel Grid ═══ */
.channel-grid {
  flex: 1; display: flex; flex-direction: column;
  background: var(--parchment); overflow: hidden;
}
/* Row-based phase coloring — BOLD visual separation */
.grid-row {
  flex: 1; display: flex; min-height: 0;
  border-bottom: 4px solid #8a7a58;
}
.grid-row:last-child { border-bottom: none; }

/* Strategy — military khaki */
.grid-row:nth-child(1) { background: #e0d4b8; }
/* Briefings — diplomatic rose */
.grid-row:nth-child(2) { background: #dcc8b8; }
/* Negotiations — intrigue amber */
.grid-row:nth-child(3) { background: #d4c4a0; }

.row-label {
  writing-mode: vertical-rl; text-orientation: mixed; transform: rotate(180deg);
  font-family: "Space Grotesk", sans-serif;
  font-size: 8px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.12em;
  color: #6a5a40; padding: 4px 3px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; width: 20px; border-right: 3px solid #8a7a58;
  background: rgba(0,0,0,0.06);
}

.grid-cell {
  flex: 1; display: flex; flex-direction: column;
  border-right: 2px solid rgba(100,80,50,0.35);
  min-width: 0; overflow: hidden; position: relative;
}
.grid-cell:last-child { border-right: none; }

.cell-header {
  font-family: "Space Grotesk", sans-serif;
  display: flex; align-items: center; gap: 4px;
  padding: 3px 6px; flex-shrink: 0;
  border-bottom: 1px solid rgba(100,80,50,0.25);
  background: rgba(0,0,0,0.03);
}
.cell-title { font-size: 9px; font-weight: 700; color: var(--ink-dim); white-space: nowrap; }
.cell-subtitle { font-size: 7px; color: var(--ink-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1; }
.cell-toggle {
  font-size: 8px; background: none; border: 1px solid var(--border);
  border-radius: 3px; padding: 1px 4px; cursor: pointer; color: var(--ink-muted);
  flex-shrink: 0;
}
.cell-toggle:hover { background: rgba(80,60,30,0.1); color: var(--ink); }

.cell-feed {
  flex: 1; overflow-y: auto; padding: 4px;
  display: flex; flex-direction: column; gap: 3px;
}
.cell-feed::-webkit-scrollbar { width: 2px; }
.cell-feed::-webkit-scrollbar-thumb { background: rgba(80,60,30,0.3); }

/* Column picker */
.col-picker {
  position: absolute; top: 24px; left: 0; right: 0; z-index: 20;
  background: var(--parchment); border: 1px solid var(--border-heavy);
  border-radius: 4px; max-height: 200px; overflow-y: auto;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}
.picker-item {
  display: block; width: 100%; text-align: left;
  background: none; border: none; border-bottom: 1px solid rgba(80,60,30,0.1);
  padding: 4px 6px; font-family: "Space Grotesk", sans-serif; font-size: 10px;
  color: var(--ink-dim); cursor: pointer;
}
.picker-item:hover { background: rgba(80,60,30,0.08); color: var(--ink); }
.picker-item.in-use { color: var(--ink-muted); font-style: italic; }

/* ═══ iOS-style Chat Bubbles ═══ */
.bubble {
  border-radius: 12px; padding: 4px 8px;
  font-family: "Space Grotesk", sans-serif;
  font-size: 10px; font-weight: 400; line-height: 1.4;
  max-width: 90%; word-wrap: break-word;
}
.bubble.left { align-self: flex-start; margin-right: auto; border-bottom-left-radius: 4px; }
.bubble.right { align-self: flex-end; margin-left: auto; border-bottom-right-radius: 4px; }

/* Faction-colored bubbles */
.bubble.left.france { background: rgba(46,90,138,0.12); }
.bubble.left.prussia { background: rgba(138,122,40,0.12); }
.bubble.left.russia { background: rgba(138,48,48,0.12); }
.bubble.right.france { background: rgba(46,90,138,0.18); }
.bubble.right.prussia { background: rgba(138,122,40,0.18); }
.bubble.right.russia { background: rgba(138,48,48,0.18); }
.bubble.left { background: rgba(0,0,0,0.05); }
.bubble.right { background: rgba(0,0,0,0.08); }

/* No visual distinction needed — compact and verbose are separate views */

.bubble-sender {
  font-family: "Space Grotesk", sans-serif;
  font-size: 8px; font-weight: 700; color: var(--ink-muted);
  text-transform: uppercase; display: block; margin-bottom: 1px;
}

.bubble.verbose { max-width: 95%; padding: 5px 8px; }
.bubble-head { display: flex; align-items: baseline; gap: 3px; margin-bottom: 2px; }
.bubble-turn { margin-left: auto; font-family: "Space Grotesk", sans-serif; font-size: 7px; color: var(--ink-muted); }
.bubble-body { font-size: 10px; line-height: 1.45; color: var(--ink); }
.bubble-body strong { font-weight: 700; }
.bubble-body em { font-style: italic; }
.bubble-body ul, .bubble-body ol { margin: 1px 0; padding-left: 12px; }
.bubble-body li { margin-bottom: 1px; }

/* ═══ SVG Territory ═══ */
.territory-path { transition: fill 0.7s ease; cursor: default; }
.territory-path:hover { fill-opacity: 0.7; }
.region-label { fill: rgba(255,255,255,0.85); font-family: "Playfair Display", serif; font-size: 10px; font-weight: 600; text-anchor: middle; pointer-events: none; }
.region-stats { fill: rgba(255,255,255,0.45); font-family: "Space Grotesk", sans-serif; font-size: 8px; text-anchor: middle; pointer-events: none; }
.edge-front { stroke: rgba(180,140,50,0.25); stroke-width: 1.5; stroke-dasharray: 4 3; animation: frontPulse 3s ease-in-out infinite; }
.edge-sea { stroke: rgba(80,140,200,0.2); stroke-width: 1; stroke-dasharray: 6 5; animation: frontPulse 4s ease-in-out infinite; }
@keyframes frontPulse { 0%,100% { opacity: 0.2; } 50% { opacity: 0.6; } }
.target-ring { fill: none; stroke-width: 2; stroke-dasharray: 6 4; opacity: 0; animation: targetIn 0.3s ease forwards, targetSpin 1s linear infinite; }
.target-ring.france { stroke: var(--france-lt); }
.target-ring.prussia { stroke: var(--prussia-lt); }
.target-ring.russia { stroke: var(--russia-lt); }
@keyframes targetIn { to { opacity: 0.7; } }
@keyframes targetSpin { to { stroke-dashoffset: -20; } }
.captured-flash { stroke-width: 2; opacity: 0; animation: capFlash 1.4s ease-out forwards; }
@keyframes capFlash { 0% { opacity: 0; fill-opacity: 0.4; } 15% { opacity: 1; fill-opacity: 0.3; } 40% { fill-opacity: 0; } 100% { opacity: 0; stroke-width: 12; } }

/* ═══ Turn Banner ═══ */
.turn-banner { position: absolute; top: 50%; left: 50%; transform: translate(-50%,-50%); z-index: 12; pointer-events: none; text-align: center; opacity: 0; transition: opacity 0.35s ease; }
.turn-banner.visible { opacity: 1; }
.turn-banner .phase { font-size: clamp(16px, 3vw, 28px); font-weight: 700; letter-spacing: 0.08em; color: #d4a840; text-shadow: 0 0 20px rgba(212,168,64,0.4); }
.turn-banner .detail { font-family: "Space Grotesk", sans-serif; font-size: 11px; color: #e8e0d0; margin-top: 4px; background: rgba(10,8,5,0.8); border-radius: 4px; padding: 4px 12px; border: 1px solid rgba(120,90,40,0.3); }

/* ═══ Victory ═══ */
.victory-overlay { position: absolute; inset: 0; z-index: 20; display: grid; place-items: center; background: radial-gradient(ellipse at center, rgba(42,34,24,0.8), rgba(20,16,10,0.95)); backdrop-filter: blur(8px); opacity: 0; pointer-events: none; transition: opacity 0.8s ease; }
.victory-overlay.visible { opacity: 1; pointer-events: auto; }
.victory-content { text-align: center; animation: vPop 0.8s ease; }
.victory-content h2 { font-size: clamp(28px, 5vw, 48px); font-weight: 700; letter-spacing: 0.06em; margin-bottom: 6px; color: var(--parchment); }
.victory-content h2.france { color: var(--france-lt); }
.victory-content h2.prussia { color: var(--prussia-lt); }
.victory-content h2.russia { color: var(--russia-lt); }
.victory-content h2.draw { color: var(--gold); }
.victory-content p { font-size: 13px; color: var(--parchment-dk); }
.victory-content .final { margin-top: 8px; font-family: "Space Grotesk", sans-serif; font-size: 14px; display: flex; gap: 14px; justify-content: center; color: var(--parchment); }
.victory-narration { font-style: italic; color: var(--parchment-dk); font-size: 12px; line-height: 1.5; max-width: 420px; margin: 12px auto; padding: 8px 14px; border-left: 2px solid var(--gold-dim); border-radius: 0 4px 4px 0; }
@keyframes vPop { 0% { transform: scale(0.5); opacity: 0; } 60% { transform: scale(1.04); } 100% { transform: scale(1); opacity: 1; } }

/* ═══ Settings Drawer ═══ */
.settings-drawer { position: fixed; top: 0; right: 0; width: 280px; height: 100%; z-index: 30; background: var(--parchment); border-left: 2px solid var(--border-heavy); padding: 12px; display: flex; flex-direction: column; gap: 8px; transform: translateX(100%); transition: transform 0.3s ease; overflow-y: auto; font-family: "Space Grotesk", sans-serif; color: var(--ink); }
.settings-drawer.open { transform: translateX(0); }
.settings-drawer h3 { font-family: "Playfair Display", serif; font-size: 13px; color: var(--gold); letter-spacing: 0.04em; border-bottom: 1px solid var(--border); padding-bottom: 4px; }
.setting { display: flex; flex-direction: column; gap: 2px; }
.setting label { font-size: 9px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--ink-muted); }
.setting select, .setting input { border-radius: 3px; border: 1px solid var(--border); padding: 4px 6px; background: rgba(255,255,255,0.5); color: var(--ink); font-family: inherit; font-size: 11px; }
.settings-note { font-size: 9px; color: var(--ink-muted); line-height: 1.4; border-top: 1px solid var(--border); padding-top: 6px; }
.close-btn { background: none; border: 1px solid var(--border); border-radius: 3px; padding: 3px 6px; color: var(--ink-dim); cursor: pointer; align-self: flex-end; font-size: 10px; }

/* ═══ Start Screen Overlay ═══ */
.start-overlay {
  position: fixed; inset: 0; z-index: 25;
  display: grid; place-items: center;
  background: radial-gradient(ellipse at center, rgba(42,34,24,0.92), rgba(20,16,10,0.98));
  backdrop-filter: blur(6px);
  transition: opacity 0.5s ease;
}
.start-overlay.hidden { opacity: 0; pointer-events: none; }
.start-content { text-align: center; max-width: 560px; padding: 24px; }
.start-content h1 {
  font-size: clamp(28px, 5vw, 48px); font-weight: 700;
  color: var(--parchment); letter-spacing: 0.06em; margin-bottom: 4px;
}
.start-subtitle {
  font-family: "Space Grotesk", sans-serif;
  font-size: 13px; color: var(--gold); text-transform: uppercase;
  letter-spacing: 0.1em; margin-bottom: 20px;
}
.start-desc {
  text-align: left; color: var(--parchment-dk); font-size: 14px; line-height: 1.7;
  margin-bottom: 24px;
}
.start-desc p { margin-bottom: 10px; }
.start-desc strong { color: var(--parchment); }
.start-big-btn {
  font-family: "Playfair Display", serif;
  font-size: 20px; font-weight: 700; letter-spacing: 0.06em;
  padding: 12px 40px; border-radius: 6px;
  background: linear-gradient(135deg, #3a6a3a, #2a5a2a);
  color: var(--parchment); border: 2px solid rgba(100,160,100,0.4);
  cursor: pointer; transition: transform 0.15s, box-shadow 0.15s;
  box-shadow: 0 4px 16px rgba(0,0,0,0.4);
}
.start-big-btn:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(0,0,0,0.5); }
.start-hint {
  font-family: "Space Grotesk", sans-serif;
  font-size: 11px; color: rgba(232,220,200,0.4); margin-top: 12px;
}

/* ═══ Status Bar ═══ */
.status-bar { font-family: "Space Grotesk", sans-serif; font-size: 9px; color: var(--ink-muted); padding: 2px 12px; border-top: 1px solid var(--border); flex-shrink: 0; background: var(--parchment-dk); }

/* ═══ UI Guide Overlay ═══ */
.guide-overlay {
  position: fixed; inset: 0; z-index: 22;
  display: grid; place-items: center;
  background: rgba(20,16,10,0.92); backdrop-filter: blur(6px);
  transition: opacity 0.4s ease;
}
.guide-overlay.hidden { opacity: 0; pointer-events: none; }
.guide-card {
  max-width: 520px; padding: 24px 28px; text-align: center;
  background: var(--parchment); border: 2px solid var(--border-heavy);
  border-radius: 8px; box-shadow: 0 8px 32px rgba(0,0,0,0.5);
}
.guide-card h2 {
  font-size: 18px; color: var(--gold); letter-spacing: 0.04em; margin-bottom: 16px;
  border-bottom: 1px solid var(--border); padding-bottom: 8px;
}
.guide-grid { display: flex; flex-direction: column; gap: 12px; text-align: left; margin-bottom: 20px; }
.guide-item {
  display: flex; gap: 10px; align-items: flex-start;
  font-family: "Space Grotesk", sans-serif; font-size: 12px; line-height: 1.5; color: var(--ink-dim);
}
.guide-item strong { color: var(--ink); }
.guide-icon { font-size: 18px; flex-shrink: 0; width: 28px; text-align: center; }
.guide-dismiss {
  font-family: "Playfair Display", serif; font-size: 14px; font-weight: 700;
  padding: 8px 24px; border-radius: 5px;
  background: linear-gradient(135deg, #3a6a3a, #2a5a2a);
  color: var(--parchment); border: 2px solid rgba(100,160,100,0.4);
  cursor: pointer; transition: transform 0.15s;
}
.guide-dismiss:hover { transform: translateY(-1px); }

@media (max-width: 700px) { .faction .name { display: none; } .row-label { display: none; } }
