:root {
  --bg: #0d0d0d;
  --panel: #171717;
  --panel2: #212121;
  --text: #ececec;
  --muted: #b4b4b4;
  --line: rgba(255, 255, 255, 0.12);
  --accent: #7482ff;
  --danger: #f06b7d;
}
body[data-theme="light"] {
  --bg: #f5f7fc;
  --panel: #ffffff;
  --panel2: #edf0fa;
  --text: #1c2140;
  --muted: #5d6682;
  --line: rgba(30, 42, 90, 0.16);
  --accent: #5865f2;
}
body[data-theme="sunset"] {
  --bg: linear-gradient(165deg, #182447, #3a285b 42%, #884568 72%, #d77969);
  --panel: rgba(39, 29, 62, 0.9);
  --panel2: rgba(68, 42, 76, 0.86);
  --text: #fff7f1;
  --muted: #dec8d3;
  --line: rgba(255, 220, 205, 0.18);
  --accent: #f47b70;
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, "Noto Sans JP", Meiryo, sans-serif;
  line-height: 1.6;
}
button,
input,
textarea,
select {
  font: inherit;
}
button {
  cursor: pointer;
}
.hidden {
  display: none !important;
}
body[data-theme="light"] input,
body[data-theme="light"] textarea,
body[data-theme="light"] select,
body[data-theme="light"] .result-editor,
body[data-theme="light"] .placement-editor,
body[data-theme="light"] .stage-form {
  background: #f8f9ff;
}
body[data-theme="light"] .entry.winner,
body[data-theme="light"] .league-teams .winner {
  color: var(--text);
}
body[data-theme="light"] .button.ghost,
body[data-theme="light"] .mini-button {
  color: var(--text);
}
body[data-theme="light"] .eyebrow,
body[data-theme="light"] .tag {
  color: #4d59c7;
}
body[data-theme="light"] .result-link {
  color: #4451bd;
}
body[data-theme="light"] .league-teams .winner,
body[data-theme="light"] .entry.winner {
  background: rgba(88, 101, 242, 0.12);
}
body[data-theme="light"] .round-title,
body[data-theme="light"] .standings th {
  color: #3f4bb5;
}
.container {
  width: min(1720px, calc(100% - clamp(40px, 5vw, 160px)));
  margin: 0 auto;
  padding: 64px 0 90px;
}
.page-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 30px;
  margin-bottom: 30px;
}
.page-heading > .button {
  flex: 0 0 auto;
}
.eyebrow {
  margin: 0 0 8px;
  color: #aeb7ff;
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.14em;
}
h1 {
  margin: 0;
  font-size: clamp(2rem, 5vw, 3.2rem);
  line-height: 1.25;
}
h2 {
  margin: 0 0 18px;
  font-size: 1.4rem;
}
.page-heading p:not(.eyebrow) {
  color: var(--muted);
  margin-bottom: 0;
}
.button {
  min-height: 40px;
  padding: 8px 14px;
  border: 1px solid transparent;
  border-radius: 8px;
  color: #fff;
  font-weight: 700;
  text-decoration: none;
}
.primary {
  background: var(--accent);
}
.primary:hover {
  background: #7f8bff;
}
.ghost {
  border-color: var(--line);
  background: transparent;
}
.ghost:hover {
  background: rgba(255, 255, 255, 0.06);
}
.danger {
  background: transparent;
  border-color: rgba(236, 99, 118, 0.55);
  color: #ff9dab;
}
.full {
  width: 100%;
}
.tournament-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 16px;
}
.tournament-card {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: var(--panel);
}
.tournament-card:hover {
  border-color: #6d7cff;
}
.tournament-card > button {
  width: 100%;
  padding: 22px;
  border: 0;
  color: inherit;
  background: transparent;
  text-align: left;
}
.tournament-card h2 {
  margin: 6px 0;
}
.tournament-card p {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
}
.result-link {
  display: block;
  padding: 10px 22px;
  border-top: 1px solid var(--line);
  color: #bdc4ff;
  font-size: 0.86rem;
  font-weight: 700;
  text-decoration: none;
}
.result-link:hover {
  background: rgba(109, 124, 255, 0.12);
}
.tag {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 999px;
  background: rgba(109, 124, 255, 0.16);
  color: #bdc4ff;
  font-size: 0.75rem;
  font-weight: 700;
}
.empty {
  color: var(--muted);
}
.viewer {
  margin-top: 36px;
}
.viewer-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 25px;
}
.viewer-head p {
  color: var(--muted);
  margin: 0;
}
.bracket {
  display: flex;
  gap: 48px;
  align-items: stretch;
  overflow-x: auto;
  padding: 12px 4px 22px;
}
.round {
  position: relative;
  flex: 0 0 250px;
  display: flex;
  flex-direction: column;
  gap: 22px;
}
.round:not(:last-child)::after {
  content: "";
  position: absolute;
  top: 42px;
  right: -26px;
  width: 26px;
  height: calc(100% - 84px);
  border-top: 1px solid #59628e;
  border-bottom: 1px solid #59628e;
}
.round-title {
  color: #aeb7ff;
  font-size: 0.8rem;
  font-weight: 800;
  letter-spacing: 0.08em;
}
.match {
  position: relative;
  min-height: 82px;
  overflow: visible;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--panel);
}
.round:not(:last-child) .match::after {
  content: "";
  position: absolute;
  top: 50%;
  right: -27px;
  width: 27px;
  border-top: 1px solid #59628e;
}
.entry {
  width: 100%;
  min-height: 40px;
  padding: 9px 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  border: 0;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  background: transparent;
  text-align: left;
}
.entry:last-of-type {
  border-bottom: 0;
}
.entry.winner {
  color: #fff;
  background: rgba(109, 124, 255, 0.14);
  font-weight: 700;
}
.result-editor,
.placement-editor {
  padding: 10px;
  border-top: 1px solid var(--line);
  background: #0c1022;
}
.result-editor label,
.placement-editor label {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 0.72rem;
}
.result-editor input,
.result-editor select,
.placement-editor select {
  width: auto;
  max-width: 78px;
  margin: 0 0 0 5px;
  padding: 4px;
  font-size: 0.74rem;
}
.placement-editor select {
  width: 100%;
  max-width: none;
  margin: 3px 0 8px;
}
.result-save {
  margin-top: 4px;
}
.manage-layout {
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 20px;
}
.panel {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel);
}
.sidebar {
  padding: 14px;
}
.manage-list {
  margin-top: 14px;
}
.manage-item {
  width: 100%;
  margin-bottom: 6px;
  padding: 10px;
  border: 0;
  border-radius: 8px;
  color: var(--muted);
  background: transparent;
  text-align: left;
}
.manage-item:hover,
.manage-item.active {
  color: #fff;
  background: var(--panel2);
}
.manage-item small {
  display: block;
  font-size: 0.72rem;
}
.manage-content {
  min-height: 400px;
  padding: 28px;
}
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.form-grid .wide {
  grid-column: 1/-1;
}
label {
  display: block;
  margin: 0 0 13px;
  font-size: 0.88rem;
  font-weight: 700;
}
input,
textarea,
select {
  width: 100%;
  margin-top: 6px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  outline: 0;
  color: var(--text);
  background: #0c1022;
}
textarea {
  min-height: 160px;
  resize: vertical;
}
.hint {
  color: var(--muted);
  font-size: 0.8rem;
}
.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 22px 0;
}
.status {
  color: var(--muted);
  font-size: 0.9rem;
}
hr {
  border: 0;
  border-top: 1px solid var(--line);
  margin: 16px 0;
}
dialog {
  width: min(430px, calc(100% - 32px));
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 14px;
  color: var(--text);
  background: var(--panel);
}
dialog::backdrop {
  background: rgba(0, 0, 0, 0.68);
}
dialog form {
  position: relative;
  padding: 28px;
}
.dialog-close {
  position: absolute;
  top: 12px;
  right: 15px;
  border: 0;
  color: var(--muted);
  background: transparent;
  font-size: 1.4rem;
}
.form-error {
  min-height: 1.5em;
  margin: 0 0 10px;
  color: #ff9dab;
  font-size: 0.85rem;
}
.account-list {
  margin-top: 20px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.85rem;
}
.account-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 7px 0;
}
.account-row small {
  color: #ff9dab;
}
.mini-button {
  margin-left: 4px;
  padding: 3px 6px;
  border: 1px solid var(--line);
  border-radius: 5px;
  color: var(--muted);
  background: transparent;
  font-size: 0.72rem;
}
.mini-button.danger-button {
  border-color: rgba(236, 99, 118, 0.55);
  color: #ff9dab;
}
.standings {
  margin: 20px 0;
  overflow-x: auto;
}
.standings h3 {
  margin: 0 0 8px;
  font-size: 1rem;
}
.standings table {
  width: 100%;
  border-collapse: collapse;
  background: #0c1022;
}
.standings th,
.standings td {
  padding: 8px 10px;
  border: 1px solid var(--line);
  text-align: left;
}
.standings th {
  color: #bdc4ff;
  font-size: 0.8rem;
}
.standings th:first-child,
.standings td:first-child {
  width: 58px;
  padding-left: 6px;
  padding-right: 6px;
  text-align: center;
}
.standings th:not(:nth-child(2)),
.standings td:not(:nth-child(2)) {
  text-align: center;
}
.bracket {
  gap: 24px;
}
.round:not(:last-child)::after,
.round:not(:last-child) .match::after {
  display: none;
}
.stage-form {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 8px;
  margin: 18px 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #0c1022;
}
.stage-form strong,
.stage-form p {
  width: 100%;
  margin: 0;
}
.stage-form strong {
  font-size: 0.86rem;
}
.stage-form p {
  color: var(--muted);
  font-size: 0.78rem;
}
.stage-form label {
  flex: 1 1 130px;
  margin: 0;
  font-size: 0.76rem;
}
.stage-form input,
.stage-form select {
  width: 100%;
  margin: 3px 0 0;
  padding: 7px;
  font-size: 0.82rem;
}
.stage-editor {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 8px;
  margin: 10px 0;
  padding: 12px;
  border: 1px solid rgba(109, 124, 255, 0.35);
  border-radius: 8px;
  background: #111630;
}
.stage-editor strong {
  width: 100%;
  font-size: 0.84rem;
}
.stage-editor label {
  flex: 1 1 140px;
  margin: 0;
  color: var(--muted);
  font-size: 0.74rem;
}
.stage-editor input,
.stage-editor select {
  width: 100%;
  margin: 3px 0 0;
  padding: 7px;
  font-size: 0.82rem;
}
.round-robin {
  margin-top: 22px;
}
.round-robin h3 {
  margin: 0 0 3px;
  font-size: 1.1rem;
}
.round-robin > p {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 0.85rem;
}
.league-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(255px, 1fr));
  gap: 10px;
}
.league-match {
  display: flex;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}
.match-no {
  width: 30px;
  display: grid;
  place-items: center;
  color: #aeb7ff;
  background: #111630;
  font-size: 0.78rem;
  font-weight: 800;
}
.league-teams {
  flex: 1;
}
.league-teams > div {
  display: flex;
  justify-content: space-between;
  padding: 7px 10px;
  border-bottom: 1px solid var(--line);
  font-size: 0.86rem;
}
.league-teams > div:last-child {
  border-bottom: 0;
}
.league-teams .winner {
  background: rgba(109, 124, 255, 0.14);
  color: #fff;
  font-weight: 800;
}
.league-editor {
  display: grid;
  align-content: center;
  gap: 5px;
  padding: 7px;
  border-left: 1px solid var(--line);
}
.league-editor label {
  margin: 0;
  color: var(--muted);
  font-size: 0.67rem;
}
.league-editor input,
.league-editor select {
  width: 78px;
  margin: 2px 0 0;
  padding: 3px;
  font-size: 0.72rem;
}
body[data-theme] input,
body[data-theme] textarea,
body[data-theme] select {
  background: var(--input-bg);
}
@media (max-width: 760px) {
  .container {
    width: min(100% - 24px, 1720px);
    padding-top: 36px;
  }
  .page-heading {
    flex-direction: column;
    gap: 18px;
  }
  .page-heading > .button {
    width: 100%;
    min-height: 44px;
  }
  .manage-layout {
    grid-template-columns: 1fr;
  }
  .sidebar {
    order: 2;
  }
  .manage-content {
    min-height: 0;
    padding: 18px;
  }
  .form-grid {
    grid-template-columns: 1fr;
  }
  .form-grid .wide {
    grid-column: auto;
  }
  .toolbar .button {
    min-height: 44px;
    flex: 1 1 140px;
  }
  .header {
    width: calc(100% - 28px);
  }
  .account-name {
    display: none;
  }
  .viewer-head {
    flex-direction: column;
  }
}
