@import url('https://fonts.googleapis.com/css2?family=Archivo:wght@400;500;600;700&family=IBM+Plex+Mono:wght@400;500;600;700&display=swap');

:root {
  --bg: #0a0a0c;
  --card: #141417;
  --hairline: #1c1c20;
  --divider: #232328;
  --border-subdued: #2a2a2f;
  --border: #3a3a40;
  --text-tertiary: #55555c;
  --text-secondary: #9a9aa2;
  --text-primary: #f2f2f0;
  --red: #ff6b57;
  --red-bg: #2a1512;
  --accent: #4ad3ff;
  --accent-bg: #0f2830;
  --grid-line: #2a2a2f;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text-primary);
  font-family: Archivo, sans-serif;
}

#app {
  max-width: 430px;
  margin: 0 auto;
  min-height: 100vh;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  padding: 0 16px;
}

.hidden { display: none !important; }

.overline {
  font-family: 'IBM Plex Mono', monospace;
  font-weight: 500;
  font-size: 10px;
  letter-spacing: 1.8px;
  text-transform: uppercase;
  color: var(--text-tertiary);
}

.mono { font-family: 'IBM Plex Mono', monospace; }

h1.title {
  font-family: Archivo, sans-serif;
  font-weight: 700;
  font-size: 23px;
  margin: 2px 0 0;
}

/* Reconnect banner */
#reconnect-banner {
  position: fixed;
  bottom: 10px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--card);
  border: 1px solid var(--border-subdued);
  color: var(--text-tertiary);
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  letter-spacing: 1px;
  padding: 6px 12px;
  border-radius: 8px;
  z-index: 998;
}

/* Toast */
#toast {
  position: fixed;
  top: 8px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--red-bg);
  border: 1px solid var(--red);
  color: var(--red);
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  padding: 6px 12px;
  border-radius: 8px;
  z-index: 999;
  max-width: 400px;
}

/* Inputs */
.field { margin-top: 18px; }
.field input {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 13px;
  background: var(--card);
  color: var(--text-primary);
  font-family: Archivo, sans-serif;
  font-size: 15px;
}
.field input.code-input {
  font-family: 'IBM Plex Mono', monospace;
  font-weight: 600;
  font-size: 20px;
  letter-spacing: 6px;
  text-align: center;
  text-transform: uppercase;
}

/* Buttons */
.btn {
  width: 100%;
  border-radius: 12px;
  padding: 14px 15px;
  font-family: Archivo, sans-serif;
  font-weight: 600;
  font-size: 15px;
  text-align: center;
  border: none;
  cursor: pointer;
}
.btn-primary { background: var(--text-primary); color: var(--bg); }
.btn-secondary { background: transparent; color: var(--text-primary); border: 1px solid var(--border); }
.btn-disabled { background: var(--divider); color: var(--text-tertiary); cursor: default; }
.btn-disabled[disabled] { pointer-events: none; }

/* Lobby */
#screen-lobby { padding-top: 20px; padding-bottom: 24px; }
.lobby-footer { margin-top: auto; padding: 20px 0; }
.link-leave {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  color: var(--text-secondary);
  cursor: pointer;
  text-decoration: underline;
}

/* Cards */
.card {
  border-radius: 14px;
  border: 1px solid var(--border-subdued);
  background: var(--card);
  padding: 14px 16px;
  margin-top: 12px;
}
.card.attention { border-color: var(--red); }

/* Fleet header */
.screen-header { padding-top: 20px; display: flex; align-items: flex-start; justify-content: space-between; }
.screen-header .right { font-family: 'IBM Plex Mono', monospace; font-size: 12px; color: var(--text-secondary); white-space: nowrap; margin-left: 8px; }
.header-row-top { display: flex; justify-content: space-between; align-items: baseline; }

/* Ship card */
.ship-card { cursor: pointer; }
.ship-card-top { display: flex; justify-content: space-between; align-items: center; }
.ship-card-name { font-weight: 600; font-size: 17px; }
.badge {
  font-family: 'IBM Plex Mono', monospace;
  font-weight: 600;
  font-size: 10px;
  letter-spacing: 1px;
  padding: 4px 8px;
  border-radius: 6px;
  white-space: nowrap;
}
.badge-outline { border: 1px solid var(--red); color: var(--red); }
.badge-solid { background: var(--text-primary); color: var(--bg); }
.ship-stat-row {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  color: var(--text-secondary);
  margin-top: 8px;
}
.ship-stat-row .stat-red { color: var(--red); }

.opponents-row {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  color: var(--text-tertiary);
  margin-top: 16px;
}

.fleet-footer { margin-top: auto; padding: 12px 0 20px; }

.tracker-strip {
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: default;
}
.tracker-strip .chevron { color: var(--text-tertiary); }

/* Worksheet header */
.ws-header { padding-top: 18px; display: flex; justify-content: space-between; align-items: flex-start; }
.ws-header-left { display: flex; gap: 10px; align-items: flex-start; }
.back-chevron { font-size: 20px; color: var(--text-primary); cursor: pointer; line-height: 1.1; }
.ws-title { font-weight: 600; font-size: 17px; }
.ws-free {
  text-align: right;
  font-family: 'IBM Plex Mono', monospace;
}
.ws-free .big { font-weight: 700; font-size: 22px; }
.ws-free .big.negative { color: var(--red); }
.ws-free .sub { font-size: 10px; color: var(--text-tertiary); letter-spacing: 1px; }

/* Tabs */
.tabs { display: flex; margin-top: 14px; border-bottom: 1px solid var(--divider); }
.tab {
  flex: 1;
  text-align: center;
  padding: 10px 0;
  font-weight: 600;
  font-size: 14px;
  color: var(--text-tertiary);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.tab.active { color: var(--text-primary); border-bottom: 2px solid var(--text-primary); }

/* Progress bar */
.progress-bar {
  height: 4px;
  background: var(--divider);
  border-radius: 2px;
  margin-top: 12px;
  overflow: hidden;
}
.progress-bar-fill { height: 100%; background: var(--text-primary); }
.progress-bar-fill.over { background: var(--red); }

/* Allocation rows */
.alloc-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 0;
  border-bottom: 1px solid var(--hairline);
}
.alloc-row-label { font-weight: 500; font-size: 15px; }
.alloc-row-sub { font-family: 'IBM Plex Mono', monospace; font-size: 11px; color: var(--text-tertiary); margin-top: 3px; }

.stepper { display: flex; align-items: center; gap: 10px; }
.stepper-btn {
  width: 34px;
  height: 34px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: transparent;
  color: var(--text-secondary);
  font-size: 16px;
  font-family: 'IBM Plex Mono', monospace;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.stepper-value {
  font-family: 'IBM Plex Mono', monospace;
  font-weight: 600;
  font-size: 17px;
  min-width: 24px;
  text-align: center;
}
.stepper-value.negative { color: var(--red); }

/* Outlined cards (arming, capacitor) */
.outline-card {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 11px 12px;
  margin: 10px 0;
  background: var(--card);
}
.outline-card.warn { border-color: var(--red); background: var(--red-bg); }
.outline-card-top { display: flex; justify-content: space-between; align-items: center; }
.outline-card-title { font-weight: 600; font-size: 15px; }
.outline-card-sub { font-family: 'IBM Plex Mono', monospace; font-size: 11px; color: var(--text-tertiary); margin-top: 3px; }
.warn .outline-card-title, .warn .outline-card-sub { color: var(--red); }

.segment-gauge { display: flex; gap: 4px; margin-top: 10px; }
.segment {
  flex: 1;
  height: 6px;
  background: var(--border);
  border-radius: 2px;
}
.segment.filled { background: var(--text-primary); }

.warn-line {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  color: var(--red);
  margin-top: 8px;
}

.batteries-row { padding: 14px 0; }
.batteries-row .alloc-row-label { margin-bottom: 4px; }
.battery-steppers { display: flex; justify-content: space-between; margin-top: 10px; gap: 16px; }
.battery-stepper-block { flex: 1; }
.battery-stepper-label { font-family: 'IBM Plex Mono', monospace; font-size: 10px; color: var(--text-tertiary); margin-bottom: 6px; letter-spacing: 1px; }

.ws-footer { margin-top: auto; padding: 16px 0 20px; }

/* SSD tab */
.ssd-section-label {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 10px;
  letter-spacing: 1.5px;
  color: var(--text-tertiary);
  margin-top: 20px;
  margin-bottom: 10px;
}
.shields-row { display: flex; gap: 6px; }
.shield-gauge { flex: 1; display: flex; flex-direction: column; align-items: center; cursor: pointer; }
.shield-bar-track {
  width: 100%;
  height: 60px;
  background: var(--divider);
  border-radius: 6px;
  display: flex;
  align-items: flex-end;
  overflow: hidden;
}
.shield-bar-fill { width: 100%; background: var(--text-primary); }
.shield-bar-fill.damaged { background: var(--red); }
.shield-label {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 10px;
  color: var(--text-secondary);
  margin-top: 6px;
}
.shield-label.damaged { color: var(--red); }

.chip-grid { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  width: 52px;
  height: 40px;
  border: 1px solid var(--border-subdued);
  border-radius: 7px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  background: var(--card);
}
.chip .chip-id { font-family: 'IBM Plex Mono', monospace; font-size: 10px; font-weight: 600; }
.chip .chip-arc { font-family: 'IBM Plex Mono', monospace; font-size: 8px; color: var(--text-tertiary); }
.chip.destroyed { border-color: var(--red); background: var(--red-bg); }
.chip.destroyed .chip-id { color: var(--red); text-decoration: line-through; }
.chip.destroyed .chip-arc { color: var(--red); }

.power-track-label { font-family: 'IBM Plex Mono', monospace; font-size: 11px; color: var(--text-secondary); margin-top: 20px; }
.power-grid { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 8px; }
.power-box {
  width: 20px;
  height: 20px;
  border: 1px solid var(--border-subdued);
  border-radius: 4px;
  cursor: pointer;
  background: var(--card);
}
.power-box.destroyed { border-color: var(--red); background: var(--red-bg); }
.ssd-stores-line { font-size: 11px; color: var(--text-tertiary); margin-top: 8px; }
.reinf-line { font-size: 11px; color: var(--accent); margin-top: 8px; }

/* Damage panel */
.damage-panel { display: flex; flex-direction: column; gap: 8px; }
.damage-row { display: flex; gap: 8px; }
.damage-panel select,
.damage-panel input {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px;
  background: var(--card);
  color: var(--text-primary);
  font-family: Archivo, sans-serif;
  font-size: 14px;
}
.damage-panel select { flex: 0 0 42%; }
.damage-panel input[type="number"] { flex: 1; }
.damage-panel input[type="text"] { flex: 1; }
.damage-result { font-size: 11px; color: var(--text-primary); margin-top: 2px; }
.damage-result-rolls { font-size: 10px; color: var(--text-tertiary); }

/* Reveal screen */
.reveal-side { margin-top: 16px; }
.reveal-side-title { font-weight: 600; font-size: 15px; }
.reveal-ships { font-family: 'IBM Plex Mono', monospace; font-size: 12px; color: var(--text-secondary); margin-top: 4px; }
.log-card { max-height: 220px; overflow-y: auto; }
.log-line { font-family: 'IBM Plex Mono', monospace; font-size: 11px; color: var(--text-secondary); padding: 3px 0; }
.log-line.dmg { color: var(--red); }
.reveal-footer { margin-top: auto; padding: 16px 0 20px; }

/* Impulse tracker */
.tracker-ship-row { padding: 10px 0; border-bottom: 1px solid var(--hairline); }
.tracker-ship-top { display: flex; justify-content: space-between; align-items: center; }
.tracker-ship-name { font-size: 14px; font-weight: 600; }
.badge-moves { background: var(--accent-bg); color: var(--accent); border: 1px solid var(--accent); }
.position-editor { display: flex; gap: 6px; margin-top: 8px; }
.position-editor input {
  width: 70px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px;
  background: var(--card);
  color: var(--text-primary);
  font-size: 13px;
}
.position-editor select {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px;
  background: var(--card);
  color: var(--text-primary);
  font-size: 13px;
}
.position-editor .btn { width: auto; padding: 8px 12px; font-size: 13px; }

/* Tracker map mode */
.map-placeholder {
  color: var(--text-tertiary);
  font-size: 12px;
  text-align: center;
  padding: 40px 12px;
}
.map-scroll {
  margin-top: 12px;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
}
.hex-svg { display: block; height: auto; max-width: none; }
.hex-cell { fill: none; stroke: var(--grid-line); stroke-width: 1; }
.hex-label {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 6px;
  fill: var(--text-tertiary);
  opacity: 0.55;
}
.hex-ship-marker.mine { fill: var(--accent); }
.hex-ship-marker.theirs { fill: var(--text-secondary); }
.hex-move-ring { fill: none; stroke: var(--accent); stroke-width: 2; }
.hex-heading.mine { fill: var(--accent); }
.hex-heading.theirs { fill: var(--text-secondary); }
.hex-ship-label {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 7px;
  fill: var(--text-primary);
  text-anchor: middle;
}

/* Full log screen */
.log-full { margin-top: 8px; padding-bottom: 4px; }
.log-turn-header { margin-top: 16px; margin-bottom: 4px; }
.log-turn-header:first-child { margin-top: 4px; }
.log-note-row { display: flex; gap: 8px; margin-top: 20px; }
.log-note-row input {
  flex: 1;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px;
  background: var(--card);
  color: var(--text-primary);
  font-family: Archivo, sans-serif;
  font-size: 14px;
}
.log-note-row .btn { width: auto; padding: 10px 14px; font-size: 13px; }

/* setup screen */
.hairline-divider { height: 1px; background: var(--hairline); margin: 16px 0; }
a.btn { display: block; text-decoration: none; box-sizing: border-box; }

.side-card { position: relative; }
.side-card-remove {
  position: absolute;
  top: 10px;
  right: 12px;
  color: var(--text-tertiary);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
}
.side-card .field { margin-top: 12px; }
.side-card .field:first-child { margin-top: 0; }
.side-card select,
.side-card input[type="text"] {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 13px;
  background: var(--bg);
  color: var(--text-primary);
  font-family: Archivo, sans-serif;
  font-size: 15px;
}

.ship-row { display: flex; gap: 8px; align-items: center; margin-top: 8px; }
.ship-row select { flex: 0 0 auto; width: 40%; }
.ship-row input[type="text"] { flex: 1; }
.ship-row .ship-row-remove {
  color: var(--text-tertiary);
  font-size: 18px;
  cursor: pointer;
  padding: 0 4px;
}
.btn-add-ship {
  width: auto;
  display: inline-block;
  padding: 8px 12px;
  font-size: 13px;
  margin-top: 10px;
}

.error-line {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  color: var(--red);
  margin-top: 14px;
}

.setup-code {
  font-weight: 600;
  font-size: 28px;
  letter-spacing: 6px;
  text-align: center;
  margin-top: 8px;
}

.setup-handout-card {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 13px;
}
