:root {
  --bg: #0f1419;
  --card: #1a2332;
  --text: #e6edf3;
  --muted: #8b9cb3;
  --accent: #3fb950;
  --border: #30363d;
  --err: #f85149;
  --mono: "JetBrains Mono", ui-monospace, monospace;
  --sans: "IBM Plex Sans KR", system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--sans);
  background: radial-gradient(1200px 800px at 10% -10%, #1f3d2c 0%, transparent 55%),
    radial-gradient(900px 600px at 100% 0%, #1a2740 0%, transparent 50%), var(--bg);
  color: var(--text);
}

.layout {
  max-width: 1100px;
  margin: 0 auto;
  padding: 2rem 1.25rem 3rem;
}

.header h1 {
  margin: 0 0 0.35rem;
  font-size: 1.75rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.sub {
  margin: 0;
  color: var(--muted);
  font-size: 0.95rem;
}

.card {
  margin-top: 1.75rem;
  padding: 1.5rem 1.35rem;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
}

.card h2 {
  margin: 0 0 1rem;
  font-size: 1.1rem;
  font-weight: 600;
}

label {
  display: block;
  margin-bottom: 0.4rem;
  font-size: 0.9rem;
  color: var(--muted);
}

input[type="password"],
input[type="search"] {
  width: 100%;
  max-width: 360px;
  padding: 0.65rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #0d1117;
  color: var(--text);
  font-size: 1rem;
}

button {
  margin-top: 0.85rem;
  padding: 0.6rem 1.1rem;
  border: none;
  border-radius: 8px;
  background: var(--accent);
  color: #0d1117;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
}

button:hover {
  filter: brightness(1.08);
}

.btn-secondary {
  margin-top: 0;
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  color: var(--text);
  border-color: var(--muted);
}

.stats-block {
  margin-bottom: 1.5rem;
  padding-bottom: 1.35rem;
  border-bottom: 1px solid var(--border);
}

.stats-section-title {
  margin: 0 0 0.35rem;
  font-size: 1.1rem;
  font-weight: 600;
}

.stats-hint {
  margin: 0 0 1rem;
  font-size: 0.82rem;
  color: var(--muted);
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 1rem;
}

.stat-card {
  padding: 1rem 1.1rem;
  background: #111820;
  border: 1px solid var(--border);
  border-radius: 10px;
}

.stat-head {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  margin-bottom: 0.65rem;
}

.stat-label {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
}

.stat-prefix {
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--muted);
}

.stat-value {
  margin: 0;
  font-size: 1.65rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--accent);
  letter-spacing: -0.02em;
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

.toolbar h2 {
  margin: 0;
}

.search-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

.search-row input {
  flex: 1;
  min-width: 200px;
  max-width: none;
}

.search-row button {
  margin-top: 0;
}

.meta {
  margin: 0.75rem 0 0.5rem;
  font-size: 0.85rem;
  color: var(--muted);
}

.table-wrap {
  overflow-x: auto;
  margin-top: 0.5rem;
  border: 1px solid var(--border);
  border-radius: 8px;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

th,
td {
  padding: 0.6rem 0.65rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

th {
  background: #111820;
  color: var(--muted);
  font-weight: 600;
  white-space: nowrap;
}

td {
  font-family: var(--mono);
  font-size: 0.8rem;
}

tbody tr:last-child td {
  border-bottom: none;
}

tbody tr:hover td {
  background: rgba(63, 185, 80, 0.06);
}

.pager {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-top: 1rem;
}

.pager button {
  margin-top: 0;
}

.error {
  margin-top: 0.75rem;
  color: var(--err);
  font-size: 0.9rem;
}

td.td-gameinfo {
  vertical-align: middle;
  white-space: nowrap;
}

button.btn-detail {
  margin-top: 0;
  padding: 0.45rem 0.85rem;
  font-size: 0.8rem;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(2px);
}

.modal-overlay[hidden] {
  display: none;
}

.modal-dialog {
  width: min(720px, 100%);
  max-height: min(85vh, 900px);
  display: flex;
  flex-direction: column;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.55);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1rem 0.5rem 1.15rem;
  border-bottom: 1px solid var(--border);
}

.modal-header h3 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 600;
}

.modal-close {
  margin-top: 0;
  padding: 0.25rem 0.55rem;
  line-height: 1;
  font-size: 1.35rem;
  background: transparent;
  color: var(--muted);
  border: 1px solid transparent;
}

.modal-close:hover {
  color: var(--text);
  border-color: var(--border);
}

.modal-sub {
  margin: 0;
  padding: 0.5rem 1.15rem 0;
  font-size: 0.85rem;
  color: var(--muted);
}

.modal-label {
  display: block;
  margin: 0.75rem 1.15rem 0.35rem;
  font-size: 0.85rem;
  color: var(--muted);
}

textarea.modal-json {
  width: calc(100% - 2rem);
  margin: 0 1rem;
  padding: 1rem;
  flex: 1;
  min-height: 180px;
  max-height: min(55vh, 640px);
  resize: vertical;
  overflow: auto;
  font-family: var(--mono);
  font-size: 0.78rem;
  line-height: 1.5;
  color: var(--text);
  background: #0d1117;
  border: 1px solid var(--border);
  border-radius: 8px;
  white-space: pre;
  word-break: normal;
}

.modal-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 0.75rem;
  padding: 1rem 1.15rem 1.15rem;
  border-top: 1px solid var(--border);
}

.modal-msg {
  margin: 0;
  flex: 1;
  min-width: 120px;
  font-size: 0.88rem;
  color: var(--accent);
}

.modal-msg.err {
  color: var(--err);
}

button.btn-save {
  margin-top: 0;
  padding: 0.55rem 1.15rem;
}
