:root {
  --bg: #07131d;
  --panel: #0e2231;
  --panel-soft: #112a3c;
  --border: #244457;
  --text: #e8f2f8;
  --muted: #9eb6c7;
  --accent: #27a7d8;
  --accent-strong: #1f84ac;
  --ok: #72d18d;
  --warn: #f0c66b;
  --danger: #ff7a7a;
  --row: #0c1b29;
  --row-alt: #0b1925;
  --shadow: rgba(0, 0, 0, 0.35);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background:
    radial-gradient(circle at top left, rgba(39, 167, 216, 0.16), transparent 34rem),
    linear-gradient(180deg, #07131d 0%, #081724 100%);
  color: var(--text);
  min-height: 100vh;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.8rem 1.2rem;
  border-bottom: 1px solid var(--border);
  background: rgba(7, 19, 29, 0.92);
  backdrop-filter: blur(12px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 1.05rem;
  font-weight: 800;
  letter-spacing: 0.02em;
}

.brand-dot {
  width: 0.75rem;
  height: 0.75rem;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 20px var(--accent);
}

.nav {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  flex-wrap: wrap;
}

.nav a {
  color: var(--text);
  text-decoration: none;
  border: 1px solid transparent;
  padding: 0.45rem 0.7rem;
  border-radius: 0.55rem;
}

.nav a:hover { border-color: var(--border); background: var(--panel-soft); }

.layout {
  width: min(2200px, calc(100% - 0.25rem));
  margin: 0.5rem auto 3rem;
}

.panel {
  background: rgba(14, 34, 49, 0.9);
  border: 1px solid var(--border);
  border-radius: 1rem;
  box-shadow: 0 18px 40px var(--shadow);
  padding: 1rem;
  margin-bottom: 1rem;
}

.board {
  padding: 0.75rem;
}

.hero {
  display: flex;
  align-items: stretch;
  justify-content: space-between;
  gap: 1rem;
}

.hero h1, .section-title h2 {
  margin: 0 0 0.35rem;
}

.hero p {
  color: var(--muted);
  margin: 0;
  max-width: 58rem;
  line-height: 1.5;
}

.stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(7rem, 1fr));
  gap: 0.75rem;
  min-width: 25rem;
}

.stat {
  background: var(--row);
  border: 1px solid var(--border);
  border-radius: 0.85rem;
  padding: 0.8rem;
  text-align: center;
}

.stat span {
  display: block;
  font-size: 1.7rem;
  font-weight: 800;
}

.stat small { color: var(--muted); }

.warning {
  border-color: rgba(240, 198, 107, 0.55);
  background: rgba(77, 57, 16, 0.55);
  line-height: 1.5;
}

code {
  color: #d8ecff;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.08);
  padding: 0.1rem 0.35rem;
  border-radius: 0.35rem;
}

.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.8rem;
}

.hint, label {
  color: var(--muted);
}

label {
  display: grid;
  gap: 0.4rem;
  font-size: 0.92rem;
}

input, textarea, button, select {
  font: inherit;
}

input[type="search"], input[type="password"], textarea {
  width: 100%;
  color: var(--text);
  background: #081824;
  border: 1px solid var(--border);
  border-radius: 0.65rem;
  padding: 0.65rem 0.75rem;
  outline: none;
}

textarea {
  resize: vertical;
  min-height: 7rem;
  line-height: 1.45;
}

input:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(39, 167, 216, 0.14);
}

select {
  color: var(--text);
  background: #081824;
  border: 1px solid var(--border);
  border-radius: 0.55rem;
  outline: none;
}

select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(39, 167, 216, 0.14);
}

.admin-grid {
  display: grid;
  grid-template-columns: minmax(18rem, 28rem) auto;
  gap: 0.8rem 1rem;
  align-items: end;
  margin-bottom: 0.8rem;
}

.checkline {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  user-select: none;
}

.checkline input { width: auto; }
.checkline.compact { white-space: nowrap; }

.admin-actions, .toolbar {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.toolbar { justify-content: flex-end; }
.toolbar input[type="search"] { min-width: min(32rem, 55vw); }

.toolbar-select {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  white-space: nowrap;
}

.toolbar-select select {
  min-width: 10rem;
  padding: 0.55rem 0.65rem;
}

button {
  border: 1px solid transparent;
  border-radius: 0.65rem;
  padding: 0.58rem 0.85rem;
  color: var(--text);
  cursor: pointer;
  transition: transform 0.12s ease, background 0.12s ease, border-color 0.12s ease;
}

button:hover { transform: translateY(-1px); }
button:disabled { opacity: 0.55; cursor: wait; transform: none; }

.primary-btn { background: var(--accent-strong); border-color: rgba(255,255,255,0.08); }
.primary-btn:hover { background: var(--accent); }
.secondary-btn { background: var(--panel-soft); border-color: var(--border); }
.ghost-btn { background: transparent; border-color: var(--border); }
.danger-btn { background: rgba(255, 122, 122, 0.12); border-color: rgba(255, 122, 122, 0.4); color: #ffd7d7; }

.preview {
  display: grid;
  gap: 0.6rem;
  margin-top: 0.8rem;
}

.preview-card {
  display: grid;
  gap: 0.15rem;
  background: var(--row);
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  padding: 0.75rem;
}

.preview-card small { color: var(--muted); }

.status-line {
  min-height: 1.3rem;
  margin-top: 0.7rem;
  color: var(--muted);
}
.status-line.ok { color: var(--ok); }
.status-line.error { color: var(--danger); }

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 0.85rem;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 1340px;
  font-size: 0.92rem;
}

thead {
  background: #0f6281;
}

th, td {
  padding: 0.7rem 0.65rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
  text-align: left;
  vertical-align: middle;
}

th {
  color: #ffffff;
  font-weight: 800;
  white-space: nowrap;
}

.actions-col,
td[data-field="actions"] {
  width: 8.5rem;
  min-width: 8.5rem;
  text-align: center;
}

td[data-field="actions"] .danger-btn {
  width: 100%;
  white-space: nowrap;
}

tbody tr { background: var(--row); }
tbody tr:nth-child(even) { background: var(--row-alt); }
tbody tr.is-soon { background: rgba(97, 71, 15, 0.45); }
tbody tr.is-ended { color: #8296a5; opacity: 0.75; }

.remaining {
  font-variant-numeric: tabular-nums;
  font-weight: 800;
  white-space: nowrap;
}

.table-control {
  width: 100%;
  min-width: 8.5rem;
  padding: 0.45rem 0.55rem;
}

.table-input {
  color: var(--text);
  background: #081824;
  border: 1px solid var(--border);
  border-radius: 0.55rem;
  outline: none;
}

.table-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(39, 167, 216, 0.14);
}

.timer-kind-badge,
.result-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 5.5rem;
  border: 1px solid transparent;
  border-radius: 0.5rem;
  padding: 0.32rem 0.55rem;
  font-weight: 800;
}

.is-attack-kind {
  color: #ffe0e0;
  background: rgba(255, 76, 76, 0.24);
  border-color: rgba(255, 76, 76, 0.55);
}

.is-defense-kind {
  color: #dfffe9;
  background: rgba(80, 190, 118, 0.24);
  border-color: rgba(80, 190, 118, 0.55);
}

.is-defended-result {
  color: #dfffe9;
  background: rgba(80, 190, 118, 0.24);
  border-color: rgba(80, 190, 118, 0.55);
}

.is-destroyed-result {
  color: #ffe0e0;
  background: rgba(255, 76, 76, 0.24);
  border-color: rgba(255, 76, 76, 0.55);
}

.result-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.35rem;
  min-width: 11.5rem;
}

.result-action-btn {
  padding: 0.4rem 0.5rem;
  border-radius: 0.5rem;
  opacity: 0.72;
}

.result-reset-btn {
  grid-column: 1 / -1;
  background: transparent;
  border-color: var(--border);
  color: var(--muted);
}

.result-action-btn.is-selected-result {
  opacity: 1;
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.12) inset;
}

.empty {
  text-align: center;
  padding: 2rem;
  color: var(--muted);
}

@media (max-width: 900px) {
  .topbar, .hero, .section-title, .board-title {
    align-items: flex-start;
    flex-direction: column;
  }
  .stats, .admin-grid {
    min-width: 0;
    width: 100%;
    grid-template-columns: 1fr;
  }
  .toolbar, .toolbar input[type="search"], .toolbar-select, .toolbar-select select {
    width: 100%;
  }
}
