:root {
  color-scheme: dark;
  font-family:
    Inter, "Segoe UI", "Microsoft YaHei", "Noto Sans SC", system-ui, sans-serif;
  --bg: #111318;
  --panel: #1c2028;
  --panel-2: #252a34;
  --line: #3b4352;
  --text: #f3f6fb;
  --muted: #9da8ba;
  --blue: #4aa3ff;
  --cyan: #49d5d0;
  --red: #ff6773;
  --yellow: #f5ca56;
  --green: #65d281;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
}

body.has-content-background {
  background:
    linear-gradient(rgba(7, 10, 15, 0.58), rgba(7, 10, 15, 0.68)),
    var(--content-background-image),
    var(--content-background-color, var(--bg));
  background-position: center, var(--content-background-position, center), center;
  background-size: auto, var(--content-background-size, cover), auto;
  background-attachment: fixed;
}

button,
input,
select {
  font: inherit;
}

button {
  min-height: 38px;
  border: 1px solid transparent;
  border-radius: 6px;
  color: var(--text);
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.app-shell {
  position: relative;
  min-height: 100vh;
  padding: 18px;
}

.content-popup-overlay {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(5, 7, 11, 0.62);
}

.content-popup {
  display: grid;
  gap: 12px;
  width: min(460px, 100%);
  border: 1px solid rgba(73, 213, 208, 0.36);
  border-radius: 8px;
  background: rgba(18, 22, 30, 0.96);
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.38);
  padding: 18px;
}

.content-popup strong {
  font-size: 18px;
}

.content-popup p {
  color: var(--muted);
  line-height: 1.6;
  white-space: pre-wrap;
}

.content-popup-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.topbar {
  display: none;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin: 0 auto 10px;
  max-width: 1480px;
}

body[data-screen="menu"] .topbar {
  position: absolute;
  top: 18px;
  left: 18px;
  right: 18px;
  z-index: 40;
  display: flex;
  max-width: none;
  margin: 0;
  pointer-events: none;
}

body[data-screen="menu"] .topbar > div,
body[data-screen="menu"] .topbar-actions {
  pointer-events: auto;
}

body[data-screen="menu"] .topbar h1 {
  display: inline-grid;
  min-height: 34px;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(8, 11, 15, 0.76);
  box-shadow: 0 0 14px rgba(0, 0, 0, 0.42);
  padding: 0 16px;
  font-size: 18px;
  line-height: 1;
  text-shadow: 0 0 5px rgba(74, 163, 255, 0.48);
}

body[data-screen="menu"] .topbar p,
body[data-screen="menu"] #copyStateButton,
body[data-screen="menu"] #resetButton {
  display: none;
}

.global-status {
  max-width: 1480px;
  margin: 0 auto 16px;
  border: 1px solid rgba(73, 213, 208, 0.22);
  border-radius: 8px;
  background: rgba(20, 24, 33, 0.82);
  padding: 10px 12px;
}

body[data-screen="menu"] .global-status,
body[data-screen="tutorial"] .global-status,
body[data-screen="setup"] .global-status,
body[data-screen="playing"] .global-status,
body[data-screen="post_game"] .global-status {
  display: none;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 24px;
  font-weight: 800;
}

h2 {
  font-size: 15px;
  font-weight: 700;
}

.topbar p {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

.slot-text {
  color: var(--cyan);
}

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

.locale-picker select {
  min-height: 30px;
  max-width: 104px;
  padding: 0 7px;
  color: #d9f7ff;
  background: #18202b;
  border: 1px solid #435163;
  border-radius: 3px;
  font: 700 11px Consolas, monospace;
}

.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;
}

body[data-screen="menu"] .topbar-actions {
  border: 1px solid rgba(73, 213, 208, 0.22);
  border-radius: 4px;
  background: rgba(16, 20, 29, 0.78);
  box-shadow: 0 0 14px rgba(0, 0, 0, 0.38);
  padding: 6px;
}

.icon-button {
  position: relative;
  min-width: 72px;
  background: var(--panel-2);
  border-color: var(--line);
}

.red-dot {
  position: absolute;
  top: 6px;
  right: 8px;
  width: 9px;
  height: 9px;
  border-radius: 999px;
  background: var(--red);
  box-shadow: 0 0 0 2px var(--panel);
}

.account-menu {
  position: relative;
  display: flex;
  align-items: center;
  gap: 6px;
}

.account-id-button {
  min-height: 34px;
  background: #141923;
  border-color: rgba(73, 213, 208, 0.45);
  color: var(--cyan);
  padding: 0 10px;
  font-family: ui-monospace, "Cascadia Mono", "SFMono-Regular", Consolas, monospace;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.02em;
}

.account-id-button:hover {
  border-color: var(--cyan);
  box-shadow: 0 0 0 2px rgba(73, 213, 208, 0.12);
}

.account-button {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  background: var(--panel-2);
  border-color: var(--line);
  padding: 4px 6px 4px 12px;
}

.account-nickname {
  max-width: 132px;
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.account-avatar,
.friend-avatar {
  position: relative;
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 1px solid rgba(73, 213, 208, 0.45);
  border-radius: 50%;
  background:
    radial-gradient(circle at 32% 26%, rgba(255, 255, 255, 0.34), transparent 28%),
    linear-gradient(135deg, color-mix(in srgb, var(--avatar-color, #4aa3ff) 58%, #0d1724), var(--avatar-color, #49d5d0));
  color: #07101d;
  font-weight: 900;
  overflow: hidden;
}

.account-avatar img,
.friend-avatar img,
.avatar-choice img,
.avatar-choice-preview img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.presence-dot {
  position: absolute;
  right: -1px;
  bottom: -1px;
  width: 11px;
  height: 11px;
  border: 2px solid #111318;
  border-radius: 50%;
}

.presence-online {
  background: var(--green);
}

.presence-busy {
  background: var(--yellow);
}

.presence-dnd {
  background: var(--red);
}

.presence-offline {
  background: var(--muted);
}

.account-dropdown {
  position: absolute;
  z-index: 20;
  top: calc(100% + 8px);
  right: 0;
  display: grid;
  gap: 6px;
  min-width: 170px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #161b24;
  box-shadow: 0 18px 44px rgba(0, 0, 0, 0.42);
  padding: 8px;
}

.dropdown-item {
  width: 100%;
  min-height: 34px;
  background: transparent;
  border-color: transparent;
  text-align: left;
}

.dropdown-item:hover {
  background: var(--panel-2);
  border-color: var(--line);
}

.difficulty-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin: 12px 0;
}

.ai-difficulty-button.active {
  border-color: var(--cyan);
  background: rgba(73, 213, 208, 0.18);
  box-shadow: 0 0 0 2px rgba(73, 213, 208, 0.12);
}

.screen {
  max-width: 1480px;
  margin: 0 auto;
}

.auth-screen,
.menu-screen,
.form-screen {
  min-height: calc(100vh - 96px);
  display: grid;
  place-items: center;
}

.menu-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 18px;
  align-items: center;
  justify-items: center;
  width: min(100%, 760px);
}

.menu-main {
  width: min(100%, 720px);
  min-height: 560px;
  display: grid;
  align-content: center;
  gap: 30px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(73, 213, 208, 0.06), transparent 34%),
    linear-gradient(135deg, rgba(74, 163, 255, 0.1), rgba(245, 202, 86, 0.08)),
    var(--panel);
  padding: clamp(22px, 5vw, 54px);
}

.game-logo {
  width: min(100%, 620px);
  margin: 0 auto;
}

.menu-logo-svg {
  display: block;
  width: 100%;
  height: auto;
  overflow: visible;
}

.logo-main {
  fill: #fff;
  stroke: #3546ff;
  stroke-width: 4.4;
  paint-order: stroke fill;
  font: italic 900 35px/1 "Yu Gothic", "Meiryo", "Arial Unicode MS", Arial, sans-serif;
  letter-spacing: 0;
}

.logo-sub {
  fill: #fff;
  stroke: #2988ff;
  stroke-width: 3.4;
  paint-order: stroke fill;
  font: italic 900 31px/1 "Yu Gothic", "Meiryo", "Arial Unicode MS", Arial, sans-serif;
  letter-spacing: 0;
}

.menu-actions {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  width: min(100%, 460px);
  margin: 0 auto;
}

.menu-button {
  min-height: 48px;
}

.menu-ranked-entry {
  display: grid;
  gap: 4px;
}

.menu-ranked-entry small {
  color: var(--muted);
  font-size: 10px;
  text-align: center;
}

.menu-panel {
  align-self: stretch;
}

.menu-status {
  width: min(100%, 520px);
  margin: 0 auto;
  text-align: center;
}

.tournament-screen {
  display: grid;
  gap: 18px;
  width: min(100%, 1480px);
  padding: 8px 0 28px;
}

.tournament-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  border-bottom: 1px solid var(--line);
  padding: 24px 4px 20px;
}

.tournament-header > div:first-child {
  display: grid;
  gap: 8px;
  max-width: 760px;
}

.tournament-header h1 {
  color: #ffffff;
  font-family: var(--mono);
  font-size: 32px;
  text-shadow:
    0 0 6px rgba(74, 163, 255, 0.88),
    0 0 16px rgba(74, 163, 255, 0.48);
}

.tournament-header p,
.tournament-summary-line {
  color: var(--muted);
  line-height: 1.6;
}

.tournament-eyebrow,
.tournament-kicker {
  color: var(--red);
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0;
  text-shadow: 0 0 8px rgba(255, 103, 115, 0.52);
}

.tournament-header-actions,
.tournament-inline-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.tournament-header-actions button,
.tournament-inline-actions button,
.tournament-match-actions button {
  width: auto;
}

.tournament-band,
.tournament-detail {
  display: grid;
  gap: 14px;
  border-top: 1px solid rgba(255, 255, 255, 0.07);
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
  background: rgba(18, 22, 30, 0.74);
  padding: 18px;
}

.tournament-band-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.tournament-band-heading > div:first-child {
  display: grid;
  gap: 4px;
}

.tournament-band-heading h2 {
  font-size: 18px;
}

.tournament-status {
  color: var(--cyan);
  font-size: 12px;
}

.tournament-queue-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 10px;
}

.tournament-queue {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 6px 12px;
  align-items: center;
  min-height: 116px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #141923;
  padding: 14px;
}

.tournament-queue strong {
  grid-row: span 3;
  color: #ffffff;
  font-family: var(--mono);
  font-size: 38px;
  line-height: 1;
  text-shadow: 0 0 10px rgba(74, 163, 255, 0.65);
}

.tournament-queue b {
  min-width: 0;
  overflow-wrap: anywhere;
  color: #ffffff;
  font-size: 14px;
}

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

.tournament-queue progress {
  width: 100%;
  height: 6px;
  accent-color: var(--cyan);
}

.tournament-queue button {
  grid-column: 1 / -1;
  margin-top: 4px;
}

.tournament-list {
  display: grid;
  gap: 8px;
}

.tournament-list-row {
  display: grid;
  grid-template-columns: minmax(160px, 1.4fr) repeat(2, minmax(90px, 0.6fr)) auto;
  gap: 12px;
  align-items: center;
  min-height: 54px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
  padding: 8px 2px;
}

.tournament-list-row:last-child {
  border-bottom: 0;
}

.tournament-list-row span,
.tournament-empty {
  color: var(--muted);
  font-size: 13px;
}

.tournament-list-row button {
  width: auto;
}

.tournament-bracket {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(230px, 1fr);
  gap: 18px;
  overflow-x: auto;
  overscroll-behavior-inline: contain;
  padding: 4px 2px 14px;
}

.tournament-round {
  display: grid;
  align-content: start;
  gap: 10px;
  min-width: 0;
}

.tournament-round-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
  padding: 0 2px 8px;
}

.tournament-round-title span {
  color: var(--muted);
  font-size: 11px;
}

.tournament-bracket-match {
  display: grid;
  gap: 6px;
  border-left: 2px solid var(--line);
  background: #121720;
  padding: 9px 10px;
}

.tournament-bracket-match.is-live {
  border-left-color: var(--red);
  box-shadow: inset 10px 0 18px rgba(255, 103, 115, 0.06);
}

.tournament-bracket-match.is-complete {
  border-left-color: var(--green);
}

.tournament-competitor {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 27px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  color: #dfe7f5;
  font-size: 12px;
}

.tournament-competitor:last-of-type {
  border-bottom: 0;
}

.tournament-competitor.is-winner {
  color: var(--yellow);
  font-weight: 800;
}

.tournament-competitor em {
  color: var(--muted);
  font-family: var(--mono);
  font-size: 10px;
  font-style: normal;
}

.tournament-match-actions {
  display: flex;
  justify-content: flex-end;
  gap: 6px;
  margin-top: 3px;
}

.tournament-match-actions button {
  min-height: 30px;
  padding: 4px 9px;
  font-size: 11px;
}

.ranked-overview {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  border-top: 1px solid rgba(74, 163, 255, 0.35);
  border-bottom: 1px solid rgba(74, 163, 255, 0.35);
  background: rgba(11, 16, 24, 0.88);
}

.ranked-overview > div {
  display: grid;
  gap: 5px;
  min-height: 84px;
  align-content: center;
  border-right: 1px solid rgba(255, 255, 255, 0.08);
  padding: 12px 18px;
}

.ranked-overview > div:last-child {
  border-right: 0;
}

.ranked-overview span,
.ranked-queue-detail {
  color: var(--muted);
  font-size: 12px;
}

.ranked-overview strong {
  color: #ffffff;
  font-family: var(--mono);
  font-size: 23px;
  text-shadow: 0 0 9px rgba(74, 163, 255, 0.65);
}

.ranked-queue-row {
  display: grid;
  grid-template-columns: auto minmax(220px, 1fr) auto;
  align-items: center;
  gap: 18px;
}

.ranked-queue-count {
  display: flex;
  align-items: baseline;
  gap: 5px;
  min-width: 112px;
}

.ranked-queue-count strong {
  color: #fff;
  font-family: var(--mono);
  font-size: 38px;
  line-height: 1;
  text-shadow: 0 0 10px rgba(255, 65, 87, 0.72);
}

.ranked-queue-count span {
  color: var(--muted);
  font-size: 12px;
}

.ranked-leaderboard {
  display: grid;
}

.ranked-leaderboard-row {
  display: grid;
  grid-template-columns: 42px minmax(140px, 1fr) 100px 110px;
  align-items: center;
  gap: 12px;
  min-height: 46px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
  color: #dfe7f5;
  font-size: 12px;
}

.ranked-leaderboard-row:last-child {
  border-bottom: 0;
}

.ranked-leaderboard-row strong {
  color: var(--yellow);
  font-family: var(--mono);
  font-size: 15px;
}

.ranked-leaderboard-row span:last-child {
  color: var(--muted);
  text-align: right;
}

.ranked-bracket-self {
  outline: 1px solid rgba(74, 163, 255, 0.52);
  outline-offset: -1px;
}

.ranked-settlement-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 1px;
  background: rgba(255, 255, 255, 0.08);
}

.ranked-settlement-grid > div {
  display: grid;
  gap: 5px;
  min-height: 72px;
  align-content: center;
  background: #111720;
  padding: 10px 14px;
}

.ranked-settlement-grid span,
.ranked-history-row span {
  color: var(--muted);
  font-size: 11px;
}

.ranked-settlement-grid strong {
  color: #fff;
  font-family: var(--mono);
  font-size: 18px;
}

.ranked-history {
  display: grid;
}

.ranked-history-row {
  display: grid;
  grid-template-columns: minmax(190px, 0.7fr) minmax(260px, 1.3fr);
  gap: 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
  padding: 12px 0;
}

.ranked-history-row > div {
  display: grid;
  gap: 4px;
}

.ranked-history-splits {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.spectator-panel {
  display: grid;
  gap: 8px;
  width: 100%;
  max-width: calc(100vw - 94px);
  border-top: 1px solid rgba(255, 103, 115, 0.35);
  background: rgba(12, 15, 21, 0.9);
  padding: 10px 12px;
}

.spectator-panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.spectator-panel-heading strong {
  color: var(--red);
  text-shadow: 0 0 8px rgba(255, 103, 115, 0.6);
}

.spectator-panel-heading span {
  color: var(--muted);
  font-size: 11px;
}

.spectator-event-log {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 5px 12px;
  max-height: 116px;
  overflow: auto;
  color: #cfd8e8;
  font-size: 12px;
}

.spectator-event-entry {
  display: grid;
  grid-template-columns: 38px 1fr;
  gap: 6px;
  min-width: 0;
}

.spectator-event-entry time {
  color: var(--cyan);
  font-family: var(--mono);
}

.spectator-event-entry span {
  overflow-wrap: anywhere;
}

.auth-card,
.form-card,
.admin-card {
  width: min(100%, 520px);
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(73, 213, 208, 0.05), transparent 38%),
    var(--panel);
  padding: clamp(18px, 4vw, 30px);
}

.admin-card {
  width: min(100%, 760px);
}

.friends-card,
.notification-card {
  width: min(100%, 980px);
}

.friends-card {
  max-height: min(78vh, 760px);
  overflow: auto;
}

.friend-code-panel {
  display: grid;
  gap: 6px;
  border: 1px solid rgba(73, 213, 208, 0.42);
  border-radius: 8px;
  background: #12151b;
  padding: 12px;
  margin-bottom: 12px;
}

.friend-code-panel span {
  color: var(--muted);
  font-size: 12px;
}

.friend-code-panel strong {
  color: var(--cyan);
  font-size: 22px;
  letter-spacing: 0.08em;
}

.inline-form {
  grid-template-columns: minmax(0, 1fr) 180px;
  align-items: end;
}

.friend-columns {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(280px, 0.7fr);
  gap: 14px;
}

.friend-list,
.notification-list {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}

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

.friend-row.compact {
  grid-template-columns: 42px minmax(0, 1fr) auto;
}

.friend-row.removed {
  opacity: 0.62;
  filter: grayscale(0.85);
}

.friend-row.blocked {
  border-color: rgba(255, 103, 115, 0.36);
}

.friend-main {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.friend-main span,
.notification p,
.notification-meta {
  color: var(--muted);
  font-size: 12px;
}

.friend-actions,
.notification-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: flex-end;
}

.friend-actions button,
.notification-actions button {
  width: auto;
  min-height: 32px;
  padding: 0 10px;
}

.tag-line {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.pill {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 11px;
}

.pill.green {
  border-color: rgba(101, 210, 129, 0.5);
  color: var(--green);
}

.pill.yellow {
  border-color: rgba(245, 202, 86, 0.5);
  color: var(--yellow);
}

.pill.red {
  border-color: rgba(255, 103, 115, 0.5);
  color: var(--red);
}

.pill.gray {
  color: var(--muted);
}

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

.notification.unread {
  border-color: rgba(73, 213, 208, 0.48);
}

.notification strong,
.notification p,
.notification-meta {
  grid-column: 1 / -1;
}

.notification-meta {
  display: flex;
  justify-content: space-between;
}

.empty-state {
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  padding: 14px;
  text-align: center;
}

.admin-subpanel {
  display: grid;
  gap: 10px;
}

.admin-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 12px 0;
}

.admin-tab {
  width: auto;
  min-width: 92px;
  min-height: 34px;
  background: var(--panel-2);
  border-color: var(--line);
  color: var(--muted);
  padding: 0 12px;
}

.admin-tab.active {
  border-color: var(--cyan);
  color: var(--cyan);
  box-shadow: inset 0 0 0 1px rgba(73, 213, 208, 0.22);
}

.admin-section {
  display: grid;
  gap: 12px;
}

.admin-ops-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.tournament-admin-form {
  grid-template-columns: minmax(180px, 1.3fr) minmax(100px, 0.5fr) repeat(2, minmax(180px, 1fr));
  align-items: end;
}

.admin-tournament-list {
  display: grid;
  gap: 10px;
}

.admin-tournament-card {
  display: grid;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #141923;
  padding: 12px;
}

.admin-tournament-heading,
.admin-tournament-whitelist > div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.admin-tournament-heading > div {
  min-width: 0;
}

.admin-tournament-heading strong,
.admin-tournament-heading small {
  display: block;
}

.admin-tournament-heading small,
.admin-tournament-windows,
.admin-tournament-whitelist {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
}

.admin-tournament-windows {
  white-space: pre-line;
}

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

.admin-tournament-whitelist {
  display: grid;
  gap: 6px;
}

.admin-tournament-whitelist > div {
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  padding-top: 6px;
}

.admin-ops-grid > form {
  border-left: 2px solid rgba(73, 213, 208, 0.45);
  padding-left: 14px;
}

#adminPenaltySearchForm {
  grid-template-columns: repeat(2, minmax(180px, 1fr)) minmax(130px, 180px) auto;
}

.admin-table,
.admin-detail,
.avatar-admin-grid {
  display: grid;
  gap: 8px;
}

.inline-form {
  grid-template-columns: minmax(180px, 1fr) minmax(130px, 180px) auto;
  align-items: end;
}

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

.avatar-admin-item {
  grid-template-columns: 46px minmax(0, 1fr) auto;
}

.avatar-admin-item.inactive {
  opacity: 0.62;
}

.admin-row strong,
.avatar-admin-item strong,
.admin-detail-card strong {
  display: block;
}

.admin-row span,
.admin-row small,
.avatar-admin-item span,
.avatar-admin-item small,
.admin-detail-card span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.admin-row-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
}

.admin-detail-card {
  display: grid;
  gap: 12px;
  border: 1px solid rgba(73, 213, 208, 0.32);
  border-radius: 8px;
  background: #121722;
  padding: 12px;
}

.admin-detail-card header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.admin-detail-grid {
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr);
  gap: 6px 12px;
  border-top: 1px solid var(--line);
  padding-top: 10px;
}

.admin-history {
  display: grid;
  gap: 4px;
  border-top: 1px solid var(--line);
  padding-top: 10px;
}

.avatar-choice-preview {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 1px solid rgba(73, 213, 208, 0.45);
  border-radius: 50%;
  background:
    radial-gradient(circle at 32% 26%, rgba(255, 255, 255, 0.34), transparent 28%),
    linear-gradient(135deg, color-mix(in srgb, var(--avatar-color, #4aa3ff) 58%, #0d1724), var(--avatar-color, #49d5d0));
  color: #07101d;
  font-weight: 900;
  overflow: hidden;
}

.avatar-upload-form {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #141923;
  padding: 12px;
}

.avatar-upload-preview {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 72px;
  color: var(--muted);
}

.avatar-upload-preview img {
  width: 64px;
  height: 64px;
  border: 1px solid rgba(73, 213, 208, 0.45);
  border-radius: 50%;
  object-fit: cover;
}

.ops-list {
  display: grid;
  gap: 8px;
}

.ops-group {
  display: grid;
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #141923;
  padding: 10px;
}

.ops-group span {
  color: var(--muted);
  font-family: var(--mono);
  font-size: 12px;
}

.auth-logo {
  width: min(100%, 420px);
  margin-bottom: 12px;
}

.auth-tabs {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin: 12px 0;
}

.auth-locale-picker {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 8px;
  margin: 4px 0 12px;
  color: var(--muted);
  font-size: 13px;
}

.auth-locale-picker select {
  min-height: 34px;
  min-width: 116px;
}

.tab-button {
  background: var(--panel-2);
  border-color: var(--line);
}

.tab-button.active {
  border-color: var(--cyan);
  color: var(--cyan);
}

.auth-form {
  display: grid;
  gap: 10px;
}

.registration-email-code-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(112px, auto);
  gap: 8px;
}

.registration-email-code-row button {
  width: auto;
  white-space: nowrap;
}

.registration-email-code-status {
  min-height: 16px;
  color: var(--muted);
  font-size: 11px;
}

.registration-email-code-status.ready {
  color: var(--cyan);
}

.offline-entry {
  display: grid;
  gap: 10px;
  margin-top: 16px;
}

.offline-entry > span {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 10px;
  align-items: center;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

.offline-entry > span::before,
.offline-entry > span::after {
  height: 1px;
  background: var(--line);
  content: "";
}

.lan-dialog-card {
  width: min(100%, 520px);
}

.lan-role-picker {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin: 0;
  border: 0;
  padding: 0;
}

.lan-role-picker legend {
  grid-column: 1 / -1;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 12px;
}

.lan-role-picker label {
  display: flex;
  min-height: 42px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #12151b;
  cursor: pointer;
}

.lan-role-picker input {
  width: 16px;
  height: 16px;
  padding: 0;
}

.lan-host-package {
  display: grid;
  gap: 10px;
  border-top: 1px solid var(--line);
  padding-top: 14px;
}

.lan-download-button {
  display: grid;
  min-height: 38px;
  place-items: center;
  text-decoration: none;
}

.lan-account-note {
  border-left: 2px solid var(--cyan);
  padding-left: 10px;
}

.captcha-block,
.mail-test-panel {
  display: grid;
  gap: 8px;
  border: 1px solid rgba(73, 213, 208, 0.2);
  border-radius: 8px;
  background: rgba(12, 18, 28, 0.48);
  padding: 10px;
}

.captcha-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
}

.captcha-row strong {
  min-height: 34px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(73, 213, 208, 0.35);
  border-radius: 6px;
  background: rgba(73, 213, 208, 0.08);
  color: var(--cyan);
  font-family: var(--mono);
  letter-spacing: 0;
}

.challenge-notice {
  border: 1px solid rgba(73, 213, 208, 0.28);
  border-radius: 8px;
  background: rgba(73, 213, 208, 0.08);
  color: var(--cyan);
  padding: 10px;
  font-weight: 700;
}

.mail-test-panel {
  margin-top: 12px;
}

.mail-test-panel small {
  color: var(--muted);
}

.mail-provider-heading {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto;
  gap: 16px;
  align-items: end;
}

.mail-provider-heading .check-field {
  min-height: 42px;
  margin-bottom: 1px;
}

.mail-provider-settings {
  display: grid;
  gap: 12px;
  padding-top: 14px;
  border-top: 1px solid rgba(73, 213, 208, 0.22);
}

.mail-settings-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(180px, 0.65fr);
  gap: 10px 14px;
}

.mail-settings-grid .wide-field {
  grid-column: 1 / -1;
}

.outlook-status-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  min-height: 58px;
}

.outlook-status-row > div:first-child {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 5px 10px;
}

.outlook-status-row strong,
.outlook-status-row small {
  min-width: 0;
  overflow-wrap: anywhere;
}

.outlook-status-row small {
  grid-column: 2;
  color: var(--muted);
}

.mail-status-badge {
  grid-row: 1 / span 2;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 74px;
  min-height: 30px;
  padding: 4px 9px;
  border: 1px solid rgba(157, 168, 186, 0.42);
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.mail-status-badge.online {
  border-color: rgba(72, 210, 138, 0.72);
  color: #65e59d;
  box-shadow: inset 0 0 12px rgba(72, 210, 138, 0.08);
}

.mail-status-badge.ready {
  border-color: rgba(73, 213, 208, 0.7);
  color: var(--cyan);
}

.mail-status-badge.error {
  border-color: rgba(255, 103, 115, 0.72);
  color: #ff7c87;
}

.compact-actions {
  flex: 0 0 auto;
  margin: 0;
}

.mail-config-note {
  color: var(--muted);
  line-height: 1.5;
}

.danger-text {
  color: #ff7c87;
  border-color: rgba(255, 103, 115, 0.42);
}

@media (max-width: 720px) {
  .mail-provider-heading,
  .mail-settings-grid {
    grid-template-columns: 1fr;
  }

  .mail-settings-grid .wide-field {
    grid-column: auto;
  }

  .outlook-status-row {
    align-items: stretch;
    flex-direction: column;
  }

  .outlook-status-row .compact-actions {
    justify-content: stretch;
  }

  .outlook-status-row .compact-actions button {
    flex: 1;
  }
}

.small-button {
  width: auto;
  min-width: 96px;
  padding: 0 12px;
}

.check-field {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  color: var(--muted);
  font-size: 13px;
}

.check-field input {
  width: auto;
  height: auto;
}

.announcement-stack {
  display: grid;
  gap: 8px;
  width: min(100%, 520px);
  margin: 0 auto;
}

.announcement {
  display: grid;
  gap: 6px;
  border: 1px solid rgba(73, 213, 208, 0.3);
  border-radius: 8px;
  background: rgba(18, 21, 27, 0.9);
  padding: 10px;
}

.announcement strong {
  font-size: 14px;
}

.announcement p {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
  white-space: pre-wrap;
}

.announcement.warning {
  border-color: rgba(245, 202, 86, 0.45);
}

.announcement.danger {
  border-color: rgba(255, 103, 115, 0.5);
}

.profile-summary {
  margin-bottom: 16px;
}

.avatar-picker {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 8px;
}

.avatar-choice {
  display: grid;
  place-items: center;
  min-height: 52px;
  border-color: var(--line);
  background:
    radial-gradient(circle at 32% 26%, rgba(255, 255, 255, 0.34), transparent 28%),
    linear-gradient(135deg, color-mix(in srgb, var(--avatar-color, #4aa3ff) 58%, #0d1724), var(--avatar-color, #49d5d0));
  color: #07101d;
  font-weight: 900;
}

.avatar-choice.active {
  border-color: var(--cyan);
  box-shadow:
    inset 0 0 0 2px rgba(255, 255, 255, 0.36),
    0 0 0 2px rgba(73, 213, 208, 0.18);
}

.room-screen {
  min-height: calc(100vh - 120px);
  display: grid;
  place-items: center;
}

.room-layout {
  width: min(100%, 660px);
}

.room-card {
  display: grid;
  gap: 16px;
}

.room-code-block {
  display: grid;
  gap: 6px;
  border: 1px solid rgba(73, 213, 208, 0.45);
  border-radius: 8px;
  background: #12151b;
  padding: 14px;
  text-align: center;
}

.room-code-block span,
.room-slots span {
  color: var(--muted);
  font-size: 12px;
}

.room-code-block strong {
  color: var(--cyan);
  font-size: clamp(32px, 7vw, 54px);
  letter-spacing: 0.08em;
}

.room-slots {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.room-slots div {
  display: grid;
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
  padding: 12px;
}

.room-slots strong {
  overflow-wrap: anywhere;
}

.room-buttons {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.layout {
  display: grid;
  grid-template-columns: minmax(420px, 1fr);
  gap: 0;
  max-width: 1240px;
  margin: 0 auto;
  align-items: start;
}

.panel,
.board-zone {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.panel {
  padding: 14px;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.field {
  display: grid;
  gap: 6px;
  margin-bottom: 10px;
}

.field span,
.group-label,
.strip-label {
  color: var(--muted);
  font-size: 12px;
}

input,
select {
  width: 100%;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #12151b;
  color: var(--text);
  padding: 0 10px;
  outline: none;
}

select {
  appearance: none;
}

.locale-field {
  position: relative;
}

.locale-field select {
  padding-right: 38px;
  cursor: pointer;
  color-scheme: dark;
}

.locale-field::after {
  content: "";
  position: absolute;
  right: 15px;
  bottom: 15px;
  width: 7px;
  height: 7px;
  border-right: 2px solid var(--cyan);
  border-bottom: 2px solid var(--cyan);
  transform: rotate(45deg);
  pointer-events: none;
}

.locale-field select:hover {
  border-color: color-mix(in srgb, var(--cyan) 72%, var(--line));
}

.locale-field select:focus-visible {
  border-color: var(--cyan);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--cyan) 22%, transparent);
}

.locale-field option {
  color: #effbff;
  background: #12151b;
}

.locale-field option:checked {
  color: #07101d;
  background: var(--cyan);
}

input:focus,
select:focus {
  border-color: var(--blue);
}

.primary-button {
  width: 100%;
  background: var(--blue);
  color: #07101d;
  font-weight: 800;
}

.secondary-button {
  width: 100%;
  background: var(--panel-2);
  border-color: var(--line);
}

.ghost-button {
  width: 100%;
  background: transparent;
  border-color: var(--line);
}

.danger-button {
  width: 100%;
  background: rgba(255, 103, 115, 0.1);
  border-color: rgba(255, 103, 115, 0.45);
  color: var(--red);
}

.danger {
  color: var(--red);
}

.split-line {
  height: 1px;
  background: var(--line);
  margin: 14px 0;
}

.info-stack {
  display: grid;
  gap: 8px;
  margin-top: 14px;
}

.info-stack div {
  display: grid;
  grid-template-columns: 58px 1fr;
  gap: 8px;
  align-items: center;
}

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

.info-stack strong {
  overflow-wrap: anywhere;
  font-size: 12px;
}

.board-zone {
  padding: clamp(6px, 1vw, 14px);
  overflow: visible;
}

body[data-screen="tutorial"] .app-shell,
body[data-screen="setup"] .app-shell,
body[data-screen="playing"] .app-shell,
body[data-screen="post_game"] .app-shell {
  min-height: 100vh;
  padding: 6px;
}

body[data-screen="tutorial"] .screen,
body[data-screen="setup"] .screen,
body[data-screen="playing"] .screen,
body[data-screen="post_game"] .screen {
  width: fit-content;
  max-width: calc(100vw - 12px);
}

body[data-screen="tutorial"] .layout,
body[data-screen="setup"] .layout,
body[data-screen="playing"] .layout,
body[data-screen="post_game"] .layout {
  width: fit-content;
  max-width: calc(100vw - 12px);
}

body[data-screen="tutorial"] .board-zone,
body[data-screen="setup"] .board-zone,
body[data-screen="playing"] .board-zone,
body[data-screen="post_game"] .board-zone {
  width: fit-content;
  max-width: calc(100vw - 12px);
  padding: 4px;
  border: 0;
  border-radius: 2px;
  background: rgba(5, 7, 11, 0.82);
}

.board-stage {
  display: grid;
  grid-template-columns: minmax(0, min(calc((100vh - 12px) * 0.703333), calc(100vw - 94px), 820px)) clamp(54px, 6vw, 74px);
  align-items: stretch;
  justify-content: center;
  gap: 4px;
  width: fit-content;
  max-width: calc(100vw - 12px);
}

.match-strip {
  display: none;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 12px;
}

.match-strip div {
  min-width: 0;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px;
}

.match-strip strong {
  display: block;
  margin-top: 4px;
  overflow-wrap: anywhere;
  font-size: 14px;
}

.board {
  position: relative;
  width: 100%;
  max-width: 820px;
  aspect-ratio: 1266 / 1800;
  --reserve-slot-width: 6.951027%;
  --reserve-slot-height: 7.222222%;
  --reserve-self-y: 92.111111%;
  --reserve-enemy-y: 0.722222%;
  --reserve-x-1: 2.843602%;
  --reserve-x-2: 10.110585%;
  --reserve-x-3: 17.377567%;
  --reserve-x-4: 24.644550%;
  --reserve-x-5: 68.799368%;
  --reserve-x-6: 76.066351%;
  --reserve-x-7: 83.333333%;
  --reserve-x-8: 90.600316%;
  margin: 0 auto;
  display: block;
  border: 0;
  background: #0b0d12;
  box-shadow: none;
  overflow: hidden;
}

.skill-dock {
  position: relative;
  z-index: 12;
  display: grid;
  grid-template-rows: minmax(0, 1fr);
  align-items: center;
  gap: 0;
  min-width: 0;
  min-height: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  padding: 0;
}

.skill-rail {
  position: relative;
  z-index: 12;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: stretch;
  min-width: 0;
  min-height: 0;
  gap: clamp(4px, 0.7vw, 8px);
  padding: 0;
}

.skill-rail-label {
  align-self: center;
  justify-self: center;
  display: grid;
  place-items: center;
  border: 0;
  background: transparent;
  color: #ff2638;
  writing-mode: vertical-rl;
  text-orientation: upright;
  font-family: var(--mono);
  font-size: clamp(28px, 3.2vw, 48px);
  font-weight: 900;
  line-height: 1;
  letter-spacing: 0;
  text-shadow:
    0 0 4px rgba(255, 38, 56, 0.95),
    0 0 10px rgba(255, 38, 56, 0.78),
    0 0 18px rgba(255, 38, 56, 0.48);
  user-select: none;
  cursor: default;
  padding: 0;
}

.skill-rail-label.cancel-active {
  grid-template-rows: repeat(2, auto);
  gap: 2px;
  writing-mode: horizontal-tb;
  text-orientation: mixed;
  font-size: clamp(18px, 2.1vw, 30px);
  cursor: pointer;
  pointer-events: auto;
}

.skill-rail-label.cancel-active span {
  display: block;
  line-height: 1;
}

.skill-rail-label.cancel-active:hover,
.skill-rail-label.cancel-active:focus-visible {
  filter: brightness(1.2);
  outline: none;
}

.skill-rail-label:disabled {
  opacity: 1;
}

.skill-dock-opponent {
  color: #ff2936;
  box-shadow: none;
}

.skill-dock-self {
  color: #00baff;
  box-shadow: none;
}

.skill-dock-title {
  display: none;
}

.skill-dock-cards {
  display: grid;
  grid-template-rows: repeat(5, minmax(0, 1fr));
  align-items: center;
  justify-items: center;
  gap: 2px;
  min-height: 0;
}

.skill-dock-card {
  position: relative;
  display: grid;
  place-items: center;
  width: 82%;
  min-width: 0;
  min-height: 0;
  aspect-ratio: 1;
  border: 0;
  border-radius: 0;
  background: transparent;
  overflow: hidden;
}

.skill-dock-card.empty {
  opacity: 0;
}

.skill-dock-card.used {
  filter: saturate(0.5) brightness(0.62);
}

.skill-dock-card.used::after {
  content: "已用";
  position: absolute;
  inset: auto 2px 2px;
  border-radius: 2px;
  background: rgba(0, 0, 0, 0.72);
  color: #fff;
  font-size: clamp(7px, 0.8vw, 10px);
  line-height: 1.3;
  text-align: center;
}

.skill-dock-card.draggable {
  cursor: grab;
  filter: drop-shadow(0 0 5px rgba(73, 213, 208, 0.58));
}

.skill-dock-card.draggable:active {
  cursor: grabbing;
}

.skill-dock-card .skill-card-image,
.skill-dock-card .skill-dock-fallback {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.skill-dock-fallback {
  display: grid !important;
  place-items: center;
  color: #fff;
  font-family: var(--mono);
  font-size: clamp(10px, 1.2vw, 16px);
  font-weight: 900;
  text-align: center;
  text-shadow: 0 1px 4px #000;
}

.skill-dock-drop-hint {
  display: none;
}

.opponent-identity-card {
  position: absolute;
  top: 10.45%;
  left: 5.15%;
  z-index: 30;
  min-width: 132px;
}

.opponent-identity-button {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-height: 40px;
  border: 1px solid rgba(74, 163, 255, 0.72);
  border-radius: 3px;
  background: rgba(15, 20, 29, 0.86);
  box-shadow:
    inset 0 0 10px rgba(74, 163, 255, 0.16),
    0 0 10px rgba(0, 0, 0, 0.45);
  padding: 5px 8px;
  text-align: left;
}

.opponent-identity-button span {
  min-width: 0;
  overflow: hidden;
  color: #d9e8ff;
  font-size: 12px;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.opponent-identity-button strong {
  color: var(--cyan);
  font-family: ui-monospace, "Cascadia Mono", "SFMono-Regular", Consolas, monospace;
  font-size: 10px;
  letter-spacing: 0;
}

.opponent-identity-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  z-index: 35;
  display: grid;
  gap: 5px;
  min-width: 132px;
  border: 1px solid rgba(74, 163, 255, 0.42);
  border-radius: 4px;
  background: rgba(15, 20, 29, 0.94);
  box-shadow: 0 12px 26px rgba(0, 0, 0, 0.5);
  padding: 6px;
}

.board-art-frame {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
  pointer-events: none;
  transform-origin: 50% 50%;
}

.board[data-viewer-color="yellow"] .board-art-frame {
  transform: rotate(180deg);
}

.board[data-viewer-color="yellow"] {
  --reserve-self-y: 92.055556%;
  --reserve-enemy-y: 0.666667%;
  --reserve-x-1: 2.448657%;
  --reserve-x-2: 9.715640%;
  --reserve-x-3: 16.982622%;
  --reserve-x-4: 24.249605%;
  --reserve-x-5: 68.404423%;
  --reserve-x-6: 75.671406%;
  --reserve-x-7: 82.938389%;
  --reserve-x-8: 90.205371%;
}

.action-panel {
  display: none;
}

.board-phase-badge,
.board-timer-badge {
  position: absolute;
  z-index: 6;
  left: 50%;
  transform: translateX(-50%);
  pointer-events: none;
  color: #ffe94a;
  font-family: var(--mono);
  font-size: clamp(16px, 2.3vw, 26px);
  font-weight: 900;
  text-shadow:
    0 0 4px rgba(255, 255, 255, 0.72),
    0 0 12px rgba(255, 232, 42, 0.95),
    0 0 22px rgba(255, 152, 0, 0.55);
}

.board-phase-badge {
  top: 5.6%;
}

.board-timer-badge {
  top: 88.4%;
  color: #ff6674;
  text-shadow:
    0 0 4px rgba(255, 255, 255, 0.5),
    0 0 12px rgba(255, 92, 110, 0.95),
    0 0 20px rgba(255, 24, 55, 0.62);
}

.board-setup-exit {
  position: absolute;
  z-index: 31;
  top: 10.45%;
  right: 5.15%;
  width: clamp(50px, 6.8vw, 72px);
  height: clamp(24px, 3.2vw, 32px);
  min-width: 0;
  padding: 0 0.55em;
  border: 1px solid #ff4058;
  border-radius: 4px;
  background: #151a22;
  color: #ff8a98;
  font-size: clamp(9px, 1.15vw, 13px);
  font-weight: 700;
  line-height: 1;
  box-shadow: 0 0 10px rgba(255, 40, 72, 0.24);
}

.board-setup-exit:hover,
.board-setup-exit:focus-visible {
  border-color: #ffffff;
  color: #ffffff;
}

.spectator-badge {
  position: absolute;
  z-index: 31;
  top: 10.45%;
  left: 5.15%;
  min-height: 32px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255, 103, 115, 0.72);
  border-radius: 3px;
  background: rgba(18, 20, 27, 0.9);
  color: #ff9aa4;
  padding: 5px 9px;
  font-family: var(--mono);
  font-size: clamp(9px, 1.15vw, 13px);
  font-weight: 900;
  text-shadow: 0 0 8px rgba(255, 54, 79, 0.64);
  pointer-events: none;
}

.board-spectator-exit {
  position: absolute;
  z-index: 31;
  top: 10.45%;
  right: 5.15%;
  width: clamp(62px, 8.4vw, 88px);
  height: clamp(24px, 3.2vw, 32px);
  min-width: 0;
  min-height: 0;
  border: 1px solid rgba(255, 103, 115, 0.72);
  border-radius: 3px;
  background: rgba(18, 20, 27, 0.9);
  color: #ff9aa4;
  padding: 0 0.5em;
  font-size: clamp(9px, 1.15vw, 13px);
}

.board-spectator-exit:hover,
.board-spectator-exit:focus-visible {
  border-color: #ffffff;
  color: #ffffff;
}

.board-toast-log {
  position: absolute;
  z-index: 6;
  top: 13.35%;
  right: 7.85%;
  max-width: 24%;
  min-height: 24px;
  pointer-events: none;
  color: rgba(236, 247, 255, 0.62);
  font-size: clamp(10px, 1.4vw, 14px);
  line-height: 1.35;
  text-align: left;
  text-shadow: 0 0 8px rgba(0, 0, 0, 0.86);
}

.board-server-controls {
  position: absolute;
  z-index: 7;
  left: 7.2%;
  right: 7.2%;
  bottom: 11.8%;
  display: grid;
  gap: min(0.8vw, 8px);
  align-items: center;
}

.board-setup-controls {
  grid-template-columns: auto auto minmax(0, 1fr) auto;
}

.board-setup-controls #autoSetupButton,
.board-setup-controls #clearSetupButton {
  width: clamp(56px, 7.2vw, 74px);
  min-width: 0;
}

.board-setup-controls #lockSetupButton {
  grid-column: 4;
  justify-self: end;
  width: clamp(68px, 9vw, 92px);
  min-width: 0;
}

.board-battle-controls {
  grid-template-columns: auto minmax(0, 1fr) auto;
}

.board-battle-controls #selectSkillsButton,
.board-battle-controls #surrenderButton {
  width: clamp(56px, 7.4vw, 78px);
  min-width: 0;
}

.board-battle-controls #selectSkillsButton {
  grid-column: 1;
}

.board-battle-controls.is-battle #selectSkillsButton {
  display: none;
}

.board-battle-controls #surrenderButton {
  grid-column: 3;
  justify-self: end;
}

.board-battle-controls.is-setup-skill #selectSkillsButton {
  grid-column: 3;
  justify-self: end;
}

.board-battle-controls.is-setup-skill #surrenderButton {
  display: none;
}

.board-server-controls button {
  height: clamp(22px, 3.15vw, 32px);
  min-height: 0;
  padding: 0 0.55em;
  border-radius: 4px;
  font-size: clamp(9px, 1.15vw, 13px);
  line-height: 1;
  white-space: nowrap;
}

.board-reserve-dock {
  position: absolute;
  z-index: 7;
  inset: 0;
  display: block;
  pointer-events: none;
}

.board-opponent-reserve-dock {
  display: block;
}

.board-reserve-dock .selection-box {
  display: none !important;
}

.cell {
  position: absolute;
  z-index: 2;
  display: grid;
  place-items: center;
  min-height: 0;
  border: 0;
  border-radius: 5%;
  background: transparent;
  color: var(--text);
  user-select: none;
  padding: 0;
  overflow: visible;
}

.cell:nth-child(odd) {
  background: transparent;
}

.cell.setup-a::before,
.cell.setup-b::before,
.cell.setup-blue::before,
.cell.setup-yellow::before {
  content: "";
  position: absolute;
  inset: -2%;
  z-index: 0;
  border-radius: 9%;
  pointer-events: none;
  background: transparent;
}

.cell.setup-a::before,
.cell.setup-blue::before {
  border: 4px solid rgba(58, 220, 255, 0.98);
  box-shadow:
    inset 0 0 0 1px rgba(230, 252, 255, 0.72),
    inset 0 0 10px rgba(34, 190, 255, 0.54),
    0 0 12px rgba(16, 180, 255, 0.82),
    0 0 22px rgba(30, 96, 255, 0.46);
}

.cell.setup-b::before,
.cell.setup-yellow::before {
  border: 4px solid rgba(255, 255, 52, 0.98);
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 230, 0.78),
    inset 0 0 10px rgba(255, 240, 0, 0.55),
    0 0 12px rgba(255, 238, 0, 0.78),
    0 0 22px rgba(255, 204, 0, 0.42);
}

.cell.setup-self {
  outline: 2px solid rgba(255, 255, 255, 0.86);
  outline-offset: -5px;
}

.cell.exit-a {
  background: transparent;
}

.cell.exit-b {
  background: transparent;
}

.cell.selected {
  outline: 3px solid var(--yellow);
  outline-offset: -4px;
}

.cell.target {
  outline: 3px solid var(--cyan);
  outline-offset: -5px;
  background: rgba(73, 213, 208, 0.13);
}

.cell.skill-drop-target {
  outline: 3px dashed rgba(255, 233, 74, 0.98);
  outline-offset: -6px;
  background: rgba(255, 233, 74, 0.16);
}

.cell.dimmed {
  filter: saturate(0.8) brightness(0.82);
}

.coord {
  position: absolute;
  z-index: 2;
  left: 8%;
  top: 8%;
  color: rgba(255, 255, 255, 0.28);
  font-size: clamp(5px, 0.8vw, 9px);
}

.piece {
  position: relative;
  z-index: 3;
  width: 58%;
  height: 58%;
  border-radius: 50%;
  display: grid;
  place-items: center;
  border: 2px solid rgba(255, 255, 255, 0.86);
  box-shadow:
    0 3px 8px rgba(0, 0, 0, 0.8),
    inset 0 0 0 2px rgba(0, 0, 0, 0.22);
  font-size: clamp(9px, 1.7vw, 17px);
  font-weight: 900;
  letter-spacing: 0;
}

.piece.token-piece {
  width: 88%;
  height: 88%;
  border: 0;
  border-radius: 9%;
  background: transparent;
  box-shadow: none;
  overflow: visible;
}

.piece.token-piece .piece-id {
  display: none;
}

.piece-id {
  position: absolute;
  left: 50%;
  bottom: 8%;
  transform: translateX(-50%);
  color: rgba(255, 255, 255, 0.72);
  font-size: clamp(5px, 0.9vw, 8px);
  line-height: 1;
}

.piece.self {
  background: #2d86d4;
}

.piece.enemy {
  background: #b34c5b;
}

.piece.token-piece.self,
.piece.token-piece.enemy {
  background: transparent;
}

.piece.concealed {
  background: #555d69;
}

.piece.token-piece.concealed {
  background: transparent;
}

.piece.setup-draggable {
  cursor: grab;
}

.piece.setup-draggable:active {
  cursor: grabbing;
  filter: drop-shadow(0 0 5px rgba(255, 233, 74, 0.72));
}

.piece.captured,
.piece.exited {
  opacity: 0.38;
}

.piece-skill-stack {
  position: absolute;
  z-index: 7;
  right: -9%;
  bottom: -9%;
  display: flex;
  align-items: flex-end;
  pointer-events: none;
}

.skill-buff-card {
  display: grid;
  place-items: center;
  width: 42%;
  min-width: 18px;
  aspect-ratio: 1;
  border: 1px solid rgba(255, 255, 255, 0.88);
  border-radius: 3px;
  background: #161a24;
  color: #fff;
  font-family: var(--mono);
  font-size: 7px;
  font-weight: 900;
  line-height: 1;
  object-fit: contain;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.72);
  transform: translate(calc(var(--stack-index) * -28%), calc(var(--stack-index) * 4%));
}

.marker {
  position: absolute;
  z-index: 3;
  right: 4px;
  top: 4px;
  color: var(--cyan);
  font-size: 13px;
}

.wall-card {
  position: relative;
  z-index: 4;
  display: block;
  width: 86%;
  height: 86%;
  object-fit: contain;
  user-select: none;
  -webkit-user-drag: none;
  pointer-events: auto;
  filter:
    drop-shadow(0 2px 3px rgba(0, 0, 0, 0.76))
    drop-shadow(0 0 6px rgba(73, 213, 208, 0.28));
}

.wall-card-draggable {
  cursor: grab;
  -webkit-user-drag: element;
}

.wall-card-draggable:active {
  cursor: grabbing;
  filter:
    drop-shadow(0 2px 3px rgba(0, 0, 0, 0.76))
    drop-shadow(0 0 8px rgba(255, 233, 74, 0.78));
}

.status-text {
  min-height: 24px;
  margin-top: 10px;
  color: var(--muted);
  font-size: 13px;
}

.tutorial-panel {
  display: grid;
  gap: 10px;
  margin-top: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #141821;
  padding: 12px;
}

.tutorial-panel p {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.button-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.button-row .secondary-button,
.button-row .primary-button,
.button-row .ghost-button {
  width: 100%;
}

.hidden {
  display: none !important;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(4, 7, 12, 0.76);
  backdrop-filter: blur(3px);
}

.modal-card {
  display: grid;
  gap: 14px;
  width: min(100%, 460px);
  border: 1px solid rgba(73, 213, 208, 0.42);
  border-radius: 8px;
  background: #171b24;
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.48);
  padding: 18px;
}

.modal-card strong {
  font-size: 20px;
}

.modal-card p {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.6;
}

.match-confirm-card {
  width: min(100%, 380px);
  text-align: center;
}

.match-confirm-countdown {
  min-height: 64px;
  color: #ff4157;
  font-family: "Consolas", monospace;
  font-size: 48px;
  font-weight: 800;
  line-height: 1;
  text-shadow: 0 0 8px rgba(255, 44, 72, 0.85);
}

.action-group {
  display: grid;
  gap: 8px;
}

.piece-palette {
  position: absolute;
  inset: 0;
  display: block;
  height: 100%;
}

.palette-piece {
  position: absolute;
  top: var(--reserve-self-y);
  width: var(--reserve-slot-width);
  height: var(--reserve-slot-height);
  min-width: 0;
  min-height: 0;
  aspect-ratio: 88 / 130;
  background: transparent;
  border: 0;
  padding: 0;
  border-radius: 0;
  font-size: clamp(9px, 1.1vw, 12px);
  pointer-events: auto;
  appearance: none;
}

.palette-piece.active {
  outline: 0;
  filter: drop-shadow(0 0 5px rgba(255, 233, 74, 0.82));
}

.palette-piece:focus,
.palette-piece:focus-visible {
  outline: 0;
}

.palette-piece.empty-slot {
  border-color: transparent;
  background: transparent;
}

.board-reserve-dock .reserve-slot:nth-child(1) {
  left: var(--reserve-x-1);
}

.board-reserve-dock .reserve-slot:nth-child(2) {
  left: var(--reserve-x-2);
}

.board-reserve-dock .reserve-slot:nth-child(3) {
  left: var(--reserve-x-3);
}

.board-reserve-dock .reserve-slot:nth-child(4) {
  left: var(--reserve-x-4);
}

.board-reserve-dock .reserve-slot:nth-child(5) {
  left: var(--reserve-x-5);
}

.board-reserve-dock .reserve-slot:nth-child(6) {
  left: var(--reserve-x-6);
}

.board-reserve-dock .reserve-slot:nth-child(7) {
  left: var(--reserve-x-7);
}

.board-reserve-dock .reserve-slot:nth-child(8) {
  left: var(--reserve-x-8);
}

.board-opponent-reserve-dock > .reserve-slot {
  top: var(--reserve-enemy-y);
}

.piece-palette > .reserve-slot {
  top: var(--reserve-self-y);
}

.reserve-slot {
  position: absolute;
  display: grid;
  place-items: center;
  line-height: 1;
  overflow: hidden;
  box-sizing: border-box;
}

.reserve-slot.self {
  border-color: transparent;
}

.reserve-slot.enemy {
  border-color: transparent;
}

.reserve-slot.returned {
  border-style: none;
  background: transparent;
}

.reserve-slot.returned strong {
  color: #f7fbff;
  font-size: clamp(9px, 1.05vw, 12px);
}

.reserve-slot .reserve-status {
  position: absolute;
  right: 3px;
  bottom: 2px;
  color: rgba(255, 233, 74, 0.84);
  font-size: clamp(6px, 0.78vw, 8px);
  font-weight: 900;
}

.reserve-slot.returned.captured {
  box-shadow: inset 0 0 10px rgba(255, 81, 96, 0.22);
}

.reserve-slot.returned.exited {
  box-shadow: inset 0 0 10px rgba(73, 213, 208, 0.28);
}

.reserve-slot.concealed strong {
  color: rgba(235, 243, 255, 0.7);
}

.unknown-token {
  display: grid;
  place-items: center;
  width: 78%;
  height: 78%;
  border: 2px solid rgba(220, 226, 235, 0.86);
  border-radius: 10%;
  background: #555d69;
  color: #f7fbff;
  font-size: clamp(13px, 2vw, 22px);
}

.board-token-image {
  display: block;
  width: 100%;
  height: 100%;
  overflow: visible;
  filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.72));
  object-fit: fill;
  user-select: none;
  -webkit-user-drag: none;
}

.board-piece-token {
  aspect-ratio: 1;
}

.reserve-token {
  aspect-ratio: 88 / 130;
}

.board-opponent-reserve-dock .reserve-token {
  transform: rotate(180deg);
}

.skill-modal-card {
  width: min(100%, 760px);
}

.skill-card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(118px, 1fr));
  gap: 10px;
}

.skill-card {
  display: grid;
  gap: 7px;
  min-height: 106px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #141923;
  padding: 12px;
  text-align: left;
}

.skill-card.image-skill-card {
  place-items: center;
  min-height: 0;
  aspect-ratio: 1;
  border-color: rgba(255, 255, 255, 0.16);
  background: transparent;
  padding: 0;
  overflow: hidden;
}

.skill-card-image {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  user-select: none;
  -webkit-user-drag: none;
}

.skill-card.image-skill-card:disabled .skill-card-image {
  filter: grayscale(0.75) brightness(0.56);
  opacity: 0.58;
}

.skill-card strong {
  color: var(--cyan);
  font-size: 18px;
}

.skill-card span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.skill-card.selected {
  border-color: var(--yellow);
  box-shadow:
    inset 0 0 0 1px rgba(245, 202, 86, 0.38),
    0 0 18px rgba(245, 202, 86, 0.18);
}

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

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

.skill-grid label {
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 32px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel-2);
  padding: 0 8px;
  font-size: 13px;
}

.skill-grid input {
  width: auto;
  height: auto;
}

.selection-box {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #12151b;
  padding: 9px;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.compact-box {
  min-height: 32px;
  padding: 7px 9px;
  font-size: 12px;
}

.hint-box {
  min-height: 36px;
  border-color: rgba(73, 213, 208, 0.45);
  color: var(--cyan);
  font-size: 12px;
}

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

.action-button.active {
  border-color: var(--cyan);
  color: var(--cyan);
  box-shadow: inset 0 0 0 1px rgba(73, 213, 208, 0.45);
}

.log {
  min-height: 140px;
  max-height: 220px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #12151b;
  padding: 8px;
  color: var(--muted);
  font-size: 12px;
}

.log div + div {
  margin-top: 6px;
}

@media (max-width: 1120px) {
  .menu-grid {
    grid-template-columns: 1fr;
  }

  .layout {
    grid-template-columns: 1fr;
  }

  .board {
    width: 100%;
  }

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

  .tournament-admin-form {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

  .ranked-overview > div:nth-child(2) {
    border-right: 0;
  }

  .ranked-queue-row {
    grid-template-columns: auto 1fr;
  }

  .ranked-queue-actions {
    grid-column: 1 / -1;
  }
}

@media (max-width: 640px) {
  .app-shell {
    padding: 10px;
  }

  .topbar,
  .topbar-actions {
    align-items: stretch;
    flex-direction: column;
  }

  body[data-screen="menu"] .topbar {
    align-items: flex-start;
    flex-direction: row;
    gap: 8px;
    left: 10px;
    right: 10px;
    top: 10px;
  }

  body[data-screen="menu"] .topbar-actions {
    align-items: center;
    flex-direction: row;
    gap: 4px;
    padding: 4px;
  }

  body[data-screen="menu"] .account-id-button {
    padding: 0 6px;
    font-size: 10px;
  }

  body[data-screen="menu"] .account-nickname {
    max-width: 72px;
  }

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

  .menu-actions,
  .room-slots,
  .button-row,
  .room-buttons {
    grid-template-columns: 1fr;
  }

  .tournament-header,
  .tournament-band-heading,
  .spectator-panel-heading {
    align-items: stretch;
    flex-direction: column;
  }

  .tournament-header h1 {
    font-size: 26px;
  }

  .tournament-queue-grid,
  .tournament-admin-form,
  .admin-tournament-whitelist-form {
    grid-template-columns: 1fr;
  }

  .admin-tournament-heading,
  .admin-tournament-whitelist > div {
    align-items: stretch;
    flex-direction: column;
  }

  .tournament-header-actions,
  .tournament-inline-actions {
    justify-content: stretch;
  }

  .tournament-header-actions button,
  .tournament-inline-actions button {
    flex: 1;
  }

  .tournament-queue-grid,
  .spectator-event-log {
    grid-template-columns: 1fr;
  }

  .tournament-list-row {
    grid-template-columns: 1fr auto;
  }

  .tournament-list-row span {
    grid-column: 1;
  }

  .tournament-list-row button {
    grid-column: 2;
    grid-row: 1 / span 3;
  }

  .ranked-overview {
    grid-template-columns: 1fr;
  }

  .ranked-settlement-grid,
  .ranked-history-row,
  .ranked-history-splits,
  .admin-ops-grid,
  #adminPenaltySearchForm {
    grid-template-columns: 1fr;
  }

  .ranked-overview > div,
  .ranked-overview > div:nth-child(2) {
    min-height: 66px;
    border-right: 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.07);
  }

  .ranked-overview > div:last-child {
    border-bottom: 0;
  }

  .ranked-queue-row {
    grid-template-columns: 1fr;
  }

  .ranked-leaderboard-row {
    grid-template-columns: 34px minmax(0, 1fr) 70px;
  }

  .ranked-leaderboard-row span:last-child {
    display: none;
  }

  .board-stage {
    grid-template-columns: minmax(0, 1fr) 44px;
    gap: 4px;
  }

  .skill-rail {
    gap: 4px;
  }

  .skill-rail-label {
    font-size: 24px;
  }

  .skill-dock {
    padding: 0;
    gap: 0;
  }

  .skill-dock-cards {
    gap: 2px;
  }

  .skill-dock-title {
    display: none;
  }

  .skill-dock-drop-hint {
    display: none;
  }
}
.oauth-callback-page {
  min-height: 100vh;
}

.oauth-callback-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.oauth-callback-card {
  width: min(420px, 100%);
  text-align: center;
}
