:root {
  color-scheme: light;
  --bg: #f7f8fa;
  --panel: #ffffff;
  --panel-2: #f2f4f6;
  --line: #e5e8eb;
  --text: #191f28;
  --muted: #6b7684;
  --soft: #6b7684;
  --primary: #3182f6;
  --primary-soft: rgba(49, 130, 246, 0.14);
  --lime: #20c997;
  --cyan: #3182f6;
  --violet: #4e5968;
  --gold: #ffd43b;
  --red: #ff6b6b;
  --orange: #f59f00;
  --navy: #191f28;
  --radius: 8px;
  --shadow: 0 10px 28px rgba(25, 31, 40, 0.08);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-width: 320px;
  background: #eef1f5;
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Apple SD Gothic Neo", "Noto Sans KR", sans-serif;
  line-height: 1.5;
  letter-spacing: 0;
}

button,
input,
select {
  font: inherit;
  letter-spacing: 0;
}

button {
  cursor: pointer;
}

h1,
h2,
p,
dl,
dd {
  margin-top: 0;
}

h1 {
  margin-bottom: 8px;
  font-size: 26px;
  line-height: 1.18;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 0;
  font-size: 18px;
  letter-spacing: 0;
}

p {
  margin-bottom: 0;
  color: var(--muted);
}

.app-root {
  width: min(430px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  padding-bottom: calc(86px + env(safe-area-inset-bottom));
  background: var(--bg);
  box-shadow: 0 0 0 1px rgba(25,31,40,0.05), 0 18px 44px rgba(25,31,40,0.08);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
  padding: calc(12px + env(safe-area-inset-top)) 14px 10px;
  background: rgba(247, 248, 250, 0.94);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(18px);
}

.brand {
  display: inline-flex;
  gap: 9px;
  align-items: center;
  min-width: 0;
  border: 0;
  background: transparent;
  color: var(--text);
  font-weight: 950;
}

.brand-mark {
  position: relative;
  display: inline-block;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: var(--primary);
  box-shadow: 0 8px 18px rgba(49, 130, 246, 0.24);
}

.brand-mark::before,
.brand-mark::after {
  content: "";
  position: absolute;
  left: 8px;
  right: 8px;
  height: 3px;
  border-radius: 999px;
  background: #fff;
  transform: rotate(-22deg);
}

.brand-mark::before {
  top: 10px;
}

.brand-mark::after {
  top: 19px;
  background: #ffffff;
}

.role-toggle,
.bottom-nav {
  display: flex;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #ffffff;
}

.role-toggle button,
.bottom-nav button {
  min-height: 34px;
  border: 0;
  border-radius: 12px;
  color: var(--muted);
  background: transparent;
  font-size: 12px;
  font-weight: 900;
  white-space: nowrap;
}

.role-toggle button {
  padding: 0 9px;
}

.role-toggle button.active,
.bottom-nav button.active {
  color: #ffffff;
  background: var(--primary);
}

.screen-shell {
  min-height: calc(100vh - 84px);
}

.bottom-nav {
  position: fixed;
  left: 50%;
  bottom: calc(12px + env(safe-area-inset-bottom));
  z-index: 30;
  width: min(406px, calc(100% - 24px));
  transform: translateX(-50%);
  background: rgba(255, 255, 255, 0.94);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
  overflow-x: auto;
}

.bottom-nav button {
  flex: 1 0 auto;
  padding: 0 9px;
  font-size: 12px;
}

.hero {
  position: relative;
  display: grid;
  align-content: end;
  gap: 16px;
  min-height: 470px;
  padding: 22px 16px 18px;
  overflow: hidden;
  isolation: isolate;
}

.hero::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -2;
  background-image: url("../assets/arena.png");
  background-size: cover;
  background-position: center;
  opacity: 0.52;
  filter: saturate(0.92) contrast(1.02);
}

.hero::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background: linear-gradient(180deg, rgba(25,31,40,0.08), rgba(25,31,40,0.48) 56%, var(--bg) 96%);
}

.hero h1 {
  max-width: 320px;
  font-size: 31px;
  font-weight: 950;
  color: #ffffff;
  text-shadow: 0 10px 24px rgba(0,0,0,0.28);
}

.hero p {
  max-width: 300px;
  color: rgba(255,255,255,0.86);
  margin-bottom: 14px;
}

.kicker {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  margin-bottom: 12px;
  padding: 3px 9px;
  border: 1px solid rgba(49, 130, 246, 0.34);
  border-radius: 999px;
  background: var(--primary-soft);
  color: #0f5ec7;
  font-size: 12px;
  font-weight: 900;
}

.arena-preview {
  padding: 12px;
  border: 1px solid rgba(255,255,255,0.30);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.88);
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
}

.preview-head,
.panel-head,
.section-head.row,
.viewer-banner,
.list-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}

.preview-head {
  margin-bottom: 12px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.mini-bracket {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.mini-bracket span,
.mini-bracket strong,
.slot {
  min-width: 0;
  border-radius: 7px;
}

.mini-bracket span,
.mini-bracket strong {
  min-height: 36px;
  padding: 8px 10px;
  background: #f2f4f6;
  color: var(--text);
  font-size: 13px;
  font-weight: 900;
}

.mini-bracket strong {
  grid-column: 1 / -1;
  color: #ffffff;
  background: var(--primary);
}

.content {
  display: grid;
  gap: 14px;
  padding: 18px 14px calc(116px + env(safe-area-inset-bottom));
}

.role-notice {
  display: grid;
  gap: 4px;
  padding: 9px 0 10px;
  border: 1px solid var(--line);
  border-width: 0 0 1px;
  border-radius: 0;
  background: transparent;
}

.role-notice span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.role-notice strong {
  color: var(--text);
  font-size: 14px;
  line-height: 1.35;
}

.role-notice.host {
  border-color: var(--line);
  background: transparent;
}

.role-notice.participant {
  border-color: var(--line);
  background: transparent;
}

.section-head p {
  margin-bottom: 0;
}

.stat-grid,
.two-col {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.two-col {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.stat-card,
.panel,
.empty-panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow);
}

.stat-card {
  min-height: 78px;
  padding: 12px;
}

.stat-card span {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.stat-card strong {
  color: var(--primary);
  font-size: 20px;
  font-weight: 950;
}

.panel,
.empty-panel {
  padding: 15px;
}

.quiet-panel {
  box-shadow: none;
}

.panel-copy {
  margin-bottom: 2px;
  font-size: 14px;
}

.empty-panel {
  display: grid;
  place-items: center;
  gap: 10px;
  min-height: 240px;
  text-align: center;
}

.empty-panel p {
  margin-bottom: 0;
}

.summary-list {
  display: grid;
  gap: 10px;
  margin-bottom: 0;
}

.summary-list div {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

.summary-list dt {
  color: var(--muted);
}

.summary-list dd {
  color: var(--text);
  font-weight: 900;
}

.form-grid,
.stack,
.list {
  display: grid;
  gap: 10px;
}

.form-inline {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.field {
  display: grid;
  gap: 7px;
}

.field span,
.choice-group legend,
.swap-panel label span {
  color: var(--text);
  font-size: 13px;
  font-weight: 900;
}

input,
select {
  width: 100%;
  min-height: 48px;
  padding: 0 13px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #ffffff;
  color: var(--text);
}

input::placeholder {
  color: var(--soft);
}

select option {
  color: #191f28;
}

input:focus,
select:focus {
  outline: 3px solid rgba(49, 130, 246, 0.18);
  border-color: var(--primary);
}

.choice-group {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.choice-group > div {
  display: grid;
  gap: 8px;
  margin-top: 8px;
}

.choice {
  display: grid;
  gap: 4px;
  min-height: 76px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-2);
}

.choice input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.choice span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.choice.checked,
.choice:has(input:checked) {
  border-color: rgba(49, 130, 246, 0.62);
  background: var(--primary-soft);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  padding: 0 13px;
  border: 1px solid transparent;
  border-radius: 7px;
  color: var(--text);
  background: #ffffff;
  font-size: 14px;
  font-weight: 900;
  text-decoration: none;
  white-space: nowrap;
}

.btn.primary {
  color: #ffffff;
  background: var(--primary);
  box-shadow: 0 8px 18px rgba(49, 130, 246, 0.22);
}

.btn.dark,
.btn.ghost,
.btn.secondary {
  border-color: var(--line);
}

.btn.danger {
  color: var(--red);
  border-color: rgba(255, 133, 137, 0.28);
  background: rgba(255, 133, 137, 0.08);
}

.btn.small {
  min-height: 34px;
  padding: 0 10px;
  font-size: 13px;
}

.btn.tiny {
  min-height: 28px;
  padding: 0 8px;
  font-size: 11px;
}

.btn.full {
  width: 100%;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.actions.compact {
  flex-wrap: nowrap;
}

.sticky-actions {
  position: sticky;
  bottom: calc(84px + env(safe-area-inset-bottom));
  z-index: 10;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(16px);
}

.sticky-actions .btn {
  flex: 1 1 0;
  min-width: 0;
}

.copy-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 8px;
  align-items: center;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #ffffff;
}

.copy-row code {
  min-width: 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 2px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #ffffff;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  white-space: nowrap;
}

.badge.green {
  color: var(--lime);
  border-color: rgba(32, 201, 151, 0.32);
}

.badge.orange {
  color: var(--orange);
  border-color: rgba(255, 209, 102, 0.32);
}

.list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.list-row,
.empty {
  min-height: 54px;
  padding: 10px 11px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #ffffff;
}

.list-row strong,
.list-row span {
  display: block;
}

.list-row > div:first-child {
  min-width: 0;
}

.list-row strong,
.list-row span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.list-row span {
  color: var(--muted);
  font-size: 12px;
}

.row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  align-items: center;
  justify-content: flex-end;
}

.empty {
  display: grid;
  place-items: center;
  color: var(--muted);
}

.swap-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto;
  gap: 8px;
  align-items: end;
  padding: 12px;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  background: #ffffff;
}

.swap-panel label {
  display: grid;
  gap: 7px;
}

.viewer-banner {
  flex-wrap: wrap;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
}

.viewer-banner strong,
.viewer-banner span {
  display: block;
}

.viewer-banner > div:first-child {
  min-width: 0;
}

.viewer-banner strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.muted {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.bracket-scroll {
  overflow-x: auto;
  padding: 12px 10px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #f2f4f6;
}

.bracket {
  display: grid;
  grid-template-columns: repeat(var(--round-count), minmax(136px, 1fr));
  gap: 10px;
  min-width: max-content;
}

.round {
  display: grid;
  align-content: start;
  gap: 10px;
}

.round h2 {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 950;
}

.round h2 span {
  color: var(--muted);
}

.match {
  position: relative;
  display: grid;
  gap: 6px;
  min-width: 136px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 1px 2px rgba(25,31,40,0.04);
}

.match.confirmed {
  border-color: rgba(32, 201, 151, 0.34);
  background: rgba(32, 201, 151, 0.08);
}

.slot {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 6px;
  align-items: center;
  min-height: 38px;
  padding: 8px;
  border: 1px solid #e5e8eb;
  background: #ffffff;
  color: #191f28;
  font-size: 12px;
  font-weight: 900;
}

.slot span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.slot strong {
  display: inline-grid;
  place-items: center;
  min-width: 22px;
  min-height: 22px;
  padding: 0 6px;
  border-radius: 999px;
  background: rgba(49, 130, 246, 0.12);
  color: var(--primary);
  font-size: 11px;
}

.slot.win {
  background: #e7f8f2;
  color: #0b5f45;
  border-color: rgba(32, 201, 151, 0.28);
}

.slot.win strong {
  background: rgba(32, 201, 151, 0.16);
  color: #0b5f45;
}

.slot.empty {
  background: #f7f8fa;
  border-color: #edf0f3;
  color: var(--soft);
}

.match footer {
  display: flex;
  justify-content: space-between;
  gap: 7px;
  align-items: center;
  min-height: 28px;
  padding-top: 3px;
}

.compact-panel {
  min-height: 220px;
}

.proposal {
  align-items: start;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(96px + env(safe-area-inset-bottom));
  z-index: 60;
  display: none;
  width: min(360px, calc(100% - 28px));
  transform: translateX(-50%);
  padding: 13px 14px;
  border-radius: var(--radius);
  color: #ffffff;
  background: var(--primary);
  box-shadow: var(--shadow);
  font-size: 14px;
  font-weight: 900;
}

.toast.show {
  display: block;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: grid;
  place-items: end center;
  padding: 18px 14px calc(18px + env(safe-area-inset-bottom));
  background: rgba(25, 31, 40, 0.36);
}

.confirm-dialog {
  display: grid;
  gap: 12px;
  width: min(402px, 100%);
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel);
  box-shadow: 0 18px 44px rgba(25, 31, 40, 0.18);
}

.confirm-dialog h2 {
  margin-bottom: 0;
  font-size: 21px;
  line-height: 1.25;
}

.confirm-dialog p {
  font-size: 14px;
}

.impact-list {
  display: grid;
  gap: 7px;
  margin: 0;
  padding: 12px 13px;
  border-radius: var(--radius);
  background: #f7f8fa;
  color: var(--muted);
  font-size: 13px;
  list-style-position: inside;
}

.dialog-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
}

@media (max-width: 380px) {
  .stat-grid,
  .two-col,
  .swap-panel {
    grid-template-columns: 1fr;
  }

  .hero h1 {
    font-size: 31px;
  }

  .copy-row {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .copy-row .btn[data-share] {
    grid-column: 1 / -1;
    width: 100%;
  }

  .section-head.row,
  .list-row {
    align-items: stretch;
  }

  .list-row {
    display: grid;
  }

  .row-actions .btn {
    flex: 1 1 0;
  }
}
