:root {
  color-scheme: dark;
  --bg: #0b1119;
  --panel: #131c27;
  --panel-2: #192534;
  --line: #2a3a4d;
  --text: #ecf2f8;
  --muted: #91a1b4;
  --blue: #4ca1ff;
  --green: #2ecc71;
  --red: #ef5350;
  --gray: #7f8b99;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  min-width: 1040px;
  background: radial-gradient(circle at 50% -20%, #18304d 0, var(--bg) 42%);
  color: var(--text);
  font-family: "Malgun Gothic", "Noto Sans KR", system-ui, sans-serif;
}
button, input, select { font: inherit; }
button, .button-link {
  border: 1px solid #3b4e64;
  border-radius: 7px;
  background: #243348;
  color: var(--text);
  padding: 9px 14px;
  cursor: pointer;
  text-decoration: none;
}
button:hover, .button-link:hover { filter: brightness(1.15); }
button:disabled { opacity: .5; cursor: wait; }
.primary { border-color: #2885d8; background: #1769aa; }
.ghost { background: transparent; }
.full { width: 100%; margin-top: 18px; }
.hidden { display: none !important; }
.muted, p { color: var(--muted); }

.topbar {
  height: 58px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 22px;
  border-bottom: 1px solid var(--line);
  background: rgba(10, 17, 25, .94);
  position: sticky;
  top: 0;
  z-index: 10;
}
.topbar strong { font-size: 18px; }
.topbar span { margin-left: 12px; color: var(--muted); font-size: 13px; }
.page { width: min(1500px, calc(100% - 28px)); margin: 14px auto 28px; }
.panel {
  background: linear-gradient(145deg, rgba(25,37,52,.96), rgba(17,26,37,.96));
  border: 1px solid var(--line);
  border-radius: 11px;
  margin-bottom: 12px;
  padding: 16px;
  box-shadow: 0 12px 35px rgba(0,0,0,.18);
}
.panel-title, .result-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 13px;
}
.panel-title.compact { margin-bottom: 8px; }
h1, h2, p { margin: 0; }
h1 { font-size: 20px; }
h2 { font-size: 17px; }
.panel-title p, .result-header p { margin-top: 4px; font-size: 13px; }
.status { color: #b8d8f7; text-align: right; font-size: 13px; }
.status.error { color: #ff8c89; }

.character-grid {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 10px;
  align-items: end;
}
label { color: #b9c7d5; font-size: 12px; }
input, select {
  width: 100%;
  margin-top: 5px;
  border: 1px solid #3b4c60;
  border-radius: 6px;
  background: #0d1621;
  color: var(--text);
  padding: 9px 10px;
  outline: none;
}
input:focus, select:focus { border-color: var(--blue); }
.fight-row { display: grid; grid-template-columns: 1fr auto auto auto; gap: 8px; margin-top: 12px; }
.fight-row select { margin: 0; }

.assignment-grid {
  display: grid;
  grid-template-columns: 72px repeat(5, minmax(130px, 1fr));
  gap: 7px;
  align-items: center;
}
.assignment-side { font-weight: 700; text-align: center; }
.assignment-side.left { color: #7bc1ff; }
.assignment-side.right { color: #ff9b78; }
.assignment-cell { display: flex; align-items: center; gap: 6px; }
.assignment-cell b { width: 16px; color: var(--muted); text-align: right; }
.assignment-cell input { margin: 0; }

.wave-tabs { display: flex; flex-wrap: wrap; gap: 6px; justify-content: end; }
.wave-tabs button.active { background: #1769aa; border-color: #4ca1ff; }
.legend { display: flex; gap: 18px; color: var(--muted); font-size: 12px; margin-bottom: 8px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.dot.success { background: var(--green); }
.dot.failed { background: var(--red); }
.dot.unknown { background: var(--gray); }
.arena-wrap {
  height: 470px;
  border: 1px solid #33475c;
  border-radius: 8px;
  overflow: hidden;
  background: #101923;
}
#arenaCanvas { display: block; width: 100%; height: 100%; }
.table-wrap { margin-top: 10px; overflow: auto; border: 1px solid var(--line); border-radius: 7px; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { position: sticky; top: 0; background: #223145; color: #cfe1f1; }
th, td { border-bottom: 1px solid #29394b; padding: 8px 10px; text-align: center; white-space: nowrap; }
tbody tr.success { background: rgba(46, 204, 113, .13); }
tbody tr.failed { background: rgba(239, 83, 80, .16); }
tbody tr.unknown { background: rgba(127, 139, 153, .12); }

.login-page {
  min-width: 0;
  min-height: 100vh;
  display: grid;
  place-items: center;
}
.login-card {
  width: min(390px, calc(100% - 32px));
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(19, 28, 39, .97);
  padding: 30px;
  box-shadow: 0 22px 70px rgba(0,0,0,.4);
}
.brand-mark {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  border-radius: 13px;
  background: #1769aa;
  font-weight: 800;
  margin-bottom: 16px;
}
.login-card h1 { margin-bottom: 6px; }
.login-card form { margin-top: 22px; }
.alert { border-radius: 6px; padding: 9px 11px; margin-top: 14px; font-size: 13px; }
.alert.error { background: rgba(239,83,80,.16); border: 1px solid rgba(239,83,80,.4); color: #ffaaa8; }

@media (max-width: 1100px) {
  body { min-width: 760px; }
  .character-grid { grid-template-columns: 1fr 1fr 1fr; }
  .character-grid button { grid-column: 1 / -1; }
  .assignment-grid { grid-template-columns: 68px repeat(5, minmax(110px, 1fr)); }
}
