:root {
  --ink: #24104f;
  --ink-2: #46366a;
  --muted: #756c88;
  --line: #e7e1ef;
  --surface: #f7f4fb;
  --purple: #6537d8;
  --purple-soft: #efe9ff;
  --orange: #ff641b;
  --red: #d93445;
  --green: #16845f;
  --white: #fff;
  --shadow: 0 28px 80px rgba(36,16,79,.15);
}

* { box-sizing: border-box; }
html { min-width: 320px; background: var(--surface); }
body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background: var(--surface);
  font-family: Pretendard, "Noto Sans KR", "Apple SD Gothic Neo", Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
button, input, textarea, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
a { color: inherit; text-decoration: none; }
img { display: block; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

.ambient { position: fixed; z-index: -1; border-radius: 50%; filter: blur(2px); pointer-events: none; }
.ambient-one { width: 520px; height: 520px; top: -250px; right: -150px; background: radial-gradient(circle, rgba(101,55,216,.17), transparent 68%); }
.ambient-two { width: 460px; height: 460px; bottom: -260px; left: -130px; background: radial-gradient(circle, rgba(255,100,27,.1), transparent 68%); }

.auth-shell { min-height: 100vh; display: grid; place-items: center; padding: 70px 24px; position: relative; }
.back-link { position: absolute; top: 28px; left: 32px; color: var(--muted); font-size: 14px; font-weight: 800; }
.back-link:hover { color: var(--purple); }
.login-panel { width: min(470px, 100%); padding: 44px; border: 1px solid rgba(101,55,216,.13); border-radius: 30px; background: rgba(255,255,255,.94); box-shadow: var(--shadow); }
.login-brand { display: flex; align-items: center; gap: 14px; margin-bottom: 38px; }
.login-brand img { border-radius: 16px; box-shadow: 0 12px 26px rgba(36,16,79,.2); }
.login-brand div { display: grid; line-height: 1.2; }
.login-brand span { color: var(--purple); font-size: 11px; font-weight: 900; letter-spacing: .12em; }
.login-brand strong { margin-top: 4px; font-size: 19px; }
.eyebrow { margin: 0 0 8px; color: var(--orange); font-size: 12px; font-weight: 900; letter-spacing: .1em; }
.login-panel h1, .page-heading h1 { margin: 0; letter-spacing: -.045em; }
.login-panel h1 { font-size: 36px; }
.login-copy { margin: 14px 0 30px; color: var(--muted); word-break: keep-all; }
.login-form { display: grid; gap: 10px; }
.login-form label, .modal-body label, .delete-modal label { color: var(--ink-2); font-size: 14px; font-weight: 800; }
input, textarea, select { width: 100%; border: 1px solid var(--line); border-radius: 12px; color: var(--ink); background: #fff; outline: none; transition: border-color .2s, box-shadow .2s; }
input, select { min-height: 50px; padding: 0 15px; }
textarea { padding: 13px 15px; line-height: 1.65; resize: vertical; }
input:focus, textarea:focus, select:focus { border-color: rgba(101,55,216,.6); box-shadow: 0 0 0 4px rgba(101,55,216,.1); }
.login-form input { margin-bottom: 8px; }
.form-error { min-height: 21px; margin: 2px 0; color: var(--red); font-size: 13px; font-weight: 700; }
.primary-button, .secondary-button, .danger-button, .ghost-button, .refresh-button {
  min-height: 48px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 12px;
  font-weight: 850;
  transition: transform .2s, opacity .2s, background .2s;
}
.primary-button { padding: 0 20px; color: #fff; background: var(--ink); box-shadow: 0 13px 25px rgba(36,16,79,.18); }
.primary-button:hover, .danger-button:hover, .refresh-button:hover { transform: translateY(-1px); }
.primary-button:disabled, .danger-button:disabled { opacity: .45; cursor: not-allowed; transform: none; }
.primary-button.compact { min-height: 44px; }
.login-note { margin: 20px 0 0; color: var(--muted); font-size: 13px; text-align: center; }

.admin-header { min-height: 76px; position: sticky; top: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between; gap: 24px; padding: 12px max(24px, calc((100% - 1320px) / 2)); border-bottom: 1px solid rgba(231,225,239,.85); background: rgba(255,255,255,.9); backdrop-filter: blur(18px); }
.admin-brand { display: inline-flex; align-items: center; gap: 12px; }
.admin-brand img { border-radius: 12px; }
.admin-brand span { display: flex; align-items: baseline; gap: 9px; }
.admin-brand b { font-size: 18px; }
.admin-brand small { color: var(--purple); font-size: 10px; font-weight: 900; letter-spacing: .12em; }
.admin-account { display: flex; align-items: center; gap: 16px; }
.account-copy { display: grid; text-align: right; line-height: 1.25; }
.account-copy small { color: var(--muted); font-size: 11px; }
.account-copy strong { font-size: 13px; }
.ghost-button { min-height: 40px; padding: 0 15px; border: 1px solid var(--line); color: var(--ink-2); background: #fff; }
.ghost-button:hover { background: var(--purple-soft); }

.admin-main { width: min(1320px, calc(100% - 48px)); margin: 0 auto; padding: 56px 0 84px; }
.page-heading { display: flex; align-items: end; justify-content: space-between; gap: 30px; margin-bottom: 32px; }
.page-heading h1 { font-size: clamp(34px, 4vw, 50px); }
.page-heading > div > p:last-child { margin: 12px 0 0; color: var(--muted); }
.sync-state { display: flex; align-items: center; gap: 8px; padding: 10px 14px; border: 1px solid var(--line); border-radius: 99px; color: var(--muted); background: #fff; font-size: 13px; font-weight: 800; white-space: nowrap; }
.sync-state i { width: 8px; height: 8px; border-radius: 50%; background: #aaa; }
.sync-state.connected i { background: var(--green); box-shadow: 0 0 0 4px rgba(22,132,95,.12); }
.sync-state.error i { background: var(--red); }

.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 20px; }
.stat-card { min-height: 148px; display: grid; align-content: center; padding: 24px; border: 1px solid var(--line); border-radius: 20px; background: #fff; box-shadow: 0 12px 32px rgba(36,16,79,.05); }
.stat-card.accent { color: #fff; border-color: var(--ink); background: var(--ink); }
.stat-card span { color: var(--muted); font-size: 13px; font-weight: 800; }
.stat-card.accent span, .stat-card.accent small { color: #c9c0dc; }
.stat-card strong { margin: 2px 0 0; font-size: 34px; letter-spacing: -.04em; }
.stat-card small { color: #978fa5; font-size: 12px; }

.content-panel { overflow: hidden; border: 1px solid var(--line); border-radius: 24px; background: #fff; box-shadow: 0 18px 45px rgba(36,16,79,.07); }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 24px; padding: 26px 28px 20px; }
.panel-head h2 { margin: 0; font-size: 22px; }
.panel-head p { margin: 4px 0 0; color: var(--muted); font-size: 13px; }
.refresh-button { min-height: 40px; padding: 0 15px; color: var(--purple); background: var(--purple-soft); }
.filters { display: grid; grid-template-columns: minmax(260px, 1fr) 180px 210px; gap: 10px; padding: 0 28px 22px; }
.search-field { position: relative; }
.search-field > span:not(.sr-only) { position: absolute; left: 15px; top: 50%; color: var(--muted); font-size: 22px; transform: translateY(-53%); }
.search-field input { padding-left: 42px; }
.table-wrap { position: relative; min-height: 270px; border-top: 1px solid var(--line); overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 980px; }
th { padding: 14px 18px; color: var(--muted); background: #faf8fc; font-size: 12px; text-align: left; letter-spacing: .04em; }
td { padding: 17px 18px; border-top: 1px solid #f0ecf4; vertical-align: middle; }
tbody tr { transition: background .16s; }
tbody tr:hover { background: #fcfaff; }
.battle-title { max-width: 400px; }
.battle-title strong { display: block; overflow: hidden; font-size: 15px; text-overflow: ellipsis; white-space: nowrap; }
.battle-title small { display: block; margin-top: 3px; color: #968da5; font-size: 11px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.category-chip, .status-chip { display: inline-flex; align-items: center; min-height: 28px; padding: 0 10px; border-radius: 99px; font-size: 12px; font-weight: 800; white-space: nowrap; }
.category-chip { color: #6b4f00; background: #fff2be; }
.status-chip { color: var(--purple); background: var(--purple-soft); }
.status-chip.ended { color: #6f6879; background: #efedf2; }
.status-chip.other { color: #a34619; background: #ffeadf; }
.number-cell, .date-cell { color: var(--ink-2); font-size: 13px; white-space: nowrap; }
.action-column { text-align: right; }
.row-actions { display: flex; justify-content: flex-end; gap: 7px; }
.table-button { min-height: 34px; padding: 0 12px; border: 1px solid var(--line); border-radius: 9px; color: var(--ink-2); background: #fff; font-size: 12px; font-weight: 800; }
.table-button:hover { color: var(--purple); border-color: rgba(101,55,216,.35); background: var(--purple-soft); }
.table-button.delete:hover { color: var(--red); border-color: rgba(217,52,69,.3); background: #fff0f2; }
.loading-state, .empty-state { min-height: 270px; display: grid; place-items: center; align-content: center; padding: 40px; color: var(--muted); text-align: center; }
.loading-state span { width: 34px; height: 34px; border: 3px solid var(--purple-soft); border-top-color: var(--purple); border-radius: 50%; animation: spin .8s linear infinite; }
.loading-state p, .empty-state p { margin: 12px 0 0; font-size: 13px; }
.empty-state > span { font-size: 34px; }
.empty-state strong { margin-top: 4px; color: var(--ink-2); }
@keyframes spin { to { transform: rotate(360deg); } }

.modal { width: min(760px, calc(100% - 28px)); max-height: 92vh; padding: 0; border: 0; border-radius: 24px; background: transparent; box-shadow: 0 30px 100px rgba(20,7,48,.34); }
.modal::backdrop { background: rgba(22,8,49,.64); backdrop-filter: blur(5px); }
.modal-card { overflow: auto; max-height: 92vh; margin: 0; border-radius: 24px; background: #fff; }
.modal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; padding: 26px 28px 20px; border-bottom: 1px solid var(--line); }
.modal-head h2, .delete-modal h2 { margin: 0; font-size: 24px; letter-spacing: -.035em; }
.modal-head small { color: #9991a8; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.icon-button { width: 40px; height: 40px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 50%; color: var(--ink-2); background: #fff; font-size: 24px; }
.modal-body { display: grid; gap: 17px; padding: 24px 28px 10px; }
.modal-body label, .delete-modal label { display: grid; gap: 7px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.modal-actions { display: flex; align-items: center; gap: 10px; padding: 20px 28px 26px; }
.modal-actions > span { flex: 1; }
.modal-actions.end { justify-content: flex-end; padding: 22px 0 0; }
.secondary-button { min-height: 44px; padding: 0 18px; border: 1px solid var(--line); color: var(--ink-2); background: #fff; }
.danger-link { padding: 8px 0; border: 0; color: var(--red); background: transparent; font-size: 13px; font-weight: 850; }
.danger-button { min-height: 44px; padding: 0 18px; color: #fff; background: var(--red); }
.delete-modal { width: min(500px, calc(100% - 28px)); }
.delete-modal .modal-card { padding: 30px; }
.delete-symbol { width: 46px; height: 46px; display: grid; place-items: center; margin-bottom: 17px; border-radius: 50%; color: var(--red); background: #fff0f2; font-size: 24px; font-weight: 900; }
.delete-modal p { color: var(--muted); word-break: keep-all; }
.delete-modal p strong { color: var(--ink); }

.comment-section { overflow: hidden; margin-top: 3px; border: 1px solid var(--line); border-radius: 16px; background: #faf8fc; }
.comment-section-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 15px 17px; border-bottom: 1px solid var(--line); background: #f5f1f9; }
.comment-section-head h3 { margin: 0; color: var(--ink); font-size: 15px; }
.comment-section-head span { color: var(--purple); font-size: 12px; font-weight: 900; }
.comment-list { max-height: 350px; overflow-y: auto; overscroll-behavior: contain; }
.comment-item { padding: 15px 17px; border-top: 1px solid #ece6f2; background: #fff; }
.comment-item:first-child { border-top: 0; }
.comment-meta { display: flex; align-items: center; gap: 8px; min-width: 0; }
.comment-meta strong { overflow: hidden; color: var(--ink-2); font-size: 13px; text-overflow: ellipsis; white-space: nowrap; }
.comment-meta time { color: #9a91a8; font-size: 11px; white-space: nowrap; }
.comment-actions { display: flex; gap: 5px; margin-left: auto; }
.comment-action { min-height: 30px; padding: 0 10px; border: 1px solid var(--line); border-radius: 8px; color: var(--ink-2); background: #fff; font-size: 12px; font-weight: 850; }
.comment-action:hover { color: var(--purple); border-color: rgba(101,55,216,.35); background: var(--purple-soft); }
.comment-action.danger { color: var(--red); }
.comment-action.danger:hover { border-color: rgba(217,52,69,.3); background: #fff0f2; }
.comment-action:disabled { opacity: .5; cursor: wait; }
.comment-reply { margin-top: 6px; color: var(--orange); font-size: 12px; font-weight: 850; }
.comment-text { margin: 7px 0 0; color: var(--ink); font-size: 14px; line-height: 1.65; white-space: pre-wrap; word-break: break-word; }
.comment-deleted { color: #968da5; font-style: italic; }
.comment-editor { display: grid; gap: 8px; margin-top: 10px; }
.comment-editor textarea { min-height: 94px; background: #fff; }
.comment-editor-actions { display: flex; justify-content: flex-end; gap: 7px; }
.comment-editor-error { min-height: 18px; margin: 0; color: var(--red); font-size: 12px; font-weight: 750; }
.comment-image { display: block; width: min(180px, 100%); margin-top: 10px; border: 1px solid var(--line); border-radius: 11px; overflow: hidden; background: var(--surface); }
.comment-image img { width: 100%; max-height: 180px; object-fit: cover; }
.comment-loading, .comment-empty, .comment-error { min-height: 112px; display: grid; place-items: center; align-content: center; padding: 22px; color: var(--muted); text-align: center; }
.comment-loading span { width: 26px; height: 26px; border: 3px solid var(--purple-soft); border-top-color: var(--purple); border-radius: 50%; animation: spin .8s linear infinite; }
.comment-loading p, .comment-empty p, .comment-error p { margin: 8px 0 0; font-size: 12px; }
.comment-error { color: var(--red); }

.toast { position: fixed; left: 50%; bottom: 26px; z-index: 100; min-width: min(390px, calc(100% - 32px)); padding: 14px 20px; border-radius: 13px; color: #fff; background: rgba(36,16,79,.96); box-shadow: 0 18px 50px rgba(20,7,48,.3); font-size: 14px; font-weight: 800; text-align: center; opacity: 0; visibility: hidden; transform: translate(-50%, 16px); transition: opacity .2s, transform .2s, visibility .2s; }
.toast.show { opacity: 1; visibility: visible; transform: translate(-50%, 0); }
.toast.error { background: rgba(183,31,50,.97); }

@media (max-width: 900px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .filters { grid-template-columns: 1fr 1fr; }
  .search-field { grid-column: 1 / -1; }
}

@media (max-width: 640px) {
  .auth-shell { padding: 70px 16px 32px; }
  .back-link { left: 18px; top: 22px; }
  .login-panel { padding: 30px 22px; border-radius: 24px; }
  .login-panel h1 { font-size: 31px; }
  .admin-header { min-height: 68px; padding: 10px 16px; }
  .admin-brand span { display: grid; gap: 0; }
  .account-copy { display: none; }
  .admin-main { width: min(100% - 28px, 1320px); padding: 38px 0 64px; }
  .page-heading { display: grid; align-items: start; }
  .page-heading h1 { font-size: 36px; }
  .sync-state { justify-self: start; }
  .stats-grid { gap: 10px; }
  .stat-card { min-height: 126px; padding: 18px; }
  .stat-card strong { font-size: 29px; }
  .panel-head { align-items: flex-start; padding: 22px 18px 16px; }
  .refresh-button { padding: 0 11px; font-size: 12px; }
  .filters { grid-template-columns: 1fr; padding: 0 18px 18px; }
  .search-field { grid-column: auto; }
  .form-grid { grid-template-columns: 1fr; }
  .modal-head { padding: 22px 20px 17px; }
  .modal-body { padding: 20px 20px 6px; }
  .modal-actions { flex-wrap: wrap; padding: 18px 20px 22px; }
  .modal-actions > span { display: none; }
  .modal-actions .danger-link { width: 100%; text-align: left; }
  .modal-actions .secondary-button, .modal-actions .primary-button { flex: 1; }
  .comment-list { max-height: 300px; }
  .comment-meta { flex-wrap: wrap; }
  .comment-actions { width: 100%; margin-left: 0; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
