/* Netrunner AI — Styles */
:root {
  --corp-color: #1a3a5c;
  --runner-color: #1a4a2a;
  --bg: #0d1117;
  --surface: #161b22;
  --surface2: #21262d;
  --border: #30363d;
  --text: #c9d1d9;
  --text-muted: #8b949e;
  --accent: #58a6ff;
  --green: #3fb950;
  --orange: #f0883e;
  --red: #f85149;
  --yellow: #e3b341;
}

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Segoe UI', system-ui, sans-serif;
  font-size: 14px;
  min-height: 100vh;
}

/* ---- Start page ---- */
.start-page {
  max-width: 900px;
  margin: 40px auto;
  padding: 24px;
}
.start-page h1 { color: var(--accent); margin-bottom: 8px; font-size: 28px; }
.start-page p { color: var(--text-muted); margin-bottom: 24px; }

.deck-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 16px;
}
.deck-section h2 { margin-bottom: 12px; font-size: 16px; color: var(--accent); }
.deck-section input, .deck-section textarea {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 4px;
  padding: 8px;
  width: 100%;
  font-family: inherit;
  font-size: 13px;
}
.deck-section textarea { resize: vertical; margin-top: 8px; }
.or-divider { color: var(--text-muted); text-align: center; margin: 8px 0; font-size: 12px; }
.deck-status { margin-top: 6px; font-size: 12px; min-height: 18px; }
.deck-status.ok { color: var(--green); }
.deck-status.error { color: var(--red); }

.ai-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 16px;
}
.ai-section h2 { margin-bottom: 12px; font-size: 16px; color: var(--accent); }
.ai-section label { display: block; margin: 6px 0; cursor: pointer; }
.ai-section input { margin-right: 6px; }

.start-btn-row { display: flex; align-items: center; gap: 16px; }

button.btn, button {
  background: var(--accent);
  color: #0d1117;
  border: none;
  border-radius: 6px;
  padding: 8px 16px;
  cursor: pointer;
  font-weight: 600;
  font-size: 13px;
  transition: opacity 0.15s;
}
button:hover { opacity: 0.85; }
button:disabled { opacity: 0.5; cursor: not-allowed; }

.error-msg { color: var(--red); font-size: 13px; }

/* ---- Saved decks ---- */
.saved-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}
.saved-header h2 { margin: 0; flex: 1; }
.save-current-btn { font-size: 11px; padding: 4px 10px; background: var(--surface2); color: var(--text-muted); border: 1px solid var(--border); }
.save-current-btn:hover { border-color: var(--accent); color: var(--text); }
.saved-group { margin-bottom: 8px; }
.saved-group-label { font-size: 11px; font-weight: bold; color: var(--text-muted); text-transform: uppercase; letter-spacing: 1px; margin-bottom: 5px; }
.saved-list { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.saved-chip { display: inline-flex; align-items: center; gap: 2px; }
.delete-btn { background: transparent; color: var(--text-muted); border: none; padding: 2px 5px; font-size: 11px; border-radius: 3px; }
.delete-btn:hover { color: var(--red); background: rgba(255,80,80,0.1); }
.text-muted { color: var(--text-muted); font-size: 12px; }

/* ---- Starter decks ---- */
.starter-section {
  background: var(--surface);
  border: 1px solid var(--accent);
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 20px;
}
.starter-section h2 { color: var(--accent); font-size: 16px; margin-bottom: 4px; }
.starter-hint { color: var(--text-muted); font-size: 12px; margin-bottom: 12px; }
.starter-pairs { display: flex; gap: 12px; flex-wrap: wrap; }
.starter-pair {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 12px;
  flex: 1;
  min-width: 260px;
}
.starter-pair-label {
  font-weight: bold;
  font-size: 13px;
  margin-bottom: 8px;
  color: var(--text);
}
.starter-pair-label small { color: var(--text-muted); font-weight: normal; }
.starter-pair-btns { display: flex; gap: 8px; flex-wrap: wrap; }
.starter-btn { font-size: 12px; padding: 6px 12px; }
.starter-btn.corp-btn { background: #1a3a5c; color: #7ab8e8; border: 1px solid #4a7fa0; }
.starter-btn.corp-btn:hover { background: #264869; }
.starter-btn.runner-btn { background: #1a3a1a; color: #7ae87a; border: 1px solid #4a9a4a; }
.starter-btn.runner-btn:hover { background: #1c4a1c; }

/* ---- Game board ---- */
#app {
  display: flex;
  flex-direction: row;
  min-height: 100vh;
  align-items: stretch;
  gap: 0;
}

/* Left actions sidebar */
.actions-sidebar {
  width: 220px;
  min-width: 180px;
  background: var(--surface2);
  border-right: 2px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 10px 8px;
  gap: 6px;
  overflow-y: auto;
  position: sticky;
  top: 0;
  height: 100vh;
}

/* Center main game content */
.game-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

/* Right log panel */
.log-panel {
  width: 280px;
  min-width: 220px;
  background: var(--surface);
  border-left: 2px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  position: sticky;
  top: 0;
  height: 100vh;
}

.turn-banner {
  padding: 10px 20px;
  font-weight: bold;
  font-size: 15px;
  text-align: center;
}
.my-turn { background: #1c3a2a; color: var(--green); }
.ai-turn { background: #1a2a3a; color: var(--text-muted); }

.zone {
  padding: 12px 16px;
  border-bottom: 2px solid var(--border);
}
.corp-zone { background: #0d1a2a; border-bottom-color: #264869; }
.runner-zone { background: #0d1a12; border-top: 2px solid #1e4a2a; }

.zone-header {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}
.identity-name { font-weight: bold; font-size: 15px; color: var(--accent); cursor: help; }
.credits { color: var(--yellow); font-weight: bold; }
.clicks { letter-spacing: 2px; color: var(--green); }
.ap { color: var(--orange); font-weight: bold; }
.tags { color: var(--red); }
.memory { color: var(--text-muted); }

/* Central servers */
.central-servers {
  display: flex;
  gap: 16px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}
.central-server {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 12px;
  min-width: 120px;
}
.server-name {
  font-weight: bold;
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.card-count { color: var(--text-muted); font-weight: normal; }
.server-label { font-size: 11px; color: var(--text-muted); margin-bottom: 2px; }

/* ICE column — vertical stack, outermost at top */
.ice-col {
  display: flex;
  flex-direction: column;
  gap: 3px;
  margin-bottom: 4px;
}

/* ICE chips */
.ice-chip {
  display: flex;
  flex-direction: column;
  padding: 3px 8px;
  border-radius: 3px;
  font-size: 11px;
  cursor: default;
  width: 100%;
  box-sizing: border-box;
}
.ice-chip-main {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.ice-chip.rezzed { background: #264869; color: var(--text); border: 1px solid #4a7fa0; }
.ice-chip.unrezzed { background: #2a2a3a; color: var(--text-muted); border: 1px solid #44446a; font-style: italic; }
.ice-chip.ice-active { border-color: var(--orange) !important; box-shadow: 0 0 4px var(--orange); }
.ice-str { font-size: 10px; color: var(--text-muted); margin-left: 6px; }
.trojan-chip {
  margin-top: 2px;
  padding: 1px 4px;
  background: #2a1a3a;
  border: 1px solid #7a4fa0;
  border-radius: 2px;
  font-size: 10px;
  color: #c9a0e8;
  cursor: default;
}

/* Remote servers */
.remote-servers {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 8px;
}
.remote-server {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px;
  min-width: 110px;
}
.content-row {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  margin-top: 4px;
}
.installed-card {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 3px;
  font-size: 11px;
  cursor: default;
}
.installed-card.rezzed { background: #1c3a1c; border: 1px solid #3fb950; color: var(--text); }
.installed-card.unrezzed { background: #2a2a2a; border: 1px dashed var(--border); color: var(--text-muted); }
.program-card { background: #1c2a3a !important; border-color: #4a7fa0 !important; }
.hardware-card { background: #2a1c3a !important; border-color: #7a4aaa !important; }
.resource-card { background: #2a2a1c !important; border-color: #a09040 !important; }

/* Hand */
.hand-label, .rig-label { font-size: 12px; color: var(--text-muted); margin: 8px 0 4px; font-weight: bold; }
.grip-info { font-size: 12px; color: var(--text-muted); margin: 6px 0; }
.hand {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin: 4px 0 8px;
}
.hand-card {
  width: 80px;
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
  background: var(--surface2);
  cursor: pointer;
  transition: transform 0.15s, border-color 0.15s;
  text-align: center;
}
.hand-card.playable { border-color: var(--green); }
.hand-card.playable:hover { transform: translateY(-6px); border-color: var(--accent); }
.hand-card.discardable { border-color: var(--red); opacity: 0.85; }
.hand-card.discardable:hover { transform: translateY(-4px); border-color: #ff6666; opacity: 1; }
.discard-notice { color: var(--red); font-size: 12px; font-weight: bold; margin-bottom: 6px; padding: 4px 8px; background: #2a1a1a; border-radius: 4px; border: 1px solid var(--red); }
.hand-card .card-img { width: 100%; display: block; }
.hand-card .card-label {
  font-size: 10px;
  padding: 3px;
  color: var(--text-muted);
  line-height: 1.2;
  word-break: break-word;
}

/* Rig */
.rig {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  margin: 4px 0 8px;
}
.counter { color: var(--orange); font-size: 10px; }

/* Log */
.game-log {
  background: var(--surface);
  padding: 8px 12px;
  flex: 1;
  overflow-y: auto;
}
.log-label { font-size: 11px; font-weight: bold; color: var(--text-muted); }
.log-toggle { font-size: 10px; padding: 2px 7px; background: var(--surface2); color: var(--text-muted); border: 1px solid var(--border); }
.log-toggle:hover { border-color: var(--accent); color: var(--text); }
.log-entry { font-size: 12px; color: var(--text-muted); padding: 1px 0; }
.log-entry:first-of-type { color: var(--text); }
.log-card-ref { color: var(--accent); cursor: help; border-bottom: 1px dotted currentColor; }

/* Actions panel (sidebar layout) */
.actions-panel {
  display: flex;
  flex-direction: column;
  gap: 5px;
  width: 100%;
}
.action-btn { font-size: 12px; padding: 6px 10px; width: 100%; text-align: left; }
.click-action-btn { background: #1a3a5c; color: #7ab8e8; border: 1px solid #4a7fa0; }
.click-action-btn:hover { background: #264869; }
.free-action-btn { background: #262626; color: var(--text-muted); border: 1px solid #444; }
.free-action-btn:hover { background: #2e2e2e; color: var(--text); }
.pass-turn-btn { background: #333; color: var(--text-muted); border: 1px solid #555; width: 100%; text-align: left; font-size: 12px; padding: 6px 10px; }
.run-action-btn { background: #1a4a1a; color: var(--green); border: 1px solid var(--green); width: 100%; text-align: left; }
.rez-yes { background: #264869; color: #58a6ff; }
.rez-no { background: #2a1a1a; color: var(--text-muted); }
.break-btn { background: #2a1c3a; color: #c992ff; }
.pump-btn { background: #1a2a3a; color: #58c8ff; }
.click-break-btn { background: #2a1a2a; color: #e89eff; }
.advance-btn { background: #3a2a1a; color: var(--orange); }
.score-btn { background: #1a3a1a; color: var(--green); }
.access-btn { background: #3a1a1a; color: var(--red); }
.run-btn { font-size: 10px; padding: 2px 6px; margin-left: 4px; background: #1a3a1a; color: var(--green); }

/* Run overlay */
.run-overlay {
  background: #1a0a0a;
  border: 2px solid var(--red);
  border-radius: 8px;
  padding: 12px 16px;
  margin: 8px 16px;
}
.run-title { font-weight: bold; color: var(--red); margin-bottom: 4px; }
.run-phase { font-size: 12px; color: var(--text-muted); margin-bottom: 4px; }
.run-ice { font-size: 13px; color: var(--text); }
.run-ice-text { font-size: 11px; color: var(--text-muted); margin-top: 2px; margin-bottom: 4px; font-style: italic; }
.run-access-header { font-size: 12px; font-weight: bold; color: var(--orange); margin: 6px 0 4px; }
.run-access-card { font-size: 13px; color: var(--text); margin: 2px 0; }
.run-access-type { font-size: 11px; color: var(--text-muted); }
.run-access-stats { font-size: 11px; color: var(--yellow); }

/* Tooltip */
.card-tooltip {
  position: fixed;
  z-index: 1000;
  border-radius: 8px;
  max-width: 220px;
  pointer-events: none;
  box-shadow: 0 4px 20px rgba(0,0,0,0.8);
  overflow: hidden;
}
.card-tooltip.hidden { display: none; }

/* Thinking banner */
.thinking-banner {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(20, 20, 30, 0.92);
  border: 1px solid var(--accent);
  color: var(--accent);
  padding: 10px 24px;
  border-radius: 20px;
  font-size: 14px;
  font-weight: bold;
  letter-spacing: 0.04em;
  z-index: 2000;
  box-shadow: 0 4px 20px rgba(0,0,0,0.6);
  display: flex;
  align-items: center;
  gap: 10px;
}
.thinking-banner.hidden { display: none; }
.thinking-spinner {
  width: 14px;
  height: 14px;
  border: 2px solid var(--accent);
  border-top-color: transparent;
  border-radius: 50%;
  display: inline-block;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.tt-title { font-weight: bold; font-size: 13px; margin-bottom: 4px; color: var(--accent); }
.tt-type { font-size: 11px; color: var(--text-muted); margin-bottom: 4px; }
.tt-stats { font-size: 11px; color: var(--yellow); margin-bottom: 6px; }
.tt-text { font-size: 11px; color: var(--text); line-height: 1.5; margin-bottom: 6px; }
.tt-img { display: block; width: 100%; }

/* Modal */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 500;
}
.modal-content {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 20px;
  min-width: 300px;
}
.modal-content h3 { margin-bottom: 12px; color: var(--accent); }
.choice-btn {
  display: block;
  width: 100%;
  margin: 6px 0;
  text-align: left;
  background: var(--surface2);
  color: var(--text);
  border: 1px solid var(--border);
}
.choice-btn:hover { border-color: var(--accent); }

/* Game over */
.game-over {
  text-align: center;
  padding: 60px 20px;
}
.game-over h1 { font-size: 40px; margin-bottom: 12px; }
.game-over p { color: var(--text-muted); margin-bottom: 24px; }

/* Error toast */
.error-toast {
  position: fixed;
  bottom: 20px;
  right: 20px;
  background: var(--red);
  color: white;
  padding: 10px 16px;
  border-radius: 6px;
  font-weight: bold;
  z-index: 999;
  display: none;
}

/* MCTS settings panel */
.mcts-settings {
  margin-top: auto;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}
.mcts-settings-title {
  font-size: 10px;
  font-weight: bold;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 6px;
}
.mcts-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 5px;
  gap: 6px;
}
.mcts-label {
  font-size: 11px;
  color: var(--text-muted);
  flex: 1;
}
.mcts-input {
  width: 62px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 4px;
  padding: 3px 5px;
  font-size: 11px;
  font-family: inherit;
}
.mcts-input:focus { outline: none; border-color: var(--accent); }

.mcts-stats-panel {
  border-top: 1px solid var(--border);
  padding: 10px 0 6px;
  margin-top: 8px;
}

/* Scrollbar */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* ---- Quick-start intro ---- */
.quick-start {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  padding: 24px 0 8px;
}

.deck-summary {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: center;
}

.deck-chip {
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 0.9rem;
  border: 1px solid var(--border);
  color: var(--text-muted);
}
.deck-chip.deck-chip-ok { color: var(--text); border-color: var(--green); }
.corp-chip.deck-chip-ok   { border-color: #e8a000; }
.runner-chip.deck-chip-ok { border-color: var(--green); }

.start-btn-big {
  font-size: 1.3rem;
  padding: 14px 48px;
  background: var(--green);
  color: #000;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-weight: bold;
  letter-spacing: 0.03em;
  transition: opacity 0.15s;
}
.start-btn-big:hover { opacity: 0.85; }
.start-btn-big:disabled { opacity: 0.4; cursor: not-allowed; }

.toggle-decks-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 6px 16px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.85rem;
}
.toggle-decks-btn:hover { color: var(--text); border-color: var(--text-muted); }
.quick-start-footer { display: flex; gap: 10px; flex-wrap: wrap; }
a.card-status-link { text-decoration: none; display: inline-block; }

.deck-section-collapsed { display: none; }
.deck-section-open {
  display: block;
  margin-top: 16px;
  border-top: 1px solid var(--border);
  padding-top: 16px;
}

.deck-inputs {
  display: flex;
  gap: 24px;
  flex-wrap: wrap;
  margin-top: 16px;
}
.deck-input-group { flex: 1; min-width: 260px; }
.deck-input-group h3 { margin: 0 0 8px; }
