/* Light theme (default) */
:root,
[data-theme="light"] {
  --bg: #ffffff;
  --surface: #ffffff;
  --surface-2: #f5f5f5;
  --text: #111111;
  --muted: #555555;
  --accent: #111111;
  --accent-hover: #333333;
  --accent-contrast: #ffffff;
  --win: #1b7a1b;
  --lose: #c62828;
  --warn: #f97316;
  --border: #111111;
  --move-hover-bg: #ebebeb;
  --timer-fill: #111111;
  --elo-arrow-fill: #e4e4e4;
  --radius: 16px;
  --font: "Segoe UI", system-ui, -apple-system, sans-serif;
}

/* Dark theme */
[data-theme="dark"] {
  --bg: #262626;
  --surface: #2e2e2e;
  --surface-2: #383838;
  --text: #f5f5f5;
  --muted: #b0b0b0;
  --accent: #e8e8e8;
  --accent-hover: #ffffff;
  --accent-contrast: #262626;
  --win: #6ecf6e;
  --lose: #f07070;
  --warn: #ff9800;
  --border: #505050;
  --move-hover-bg: #454545;
  --timer-fill: #f5f5f5;
  --elo-arrow-fill: #454545;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

@media (min-width: 641px) {
  html {
    zoom: 0.9;
  }
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  font-family: var(--font);
  font-size: 15px;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  overflow-x: hidden;
  transition: background 0.2s, color 0.2s;
  -webkit-text-size-adjust: 100%;
}

.site-header {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
  padding: 1.25rem 2rem;
  padding-left: max(1.25rem, env(safe-area-inset-left));
  padding-right: max(1.25rem, env(safe-area-inset-right));
  background: var(--move-hover-bg);
}

.mode-toggle-wrap {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
  z-index: 2;
}

.mode-toggle-wrap.hidden {
  display: none;
}

.mode-toggle-label {
  font-size: 0.9rem;
  font-weight: 600;
  text-transform: lowercase;
  color: var(--muted);
  letter-spacing: 0.05em;
  line-height: 1;
}

.mode-toggle-track {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 6.5rem;
  height: 2.85rem;
  padding: 0 0.3rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  cursor: pointer;
  transition: border-color 0.15s;
}

.mode-toggle-track:hover {
  border-color: var(--accent);
}

.mode-toggle-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.1rem;
  height: 2.1rem;
  z-index: 1;
  pointer-events: none;
}

.mode-toggle-icon img {
  width: 1.75rem;
  height: 1.75rem;
  object-fit: contain;
}

.mode-toggle-thumb {
  position: absolute;
  top: 50%;
  left: 0.24rem;
  width: 2.3rem;
  height: 2.3rem;
  border-radius: 50%;
  background: var(--accent);
  transform: translateY(-50%);
  transition: left 0.2s ease;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.22);
}

[data-lol-mode] .mode-toggle-thumb {
  left: calc(100% - 2.3rem - 0.24rem);
}

.header-nav {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.home-link,
.nav-link {
  text-decoration: none;
}

.home-link {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.5rem 0.75rem;
  border-radius: 10px;
  background: var(--surface);
  transition: background 0.15s;
}

.home-link:hover {
  background: var(--surface-2);
}

.nav-link {
  display: inline-block;
  padding: 0.6rem 1.1rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--text);
  font-size: 1.05rem;
  font-weight: 600;
  transition: background 0.15s, border-color 0.15s;
}

.nav-link:hover {
  background: var(--move-hover-bg);
}

.nav-link.active {
  background: var(--accent);
  color: var(--accent-contrast);
  border-color: var(--accent);
}

.header-nav-links {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  flex-shrink: 0;
}

.active-players {
  color: var(--muted);
  font-size: 0.95rem;
  font-weight: 500;
  white-space: nowrap;
}

.brand-icon {
  width: 3.25rem;
  height: 3.25rem;
  display: block;
  object-fit: contain;
  flex-shrink: 0;
  background: transparent;
}

.home-title {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--text);
}

.brand-tld {
  font-weight: 400;
  color: var(--muted);
}

.player-bar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 1rem;
}

.player-account-btn {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin: 0;
  padding: 0.2rem 0.2rem 0.2rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: transparent;
  color: inherit;
  font: inherit;
  cursor: pointer;
  max-width: 100%;
  min-width: 0;
  transition: background 0.15s, border-color 0.15s;
}

.player-account-btn:hover {
  background: var(--surface-2);
}

.player-account-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.player-label {
  color: var(--muted);
  font-size: 1.05rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 10rem;
}

.rank-icon {
  width: 1.75rem;
  height: 1.75rem;
  object-fit: contain;
  flex-shrink: 0;
  display: block;
  border-radius: 4px;
}

.rank-icon[data-rank-tooltip="1"] {
  cursor: default;
}

.rank-icon-wrap,
.hover-tooltip-host {
  position: relative;
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
  vertical-align: middle;
}

.corner-control.hover-tooltip-host,
.connection-warning.hover-tooltip-host {
  display: flex;
}

.hover-tooltip {
  position: absolute;
  left: 50%;
  bottom: calc(100% + 8px);
  transform: translateX(-50%);
  z-index: 400;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
  padding: 0.55rem 0.7rem 0.45rem;
  font-size: 0.8rem;
  font-weight: 600;
  line-height: 1.2;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.12);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.12s ease, visibility 0.12s ease;
  white-space: nowrap;
}

.hover-tooltip-icon {
  width: 3.25rem;
  height: 3.25rem;
  object-fit: contain;
  display: block;
}

.hover-tooltip-label {
  display: block;
}

.rank-icon-wrap:hover .hover-tooltip,
.rank-icon-wrap:focus-within .hover-tooltip,
.hover-tooltip-host:hover .hover-tooltip,
.hover-tooltip-host:focus-within .hover-tooltip {
  opacity: 1;
  visibility: visible;
}

.connection-warning .hover-tooltip {
  left: 0;
  transform: none;
}

.match-corner-identity .rank-icon {
  width: 1.35rem;
  height: 1.35rem;
}

.elo-badge {
  background: var(--surface);
  padding: 0.6rem 1.1rem;
  border-radius: 10px;
  font-weight: 600;
  font-size: 1.05rem;
  color: var(--text);
  flex-shrink: 0;
}

.corner-controls {
  position: fixed;
  right: max(1.5rem, env(safe-area-inset-right));
  bottom: max(1.5rem, env(safe-area-inset-bottom));
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.corner-control {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.75rem;
  height: 2.75rem;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-2);
  cursor: pointer;
  font-size: 1.35rem;
  line-height: 1;
  transition: background 0.15s, transform 0.1s;
}

.corner-control:hover {
  background: var(--move-hover-bg);
}

.corner-control:active {
  transform: scale(0.96);
}

.connection-warning {
  position: fixed;
  left: max(1.5rem, env(safe-area-inset-left));
  bottom: max(1.5rem, env(safe-area-inset-bottom));
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.75rem;
  height: 2.75rem;
  border: 2px solid #ff1f1f;
  border-radius: 999px;
  background: var(--surface-2);
  color: #ff1f1f;
}

.connection-warning svg {
  width: 1.35rem;
  height: 1.35rem;
}

.auth-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  background: rgba(0, 0, 0, 0.45);
}

.auth-overlay.hidden {
  display: none;
}

.auth-dialog {
  width: 100%;
  max-width: 400px;
  padding: 2rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.auth-form label {
  display: block;
  margin-bottom: 1rem;
  font-size: 0.95rem;
  font-weight: 600;
}

.auth-form input {
  display: block;
  width: 100%;
  margin-top: 0.35rem;
  padding: 0.65rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
}

.auth-error {
  margin: 0 0 1rem;
  color: var(--lose);
  font-size: 0.9rem;
}

.auth-error:empty {
  display: none;
}

.auth-honeypot {
  position: absolute;
  left: -10000px;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.auth-submit-banner {
  display: block;
  width: 100%;
  margin-top: 0.25rem;
  padding: 0.85rem 1.25rem;
  font-size: 1.05rem;
  font-weight: 700;
  border-radius: 10px;
}

.auth-switch-mode {
  margin: 0.75rem 0 0;
  font-size: 0.9rem;
  color: var(--muted);
  text-align: center;
}

.auth-guest-note {
  margin: 0 0 0.65rem;
  font-size: 0.75rem;
  color: var(--muted);
  text-align: center;
  line-height: 1.35;
}

.account-modal-name {
  margin: 0 0 0.35rem;
  font-size: 1.35rem;
  font-weight: 700;
  text-align: center;
  word-break: break-word;
}

.account-modal-elo-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  margin: 0 0 1.35rem;
}

.account-modal-rank-icon {
  width: 1.75rem;
  height: 1.75rem;
}

.account-modal-elo {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--muted);
  text-align: center;
}

.auth-switch-mode button {
  padding: 0;
  border: none;
  background: none;
  color: var(--text);
  font: inherit;
  font-weight: 600;
  text-decoration: underline;
  cursor: pointer;
}

.auth-switch-mode button:hover {
  color: var(--accent-hover);
}

.layout {
  max-width: 920px;
  margin: 0 auto;
  padding: 2rem;
  padding-left: max(2rem, env(safe-area-inset-left));
  padding-right: max(2rem, env(safe-area-inset-right));
  padding-bottom: max(2rem, env(safe-area-inset-bottom));
}

.view {
  width: 100%;
}


.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2.5rem;
}

.game-panel h1,
.game-panel h2,
.leaderboard-panel h2,
.rank-panel h2,
.legal-panel h1 {
  margin: 0 0 0.75rem;
  font-size: 1.75rem;
  color: var(--text);
}

.rank-value {
  margin: 0 0 0.5rem;
  font-size: 3.5rem;
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: -0.02em;
  color: var(--text);
}

.rank-meta {
  margin: 0 0 1.5rem;
  font-size: 1.05rem;
  color: var(--muted);
}

.rank-message {
  margin: 0;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border);
  font-size: 1.05rem;
  color: var(--muted);
  line-height: 1.55;
}

.subtitle {
  color: var(--muted);
  margin: 0 0 1.75rem;
  font-size: 1.15rem;
}

.footer-links {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  margin: 2.5rem 0 0;
  padding: 0.25rem 0.5rem;
  color: var(--muted);
  font-size: 0.8125rem;
  font-weight: 500;
  letter-spacing: 0.01em;
  text-align: center;
}

.footer-links a {
  color: inherit;
  text-decoration: none;
  background: none;
  border: none;
}

.footer-links a:hover {
  color: var(--text);
  text-decoration: underline;
}

.footer-links-sep {
  color: var(--muted);
  user-select: none;
}

.legal-panel {
  max-width: 40rem;
  margin: 0 auto;
}

.legal-updated {
  margin: 0 0 1.5rem;
  color: var(--muted);
  font-size: 0.95rem;
}

.legal-panel h2 {
  margin: 1.75rem 0 0.5rem;
  font-size: 1.15rem;
  color: var(--text);
}

.legal-panel p,
.legal-panel li {
  margin: 0 0 0.85rem;
  color: var(--text);
  line-height: 1.6;
}

.legal-panel ul {
  margin: 0 0 0.85rem;
  padding-left: 1.25rem;
}

.legal-panel a {
  color: var(--text);
  text-decoration: underline;
}

.legal-panel a:hover {
  color: var(--accent-hover);
}

.info-panel {
  max-width: 36rem;
}

.home-ranks-panel {
  margin-top: 1.5rem;
  max-width: 36rem;
  margin-left: auto;
  margin-right: auto;
  text-align: center;
}

.home-ranks-panel h2 {
  margin: 0 0 1rem;
  font-size: 1.35rem;
  color: var(--text);
}

.info-rank-list {
  list-style: none;
  margin: 0 0 0.5rem;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.home-ranks-panel .info-rank-list {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 1.25rem 1.5rem;
}

.home-ranks-panel .info-rank-item:nth-child(-n + 9):nth-child(3n + 1) {
  grid-column: 1 / 3;
}

.home-ranks-panel .info-rank-item:nth-child(-n + 9):nth-child(3n + 2) {
  grid-column: 3 / 5;
}

.home-ranks-panel .info-rank-item:nth-child(-n + 9):nth-child(3n) {
  grid-column: 5 / 7;
}

.home-ranks-panel .info-rank-item:nth-last-child(2) {
  grid-column: 2 / 4;
  justify-self: center;
}

.home-ranks-panel .info-rank-item:nth-last-child(1) {
  grid-column: 4 / 6;
  justify-self: center;
}

.home-ranks-panel .info-rank-item {
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
  padding: 0;
  text-align: center;
}

.home-ranks-panel .info-rank-icon {
  width: 3.5rem;
  height: 3.5rem;
}

.home-ranks-panel .info-rank-text {
  align-items: center;
}

.home-ranks-panel .info-rank-name {
  font-size: 0.95rem;
}

.home-ranks-panel .info-rank-elo {
  font-size: 0.8rem;
}

.info-rank-item {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin: 0;
  padding: 0.35rem 0;
}

.info-rank-icon {
  width: 4rem;
  height: 4rem;
  flex-shrink: 0;
  object-fit: contain;
}

.info-rank-text {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  min-width: 0;
}

.info-rank-name {
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--text);
  line-height: 1.2;
}

.info-rank-elo {
  font-size: 0.95rem;
  color: var(--muted);
  line-height: 1.3;
}

.debug-play {
  display: flex;
  gap: 0.75rem;
  justify-content: center;
  margin-top: 1rem;
}

.debug-sound-test {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: center;
  margin-top: 1rem;
  max-width: 36rem;
  margin-left: auto;
  margin-right: auto;
}

.debug-sound-test .btn {
  font-size: 0.875rem;
  padding: 0.4rem 0.65rem;
}

.debug-play.hidden {
  display: none;
}

.hint {
  margin-top: 1.25rem;
  font-size: 1rem;
  color: var(--muted);
}

.hidden {
  display: none !important;
}

.btn {
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-family: inherit;
  font-weight: 600;
  transition: background 0.15s, transform 0.1s;
}

.btn:active {
  transform: scale(0.98);
}

.btn-primary {
  background: var(--accent);
  color: var(--accent-contrast);
  border: 1px solid var(--border);
}

.btn-primary:hover:not(:disabled) {
  background: var(--accent-hover);
}

.btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-secondary {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 0.85rem 1.75rem;
  font-size: 1.05rem;
}


.game-panel#game-panel {
  position: relative;
  height: 530px;
  min-height: 530px;
  max-height: 530px;
  box-sizing: border-box;
  padding: 1.75rem 2.5rem 1.25rem;
  display: flex;
  flex-direction: column;
}

.game-panel#game-panel > .timer-pie {
  position: absolute;
  top: 1.25rem;
  right: 2rem;
  z-index: 3;
  width: 52px;
  height: 52px;
}

.play-box-brand {
  position: absolute;
  right: 1rem;
  bottom: 0.45rem;
  z-index: 2;
  font-size: 0.625rem;
  letter-spacing: 0.04em;
  color: var(--muted);
  opacity: 0.55;
  pointer-events: none;
  user-select: none;
}

.game-body {
  flex: 1;
  min-height: 0;
  margin-bottom: 0.25rem;
  overflow: visible;
}

.match-arena {
  position: relative;
  width: 100%;
  height: 100%;
}

.match-corner {
  position: absolute;
  left: 0;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.25rem;
  max-width: calc(100% - 1rem);
}

.match-corner-opponent {
  top: 0;
}

.match-corner-player {
  bottom: 0;
}

.match-center {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  overflow: visible;
  padding: 0.5rem 0.75rem;
  box-sizing: border-box;
}

.play-stage {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.match-end-stage {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: stretch;
  justify-content: center;
}

.match-end-top-spacer {
  flex: none;
  width: 100%;
  min-height: 5rem;
}

.vs-divider.match-end-spacer {
  flex: 1;
  align-items: flex-start;
  min-height: 3.5rem;
  padding: 1.25rem 0 1.5rem;
}

.match-end-stage.hidden {
  display: none;
}

.match-stack {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  height: 100%;
  overflow: visible;
}

.match-play-column {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  width: fit-content;
  max-width: 100%;
  height: 100%;
  overflow: visible;
}

.opponent-zone {
  display: flex;
  justify-content: center;
  width: 100%;
}

.opponent-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  padding: 1.5rem 1.75rem;
  min-width: 140px;
  box-sizing: border-box;
  background: var(--surface-2);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  transition: border-color 0.25s, box-shadow 0.25s, opacity 0.25s;
}

.opponent-box-label {
  font-size: 1.05rem;
  font-weight: 400;
  color: var(--text);
}

.opponent-panel.opponent-unrevealed .opponent-box {
  opacity: 0.4;
}

.opponent-box-content {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 3.25rem;
}

.opponent-status {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 3.25rem;
  line-height: 1;
  min-height: 3.25rem;
}

.opponent-status-waiting {
  color: var(--muted);
  letter-spacing: 0.12em;
  animation: reveal-waiting-pulse 1.1s ease-in-out infinite;
}

.opponent-status-picked {
  color: var(--muted);
  font-weight: 700;
}

@keyframes reveal-waiting-pulse {
  0%,
  100% {
    opacity: 0.35;
  }
  50% {
    opacity: 0.85;
  }
}

.player-zone {
  width: 100%;
}

.vs-divider {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  align-self: center;
  text-align: center;
  width: 100%;
  min-height: 3.5rem;
  padding: 1.5rem 0;
  font-weight: 800;
  color: var(--muted);
  font-size: 1.15rem;
  line-height: 1;
}

.match-end-actions {
  display: flex;
  justify-content: center;
  width: 100%;
}

.match-end-actions .btn-secondary {
  min-width: 10rem;
  padding: 0.85rem 2.5rem;
}

.match-corner .win-dots {
  justify-content: flex-start;
}

.match-corner-identity {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  min-width: 0;
  max-width: 100%;
}

.match-corner-name {
  display: block;
  font-size: 1.1rem;
  font-weight: 400;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
  max-width: 100%;
}

.btn-secondary:hover {
  background: var(--move-hover-bg);
}

.btn-lg {
  padding: 1.1rem 2.75rem;
  font-size: 1.25rem;
}

.lobby-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.85rem;
  align-items: center;
}

.lobby-actions .btn {
  line-height: 1.2;
  flex: 0 0 auto;
  width: auto;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.lobby-actions .btn-primary {
  padding: 1.1rem 2.75rem;
  font-size: 1.25rem;
}

.lobby-actions .btn-secondary {
  padding: 1.1rem 1.15rem;
  font-size: 1.05rem;
}

.win-dots {
  display: flex;
  justify-content: flex-start;
  gap: 0.75rem;
}

.dot {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 2px solid var(--border);
  background: transparent;
  transition: background 0.25s, border-color 0.25s;
}

.dot.won {
  background: var(--win);
  border-color: var(--win);
}

.elo-reward-display {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 360px;
  height: 239px;
}

.elo-arrow-shape {
  position: relative;
  width: 360px;
  height: 239px;
}

.elo-arrow-icon {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

.elo-arrow-path {
  fill: var(--elo-arrow-fill);
}

.elo-change-hero {
  position: absolute;
  left: 47%;
  top: 50%;
  z-index: 1;
  /* Previous: Herculanum, "Herculanum Regular", fantasy; */
  font-family: Helvetica, "Helvetica Neue", Arial, sans-serif;
  font-size: 3.75rem;
  font-weight: 400;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.03em;
  transform: translate(-50%, -50%);
}

.elo-reward-display.win .elo-change-hero {
  color: var(--win);
  top: 37%;
}

.elo-reward-display.lose .elo-change-hero {
  color: var(--lose);
  left: 49%;
  top: 59%;
}

.elo-tie-shape {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 360px;
  height: 239px;
  background: var(--elo-arrow-fill);
  border-radius: var(--radius);
}

.elo-tie-label {
  /* Previous: Herculanum, "Herculanum Regular", fantasy; */
  font-family: Helvetica, "Helvetica Neue", Arial, sans-serif;
  font-size: 3.75rem;
  font-weight: 400;
  line-height: 1;
  letter-spacing: -0.03em;
  color: var(--text);
}

.timer-pie {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  border: 2px solid var(--border);
  background: conic-gradient(
    var(--bg) 0deg calc(var(--timer-elapsed, 0) * 360deg),
    var(--timer-fill) calc(var(--timer-elapsed, 0) * 360deg) 360deg
  );
}

.timer-pie.timer-empty {
  background: var(--bg);
}

.opponent-panel.round-resolved .opponent-box {
  opacity: 1;
  border-color: var(--text);
  background: var(--move-hover-bg);
}

.opponent-panel.round-win .opponent-box {
  border-color: var(--win);
  box-shadow: inset 0 0 0 3px var(--win);
}

.opponent-panel.round-lose .opponent-box {
  border-color: var(--lose);
  box-shadow: inset 0 0 0 3px var(--lose);
}

.opponent-panel.round-tie .opponent-box {
  border-color: var(--warn);
  box-shadow: inset 0 0 0 3px var(--warn);
}

.opponent-reveal {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 3.25rem;
  line-height: 1;
  min-height: 3.25rem;
}

@media (prefers-reduced-motion: reduce) {
  .opponent-status-waiting {
    animation: none;
  }
}

.result-message {
  text-align: center;
  min-height: 1.75rem;
  margin: 0 0 0.45rem;
  font-size: 1.15rem;
}

.result-message:empty {
  min-height: 0;
  margin: 0;
}

.result-message.win {
  color: var(--win);
}

.result-message.lose {
  color: var(--lose);
}

.result-message.tie {
  color: var(--warn);
}

.result-message.waiting {
  color: var(--muted);
  font-style: italic;
}

.search-status {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  margin-top: 1rem;
}

.search-message {
  margin: 0;
  font-size: 1.1rem;
  color: var(--muted);
}

.search-bad-connection {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 700;
  color: #ff1f1f;
}

.moves {
  display: flex;
  gap: 1.25rem;
  justify-content: center;
  flex-wrap: nowrap;
  overflow: visible;
  padding: 0.5rem;
  margin: -0.5rem;
}

.move-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  padding: 1.5rem 1.75rem;
  min-width: 140px;
  box-sizing: border-box;
  background: var(--surface-2);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  cursor: pointer;
  font-family: inherit;
  font-size: 1.05rem;
  transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
  -webkit-tap-highlight-color: transparent;
  outline: none;
}

.move-btn:focus-visible {
  border-color: var(--text);
  box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--text);
}

@media (hover: hover) and (pointer: fine) {
  .move-btn:hover:not(:disabled) {
    border-color: var(--text);
    background: var(--move-hover-bg);
  }
}

.move-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.move-btn.move-picked:disabled {
  opacity: 1;
}

.move-btn.move-picked {
  position: relative;
  z-index: 2;
  animation: move-picked 0.35s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
  border-color: var(--text);
  background: var(--move-hover-bg);
}

.move-btn.round-win {
  border-color: var(--win);
  box-shadow: inset 0 0 0 3px var(--win);
  opacity: 1;
}

.move-btn.round-lose {
  border-color: var(--lose);
  box-shadow: inset 0 0 0 3px var(--lose);
  opacity: 1;
}

.move-btn.round-tie {
  border-color: var(--warn);
  box-shadow: inset 0 0 0 3px var(--warn);
  opacity: 1;
}

@keyframes move-picked {
  0% {
    transform: scale(1);
  }
  45% {
    transform: scale(1.08);
  }
  100% {
    transform: scale(1);
  }
}

@media (prefers-reduced-motion: reduce) {
  .move-btn.move-picked {
    animation: none;
    transform: none;
  }
}

.move-emoji {
  font-size: 3.25rem;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

.move-icon-img {
  width: 4.25rem;
  height: 4.25rem;
  object-fit: contain;
}

.opponent-reveal .move-icon-img {
  width: 4.25rem;
  height: 4.25rem;
  object-fit: contain;
}

.leaderboard-list {
  margin: 0;
  padding-left: 1.5rem;
}

.leaderboard-list li {
  padding: 0.6rem 0;
  font-size: 1.15rem;
}

.leaderboard-list .rank-icon-wrap {
  vertical-align: -0.25em;
  margin-right: 0.35rem;
}

.leaderboard-list .leaderboard-rank-icon {
  width: 1.35rem;
  height: 1.35rem;
  display: block;
}

.leaderboard-list .leaderboard-name {
  min-width: 0;
}

.leaderboard-list li.empty {
  list-style: none;
  padding-left: 0;
  color: var(--muted);
}

.leaderboard-list .elo-meta {
  color: var(--muted);
  font-weight: 400;
}

.tags-table-wrap {
  overflow-x: auto;
}

.tags-table {
  width: 100%;
  table-layout: fixed;
  border-collapse: collapse;
  font-size: 1rem;
}

.tags-table thead th {
  text-align: left;
  padding: 0.6rem 0.75rem;
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
}

.tags-table tbody tr {
  border-bottom: 1px solid var(--border);
}

.tags-table tbody tr:nth-child(even) {
  background: var(--surface-2);
}

.tags-table td {
  padding: 0.6rem 0.75rem;
  vertical-align: middle;
}

.tags-table tr.empty td {
  color: var(--muted);
  text-align: center;
}

.tags-col-rank,
.tags-cell-rank {
  color: var(--muted);
  width: 4rem;
}

.tags-col-tag,
.tags-cell-tag {
  font-weight: 600;
  color: var(--text);
  width: auto;
}

.tags-hash {
  color: var(--muted);
  font-weight: 400;
  margin-right: 0.1rem;
}

.tags-col-count,
.tags-cell-count {
  width: 8rem;
  text-align: right;
}

.tags-table thead th.tags-col-count {
  text-align: right;
  padding-right: 0;
}

.tags-cell-count {
  color: var(--muted);
}

.tags-search {
  display: block;
  width: 100%;
  margin: 0.5rem 0 1.25rem;
  padding: 0.6rem 0.85rem;
  font-size: 1rem;
  color: var(--text);
  background: var(--surface-2, var(--surface));
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.tags-search:focus {
  outline: none;
  border-color: var(--accent);
}

.leaderboard-sentinel {
  height: 1px;
}

.leaderboard-status {
  margin: 1rem 0 0;
  text-align: center;
  font-size: 1rem;
  color: var(--muted);
}

.round-history {
  margin-top: 1.75rem;
  overflow-x: auto;
  max-width: 100%;
  padding: 0.25rem 0;
}

.round-history-track {
  position: relative;
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  width: fit-content;
}

.round-history-track::before {
  content: "";
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 3rem;
  background: var(--surface-2);
  border-radius: 8px;
  z-index: 0;
  pointer-events: none;
}

.history-turn {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.6rem;
  flex-shrink: 0;
  padding: 0 0.65rem;
  border-right: 1px solid transparent;
}

[data-theme="light"] .history-turn {
  border-right-color: rgba(0, 0, 0, 0.16);
}

[data-theme="dark"] .history-turn {
  border-right-color: rgba(255, 255, 255, 0.18);
}

.history-turn:first-child {
  padding-left: 0;
}

.history-turn:last-child {
  border-right: none;
  padding-right: 0;
}

.history-emoji {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 3rem;
  height: 3rem;
  border-radius: 50%;
  border: 4px solid var(--border);
  font-size: 1.5rem;
  line-height: 1;
  overflow: hidden;
}

.history-move-img {
  width: 145%;
  height: 145%;
  object-fit: cover;
  object-position: center;
}

.history-emoji.round-win {
  border-color: var(--win);
}

.history-emoji.round-lose {
  border-color: var(--lose);
}

.history-emoji.round-tie {
  border-color: #d0d0d0;
}

[data-theme="dark"] .history-emoji.round-tie {
  border-color: #666666;
}

/* Mobile — must stay after base rules so overrides win */
@media (max-width: 640px) {
  body {
    font-size: 13px;
  }

  .site-header {
    flex-direction: column;
    align-items: stretch;
    gap: 0.4rem;
    padding: 0.5rem 0.65rem;
    padding-left: max(0.65rem, env(safe-area-inset-left));
    padding-right: max(0.65rem, env(safe-area-inset-right));
  }

  .header-nav {
    gap: 0.35rem;
    width: 100%;
    justify-content: space-between;
  }

  .home-link {
    gap: 0.35rem;
    padding: 0.25rem 0.4rem;
    min-width: 0;
    flex: 1;
  }

  .home-title {
    font-size: 0.9rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .brand-tld {
    display: none;
  }

  .brand-icon {
    width: 1.75rem;
    height: 1.75rem;
    flex-shrink: 0;
  }

  .nav-link {
    padding: 0.4rem 0.55rem;
    font-size: 0.8rem;
    flex-shrink: 0;
  }

  .header-nav-links {
    gap: 0.45rem;
  }

  .active-players {
    font-size: 0.7rem;
  }

  .mode-toggle-wrap {
    display: none !important;
  }

  .player-bar {
    width: 100%;
    justify-content: flex-end;
    gap: 0.35rem;
  }

  .player-account-btn {
    gap: 0.45rem;
    padding: 0.12rem 0.12rem 0.12rem 0.55rem;
    border-radius: 10px;
  }

  .player-label {
    max-width: 8rem;
    font-size: 0.85rem;
  }

  .rank-icon {
    width: 1.35rem;
    height: 1.35rem;
  }

  .elo-badge {
    padding: 0.35rem 0.55rem;
    font-size: 0.85rem;
  }

  .layout {
    padding: 0.6rem;
    padding-left: max(0.6rem, env(safe-area-inset-left));
    padding-right: max(0.6rem, env(safe-area-inset-right));
    padding-bottom: max(0.6rem, env(safe-area-inset-bottom));
  }

  .footer-links {
    margin-top: 1.75rem;
  }

  .panel {
    padding: 0.85rem;
  }

  .game-panel h1,
  .game-panel h2,
  .leaderboard-panel h2,
  .rank-panel h2,
  .legal-panel h1,
  .home-ranks-panel h2 {
    font-size: 1.2rem;
    margin-bottom: 0.4rem;
  }

  .home-ranks-panel {
    margin-top: 0.85rem;
  }

  .home-ranks-panel .info-rank-list {
    gap: 0.85rem 0.65rem;
  }

  .home-ranks-panel .info-rank-icon {
    width: 2.75rem;
    height: 2.75rem;
  }

  .home-ranks-panel .info-rank-name {
    font-size: 0.8rem;
  }

  .home-ranks-panel .info-rank-elo {
    font-size: 0.7rem;
  }

  .rank-value {
    font-size: 2.5rem;
  }

  .rank-meta,
  .rank-message,
  .legal-updated,
  .legal-panel p,
  .legal-panel li {
    font-size: 0.9rem;
  }

  .info-rank-icon {
    width: 3.25rem;
    height: 3.25rem;
  }

  .info-rank-name {
    font-size: 1.05rem;
  }

  .info-rank-elo {
    font-size: 0.85rem;
  }

  .subtitle {
    font-size: 0.9rem;
    margin-bottom: 0.85rem;
  }

  .btn-lg {
    display: block;
    width: 100%;
    padding: 0.85rem 1rem;
    font-size: 1rem;
  }

  .lobby-actions {
    flex-direction: row;
  }

  .btn-secondary {
    padding: 0.65rem 1.25rem;
    font-size: 0.95rem;
  }

  .lobby-actions .btn-primary {
    padding: 0.85rem 1rem;
    font-size: 1rem;
  }

  .lobby-actions .btn-secondary {
    padding: 0.85rem 0.75rem;
    font-size: 0.9rem;
  }

  .debug-play {
    flex-direction: column;
  }

  .debug-play .btn,
  .debug-sound-test .btn {
    width: 100%;
  }

  .game-panel#game-panel {
    height: auto;
    min-height: 0;
    max-height: none;
    padding: 0.65rem 0.65rem 0.75rem;
  }

  .game-panel#game-panel > .timer-pie {
    top: 0.5rem;
    right: 0.5rem;
    width: 34px;
    height: 34px;
  }

  .result-message {
    font-size: 0.85rem;
    min-height: 1.25rem;
    margin: 0 2.5rem 0.35rem 0;
    text-align: left;
  }

  .result-message:empty {
    min-height: 0;
    margin: 0;
  }

  .game-body {
    min-height: 0;
    flex: none;
    margin-bottom: 0;
  }

  .match-arena {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    height: auto;
    gap: 0.45rem;
  }

  .match-corner {
    position: static;
    max-width: 100%;
    gap: 0.15rem;
  }

  .match-corner-opponent {
    order: 1;
  }

  .match-center {
    order: 2;
    height: auto;
    padding: 0;
    overflow: visible;
  }

  .match-corner-player {
    order: 3;
  }

  .match-corner-name {
    font-size: 0.8rem;
    max-width: 100%;
  }

  .match-corner-identity .rank-icon {
    width: 1.1rem;
    height: 1.1rem;
  }

  .play-stage,
  .match-stack,
  .match-play-column {
    width: 100%;
    height: auto;
  }

  .vs-divider {
    flex: none;
    padding: 0.4rem 0;
    min-height: 0;
    font-size: 0.8rem;
  }

  .opponent-box-label {
    display: none;
  }

  .opponent-box {
    padding: 0.85rem 0.2rem;
    min-width: 0;
    width: calc((100% - 0.6rem) / 3);
    gap: 0;
    min-height: 4.25rem;
  }

  .opponent-reveal,
  .opponent-status {
    font-size: 1.75rem;
    min-height: 1.75rem;
  }

  .opponent-box-content {
    min-height: 1.75rem;
  }

  .win-dots {
    gap: 0.3rem;
  }

  .dot {
    width: 14px;
    height: 14px;
  }

  .match-end-stage {
    position: relative;
    inset: auto;
    width: 100%;
  }

  .match-end-top-spacer {
    display: none;
  }

  .vs-divider.match-end-spacer {
    flex: none;
    min-height: 0;
    padding: 0.5rem 0 0.75rem;
  }

  .elo-reward-display,
  .elo-arrow-shape,
  .elo-tie-shape {
    width: min(240px, 72vw);
    height: auto;
    aspect-ratio: 360 / 239;
  }

  .elo-tie-label,
  .elo-change-hero {
    font-size: clamp(1.15rem, 5.5vw, 1.55rem);
  }

  .moves {
    width: 100%;
    gap: 0.3rem;
    padding: 0;
    margin: 0;
    overflow: hidden;
  }

  .move-btn {
    flex: 1 1 0;
    min-width: 0;
    max-width: none;
    padding: 0.85rem 0.15rem;
    min-height: 5.25rem;
    font-size: 0.75rem;
    gap: 0.3rem;
  }

  .move-emoji {
    font-size: 1.85rem;
  }

  .match-end-actions .btn-secondary {
    width: 100%;
    text-align: center;
  }

  .play-box-brand {
    position: static;
    display: block;
    margin-top: 0.35rem;
    text-align: right;
    font-size: 0.55rem;
  }

  .corner-controls {
    right: max(0.65rem, env(safe-area-inset-right));
    bottom: max(0.65rem, env(safe-area-inset-bottom));
  }

  .corner-control {
    width: 2.5rem;
    height: 2.5rem;
    font-size: 1.15rem;
  }

  .connection-warning {
    left: max(0.65rem, env(safe-area-inset-left));
    bottom: max(0.65rem, env(safe-area-inset-bottom));
    width: 2.5rem;
    height: 2.5rem;
  }

  .connection-warning svg {
    width: 1.15rem;
    height: 1.15rem;
  }

  .auth-overlay {
    padding: 0.65rem;
    align-items: flex-end;
  }

  .auth-dialog {
    padding: 1.1rem;
    max-height: calc(100dvh - 1.25rem);
    overflow-y: auto;
    border-radius: 16px 16px 0 0;
  }

  .auth-form input {
    font-size: 16px;
  }

  .leaderboard-list {
    padding-left: 1.1rem;
  }

  .leaderboard-list li {
    font-size: 0.9rem;
    padding: 0.4rem 0;
    word-break: break-word;
  }

  .leaderboard-list .leaderboard-rank-icon {
    width: 1.1rem;
    height: 1.1rem;
  }

  .round-history {
    margin-top: 0.75rem;
    -webkit-overflow-scrolling: touch;
  }

  .history-emoji {
    width: 2rem;
    height: 2rem;
    font-size: 1rem;
    border-width: 3px;
  }

  .round-history-track::before {
    height: 2rem;
  }

  .history-turn {
    padding: 0 0.4rem;
    gap: 0.35rem;
  }
}

@media (max-width: 380px) {
  .brand-icon {
    width: 1.5rem;
    height: 1.5rem;
  }

  .move-btn {
    font-size: 0.7rem;
    padding: 0.7rem 0.1rem;
    min-height: 4.75rem;
  }

  .move-emoji {
    font-size: 1.65rem;
  }

  .opponent-reveal,
  .opponent-status {
    font-size: 1.55rem;
    min-height: 1.55rem;
  }

  .opponent-box {
    padding: 0.7rem 0.1rem;
    min-height: 3.85rem;
  }

  .elo-tie-label,
  .elo-change-hero {
    font-size: 1.15rem;
  }
}
