:root {
  --bg: #0e1218;
  --panel: #161d27;
  --border: #2a3545;
  --text: #e9eef5;
  --muted: #8b9bb0;
  --accent: #3dd9a5;
  --danger: #f87171;
  --font: system-ui, -apple-system, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}
body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.45;
  padding: 1rem 1.25rem 2.5rem;
  max-width: 1280px;
  margin-inline: auto;
}

.top h1 {
  font-size: 1.35rem;
  margin: 0 0 0.25rem;
}
.sub {
  color: var(--muted);
  margin: 0 0 1.25rem;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1rem 1.1rem;
  margin-bottom: 1rem;
}
.panel h2 {
  font-size: 1rem;
  margin: 0 0 0.75rem;
}

.row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  align-items: flex-end;
  margin-bottom: 0.5rem;
}
.row label {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-size: 0.75rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.grow {
  flex: 1 1 200px;
}

input,
select,
button {
  font: inherit;
  color: var(--text);
  background: #1a222e;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.45rem 0.55rem;
}
button {
  cursor: pointer;
  font-weight: 600;
}
button.ghost {
  background: transparent;
}
button.danger {
  color: var(--danger);
  border-color: #5c2d2d;
}
#btn-new {
  background: var(--accent);
  color: #04120d;
  border: none;
}

.msg {
  font-size: 0.85rem;
  color: var(--muted);
  min-height: 1.25rem;
  margin: 0.25rem 0 0;
}
.hint {
  font-size: 0.88rem;
  color: var(--muted);
  margin: 0 0 0.75rem;
}

.scroll {
  overflow: auto;
  max-height: min(52vh, 420px);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.scroll-short {
  max-height: min(36vh, 320px);
}

.sheet-panel {
  padding-top: 0.85rem;
}

.sheet-toolbar {
  margin-bottom: 1rem;
}

.filters {
  margin-bottom: 0.35rem;
}

.room-title {
  margin: 0;
  font-size: 0.95rem;
  color: var(--accent);
  font-weight: 600;
}

.blocks {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.block {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.85rem 0.9rem;
  background: #121820;
}

.block-ref {
  border-color: #2a3a4f;
}

.block-proj {
  border-color: #2f4a3d;
}

.block-compare {
  border-color: #3a3545;
}

.block-head {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 0.55rem;
}

.block-head h3 {
  margin: 0;
  font-size: 0.95rem;
}

.block-tag {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.12rem 0.45rem;
}

.block-tag.accent {
  color: var(--accent);
  border-color: #2f5a48;
}

.block-hint {
  margin: 0 0 0.6rem;
}

.team-ref-note {
  margin: 0.55rem 0 0;
  font-size: 0.8rem;
  color: var(--muted);
}

.panel-secondary {
  opacity: 0.92;
}

.panel-secondary h2 {
  font-size: 0.95rem;
}

.grid {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
}
.grid th,
.grid td {
  border-bottom: 1px solid var(--border);
  padding: 0.35rem 0.45rem;
  text-align: left;
  white-space: nowrap;
}
.grid th {
  position: sticky;
  top: 0;
  background: #1a222e;
  color: var(--muted);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.grid td.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.grid tbody tr {
  background: transparent;
}
.grid tbody tr:nth-child(even):not(.total-row) {
  background: rgba(255, 255, 255, 0.025);
}
.grid tbody tr:hover:not(.total-row) {
  background: rgba(61, 217, 165, 0.07);
}
.grid input.cell {
  width: 4.25rem;
  padding: 0.2rem 0.35rem;
  font-size: 0.8rem;
  background: rgba(255, 255, 255, 0.03);
  border-color: #222c39;
  text-align: right;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.grid input.cell::placeholder {
  color: var(--muted);
  opacity: 0.55;
  font-style: italic;
}
.grid input.cell:hover {
  border-color: var(--border);
}
.grid input.cell:focus {
  outline: none;
  background: #1a222e;
  border-color: var(--accent);
}
.grid input.cell.flash-saved {
  animation: cell-saved 0.9s ease-out;
}
@keyframes cell-saved {
  0% {
    background: rgba(61, 217, 165, 0.35);
  }
  100% {
    background: transparent;
  }
}

.grid td.empty-cell {
  color: var(--muted);
  font-style: italic;
  text-align: center;
  padding: 1rem 0.5rem;
}

.departed-tag,
.new-tag {
  display: inline-block;
  margin-left: 0.45rem;
  font-size: 0.6rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  border-radius: 999px;
  padding: 0.08rem 0.4rem;
  vertical-align: middle;
}
.departed-tag {
  color: #f0b35c;
  border: 1px solid #5c482d;
}
.new-tag {
  color: #7cc4f8;
  border: 1px solid #2d465c;
}

.grid td.player-name {
  font-weight: 600;
  min-width: 9rem;
  position: sticky;
  left: 0;
  background: #121820;
  z-index: 1;
}
.grid tbody tr:nth-child(even):not(.total-row) td.player-name {
  background: #181e26;
}
.grid tbody tr:hover:not(.total-row) td.player-name {
  background: #152622;
}
.grid tr.total-row td.player-name {
  background: #1a222e;
}

.grid tr.total-row td {
  border-top: 2px solid var(--border);
  font-weight: 700;
  background: #1a222e;
}

.grid td.total {
  color: var(--accent);
}

.grid td.computed {
  color: var(--muted);
  font-style: italic;
}

.grid td.muted-col {
  color: #7a8aa0;
}

.pct-up {
  color: #6ee7b7;
}

.pct-down {
  color: #f87171;
}

.pct-flat {
  color: var(--muted);
}

.tab {
  margin-right: 0.25rem;
}

.ref {
  color: #6b7d95;
}

.passcode-row {
  margin-bottom: 0.85rem;
  padding: 0.75rem;
  border-radius: 8px;
  border: 1px solid var(--accent);
  background: #121820;
}

.passcode-row .hint {
  margin: 0 0 0.5rem;
}

.passcode-inline {
  align-items: stretch;
  gap: 0.5rem;
}

.passcode-inline input[type="password"] {
  flex: 1;
  min-width: 12rem;
  padding: 0.55rem 0.65rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font: inherit;
}

body.view-only .panel input.cell,
body.view-only #btn-new,
body.view-only #btn-reseed,
body.view-only #btn-del {
  opacity: 0.55;
  pointer-events: none;
}
