:root {
  --bg: #f2efe7;
  --ink: #1f1f1f;
  --panel: #fffdf7;
  --light: #f0d9b5;
  --dark: #b58863;
  --accent: #d81921;
  --accent-soft: #ff7844;
  --accent-gold: #ffdf6f;
  --accent-gradient: linear-gradient(180deg, #ffb23a 0%, #ff5a2f 46%, #d81921 100%);
  --accent-gradient-strong: linear-gradient(180deg, #ff8a2e 0%, #f03a22 48%, #b30f18 100%);
  --accent-shadow: rgba(216, 25, 33, 0.34);
  --accent-ring: rgba(216, 25, 33, 0.22);
  --select: #ffcc00;
  --caps-title-font: "Arial Narrow Bold", "Impact", "Haettenschweiler", "Franklin Gothic Medium", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  color: var(--ink);
  background: radial-gradient(circle at 20% 20%, #fff6df 0%, var(--bg) 50%, #e6dfcf 100%);
}

.root-page {
  position: relative;
}

.root-page .topbar,
.root-page .explainer-layout,
.rules-page .topbar,
.rules-page .explainer-layout {
  position: relative;
  z-index: 2;
}

.root-mouse-trail {
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0;
  z-index: 1;
  transition: opacity 260ms ease;
}

.root-mouse-trail.active {
  opacity: 1;
}

.root-mouse-trail-logo {
  position: absolute;
  width: var(--trail-size, 28px);
  height: var(--trail-size, 28px);
  transform: translate(-50%, -50%);
  opacity: var(--trail-opacity, 0.14);
  filter: saturate(1.1) drop-shadow(0 3px 6px rgba(0, 0, 0, 0.1));
}

@media (max-width: 900px) {
  .root-mouse-trail {
    display: none;
  }
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 18px;
  border-bottom: 2px solid #d8cfbb;
  background: rgba(255, 253, 247, 0.9);
  backdrop-filter: blur(3px);
}

.play-rules-bottom-notice {
  padding: 7px 14px;
  text-align: center;
  font-size: 0.84rem;
  font-weight: 700;
  color: #4c3319;
  background: linear-gradient(180deg, #ffe8ba 0%, #ffd690 100%);
  border-top: 1px solid #ddb36f;
}

.play-rules-bottom-notice a {
  color: #7d1b1f;
  text-decoration: none;
}

.play-rules-bottom-notice a:hover {
  text-decoration: underline;
}

.rules-jump-notice {
  border: 1px solid #d8b06f;
  border-radius: 10px;
  background: linear-gradient(180deg, #fff0cd 0%, #ffe0a2 100%);
  padding: 10px 12px;
  font-weight: 700;
  color: #4c3319;
}

.rules-jump-notice a {
  color: #7d1b1f;
  text-decoration: none;
}

.rules-jump-notice a:hover {
  text-decoration: underline;
}

.topbar h1 {
  margin: 0;
  font-size: 1.5rem;
}

.brand-title {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  letter-spacing: 0.01em;
}

.brand-wordmark {
  display: inline-flex;
  align-items: baseline;
  gap: 0;
}

.brand-mobile-logo {
  display: none;
  width: 30px;
  height: 30px;
  flex: 0 0 auto;
}

.brand-wordmark-icon {
  width: 0.92em;
  height: 0.92em;
  margin: 0;
  transform: translateY(0.06em);
  flex: 0 0 auto;
  display: block;
  transform-origin: center;
  animation: brandWordmarkStrikeHum 4.8s linear infinite;
}

.brand-wordmark-icon:nth-of-type(2) {
  animation-delay: 0.35s;
}

.brand-logo {
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  border-radius: 8px;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.22);
}

.topbar button {
  border: none;
  border-radius: 8px;
  padding: 10px 14px;
  background: var(--accent-gradient);
  color: #fff;
  font-weight: 700;
  cursor: pointer;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  position: relative;
}

.play-topbar {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  column-gap: 14px;
}

.topbar-center-nav {
  display: inline-flex;
  justify-self: center;
  align-items: center;
  gap: 12px;
}

.topbar-nav-item {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-width: 76px;
  padding: 6px 6px;
  border-radius: 10px;
  text-decoration: none;
  color: #4d3218;
  background: rgba(255, 248, 233, 0.55);
  border: 1px solid rgba(176, 132, 89, 0.48);
}

.topbar-nav-item:hover {
  background: rgba(255, 235, 198, 0.82);
}

.topbar-nav-icon {
  font-size: 1.05rem;
  line-height: 1;
}

.topbar-nav-icon-svg {
  width: 18px;
  height: 18px;
  display: block;
}

.topbar-nav-icon-brand {
  width: 18px;
  height: 18px;
  display: block;
}

.topbar-nav-label {
  margin-top: 3px;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.topbar-nav-item.is-active,
.topbar-nav-item.is-disabled {
  pointer-events: none;
}

.topbar-nav-item.is-active {
  background: rgba(216, 25, 33, 0.2);
  border-color: var(--accent);
  color: var(--accent);
}

.topbar-nav-item.is-disabled {
  opacity: 0.45;
}

.topbar .topbar-menu-btn {
  display: none;
  min-width: 40px;
  width: 40px;
  height: 40px;
  padding: 0;
  border-radius: 9px;
  background: rgba(255, 247, 229, 0.92);
  border: 1px solid rgba(176, 132, 89, 0.55);
  color: #4f3318;
  font-size: 1.2rem;
  line-height: 1;
}

.topbar-mobile-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  min-width: 180px;
  background: rgba(255, 252, 243, 0.98);
  border: 1px solid #d2c0a1;
  border-radius: 10px;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.2);
  padding: 6px;
  display: grid;
  gap: 4px;
  z-index: 40;
}

.topbar-mobile-menu[hidden] {
  display: none !important;
}

.topbar-mobile-menu-item {
  display: block;
  text-decoration: none;
  color: #4f3318;
  font-weight: 700;
  padding: 8px 10px;
  border-radius: 8px;
}

.topbar-mobile-menu-item:hover {
  background: rgba(255, 233, 196, 0.82);
}

.topbar-mobile-menu-item.is-active,
.topbar-mobile-menu-item.is-disabled {
  pointer-events: none;
}

.topbar-mobile-menu-item.is-active {
  color: var(--accent);
  background: rgba(216, 25, 33, 0.2);
}

.topbar-mobile-menu-item.is-disabled {
  opacity: 0.46;
}

.play-profile-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 42px;
  background: var(--accent-gradient);
  border: 1px solid #b51a1f;
  box-shadow: 0 4px 10px var(--accent-shadow);
  color: #fff;
  text-decoration: none;
  border-radius: 8px;
}

.play-profile-link:hover {
  background: var(--accent-gradient-strong);
}

.profile-name-full {
  display: inline;
}

.profile-name-initial {
  display: none;
  font-weight: 800;
}

.online-room-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 8px;
  align-items: center;
}

.online-onboarding {
  border: 1px solid #cfbfa1;
  border-radius: 8px;
  background: rgba(255, 248, 230, 0.7);
  padding: 8px 10px;
  margin-bottom: 8px;
}

.online-onboarding-title {
  margin: 0 0 4px;
  color: #5b4127;
  font-weight: 700;
}

.online-onboarding-text {
  margin: 0;
}

.online-name-ready {
  font-size: 0.8rem;
  font-weight: 700;
  color: #8f744f;
}

.online-name-ready.ready {
  color: #2b6333;
}

.train-layout {
  grid-template-columns: minmax(320px, 1fr);
  gap: 16px;
}

.train-panel {
  width: min(1200px, 100%);
  justify-self: center;
}

.train-main-grid {
  display: grid;
  grid-template-columns: minmax(280px, auto) minmax(260px, 330px);
  gap: 18px;
  align-items: start;
  justify-content: center;
}

.train-board-column {
  grid-column: 1;
  display: flex;
  flex-direction: column;
  gap: 10px;
  justify-content: flex-start;
  align-items: center;
}

.train-board-wrap {
  width: fit-content;
}

.train-odds-banner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  max-width: 320px;
  border: 1px solid #d8c8ab;
  border-radius: 10px;
  background: rgba(255, 250, 240, 0.9);
  padding: 6px 10px;
}

.train-odds-banner[hidden] {
  display: none !important;
}

.train-odds-label {
  font-size: 0.74rem;
  font-weight: 700;
  color: #5a4025;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.train-odds-piece {
  width: 22px;
  height: 22px;
}

.train-odds-logo {
  animation: demoSkirmishCenterVibrate 1.2s ease-in-out infinite;
}

.train-board-wrap .board-overlay .skirmish-countdown-progress {
  margin-top: 8px;
  width: min(180px, 68%);
}

.train-options-column {
  grid-column: 2;
  display: grid;
  gap: 10px;
}

.train-options-stack {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

.train-options-stack label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.88rem;
  font-weight: 700;
  color: #4f3318;
}

.train-options-stack input,
.train-options-stack select {
  width: 100%;
  border: 1px solid #cfbfa1;
  border-radius: 8px;
  padding: 7px;
  background: #fffaf0;
}

.train-options-stack select {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 30px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%23654a2a' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 9px center;
  background-size: 12px 8px;
}

.train-options-stack input:focus,
.train-options-stack select:focus {
  outline: 2px solid rgba(216, 25, 33, 0.25);
  border-color: var(--accent);
}

.train-checkbox-wrap {
  margin: 0;
}

.train-button-row {
  margin-top: 2px;
}

.train-settings-actions {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  width: 100%;
}

.train-settings-action {
  width: 100%;
}

.train-pending-settings {
  margin: 0;
  padding: 7px 9px;
  border: 1px solid #d8c8ab;
  border-radius: 8px;
  background: rgba(255, 243, 214, 0.85);
  color: #5c4120;
  font-weight: 700;
}

.train-session-score {
  margin-top: 2px;
}

.train-session-score-top {
  margin: 0;
  font-size: 0.94rem;
  font-weight: 700;
}

.train-clock-row {
  margin: 0;
  max-width: 320px;
}

.train-clock-note {
  margin: 0;
  min-height: 1.2em;
}

.train-info-piece {
  width: 18px;
  height: 18px;
  vertical-align: text-bottom;
  margin: 0 2px;
}

.train-piece-move-pop {
  animation: pieceTravelQuick 240ms ease-out 1;
}

.train-range-input {
  width: 100%;
  accent-color: #8c2b1f;
}

@media (max-width: 900px) {
  .train-main-grid {
    grid-template-columns: 1fr;
  }

  .train-board-column {
    grid-column: 1;
    justify-content: center;
  }

  .train-options-column {
    grid-column: 1;
  }

}

#createUsernameBtn {
  background: #365f85;
}

#createUsernameBtn:disabled {
  opacity: 0.55;
  cursor: default;
}

#onlineOptions {
  margin-top: 4px;
}

.online-action-group {
  border: 1px solid #d7c8ad;
  border-radius: 8px;
  background: rgba(255, 252, 244, 0.75);
  padding: 8px;
  margin-bottom: 8px;
}

.online-seat-label {
  font-size: 0.85rem;
  font-weight: 700;
  color: #5b4127;
}

.online-room-input {
  border: 1px solid #cbbda2;
  border-radius: 6px;
  padding: 8px;
  background: #fff;
  width: 140px;
  text-transform: uppercase;
}

.online-name-input {
  width: 220px;
  text-transform: none;
}

.online-lobby-stats {
  margin: 8px auto 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: center;
  align-items: center;
  text-align: center;
}

.online-stat-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border: 1px solid #d7c8ad;
  border-radius: 999px;
  background: rgba(255, 252, 244, 0.82);
  color: #4a331d;
  font-size: 0.8rem;
  font-weight: 700;
  padding: 4px 9px;
}

.online-stat-chip-icon {
  width: 0.92em;
  height: 0.92em;
  flex: 0 0 auto;
}

.online-waiting-banner {
  margin: 8px 0;
  padding: 10px 12px;
  border-radius: 10px;
  border: 2px solid #8f744f;
  background: linear-gradient(135deg, #fff1cf 0%, #ffe2a4 100%);
  color: #3f2b14;
  font-weight: 700;
  letter-spacing: 0.01em;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.12);
}

.online-waiting-banner-compact {
  margin: 8px 0 6px;
  padding: 8px 10px;
  font-size: 0.88rem;
}

.active-games-list {
  margin-top: 8px;
  display: grid;
  gap: 6px;
}

.active-games-list.live-rooms-grid {
  gap: 10px;
}

.online-live-games-section {
  border: 1px solid #d7c8ad;
  border-radius: 10px;
  background: rgba(255, 252, 244, 0.78);
  padding: 8px;
  margin-top: 8px;
}

.online-empty-banner {
  margin: 0 0 8px;
  padding: 9px 10px;
  width: 100%;
  border-radius: 8px;
  border: 1px solid #cfbfa1;
  background: rgba(255, 250, 238, 0.82);
  color: #5b4127;
  text-align: center;
  font-size: 0.86rem;
  font-weight: 700;
}

#activeGamesList {
  grid-template-columns: repeat(5, minmax(168px, 208px));
  justify-content: start;
}

#liveGamesList {
  grid-template-columns: repeat(auto-fill, minmax(172px, 210px));
  justify-content: start;
}

#activeGamesList.live-rooms-grid {
  grid-template-columns: repeat(5, minmax(168px, 208px));
  justify-content: start;
}

#liveGamesList.live-rooms-grid {
  grid-template-columns: repeat(auto-fill, minmax(172px, 210px));
  justify-content: start;
}

.live-room-card {
  border: 1px solid #cfbfa1;
  border-radius: 10px;
  padding: 8px;
  background: linear-gradient(180deg, rgba(255, 253, 245, 0.94) 0%, rgba(255, 248, 233, 0.92) 100%);
  display: grid;
  gap: 7px;
  align-content: start;
  min-width: 0;
  width: min(100%, 210px);
  max-width: 210px;
  justify-self: start;
}

.live-room-player-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  font-size: 0.73rem;
  min-width: 0;
}

.live-room-player-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 700;
  font-size: 0.72rem;
}

.live-room-player-time {
  flex: 0 0 auto;
  font-family: "Courier New", monospace;
  font-weight: 700;
  font-size: 0.71rem;
  color: #47321f;
  border: 1px solid #cfbfa1;
  border-radius: 6px;
  padding: 1px 5px;
  background: rgba(255, 252, 244, 0.95);
}

.live-room-seat-open {
  color: #8f744f;
  font-style: italic;
}

.live-room-board-wrap {
  width: 100%;
  aspect-ratio: 1;
}

.live-room-board-wrap .active-game-main-preview {
  width: 100%;
  height: 100%;
  margin-left: 0;
}

.live-room-board-empty {
  width: 100%;
  height: 100%;
  border: 1px dashed #c8b297;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #8f744f;
  font-size: 0.8rem;
  background: rgba(255, 251, 243, 0.8);
}

.live-room-config-line {
  font-size: 0.74rem;
  color: #5b4127;
  border-top: 1px solid rgba(143, 116, 79, 0.28);
  padding-top: 6px;
  line-height: 1.3;
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.live-room-config-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  border: 1px solid #cfbfa1;
  border-radius: 999px;
  background: rgba(255, 250, 238, 0.78);
  padding: 2px 7px;
  text-transform: lowercase;
  font-weight: 400;
}

.live-room-config-logo {
  width: 0.82em;
  height: 0.82em;
  flex: 0 0 auto;
}

.live-room-config-draw-mark {
  font-weight: 400;
  color: #7d1b1f;
}

.live-room-rules-line {
  font-size: 0.72rem;
  color: #8f744f;
  text-align: center;
  text-transform: lowercase;
}

.live-room-actions {
  display: flex;
  flex-wrap: nowrap;
  gap: 6px;
}

.live-room-actions > * {
  flex: 1 1 calc(50% - 3px);
  min-width: 0;
}

.live-room-actions > *:only-child {
  flex-basis: 100%;
}

.live-room-actions .active-game-watch-btn,
.live-room-actions .online-history-btn {
  width: 100%;
}

.active-game-item {
  border: 1px solid #cfbfa1;
  border-radius: 8px;
  padding: 8px;
  background: rgba(255, 250, 238, 0.76);
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 10px;
}

.active-game-main-preview {
  width: 128px;
  height: 128px;
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  grid-template-rows: repeat(8, 1fr);
  border: 1px solid #bfa988;
  border-radius: 6px;
  overflow: hidden;
  flex: 0 0 auto;
  margin-left: auto;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.35);
}

.active-game-label {
  flex: 1 1 auto;
  min-width: 0;
}

.active-game-item .online-room-row {
  flex: 0 0 auto;
}

.active-game-main-sq {
  position: relative;
}

.active-game-main-sq.light {
  background: var(--light);
}

.active-game-main-sq.dark {
  background: var(--dark);
}

.active-game-main-sq.last-move {
  box-shadow: inset 0 0 0 4px rgba(255, 238, 92, 0.78);
  animation: moveFlash 170ms ease-out 1;
}

.active-game-main-sq.last-move-from {
  box-shadow: inset 0 0 0 4px rgba(255, 238, 92, 0.58);
  animation: moveFlash 170ms ease-out 1;
}

.active-game-main-sq.last-move-skirmish-capture::after {
  content: "";
  position: absolute;
  inset: 0;
  background-image: url("/static/skirmish-logo-variant-strike.svg");
  background-repeat: no-repeat;
  background-position: center;
  background-size: 100% 100%;
  filter: drop-shadow(0 0 2px rgba(0, 0, 0, 0.38));
  z-index: 4;
  transform-origin: center;
  pointer-events: none;
  animation: skirmishCenterHum 1.2s ease-in-out infinite;
}

.active-game-main-piece {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.active-game-label {
  font-size: 0.84rem;
}

.username-link {
  color: #1f4f7a;
  text-decoration: none;
  font-weight: 700;
}

.bot-name-icon {
  width: 0.92em;
  height: 0.92em;
  vertical-align: -0.08em;
  margin-right: 0.28em;
}

.username-link:hover {
  text-decoration: underline;
}

.active-game-watch-btn {
  padding: 6px 10px;
  font-size: 0.8rem;
}

.lobby-spectate-btn {
  border: 1px solid rgba(111, 88, 64, 0.42);
  background: rgba(255, 250, 238, 0.62);
  color: #4a3825;
  box-shadow: none;
}

.lobby-spectate-btn:hover {
  background: rgba(255, 250, 238, 0.88);
  border-color: rgba(111, 88, 64, 0.62);
}

.lobby-join-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
}

.join-skirmish-logo {
  width: 0.9em;
  height: 0.9em;
  animation: skirmishCenterHum 0.95s ease-in-out infinite;
}

.recent-finished-table-wrap {
  width: 100%;
  overflow-x: auto;
}

.recent-finished-table {
  width: 100%;
  border-collapse: collapse;
  border: 1px solid #cfbfa1;
  background: rgba(255, 250, 238, 0.8);
  font-size: 0.83rem;
}

.recent-finished-table th,
.recent-finished-table td {
  border-bottom: 1px solid #ddceb2;
  padding: 6px 8px;
  text-align: left;
  white-space: nowrap;
}

.recent-finished-table th {
  background: rgba(239, 225, 199, 0.88);
  color: #4a331d;
  font-weight: 700;
}

.recent-finished-table tr:last-child td {
  border-bottom: none;
}

.online-subsection-title {
  margin: 10px 0 6px;
  font-size: 0.92rem;
  font-family: var(--caps-title-font);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #5b4127;
}

.online-history-link-wrap {
  margin: 8px 0 2px;
}

.online-history-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 7px 12px;
  border-radius: 8px;
  background: var(--accent-gradient);
  box-shadow: 0 4px 10px var(--accent-shadow);
  color: #fff;
  text-decoration: none;
  font-weight: 700;
  font-size: 0.82rem;
}

.online-history-btn:hover {
  background: var(--accent-gradient-strong);
}

.online-history-link {
  color: #1f4f7a;
  text-decoration: none;
  font-weight: 700;
}

.online-history-link:hover {
  text-decoration: underline;
}

.history-layout {
  grid-template-columns: minmax(320px, 920px);
  justify-content: center;
}

.history-back-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  padding: 8px 12px;
  background: var(--accent-gradient);
  box-shadow: 0 4px 10px var(--accent-shadow);
  color: #fff;
  text-decoration: none;
  font-weight: 700;
}

.history-back-link:hover {
  background: var(--accent-gradient-strong);
}

.history-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 8px 0 10px;
}

.history-search-input {
  width: 220px;
  text-transform: none;
}

.history-select {
  border: 1px solid #cbbda2;
  border-radius: 6px;
  background: #fff;
  padding: 8px;
  min-width: 140px;
}

.history-stats {
  margin: 8px 0;
}

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

.history-list.history-cards-grid {
  gap: 10px;
  grid-template-columns: repeat(auto-fill, minmax(172px, 210px));
  justify-content: start;
}

.history-game-card {
  width: min(100%, 210px);
  justify-self: start;
}

.history-game-card .live-room-actions {
  margin-top: 2px;
}

.history-game-date {
  font-size: 0.71rem;
  color: #6f5840;
}

.history-item {
  border: 1px solid #cfbfa1;
  border-radius: 8px;
  padding: 9px;
  background: rgba(255, 250, 238, 0.76);
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-areas:
    "head board"
    "mid board"
    "bottom board";
  column-gap: 10px;
  row-gap: 3px;
}

.history-item-head {
  grid-area: head;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.history-item-top {
  font-weight: 700;
  font-size: 0.9rem;
}

.history-view-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 12px;
  font-size: 0.78rem;
  border-radius: 8px;
  background: var(--accent-gradient);
  box-shadow: 0 4px 10px var(--accent-shadow);
  color: #fff;
  text-decoration: none;
  font-weight: 700;
}

.history-view-btn:hover {
  background: var(--accent-gradient-strong);
}

.history-item-mid {
  grid-area: mid;
  margin-top: 2px;
  font-size: 0.84rem;
}

.history-item-bottom {
  grid-area: bottom;
  margin-top: 4px;
  font-size: 0.76rem;
  color: #6f5840;
}

.history-mini-board {
  grid-area: board;
  width: 84px;
  height: 84px;
  border: 1px solid #6f5840;
  border-radius: 6px;
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  grid-template-rows: repeat(8, 1fr);
  overflow: hidden;
}

.history-board-square {
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.history-board-square.light {
  background: var(--light);
}

.history-board-square.dark {
  background: var(--dark);
}

.history-board-piece {
  width: 84%;
  height: 84%;
  object-fit: contain;
  pointer-events: none;
}

.history-board-piece.mini {
  width: 90%;
  height: 90%;
}

.history-board-square.last-move {
  box-shadow: inset 0 0 0 4px rgba(255, 238, 92, 0.78);
  animation: moveFlash 170ms ease-out 1;
}

.history-board-square.last-move-from {
  box-shadow: inset 0 0 0 4px rgba(255, 238, 92, 0.58);
  animation: moveFlash 170ms ease-out 1;
}

.history-board-square.king-in-check {
  box-shadow: inset 0 0 0 5px rgba(196, 39, 39, 0.88),
    0 0 12px rgba(196, 39, 39, 0.45);
}

.history-board-square.last-move-skirmish-capture::after {
  content: none;
}

.history-replay-panel {
  margin-top: 14px;
  border: 1px solid #cfbfa1;
  border-radius: 10px;
  background: rgba(255, 250, 238, 0.86);
  padding: 10px;
}

.history-replay-panel h3 {
  margin: 0 0 8px;
}

.history-replay-grid {
  display: grid;
  grid-template-columns: minmax(200px, 320px) 1fr;
  gap: 12px;
  align-items: start;
}

.history-replay-board {
  width: min(62vw, 320px);
  aspect-ratio: 1 / 1;
  border: 2px solid #6f5840;
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  grid-template-rows: repeat(8, 1fr);
}

.history-replay-side {
  display: grid;
  gap: 8px;
}

.history-replay-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.history-replay-move {
  min-height: 1.3em;
  font-family: "Courier New", monospace;
  font-size: 0.9rem;
  color: #4f3b26;
}

.rules-replay-explanation {
  border: 1px solid #d7c6a8;
  border-radius: 8px;
  background: rgba(255, 248, 233, 0.82);
  padding: 9px 10px;
  min-height: 72px;
  line-height: 1.45;
}

.special-situations-carousel {
  display: grid;
  gap: 10px;
}

.special-situation-tabs {
  margin-bottom: 2px;
}

.special-situation-tabs .special-situation-tab {
  flex: 1 1 220px;
  text-wrap: balance;
}

.special-situation-stage {
  display: grid;
  grid-template-columns: minmax(220px, 340px) minmax(240px, 1fr);
  gap: 12px;
  align-items: start;
}

.special-situation-grid {
  width: 100%;
}

.special-situation-board-col {
  --replay-board-width: min(62vw, 320px);
}

.special-situation-board {
  width: 100%;
  position: relative;
  overflow: hidden;
}

.special-situation-copy h4 {
  margin: 0 0 8px;
}

.special-situation-copy .rules-replay-explanation {
  margin: 0;
  min-height: 90px;
}

.special-situation-move-row {
  grid-template-columns: 2.8em 1fr auto;
}

.special-situation-move-main {
  white-space: nowrap;
}

.special-situation-mate-token {
  margin-left: 1px;
  font-weight: 800;
  color: #7d1b1f;
}

.special-situation-move-alt {
  opacity: 0.94;
}

.move-inline {
  font-family: "Courier New", monospace;
}

.replay-page-panel {
  width: min(1120px, 100%);
  max-width: 1120px;
  display: grid;
  justify-self: center;
}

.replay-page-panel #replayMeta {
  text-align: center;
  justify-self: center;
}

.layout.history-layout {
  grid-template-columns: minmax(320px, 1120px);
  justify-content: center;
}

.replay-key-hint {
  display: none;
  margin: 0;
  font-family: "Courier New", monospace;
  text-align: center;
}

@media (min-width: 901px) {
  .replay-board-col .replay-key-hint {
    display: block;
  }
}

.replay-main-grid {
  display: grid;
  grid-template-columns: minmax(260px, 420px) minmax(240px, 360px);
  gap: 14px;
  align-items: start;
  width: max-content;
  max-width: 100%;
  margin-inline: auto;
  justify-self: center;
}

.replay-board-col {
  display: grid;
  gap: 8px;
  --replay-board-width: min(62vw, 400px);
  width: var(--replay-board-width);
  max-width: 100%;
}

.captured-strip {
  display: flex;
  align-items: center;
  gap: 2px;
  flex-wrap: wrap;
  color: #5a4a2e;
  flex-basis: 100%;
  width: 100%;
  margin-top: 3px;
}

.captured-strip.top {
  justify-content: flex-start;
}

.captured-strip.bottom {
  justify-content: flex-end;
}

.captured-piece-stack {
  position: relative;
  width: calc(16px + (max(1, var(--stack-layers, 1)) - 1) * 4px);
  height: 16px;
  display: inline-block;
}

.captured-piece {
  width: 16px;
  height: 16px;
  object-fit: contain;
  opacity: 0.95;
}

.captured-piece-layer {
  position: absolute;
  left: calc(var(--stack-index, 0) * 4px);
  top: 0;
}

.captured-diff {
  margin-left: 2px;
  font-size: 0.82rem;
  font-weight: 700;
  color: #1f6f45;
}

.captured-strip[hidden] {
  display: none !important;
}

.replay-board-wrap {
  width: 100%;
}

.replay-clock-row {
  margin: 0;
  min-height: 38px;
  width: 100%;
}

.replay-clock-row .clock-label {
  font-size: 0.9rem;
}

.replay-clock-row .clock-time {
  min-width: 68px;
}

.replay-controls {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 8px;
  width: 100%;
}

.replay-controls > button {
  flex: 1 1 0;
  min-width: 0;
}

.history-replay-grid .replay-board-col {
  --replay-board-width: min(62vw, 320px);
}

.replay-board-col .history-replay-board {
  width: 100%;
}

.history-replay-grid .history-replay-board {
  width: 100%;
}

.history-replay-controls {
  flex-wrap: nowrap;
  width: 100%;
}

.history-replay-controls > button {
  flex: 1 1 0;
  min-width: 0;
}

.replay-moves-col h3 {
  margin: 0 0 8px;
}

.replay-export-actions {
  display: grid;
  gap: 6px;
  margin: 0 0 10px;
}

.replay-export-btn {
  width: 100%;
  border: 1px solid rgba(111, 88, 64, 0.42);
  background: rgba(255, 250, 238, 0.62);
  color: #4a3825;
  border-radius: 7px;
  padding: 5px 8px;
  font-size: 0.76rem;
  font-family: "Courier New", monospace;
  font-weight: 600;
  line-height: 1.15;
}

.replay-export-btn:hover {
  background: rgba(255, 250, 238, 0.88);
  border-color: rgba(111, 88, 64, 0.62);
}

.replay-export-btn:active {
  transform: translateY(1px);
}

.replay-export-btn.copy-success {
  border-color: rgba(35, 102, 64, 0.72);
  background: rgba(206, 238, 220, 0.9);
  color: #1b5a35;
}

.replay-export-btn.copy-failure {
  border-color: rgba(138, 32, 32, 0.68);
  background: rgba(247, 219, 219, 0.92);
  color: #7a1717;
}

.replay-moves-col {
  width: 100%;
  max-width: 360px;
  justify-self: center;
}

.replay-moves-col .history-replay-move {
  text-align: center;
  margin: 0 0 8px;
}

.replay-moves-list {
  max-height: min(66vh, 560px);
  overflow-y: auto;
  border: 1px solid #cfbfa1;
  border-radius: 8px;
  background: rgba(255, 250, 238, 0.68);
  padding: 6px;
  display: grid;
  gap: 4px;
}

.replay-move-row {
  display: grid;
  grid-template-columns: 2.4em 1fr 1fr;
  gap: 6px;
  align-items: center;
}

.replay-move-num {
  color: #6f5840;
  font-family: "Courier New", monospace;
  font-size: 0.85rem;
}

.replay-move-cell {
  text-align: left;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: #2c2c2c;
  font-family: "Courier New", monospace;
  font-size: 0.88rem;
  padding: 4px 6px;
  min-height: 28px;
  cursor: pointer;
}

.replay-move-cell:hover {
  border-color: rgba(111, 143, 91, 0.48);
  background: rgba(111, 143, 91, 0.12);
}

.replay-move-cell.current {
  border-color: #7d1b1f;
  background: rgba(216, 25, 33, 0.16);
  color: #4c0f13;
  font-weight: 700;
}

.replay-skirmish-badge {
  display: inline-flex;
  align-items: center;
  gap: 1px;
  margin-left: 1px;
  vertical-align: middle;
}

.replay-skirmish-outcome {
  font-weight: 800;
  color: #7d1b1f;
  line-height: 1;
}

.replay-skirmish-icon {
  width: 0.9em;
  height: 0.9em;
}

.replay-move-cell.replay-move-gap {
  cursor: default;
  background: transparent;
  border-color: transparent;
}

@media (max-width: 760px) {
  .history-item {
    grid-template-columns: 1fr;
    grid-template-areas:
      "head"
      "mid"
      "bottom"
      "board";
  }

  .history-mini-board {
    width: 108px;
    height: 108px;
  }

  .history-list.history-cards-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    justify-content: stretch;
  }

  .history-game-card {
    width: 100%;
    max-width: none;
  }

  .history-replay-grid {
    grid-template-columns: 1fr;
  }

  .special-situation-stage {
    grid-template-columns: 1fr;
  }

  .special-situation-board {
    width: min(90vw, 340px);
  }

  .history-replay-board {
    width: min(90vw, 320px);
  }

  .replay-board-col,
  .history-replay-grid .replay-board-col {
    width: 100%;
    --replay-board-width: min(90vw, 420px);
  }

  .replay-main-grid {
    grid-template-columns: 1fr;
  }

  .replay-moves-list {
    max-height: 44vh;
  }
}

.history-pagination {
  margin-top: 10px;
  display: flex;
  align-items: center;
  gap: 8px;
}

#copyRoomCodeBtn:disabled {
  opacity: 0.55;
  cursor: default;
}

#copyJoinLinkBtn:disabled,
#copyWatchLinkBtn:disabled {
  opacity: 0.55;
  cursor: default;
}

button {
  border: none;
  border-radius: 8px;
  padding: 10px 12px;
  background: var(--accent-gradient);
  color: #fff;
  font-weight: 700;
  cursor: pointer;
}

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

.explainer-topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
}

.explainer-brand-left {
  justify-self: start;
  display: inline-flex;
  align-items: center;
}

.explainer-brand-logo {
  width: 56px;
  height: 56px;
  flex: 0 0 auto;
}

.explainer-brand-center {
  justify-self: center;
}

.explainer-topbar .topbar-actions {
  justify-self: end;
}

@media (max-width: 720px) {
  .explainer-topbar {
    grid-template-columns: auto 1fr;
  }

  .explainer-brand-center {
    display: none;
  }

  .explainer-brand-logo {
    width: 44px;
    height: 44px;
  }
}

@media (max-width: 1024px) {
  .replay-main-grid {
    grid-template-columns: 1fr;
    width: 100%;
    max-width: 100%;
    margin-inline: 0;
    justify-self: stretch;
  }

  .replay-board-col,
  .history-replay-grid .replay-board-col {
    width: 100%;
    --replay-board-width: min(
      100%,
      calc(100vw - env(safe-area-inset-left) - env(safe-area-inset-right) - 32px)
    );
  }

  .history-replay-board,
  .replay-board-col .history-replay-board,
  .history-replay-grid .history-replay-board {
    width: var(--replay-board-width);
    max-width: 100%;
  }

  .replay-moves-col {
    width: 100%;
    max-width: 100%;
    justify-self: stretch;
  }

  .play-topbar {
    grid-template-columns: 1fr auto;
  }

  .topbar-center-nav {
    display: none;
    pointer-events: none;
  }

  .topbar .topbar-menu-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    order: 2;
  }

  .play-profile-link {
    order: 1;
  }

  .brand-wordmark {
    display: none;
  }

  .brand-mobile-logo {
    display: block;
  }

  .profile-name-full {
    display: inline;
    font-size: 0.72rem;
    line-height: 1.1;
    max-width: 36vw;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .profile-name-initial {
    display: none;
  }

  .play-profile-link {
    min-width: 0;
    max-width: 40vw;
    padding: 6px 9px;
    pointer-events: auto;
  }
}

@media (hover: none) and (pointer: coarse) {
  .play-topbar {
    grid-template-columns: 1fr auto;
  }

  .topbar-center-nav {
    display: none !important;
    visibility: hidden;
    pointer-events: none !important;
  }

  .topbar .topbar-menu-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    order: 2;
  }

  .brand-wordmark {
    display: none;
  }

  .brand-mobile-logo {
    display: block;
  }

  .profile-name-full {
    display: inline;
    font-size: 0.72rem;
    line-height: 1.1;
    max-width: 36vw;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .profile-name-initial {
    display: none;
  }

  .play-profile-link {
    min-width: 0;
    max-width: 40vw;
    padding: 6px 9px;
  }
}

.explainer-layout {
  display: grid;
  gap: 14px;
  max-width: 980px;
  margin: 0 auto;
  padding: 18px 16px 52px;
}

.root-pre-hero-brand {
  justify-content: center;
  margin: 16px 0 8px;
  font-size: clamp(1.9rem, 5.6vw, 3rem);
}

.root-pre-hero-brand .brand-wordmark {
  display: inline-flex;
}

.root-mini-dictionary {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
  margin: 2px 0 8px;
  width: 100%;
  justify-items: center;
}

.root-mini-dictionary-entry {
  display: grid;
  grid-template-columns: minmax(190px, 230px) minmax(0, 1fr);
  align-items: center;
  gap: 14px;
  padding: 4px 8px;
  width: min(760px, 100%);
}

.root-mini-dictionary-board-col {
  display: flex;
  align-items: center;
  justify-content: center;
}

.root-mini-dict-board.demo-board-5 {
  width: min(100%, 230px);
}

.root-mini-dictionary-copy {
  min-width: 0;
}

@media (max-width: 760px) {
  .root-mini-dictionary-entry {
    grid-template-columns: 1fr;
    justify-items: center;
  }

  .root-mini-dictionary-board-col {
    width: 100%;
  }

  .root-mini-dictionary-copy {
    width: 100%;
  }
}

.root-mini-dictionary-entry .dict-term {
  margin: 0;
  font-family: "Baskerville", "Palatino Linotype", "Book Antiqua", serif;
  font-size: clamp(1.5rem, 4vw, 2.25rem);
  font-weight: 500;
  letter-spacing: 0.01em;
  text-transform: none;
  color: #433021;
  text-align: left;
}

.root-mini-dictionary-entry .dict-pronunciation {
  margin: 2px 0 0;
  padding-left: 2px;
  font-size: 0.95rem;
  letter-spacing: 0.02em;
  color: #5e4a35;
  text-align: left;
}

.root-mini-dictionary-entry .dict-pos-inline {
  margin-left: 10px;
  font-size: 1rem;
  font-style: italic;
  color: #58432f;
}

.root-mini-dictionary-entry .dict-definition-block {
  margin-top: 8px;
  border-left: 2px solid #ccbca5;
  padding-left: 12px;
  width: 100%;
}

.root-mini-dictionary-entry .dict-definition-block p {
  margin: 0;
  color: #4c3722;
  line-height: 1.42;
}

.root-mini-dictionary-entry .dict-definition-block .example {
  margin-top: 6px;
  color: #6a5239;
  font-size: 0.93rem;
}

.rules-top-dual-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
}

@media (min-width: 900px) {
  .rules-top-dual-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: stretch;
  }
}

.explainer-hero {
  background:
    radial-gradient(circle at 92% 8%, rgba(216, 25, 33, 0.16), transparent 34%),
    radial-gradient(circle at 8% 90%, rgba(255, 120, 68, 0.2), transparent 30%),
    var(--panel);
}

.hero-logo-cluster {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 8px;
}

.hero-logo-main {
  width: 48px;
  height: 48px;
}

.hero-logo-side {
  width: 20px;
  height: 20px;
  opacity: 0.62;
}

.explainer-title-with-logo {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--caps-title-font);
  text-transform: uppercase;
  letter-spacing: 0.045em;
}

.explainer-title-with-logo img {
  width: 0.95em;
  height: 0.95em;
  display: block;
}

.eyebrow {
  margin: 0 0 8px;
  font-size: 0.76rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #6f5840;
  font-weight: 700;
}

.explainer-hero h2 {
  margin: 0 0 10px;
  font-size: clamp(1.45rem, 3.2vw, 2.25rem);
}

.hero-actions {
  margin-top: 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.explainer-hero .hero-actions,
.centered-actions {
  justify-content: center;
}

.play-cta,
.play-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  text-decoration: none;
  font-weight: 700;
  font-family: var(--caps-title-font);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  transition: transform 140ms ease, box-shadow 140ms ease;
}

.play-cta {
  background: var(--accent-gradient);
  color: #fff;
  padding: 10px 16px;
  box-shadow: 0 7px 14px var(--accent-shadow);
}

.play-cta:hover,
.play-secondary:hover {
  transform: translateY(-1px);
}

.play-cta-small {
  padding: 8px 12px;
  box-shadow: none;
}

.play-secondary {
  background: #ece2cd;
  color: #3f2f1d;
  border: 1px solid #cfbfa1;
  padding: 10px 14px;
}

.support-cta {
  background: linear-gradient(180deg, #f1d592 0%, #d3a14e 100%);
  color: #3b2814;
  border: 1px solid #b98532;
  box-shadow: 0 4px 10px rgba(95, 64, 22, 0.24);
}

.support-cta:hover {
  background: linear-gradient(180deg, #f7dfa6 0%, #dea95a 100%);
}

.support-bottom-bar {
  margin-top: 14px;
  padding: 10px 12px;
  border: 1px solid #d7c6a8;
  border-radius: 10px;
  background: linear-gradient(180deg, rgba(255, 248, 233, 0.96) 0%, rgba(248, 237, 213, 0.92) 100%);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.support-bottom-bar .hint {
  margin: 0;
  flex: 1 1 320px;
}

.lobby-support-bar {
  margin-top: 12px;
}

.play-bottom-banners {
  grid-column: 1 / -1;
  width: 100%;
  max-width: 1120px;
  justify-self: center;
  margin-top: 8px;
}

.play-bottom-banners .lobby-support-bar:first-child {
  margin-top: 0;
}

.user-support-wrap {
  width: 100%;
  max-width: 600px;
  margin: 10px auto 0;
}

@media (min-width: 980px) {
  .user-support-wrap {
    max-width: 760px;
  }
}

.explainer-section h3 {
  margin-top: 0;
}

.explainer-section h4 {
  margin: 14px 0 8px;
  color: #4b3620;
  font-family: var(--caps-title-font);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.explainer-list {
  margin: 8px 0 0;
  padding-left: 20px;
}

.explainer-list li {
  margin-bottom: 7px;
}

.explainer-sublist {
  margin: 8px 0 0;
  padding-left: 22px;
}

.explainer-sublist li {
  margin-bottom: 6px;
}

.landing-step-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 10px;
  margin-top: 8px;
}

.mini-dictionary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 10px;
  margin-top: 8px;
}

.mini-dictionary-entry {
  border: 1px solid #d6c8ac;
  border-radius: 10px;
  background: linear-gradient(160deg, rgba(255, 250, 239, 0.95), rgba(245, 234, 212, 0.9));
  padding: 10px;
}

.mini-dictionary-entry h4 {
  margin: 0 0 6px;
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-family: "Georgia", "Times New Roman", serif;
  text-transform: none;
  letter-spacing: 0.01em;
}

.mini-dictionary-entry .term {
  font-size: 1.05rem;
  font-weight: 700;
  color: #3f2a18;
}

.mini-dictionary-entry .part-of-speech {
  font-size: 0.78rem;
  color: #7a6147;
  font-style: italic;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.mini-dictionary-entry p {
  margin: 0;
  line-height: 1.45;
}

.landing-step-card {
  border: 1px solid #d6c8ac;
  border-radius: 10px;
  background: linear-gradient(150deg, rgba(255, 251, 243, 0.95), rgba(243, 233, 214, 0.9));
  padding: 10px;
}

.landing-step-card h4 {
  margin: 0 0 6px;
  font-family: var(--caps-title-font);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.landing-step-card p {
  margin: 0;
  line-height: 1.45;
}

.landing-step-subtle {
  margin-top: 5px !important;
  font-size: 0.9rem;
  font-family: "Trebuchet MS", "Lucida Sans Unicode", "Lucida Grande", "Lucida Sans", Arial, sans-serif;
  color: #6f5840;
  opacity: 0.92;
}

.sk-showcase-section {
  background:
    radial-gradient(circle at 88% 12%, rgba(216, 25, 33, 0.12), transparent 36%),
    radial-gradient(circle at 10% 88%, rgba(255, 120, 68, 0.14), transparent 34%),
    rgba(255, 248, 233, 0.72);
}

.sk-showcase-grid {
  display: flex;
  flex-wrap: nowrap;
  align-items: stretch;
  justify-content: stretch;
  gap: 14px;
}

.sk-showcase-inline-item {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  flex: 1 1 0;
  min-width: 0;
  gap: 6px;
}

.sk-showcase-board-wrap {
  position: relative;
  width: 100%;
}

.sk-showcase-board {
  width: 100%;
}

.sk-showcase-notation {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  font-family: "Courier New", monospace;
  font-size: 0.86rem;
  font-weight: 700;
  color: #4f3b26;
  text-transform: uppercase;
}

.sk-showcase-notation img {
  width: 0.9em;
  height: 0.9em;
}

.sk-showcase-overlay {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  border-radius: 6px;
  font-weight: 800;
  letter-spacing: 0.03em;
  color: #fff7ee;
  background: rgba(33, 23, 14, 0.72);
  backdrop-filter: blur(1px);
  text-transform: uppercase;
  pointer-events: none;
}

.sk-showcase-overlay[hidden] {
  display: none !important;
}

.sk-showcase-overlay.attacker-win {
  background: rgba(21, 98, 37, 0.74);
}

.sk-showcase-overlay.defender-win {
  background: rgba(141, 34, 22, 0.76);
}

.sk-showcase-overlay.draw {
  background: rgba(66, 58, 46, 0.76);
}

.demo-sq.last-move {
  box-shadow: inset 0 0 0 3px rgba(255, 238, 92, 0.78);
}

.demo-sq.last-move-from {
  box-shadow: inset 0 0 0 3px rgba(255, 238, 92, 0.58);
}

.demo-sq.last-move-skirmish-capture::after {
  content: "";
  position: absolute;
  top: 3px;
  right: 3px;
  width: 30%;
  aspect-ratio: 1 / 1;
  background-image: url("/static/skirmish-logo-variant-strike.svg");
  background-repeat: no-repeat;
  background-position: center;
  background-size: contain;
  filter: drop-shadow(0 0 2px rgba(0, 0, 0, 0.34));
  pointer-events: none;
}

@media (max-width: 900px) {
  .sk-showcase-grid {
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
  }

  .sk-showcase-inline-item {
    flex: 1 1 auto;
  }

  .sk-showcase-board-wrap {
    width: 100%;
  }
}

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

.example-card {
  border: 1px solid #d6c8ac;
  border-radius: 10px;
  background: rgba(255, 251, 243, 0.9);
  padding: 10px;
}

.example-card h4 {
  margin: 0 0 8px;
  font-family: var(--caps-title-font);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.demo-board {
  border: 2px solid #6f5840;
  border-radius: 6px;
  overflow: hidden;
  display: grid;
  margin: 0;
  background: #ead8b8;
}

.demo-board-8 {
  grid-template-columns: repeat(8, 1fr);
  grid-template-rows: repeat(8, 1fr);
  width: min(100%, 340px);
  aspect-ratio: 1 / 1;
}

.demo-board-5 {
  grid-template-columns: repeat(5, 1fr);
  grid-template-rows: repeat(5, 1fr);
  width: min(100%, 260px);
  aspect-ratio: 1 / 1;
}

.sk-showcase-board.demo-board,
.sk-showcase-board.demo-board-5 {
  width: 100%;
}

.demo-sq {
  display: flex;
  align-items: center;
  justify-content: center;
  aspect-ratio: 1 / 1;
  position: relative;
  overflow: hidden;
}

.demo-sq.skirmish-center-logo::before {
  content: "";
  position: absolute;
  inset: 22%;
  background-image: url("/static/skirmish-logo-variant-strike.svg");
  background-repeat: no-repeat;
  background-position: center;
  background-size: contain;
  opacity: 0.36;
  z-index: 1;
  transform-origin: center;
  animation: demoSkirmishCenterVibrate 1.5s ease-in-out infinite;
  pointer-events: none;
}

.demo-sq.light {
  background: var(--light);
}

.demo-sq.dark {
  background: var(--dark);
}

.demo-sq.demo-last-from {
  box-shadow: inset 0 0 0 3px rgba(255, 238, 92, 0.52);
}

.demo-sq.demo-last-to {
  box-shadow: inset 0 0 0 3px rgba(255, 238, 92, 0.78);
}

.demo-piece {
  width: 82%;
  height: 82%;
  object-fit: contain;
  pointer-events: none;
  filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.28));
  position: relative;
  z-index: 2;
}

.demo-piece-travel-ghost {
  position: absolute;
  transform: translate(-50%, -50%);
  pointer-events: none;
  z-index: 6;
  filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.28));
}

.demo-piece.demo-piece-fade-out,
.sk-random-marker.demo-piece-fade-out {
  opacity: 0;
  transition: opacity 160ms ease;
}

.demo-piece.demo-piece-fade-in,
.sk-random-marker.demo-piece-fade-in {
  opacity: 0;
  animation: demoPieceFadeIn 170ms ease forwards;
}

.skirmish-setup-chooser {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 8px;
}

.sk-demo-setup-btn {
  background: rgba(255, 241, 224, 0.95);
  color: #582a18;
  border: 1px solid #d6a378;
  padding: 6px 9px;
  border-radius: 8px;
  font-size: 0.8rem;
}

.sk-demo-setup-btn:hover {
  border-color: #cf4b2b;
  background: rgba(255, 229, 206, 0.96);
}

.sk-demo-setup-btn.active {
  background: var(--accent-gradient);
  color: #fff7ee;
  border-color: #b51a1f;
  box-shadow: 0 0 0 2px rgba(216, 25, 33, 0.28);
}

.sk-random-marker {
  font-family: "Courier New", monospace;
  font-weight: 700;
  color: #2f2417;
  font-size: clamp(0.72rem, 2vw, 0.95rem);
}

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

.idea-card {
  border: 1px solid #d6c8ac;
  border-radius: 10px;
  background: linear-gradient(150deg, rgba(255, 251, 243, 0.95), rgba(243, 233, 214, 0.9));
  padding: 10px;
}

.idea-card h4 {
  margin: 0 0 8px;
}

.idea-card p {
  margin: 0;
  line-height: 1.45;
}

.final-cta-panel {
  text-align: center;
}

.final-cta-panel .hero-actions {
  justify-content: center;
}

.layout {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 16px;
  padding: 16px 16px 58px;
}

.panel {
  background: var(--panel);
  border: 1px solid #d8cfbb;
  border-radius: 12px;
  padding: 14px;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.08);
}

#settingsPanel {
  grid-column: 1 / -1;
  width: 100%;
  max-width: 1120px;
  justify-self: center;
}

.panel h2 {
  margin-top: 0;
}

.panel h3 {
  margin: 10px 0 8px;
  font-size: 1rem;
}

.main-result-banner {
  margin: 6px 0 10px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 2px solid #8f744f;
  background: linear-gradient(135deg, #fff1cf 0%, #ffe2a4 100%);
  color: #3f2b14;
  font-weight: 700;
  letter-spacing: 0.01em;
  box-shadow: 0 3px 12px rgba(0, 0, 0, 0.12);
}

.main-result-banner.white-win {
  border-color: #3a5d7a;
  background: linear-gradient(135deg, #f3f8ff 0%, #dae8ff 100%);
  color: #1f3b5a;
}

.main-result-banner.black-win {
  border-color: #513a21;
  background: linear-gradient(135deg, #ffe6c3 0%, #eec286 100%);
  color: #3d2610;
}

.main-online-meta-row {
  margin: 4px 0 8px;
  padding: 8px 10px;
  border: 1px solid #cfbfa1;
  border-radius: 10px;
  background: rgba(255, 250, 238, 0.85);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.main-online-meta-row[hidden] {
  display: none !important;
}

.main-online-room-line {
  margin: 0;
  font-weight: 700;
}

.main-online-share-actions {
  display: inline-flex;
  gap: 8px;
  flex-wrap: wrap;
}

.main-return-lobby-btn {
  margin: 4px 0 10px;
  background: var(--accent-gradient);
  box-shadow: 0 4px 10px var(--accent-shadow);
  color: #fff;
}

.main-return-lobby-btn:hover {
  background: var(--accent-gradient-strong);
}

.main-finish-actions {
  margin: 4px 0 10px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.main-finish-actions[hidden] {
  display: none !important;
}

.main-finish-actions .main-return-lobby-btn,
.main-finish-actions .main-see-replay-btn {
  margin: 0;
}

.main-see-replay-btn {
  background: #ece2cd;
  color: #3f2f1d;
  border: 1px solid #cfbfa1;
}

.main-see-replay-btn:hover {
  background: #f5ecda;
}

.settings-accordion {
  border: 1px solid #cfbfa1;
  border-radius: 10px;
  background: rgba(255, 250, 238, 0.68);
  margin-bottom: 10px;
  overflow: clip;
}

.settings-accordion > summary {
  list-style: none;
  cursor: pointer;
  padding: 10px;
  user-select: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(255, 255, 255, 0.45);
}

.settings-accordion > summary::-webkit-details-marker {
  display: none;
}

.settings-accordion > summary::after {
  content: "+";
  font-weight: 700;
  font-size: 1rem;
  color: #6f5840;
}

.settings-accordion[open] > summary::after {
  content: "-";
}

.settings-accordion > summary h3 {
  margin: 0;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.settings-accordion > :not(summary) {
  padding: 0 10px 10px;
}

.settings-static-section > .settings-static-title {
  margin: 0;
  padding: 10px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  background: rgba(255, 255, 255, 0.45);
}

.settings-static-section > :not(.settings-static-title) {
  padding: 0 10px 10px;
}

.summary-meta {
  font-size: 0.8rem;
  font-weight: 400;
  color: #6f5840;
}

.visual-summary-preview {
  display: inline-flex;
  gap: 4px;
  align-items: center;
}

.visual-summary-square {
  width: 20px;
  height: 20px;
  border: 1px solid #6f5840;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.visual-summary-piece {
  width: 82%;
  height: 82%;
  object-fit: contain;
  pointer-events: none;
}

.board {
  display: grid;
  width: min(92vw, 480px);
  aspect-ratio: 1 / 1;
  border: 2px solid #6f5840;
  position: relative;
  overflow: hidden;
}

#mainBoard {
  width: min(92vw, 480px);
  max-width: 100%;
}

.main-board-row {
  display: flex;
  flex-direction: row-reverse;
  align-items: flex-start;
  justify-content: center;
  gap: 10px;
}

.main-play-area {
  display: grid;
  grid-template-areas:
    "top"
    "board"
    "bottom";
  gap: 6px;
  width: fit-content;
  max-width: 100%;
  min-width: 0;
}

#mainBlackClockRow {
  grid-area: top;
}

#mainClockNote {
  display: none;
  margin: 0;
}

.main-play-area .board-wrap {
  grid-area: board;
  width: min(92vw, 480px);
  max-width: 100%;
}

#mainWhiteClockRow {
  grid-area: bottom;
}

.skirmish-play-area {
  display: grid;
  grid-template-areas:
    "top"
    "note"
    "board"
    "bottom";
  gap: 6px;
  width: fit-content;
  max-width: 100%;
}

#skirmishBlackClockRow {
  grid-area: top;
}

#skirmishClockNote {
  grid-area: note;
  margin: 0;
}

#skirmishPanel .board-wrap {
  grid-area: board;
}

#skirmishWhiteClockRow {
  grid-area: bottom;
}

.face-to-face-mode .piece-black-facing {
  --piece-rotate: 180deg;
  transform: rotate(180deg);
}

#mainPanel.skirmish-active #mainBoard {
  filter: grayscale(0.65) brightness(0.78);
  opacity: 0.75;
}

#mainPanel.skirmish-active .moves-panel {
  opacity: 0.88;
}

.board-wrap {
  position: relative;
  display: inline-block;
  width: fit-content;
}

.board-annotations {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 3;
}

.board-annotations[hidden] {
  display: none !important;
}

.board-top-alerts {
  position: absolute;
  top: 8px;
  left: 8px;
  right: 8px;
  z-index: 10;
  display: grid;
  gap: 8px;
  pointer-events: auto;
}

.board-top-alert {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border-radius: 10px;
  padding: 8px 10px;
  border: 1px solid rgba(255, 255, 255, 0.44);
  color: #fff7e8;
  font-weight: 700;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.32);
}

.board-top-alerts[hidden],
.board-top-alert[hidden] {
  display: none !important;
}

.board-top-alert.draw-offer-alert {
  background: rgba(128, 64, 15, 0.9);
  animation: drawOfferPulse 1.1s ease-in-out infinite;
}

.board-top-alert.first-move-alert {
  background: rgba(32, 90, 168, 0.92);
}

.board-top-alert.first-move-alert.warn {
  background: rgba(149, 84, 6, 0.92);
}

.board-top-alert.first-move-alert.danger {
  background: rgba(151, 29, 20, 0.95);
  animation: inactivityPulse 0.95s ease-in-out infinite;
}

.board-top-alert.inactivity-alert {
  background: rgba(145, 32, 22, 0.9);
}

.board-top-alert.inactivity-alert.warn {
  background: rgba(149, 84, 6, 0.9);
}

.board-top-alert.inactivity-alert.danger {
  background: rgba(151, 29, 20, 0.94);
  animation: inactivityPulse 0.95s ease-in-out infinite;
}

#mainThinkingBtn {
  border: none;
  border-radius: 8px;
  padding: 7px 10px;
  background: #fff4db;
  color: #5d310f;
  font-weight: 800;
  cursor: pointer;
  pointer-events: auto;
  touch-action: manipulation;
}

#mainThinkingBtn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.board-overlay {
  position: absolute;
  inset: 0;
  z-index: 8;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  background: rgba(20, 20, 20, 0.62);
  border: 2px solid #6f5840;
  pointer-events: none;
  padding-top: 10px;
}

.board-overlay.result {
  align-items: center;
  padding: 16px;
  background: rgba(12, 24, 21, 0.74);
}

.board-overlay.main-end-overlay {
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(23, 23, 23, 0.78);
}

.board-overlay.main-end-overlay.white-win {
  background: rgba(22, 63, 101, 0.8);
}

.board-overlay.main-end-overlay.black-win {
  background: rgba(92, 55, 19, 0.82);
}

.board-overlay.main-end-overlay.draw {
  background: rgba(64, 64, 64, 0.82);
}

.board-overlay.waiting-overlay {
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(31, 51, 29, 0.78);
}

.board-overlay.result.attacker-win {
  background: rgba(23, 67, 36, 0.78);
}

.board-overlay.result.defender-win {
  background: rgba(76, 48, 24, 0.79);
}

.board-overlay.result.draw {
  background: rgba(55, 55, 55, 0.78);
}

.board-overlay[hidden] {
  display: none !important;
}

.board-overlay.flash {
  animation: overlayFlash 0.35s ease-in-out infinite;
}

.board-overlay.countdown-logo-drop {
  overflow: hidden;
}

.board-overlay.countdown-logo-drop::after {
  content: "";
  position: absolute;
  inset: -42%;
  background-image: url("/static/skirmish-logo-variant-strike.svg");
  background-repeat: no-repeat;
  background-position: center;
  background-size: contain;
  opacity: 0.28;
  filter: drop-shadow(0 8px 26px rgba(0, 0, 0, 0.52));
  animation: overlayStrikeDrop 0.72s cubic-bezier(0.16, 0.9, 0.2, 1) both;
  pointer-events: none;
}

.board-overlay.countdown-logo-drop .board-overlay-text {
  position: relative;
  z-index: 1;
}

.board-overlay.prestart-countdown {
  align-items: center;
  justify-content: center;
  padding: 0;
}

.board-overlay.prestart-countdown .board-overlay-text {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -62%);
  width: clamp(44px, 20%, 92px);
  aspect-ratio: 1 / 1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: clamp(1.25rem, 6.8vw, 2.55rem);
  font-weight: 900;
  line-height: 1;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.46);
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  z-index: 2;
}

.skirmish-countdown-progress {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, 18px);
  width: min(58%, 220px);
  height: 6px;
  background: rgba(238, 238, 238, 0.34);
  z-index: 2;
  pointer-events: none;
}

.skirmish-countdown-progress-fill {
  width: 100%;
  height: 100%;
  background: rgba(246, 246, 246, 0.9);
  transform-origin: right center;
  transform: scaleX(1);
}

.board-overlay-text {
  color: #fff8e7;
  font-weight: 700;
  font-size: clamp(9rem, 60vw, 16rem);
  line-height: 1;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
  text-align: center;
}

.board-overlay.result .board-overlay-text {
  white-space: pre-line;
  font-size: clamp(1.45rem, 7.7vw, 2.5rem);
  line-height: 1.15;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.board-overlay.main-end-overlay .board-overlay-text {
  white-space: pre-line;
  font-size: clamp(1.35rem, 6vw, 2.7rem);
  line-height: 1.15;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.board-overlay.waiting-overlay .board-overlay-text {
  white-space: pre-line;
  font-size: clamp(1.4rem, 6vw, 2.8rem);
  line-height: 1.2;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.board-8 {
  grid-template-columns: repeat(8, 1fr);
  grid-template-rows: repeat(8, 1fr);
}

.board-5 {
  width: min(86vw, 360px);
  grid-template-columns: repeat(5, 1fr);
  grid-template-rows: repeat(5, 1fr);
}

.square {
  display: flex;
  align-items: center;
  justify-content: center;
  user-select: none;
  cursor: pointer;
  position: relative;
  overflow: hidden;
}

.piece-img {
  --piece-rotate: 0deg;
  width: 84%;
  height: 84%;
  object-fit: contain;
  pointer-events: none;
  filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.2));
  position: relative;
  z-index: 2;
}

.piece-move-ghost {
  position: absolute;
  inset: 0;
  margin: auto;
  z-index: 7;
  pointer-events: none;
}

.piece-move-anim {
  --move-from-x: 0px;
  --move-from-y: 0px;
  animation: pieceTravelQuick 135ms ease-out 1;
  will-change: transform;
}

.square.piece-move-anim-host,
.active-game-main-sq.piece-move-anim-host,
.history-board-square.piece-move-anim-host,
.user-test-square.piece-move-anim-host,
.demo-sq.piece-move-anim-host {
  overflow: visible;
  z-index: 8;
}

@keyframes pieceTravelQuick {
  from {
    transform: translate(var(--move-from-x), var(--move-from-y)) rotate(var(--piece-rotate, 0deg));
  }
  to {
    transform: translate(0, 0) rotate(var(--piece-rotate, 0deg));
  }
}

.main-skirmish-flight {
  position: absolute;
  left: -999px;
  top: -999px;
  width: clamp(20px, 4.4vw, 32px);
  aspect-ratio: 1 / 1;
  background-image: url("/static/skirmish-logo-variant-strike.svg");
  background-repeat: no-repeat;
  background-position: center;
  background-size: contain;
  transform: translate(-50%, -50%) scale(0.84);
  opacity: 0;
  z-index: 6;
  pointer-events: none;
  filter: drop-shadow(0 0 2px rgba(0, 0, 0, 0.5));
}

.main-skirmish-flight.active {
  opacity: 0.94;
}

.main-skirmish-flight.impact {
  filter: drop-shadow(0 0 7px rgba(255, 196, 122, 0.72));
}

#mainBoard.skirmish-intro-active .square.skirmish-intro-source {
  box-shadow: inset 0 0 0 3px rgba(255, 236, 133, 0.9);
}

#mainBoard.skirmish-intro-active .square.skirmish-intro-target {
  animation: skirmishIntroTargetPulse 0.5s ease-in-out infinite;
}

.square.skirmish-center-logo::before {
  content: "";
  position: absolute;
  inset: 21%;
  background-image: url("/static/skirmish-logo-variant-strike.svg");
  background-repeat: no-repeat;
  background-position: center;
  background-size: contain;
  opacity: 0.38;
  z-index: 1;
  transform-origin: center;
  pointer-events: none;
}

#skirmishBoard.skirmish-center-vibrating .square.skirmish-center-logo::before {
  animation: skirmishCenterHum 1.7s ease-in-out infinite;
}

#skirmishBoard.skirmish-logo-intro .square.skirmish-center-logo::before {
  animation: skirmishCenterStrikeIn 0.78s cubic-bezier(0.16, 0.9, 0.2, 1) both;
}

#skirmishBoard.overlay-center-logo-hidden .square.skirmish-center-logo::before {
  opacity: 0;
  animation: none;
}

.square.last-move-skirmish-capture::after {
  content: none;
}

.skirmish-capture-badge {
  position: absolute;
  top: 4px;
  right: 4px;
  width: clamp(10px, 24%, 16px);
  aspect-ratio: 1 / 1;
  object-fit: contain;
  filter: drop-shadow(0 0 2px rgba(0, 0, 0, 0.38));
  z-index: 3;
  transform-origin: center;
  pointer-events: none;
}

#mainBoard.main-skirmish-resolve-pulse
  .square.last-move-skirmish-capture
  .skirmish-capture-badge,
.history-replay-board.replay-skirmish-finish-pulse
  .history-board-square.last-move-skirmish-capture
  .skirmish-capture-badge {
  animation: skirmishResolveBadgeVibrate 0.95s ease-in-out 1;
}

.square.defense-under-danger {
  box-shadow: inset 0 0 0 4px rgba(160, 24, 24, 0.42);
}

.piece-img.piece-under-danger {
  filter: saturate(1.25) drop-shadow(0 0 4px rgba(189, 31, 31, 0.8));
}


.square.light {
  background: var(--light);
}

.square.dark {
  background: var(--dark);
}

.square.selected {
  outline: 3px solid var(--select);
  outline-offset: -3px;
}

.square.drag-origin .piece-img {
  opacity: 0.28;
}

.square.drag-drop-hover {
  box-shadow: inset 0 0 0 5px rgba(72, 140, 235, 0.82), 0 0 0 1px rgba(72, 140, 235, 0.7);
}

.square.last-move {
  box-shadow: inset 0 0 0 4px rgba(255, 238, 92, 0.78);
}

.square.last-move-from {
  box-shadow: inset 0 0 0 4px rgba(255, 238, 92, 0.58);
}

@keyframes moveFlash {
  from {
    filter: brightness(1.12);
  }
  to {
    filter: brightness(1);
  }
}

.square.king-in-check {
  box-shadow: inset 0 0 0 5px rgba(196, 39, 39, 0.88), 0 0 12px rgba(196, 39, 39, 0.45);
}

.move-dot {
  width: 26%;
  height: 26%;
  border-radius: 50%;
  background: rgba(36, 36, 36, 0.35);
  pointer-events: none;
}

.target-capture {
  box-shadow: inset 0 0 0 5px rgba(173, 45, 45, 0.55);
}

.square.coord-rank::before,
.square.coord-file::after,
.active-game-main-sq.coord-rank::before,
.active-game-main-sq.coord-file::after,
.history-board-square.coord-rank::before,
.history-board-square.coord-file::after,
.demo-sq.coord-rank::before,
.demo-sq.coord-file::after,
.user-test-square.coord-rank::before,
.user-test-square.coord-file::after {
  position: absolute;
  color: rgba(34, 22, 15, 0.62);
  font-family: "Courier New", monospace;
  font-weight: 700;
  line-height: 1;
  pointer-events: none;
  z-index: 4;
}

.board.show-board-coordinates .square.coord-rank::before,
.active-game-main-preview.show-board-coordinates .active-game-main-sq.coord-rank::before,
.history-replay-board.show-board-coordinates .history-board-square.coord-rank::before,
.active-game-main-preview.show-board-coordinates .history-board-square.coord-rank::before,
.demo-board.show-board-coordinates .demo-sq.coord-rank::before,
.user-test-board.show-board-coordinates .user-test-square.coord-rank::before {
  content: attr(data-rank);
  top: 2px;
  left: 2px;
  font-size: clamp(8px, 0.72vw, 10px);
}

.board.show-board-coordinates .square.coord-file::after,
.active-game-main-preview.show-board-coordinates .active-game-main-sq.coord-file::after,
.history-replay-board.show-board-coordinates .history-board-square.coord-file::after,
.active-game-main-preview.show-board-coordinates .history-board-square.coord-file::after,
.demo-board.show-board-coordinates .demo-sq.coord-file::after,
.user-test-board.show-board-coordinates .user-test-square.coord-file::after {
  content: attr(data-file);
  right: 2px;
  bottom: 2px;
  font-size: clamp(8px, 0.72vw, 10px);
}

.board-drag-preview {
  position: fixed;
  width: min(9vw, 56px);
  height: min(9vw, 56px);
  transform: translate(-50%, -50%);
  pointer-events: none;
  opacity: 0;
  z-index: 3000;
  filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.4));
}

.board-drag-preview.active {
  opacity: 0.96;
}

#status {
  font-family: "Courier New", monospace;
  white-space: pre-wrap;
  font-size: 0.95rem;
}

#message {
  margin-top: 10px;
  font-weight: 700;
}

.config-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px;
  margin-bottom: 10px;
}

.clock-settings-group {
  border: 1px solid #cfbfa1;
  border-radius: 10px;
  background: rgba(255, 250, 238, 0.68);
  padding: 10px;
  margin-bottom: 10px;
}

.clock-settings-group h4 {
  margin: 0 0 8px;
  font-size: 0.95rem;
}

.slider-row {
  display: grid;
  grid-template-columns: 120px 1fr 64px;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  font-size: 0.9rem;
}

.slider-row input[type="range"] {
  width: 100%;
}

.sk-setup-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 10px;
}

.sk-setup-preset {
  text-align: left;
  border: 1px solid #d6b092;
  background: rgba(255, 245, 231, 0.92);
  color: #402415;
  border-radius: 10px;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: fit-content;
}

.sk-setup-name {
  font-weight: 700;
  font-size: 0.85rem;
}

.sk-setup-mini-board {
  width: 110px;
  height: 110px;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  grid-template-rows: repeat(5, 1fr);
  border: 2px solid #6f5840;
  border-radius: 4px;
}

.sk-setup-mini-square {
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}

.sk-setup-mini-square.skirmish-center-logo::before {
  content: "";
  position: absolute;
  inset: 22%;
  background-image: url("/static/skirmish-logo-variant-strike.svg");
  background-repeat: no-repeat;
  background-position: center;
  background-size: contain;
  opacity: 0.36;
  z-index: 1;
  transform-origin: center;
  animation: demoSkirmishCenterVibrate 1.5s ease-in-out infinite;
  pointer-events: none;
}

.sk-setup-mini-square.light {
  background: var(--light);
}

.sk-setup-mini-square.dark {
  background: var(--dark);
}

.sk-setup-mini-piece {
  width: 70%;
  height: 70%;
  object-fit: contain;
  pointer-events: none;
  position: relative;
  z-index: 2;
}

.sk-setup-mini-piece.sk-setup-piece-fade-out,
.sk-preview-question.sk-setup-piece-fade-out {
  opacity: 0;
  transition: opacity 160ms ease;
}

.sk-setup-mini-piece.sk-setup-piece-fade-in,
.sk-preview-question.sk-setup-piece-fade-in {
  opacity: 0;
  animation: demoPieceFadeIn 170ms ease forwards;
}

.sk-preview-question {
  font-family: "Courier New", monospace;
  font-weight: 700;
  font-size: 0.82rem;
  color: #2f2518;
}

.sk-setup-preset:hover {
  border-color: #cf4b2b;
  box-shadow: 0 0 0 2px rgba(255, 120, 68, 0.18);
}

.sk-setup-preset.active {
  border-color: #b51a1f;
  background: linear-gradient(180deg, rgba(255, 240, 224, 0.98), rgba(255, 207, 173, 0.96));
  box-shadow: 0 0 0 2px rgba(216, 25, 33, 0.24), 0 8px 16px rgba(216, 25, 33, 0.18);
  color: #7a1219;
}

.sk-setup-preset.active .sk-setup-name {
  color: #7a1219;
}

.skirmish-setup-config-grid {
  margin-top: 8px;
}

.slider-out {
  font-family: "Courier New", monospace;
  font-size: 0.86rem;
  text-align: right;
}

.button-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
  margin-bottom: 10px;
}

.play-create-game-heading {
  margin: 16px 0 10px;
  padding-top: 8px;
}

.play-create-game-heading h3 {
  margin: 0;
  font-family: var(--caps-title-font);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #4b3620;
}

#startPassAndPlayBtn {
  background: #6f7a66;
  color: #f7f3e8;
}

#startPassAndPlayBtn:hover {
  background: #7a866f;
}

#startBotBtn {
  background: #8f3a12;
  color: #fff5ef;
}

#startBotBtn:hover {
  background: #a3471b;
}

.bot-start-dialog {
  border: 1px solid #c8b297;
  border-radius: 12px;
  padding: 0;
  width: min(420px, calc(100vw - 24px));
  background: #fff8ef;
  color: #3b2a1b;
}

.bot-start-dialog::backdrop {
  background: rgba(25, 18, 12, 0.48);
}

.bot-start-form {
  display: grid;
  gap: 12px;
  padding: 16px;
}

.bot-start-form h3 {
  margin: 0;
  color: #8f3a12;
}

#uiConfirmMessage {
  margin: 0;
  font-size: 0.94rem;
  color: #4a3421;
}

.bot-start-form label {
  display: grid;
  gap: 6px;
  font-size: 0.92rem;
}

.bot-start-form select {
  border: 1px solid #c8b297;
  border-radius: 8px;
  padding: 8px;
  background-color: #fffaf2;
  color: #4a3421;
}

.bot-start-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.split-dropdown {
  position: relative;
  display: inline-flex;
}

.split-dropdown > button:first-child {
  border-top-right-radius: 0;
  border-bottom-right-radius: 0;
}

.split-dropdown-toggle {
  min-width: 40px;
  padding: 10px;
  border-left: 1px solid rgba(255, 255, 255, 0.35);
  border-top-left-radius: 0;
  border-bottom-left-radius: 0;
}

.split-dropdown-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 12;
  min-width: 220px;
  border: 1px solid #cdbb9f;
  border-radius: 10px;
  background: rgba(255, 253, 247, 0.98);
  box-shadow: 0 10px 18px rgba(0, 0, 0, 0.18);
  padding: 6px;
  display: grid;
  gap: 6px;
}

.split-dropdown-menu[hidden] {
  display: none;
}

.split-dropdown-menu button {
  width: 100%;
  text-align: left;
}

.preset-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
  margin-bottom: 10px;
}

.favorite-preset-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-bottom: 10px;
}

.favorite-preset-row.unavailable {
  display: none;
}

.favorite-preset-input {
  border: 1px solid #cbbda2;
  border-radius: 6px;
  padding: 8px;
  background: #fff;
  min-width: 220px;
}

#favoritePresetContainer {
  margin-bottom: 12px;
}

#favoritePresetContainer .preset-btn {
  width: 100%;
}

.preset-btn {
  text-align: left;
  border: 1px solid #d6b092;
  background: rgba(255, 245, 231, 0.92);
  color: #402415;
  border-radius: 10px;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.preset-btn span:first-child {
  font-weight: 700;
}

.preset-btn span:nth-child(2) {
  font-family: "Courier New", monospace;
  font-size: 0.88rem;
}

.preset-btn span:nth-child(3) {
  font-size: 0.82rem;
  opacity: 0.9;
}

.preset-btn:hover {
  border-color: #cf4b2b;
  box-shadow: 0 0 0 2px rgba(255, 120, 68, 0.18);
}

.preset-btn.active {
  border-color: #b51a1f;
  background: linear-gradient(180deg, rgba(255, 240, 224, 0.98), rgba(255, 207, 173, 0.96));
  box-shadow: 0 0 0 2px rgba(216, 25, 33, 0.24), 0 8px 16px rgba(216, 25, 33, 0.18);
}

.preset-btn.active span:first-child {
  color: #7a1219;
}

.preset-btn-favorite {
  border-color: #7b6bb1;
  background: rgba(238, 232, 252, 0.85);
}

.appearance-preview {
  border: 1px solid #cfbfa1;
  border-radius: 10px;
  background: rgba(255, 250, 238, 0.8);
  padding: 10px;
  margin-bottom: 12px;
}

.preview-title {
  font-size: 0.86rem;
  font-weight: 700;
  margin-bottom: 8px;
}

.preview-piece-row {
  display: flex;
  gap: 6px;
  margin-bottom: 10px;
}

.preview-piece-cell {
  width: 34px;
  height: 34px;
  border: 1px solid #cfbfa1;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
}

.preview-board {
  width: 120px;
  height: 120px;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  grid-template-rows: repeat(4, 1fr);
  border: 2px solid #6f5840;
}

.preview-square.light {
  background: var(--light);
}

.preview-square.dark {
  background: var(--dark);
}

.config-grid label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.9rem;
}

.config-grid input,
.config-grid select {
  border: 1px solid #cbbda2;
  border-radius: 6px;
  padding: 6px 8px;
  font-size: 0.95rem;
  background: #fff;
}

.hint {
  font-size: 0.9rem;
  color: #555;
}

.moves-panel {
  margin-top: 0;
  border: 1px solid #cfbfa1;
  border-radius: 10px;
  background: rgba(255, 250, 238, 0.82);
  padding: 8px;
  width: 220px;
  flex: 0 0 220px;
  min-width: 0;
}

.moves-panel h3 {
  margin: 0 0 6px;
}

.online-board-controls {
  display: grid;
  gap: 6px;
  margin-bottom: 8px;
  padding-bottom: 8px;
  border-bottom: 1px solid rgba(111, 88, 64, 0.25);
}

.online-board-actions {
  display: grid;
  gap: 6px;
}

.online-board-actions button {
  width: 100%;
  padding: 7px 8px;
  font-size: 0.82rem;
}

.online-inactivity-hint {
  margin: 0;
  font-size: 0.8rem;
  color: #5b4127;
  font-family: "Courier New", monospace;
}

.online-inactivity-hint.warn {
  color: #9a5d00;
  font-weight: 700;
}

.online-inactivity-hint.danger {
  color: #9a1a1a;
  font-weight: 700;
}

@keyframes drawOfferPulse {
  0% {
    transform: translateY(0);
    box-shadow: 0 8px 18px rgba(0, 0, 0, 0.3);
  }
  50% {
    transform: translateY(-1px);
    box-shadow: 0 10px 22px rgba(0, 0, 0, 0.38);
  }
  100% {
    transform: translateY(0);
    box-shadow: 0 8px 18px rgba(0, 0, 0, 0.3);
  }
}

@keyframes inactivityPulse {
  0% {
    filter: saturate(0.95);
  }
  50% {
    filter: saturate(1.15);
  }
  100% {
    filter: saturate(0.95);
  }
}

.moves-list {
  max-height: 220px;
  overflow-y: auto;
  font-family: "Courier New", monospace;
  font-size: 0.9rem;
}

.move-row {
  display: grid;
  grid-template-columns: 2.2em minmax(0, 1fr) minmax(0, 1fr);
  gap: 8px;
  padding: 2px 0;
  border-bottom: 1px dotted rgba(111, 88, 64, 0.25);
}

.move-row:last-child {
  border-bottom: none;
}

.move-num {
  color: #6f5840;
}

.move-entry-line {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 1.2em;
  min-width: 0;
}

.move-san {
  white-space: normal;
  overflow-wrap: anywhere;
}

.skirmish-move-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 1px;
  width: auto;
  background: rgba(111, 143, 91, 0.18);
  color: #234a27;
  border: 1px solid rgba(111, 143, 91, 0.45);
  border-radius: 6px;
  padding: 1px 4px;
  font-size: 0.72rem;
  font-family: "Courier New", monospace;
}

.skirmish-move-btn:hover {
  background: rgba(111, 143, 91, 0.3);
}

.skirmish-move-icon {
  width: 0.88em;
  height: 0.88em;
  flex: 0 0 auto;
}

.skirmish-move-outcome {
  font-weight: 800;
  color: #7d1b1f;
  line-height: 1;
}

.skirmish-detail {
  margin-top: 3px;
  font-size: 0.78rem;
  font-weight: 700;
  color: #4a3a2a;
  line-height: 1.2;
}

.clock-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  font-family: "Courier New", monospace;
  border: 1px solid #cfbfa1;
  border-radius: 8px;
  background: rgba(255, 250, 238, 0.75);
  padding: 6px 10px;
  margin: 6px 0;
  width: 100%;
  box-sizing: border-box;
}

.face-to-face-mode .main-play-area,
.face-to-face-mode .skirmish-play-area {
  grid-template-columns: minmax(0, 1fr) clamp(86px, 11vw, 106px);
  grid-template-rows: auto auto minmax(0, 1fr) minmax(0, 1fr) auto;
  grid-template-areas:
    "note note"
    "name-top clock-top"
    "board clock-top"
    "board clock-bottom"
    "name-bottom clock-bottom";
  column-gap: 2px;
  row-gap: 6px;
  align-items: stretch;
}

.face-to-face-mode .main-play-area .clock-row,
.face-to-face-mode .skirmish-play-area .clock-row {
  display: contents;
}

.face-to-face-mode .main-play-area .clock-time,
.face-to-face-mode .skirmish-play-area .clock-time {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  min-height: 0;
  border: 1px solid #cfbfa1;
  border-radius: 8px;
  background: rgba(255, 250, 238, 0.75);
  padding: 6px 4px;
  writing-mode: vertical-rl;
  text-orientation: mixed;
  white-space: nowrap;
}

.face-to-face-mode .main-play-area .clock-label,
.face-to-face-mode .skirmish-play-area .clock-label {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  justify-self: center;
  align-self: center;
  width: 100%;
  border: 1px solid #cfbfa1;
  border-radius: 8px;
  background: rgba(255, 250, 238, 0.75);
  padding: 4px 6px;
  writing-mode: horizontal-tb;
  text-orientation: initial;
  white-space: nowrap;
}

.face-to-face-mode #mainBlackClockRow .clock-label,
.face-to-face-mode #skirmishBlackClockRow .clock-label {
  grid-area: name-top;
  transform: rotate(180deg);
}

.face-to-face-mode #mainWhiteClockRow .clock-label,
.face-to-face-mode #skirmishWhiteClockRow .clock-label {
  grid-area: name-bottom;
}

.face-to-face-mode #mainBlackClockRow .clock-time,
.face-to-face-mode #skirmishBlackClockRow .clock-time {
  grid-area: clock-top;
}

.face-to-face-mode #mainWhiteClockRow .clock-time,
.face-to-face-mode #skirmishWhiteClockRow .clock-time {
  grid-area: clock-bottom;
}

.face-to-face-mode .main-play-area .clock-row.active .clock-time,
.face-to-face-mode .skirmish-play-area .clock-row.active .clock-time {
  border-color: #6f8f5b;
  box-shadow: 0 0 0 3px rgba(111, 143, 91, 0.32),
    0 0 14px rgba(111, 143, 91, 0.4);
  animation: activeClockPulse 0.9s ease-in-out infinite;
}

.clock-row.active {
  border-color: #6f8f5b;
  box-shadow: 0 0 0 3px rgba(111, 143, 91, 0.32), 0 0 14px rgba(111, 143, 91, 0.4);
  animation: activeClockPulse 0.9s ease-in-out infinite;
}

@media (min-width: 901px) {
  body.online-game .moves-panel,
  body:not(.face-to-face-mode) .moves-panel {
    width: 280px;
    flex: 0 0 280px;
  }

  body.online-game .moves-panel {
    display: flex;
    flex-direction: column;
  }

  body.online-game .moves-list {
    max-height: none;
    flex: 1 1 auto;
    min-height: 0;
  }

  body.desktop-main-centered .layout {
    grid-template-columns: 1fr;
    justify-items: center;
  }

  body.desktop-main-centered #mainPanel {
    width: min(1120px, 96vw);
  }

  body.desktop-main-centered #mainPanel .main-board-row {
    width: fit-content;
    margin: 0 auto;
  }

  body.desktop-skirmish-layout .layout {
    grid-template-columns: auto auto;
    column-gap: 14px;
    align-items: start;
    justify-content: center;
  }

  body.desktop-skirmish-layout #mainPanel {
    grid-column: 1;
    width: min(860px, 56vw);
  }

  body.desktop-skirmish-layout #mainPanel .main-board-row {
    width: fit-content;
    margin: 0;
  }

  body.desktop-skirmish-layout #skirmishPanel {
    grid-column: 2;
  }
}

.clock-label {
  font-weight: 700;
}

.clock-time {
  font-size: 1.1rem;
  font-weight: 700;
}

.turn-chip-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 6px;
}

.turn-chip {
  display: inline-block;
  border: 1px solid #b9ad97;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 0.85rem;
  font-weight: 700;
  background: rgba(255, 250, 238, 0.8);
}

.turn-chip.active {
  border-color: #6f8f5b;
  background: rgba(208, 232, 187, 0.65);
}

.engine-usage-badge {
  display: inline-block;
  border: 1px solid #b9ad97;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 0.78rem;
  line-height: 1.15;
  white-space: nowrap;
  font-weight: 700;
  background: rgba(255, 250, 238, 0.8);
  color: #2f2113;
  text-shadow: 0 0 0 transparent;
}

.engine-usage-badge.stockfish-on {
  border-color: #2e7d32;
  background: rgba(210, 238, 212, 0.78);
  color: #1f4c22;
}

.engine-usage-badge.stockfish-off {
  border-color: #a1772f;
  background: rgba(255, 240, 205, 0.84);
  color: #6d4b10;
}

.engine-usage-badge.danger {
  border-color: #a12e2e;
  background: rgba(255, 226, 226, 0.9);
  color: #7e1818;
}

.live-room-engine-badge {
  margin-left: 6px;
  padding: 2px 7px;
  font-size: 0.7rem;
}

.skirmish-urgency-label {
  margin: 2px 0 6px;
  padding: 6px 8px;
  border-radius: 8px;
  border: 1px solid #cfbfa1;
  background: rgba(255, 248, 230, 0.8);
  color: #5b4127;
  font-size: 0.86rem;
  font-weight: 700;
}

.skirmish-urgency-label.danger {
  border-color: #a12e2e;
  background: rgba(255, 226, 226, 0.86);
  color: #7e1818;
}

@keyframes overlayFlash {
  0% {
    background: rgba(20, 20, 20, 0.62);
  }
  50% {
    background: rgba(137, 17, 17, 0.72);
  }
  100% {
    background: rgba(20, 20, 20, 0.62);
  }
}

@keyframes overlayStrikeDrop {
  0% {
    transform: scale(3.3);
    opacity: 0.08;
  }
  62% {
    transform: scale(0.9);
    opacity: 0.42;
  }
  100% {
    transform: scale(1);
    opacity: 0.3;
  }
}

@keyframes skirmishCenterHum {
  0% {
    transform: translate3d(0, 0, 0) rotate(0deg);
  }
  6% {
    transform: translate3d(1px, -1px, 0) rotate(0.8deg);
  }
  12% {
    transform: translate3d(-1px, 1px, 0) rotate(-0.9deg);
  }
  18% {
    transform: translate3d(1px, 0, 0) rotate(0.7deg);
  }
  24% {
    transform: translate3d(-1px, -1px, 0) rotate(-0.7deg);
  }
  30% {
    transform: translate3d(0, 0, 0) rotate(0deg);
  }
  100% {
    transform: translate3d(0, 0, 0) rotate(0deg);
  }
}

@keyframes skirmishIntroTargetPulse {
  0% {
    box-shadow: inset 0 0 0 3px rgba(255, 202, 92, 0.42);
  }
  50% {
    box-shadow: inset 0 0 0 4px rgba(255, 202, 92, 0.92);
  }
  100% {
    box-shadow: inset 0 0 0 3px rgba(255, 202, 92, 0.42);
  }
}

@keyframes skirmishCenterStrikeIn {
  0% {
    transform: scale(6.2);
    opacity: 0.06;
  }
  58% {
    transform: scale(0.88);
    opacity: 0.46;
  }
  100% {
    transform: scale(1);
    opacity: 0.38;
  }
}

@keyframes skirmishResolveBadgePulse {
  0% {
    transform: scale(0.75);
    opacity: 0.45;
  }
  45% {
    transform: scale(1.5);
    opacity: 1;
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

@keyframes skirmishResolveBadgeVibrate {
  0% {
    transform: translate3d(0, 0, 0) scale(0.9);
    opacity: 0.6;
  }
  14% {
    transform: translate3d(1px, -1px, 0) rotate(3deg) scale(1.18);
    opacity: 1;
  }
  28% {
    transform: translate3d(-1px, 1px, 0) rotate(-3deg) scale(1.16);
  }
  42% {
    transform: translate3d(1px, 0, 0) rotate(2.5deg) scale(1.12);
  }
  56% {
    transform: translate3d(-1px, -1px, 0) rotate(-2deg) scale(1.08);
  }
  72% {
    transform: translate3d(0, 0, 0) rotate(1deg) scale(1.04);
  }
  100% {
    transform: translate3d(0, 0, 0) rotate(0deg) scale(1);
    opacity: 1;
  }
}

@keyframes demoSkirmishCenterVibrate {
  0%, 16% {
    transform: translate3d(0, 0, 0) rotate(0deg) scale(1);
    opacity: 0.42;
  }
  24% {
    transform: translate3d(1px, -1px, 0) rotate(3deg) scale(1.14);
    opacity: 0.95;
  }
  38% {
    transform: translate3d(-1px, 1px, 0) rotate(-3deg) scale(1.12);
    opacity: 0.86;
  }
  52% {
    transform: translate3d(1px, 0, 0) rotate(2deg) scale(1.08);
    opacity: 0.78;
  }
  66% {
    transform: translate3d(-1px, 0, 0) rotate(-2deg) scale(1.06);
    opacity: 0.7;
  }
  100% {
    transform: translate3d(0, 0, 0) rotate(0deg) scale(1);
    opacity: 0.42;
  }
}

@keyframes demoPieceFadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes activeClockPulse {
  0% {
    background: rgba(255, 250, 238, 0.78);
    box-shadow: 0 0 0 3px rgba(111, 143, 91, 0.3), 0 0 12px rgba(111, 143, 91, 0.32);
  }
  50% {
    background: rgba(205, 240, 170, 1);
    box-shadow: 0 0 0 5px rgba(111, 143, 91, 0.5), 0 0 22px rgba(111, 143, 91, 0.58);
  }
  100% {
    background: rgba(255, 250, 238, 0.78);
    box-shadow: 0 0 0 3px rgba(111, 143, 91, 0.3), 0 0 12px rgba(111, 143, 91, 0.32);
  }
}

@keyframes brandWordmarkStrikeHum {
  0% {
    transform: translateY(0.06em) translateX(0) rotate(0deg);
  }

  3% {
    transform: translateY(0.06em) translateX(-0.75px) rotate(-1.35deg);
  }

  6% {
    transform: translateY(0.06em) translateX(0.75px) rotate(1.35deg);
  }

  9% {
    transform: translateY(0.06em) translateX(-0.6px) rotate(-1deg);
  }

  12% {
    transform: translateY(0.06em) translateX(0.6px) rotate(1deg);
  }

  15% {
    transform: translateY(0.06em) translateX(0) rotate(0deg);
  }

  100% {
    transform: translateY(0.06em) translateX(0) rotate(0deg);
  }
}

@media (prefers-reduced-motion: reduce) {
  .clock-row.active {
    animation: none;
  }

  .brand-wordmark-icon {
    animation: none;
  }

  .board-overlay.flash,
  .board-overlay.countdown-logo-drop::after,
  .demo-sq.skirmish-center-logo::before,
  #skirmishBoard.skirmish-center-vibrating .square.skirmish-center-logo::before,
  #skirmishBoard.skirmish-logo-intro .square.skirmish-center-logo::before,
  #mainBoard.main-skirmish-resolve-pulse .square.last-move-skirmish-capture::after,
  .history-replay-board.replay-skirmish-finish-pulse
    .history-board-square.last-move-skirmish-capture::after {
    animation: none;
  }
}

@media (max-width: 900px) {
  .layout {
    grid-template-columns: 1fr;
    padding-left: 12px;
    padding-right: 12px;
  }

  .main-board-row {
    flex-direction: column;
    min-width: 0;
  }

  #mainPanel,
  #mainPanel .panel,
  .main-play-area,
  .skirmish-play-area {
    min-width: 0;
  }

  .board {
    max-width: 100%;
  }

  #mainBoard {
    justify-self: stretch;
    width: min(
      100%,
      calc(100vw - env(safe-area-inset-left) - env(safe-area-inset-right) - 32px)
    );
    max-width: 100%;
  }

  .main-play-area .board-wrap {
    width: min(
      100%,
      calc(100vw - env(safe-area-inset-left) - env(safe-area-inset-right) - 32px)
    );
  }

  .board-top-alerts {
    top: 4px;
    left: 4px;
    right: 4px;
    z-index: 30;
  }

  .board-top-alert {
    font-size: 0.8rem;
    padding: 7px 8px;
    gap: 8px;
  }

  #mainThinkingBtn {
    padding: 8px 10px;
    font-size: 0.78rem;
    min-height: 34px;
  }

  .moves-panel {
    width: 100%;
    flex: 0 1 auto;
  }

  .active-game-item {
    align-items: flex-start;
    flex-wrap: wrap;
  }

  .active-game-main-preview {
    width: min(100%, 160px);
    height: auto;
    aspect-ratio: 1;
    margin-left: 0;
  }

  #activeGamesList.live-rooms-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    justify-content: stretch;
  }

  #activeGamesList {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    justify-content: stretch;
  }

  #liveGamesList.live-rooms-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    justify-content: stretch;
  }

  #liveGamesList {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    justify-content: stretch;
  }

  .live-room-card {
    width: 100%;
    max-width: none;
  }
}

/* Auth Page Styles */
.auth-layout {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: calc(100vh - 60px);
  padding: 20px;
}

.auth-panel {
  width: 100%;
  max-width: 400px;
}

.auth-container {
  background: var(--panel-bg);
  border-radius: 8px;
  padding: 32px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.auth-tabs {
  display: flex;
  gap: 6px;
  padding: 4px;
  border: 1px solid #d7c8ad;
  border-radius: 10px;
  background: rgba(239, 225, 199, 0.55);
  margin-bottom: 24px;
}

.auth-tab {
  flex: 1;
  padding: 12px 16px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.95rem;
  font-weight: 600;
  color: #5f4a33;
  transition: all 0.2s ease;
}

.auth-tab:hover {
  color: #3f2f1d;
  background: rgba(255, 255, 255, 0.45);
}

.auth-tab.active {
  color: #fff;
  background: var(--accent-gradient);
  border-color: #b51a1f;
  box-shadow: 0 4px 10px var(--accent-shadow);
}

.auth-tab-panel {
  display: none;
}

.auth-tab-panel.active {
  display: block;
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-group label {
  font-weight: 500;
  font-size: 0.9rem;
  color: #333;
}

.form-group input,
.form-group select {
  padding: 10px 12px;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 0.95rem;
  font-family: inherit;
  transition: border-color 0.2s ease;
}

.form-group input:focus,
.form-group select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-ring);
}

.form-error {
  color: #c62828;
  font-size: 0.85rem;
  min-height: 16px;
}

.form-message {
  font-size: 0.85rem;
  padding: 8px;
  border-radius: 4px;
  text-align: center;
  min-height: 16px;
}

.auth-submit {
  padding: 12px 16px;
  background: var(--accent-gradient);
  color: white;
  border: none;
  border-radius: 4px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s ease;
}

.auth-submit:hover {
  background: var(--accent-gradient-strong);
}

.auth-submit:active {
  background: #a4131b;
}

.auth-back-link {
  display: block;
  width: 100%;
  margin-top: 14px;
  text-align: center;
}

/* User Page Styles */
.user-layout {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: calc(100vh - 60px);
  padding: 20px;
}

.user-panel {
  width: 100%;
  max-width: 600px;
}

@media (min-width: 980px) {
  .user-panel {
    max-width: 760px;
  }

  #userGamesList.history-cards-grid {
    grid-template-columns: repeat(3, minmax(172px, 210px));
    justify-content: start;
  }
}

.user-container {
  background: var(--panel);
  border-radius: 8px;
  padding: 32px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.user-username {
  margin-bottom: 24px;
  font-size: 1.8rem;
  color: #333;
}

.user-subtitle {
  margin-top: -16px;
  margin-bottom: 16px;
}

.user-tabs {
  margin-bottom: 16px;
}

.user-tabs .auth-tab {
  font-weight: 700;
}

.user-section {
  margin-bottom: 28px;
}

.user-section h3 {
  margin-bottom: 16px;
  font-size: 1.1rem;
  color: #333;
  border-bottom: 1px solid #eee;
  padding-bottom: 8px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 12px;
}

.elo-chart-card {
  border: 1px solid #e5dccb;
  border-radius: 10px;
  background: #fbf9f4;
  padding: 12px;
  margin-bottom: 12px;
}

.elo-chart-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

.elo-range-buttons {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.elo-range-btn {
  padding: 6px 9px;
  font-size: 0.78rem;
  border-radius: 8px;
  border: 1px solid #d6b092;
  background: rgba(255, 245, 231, 0.92);
  color: #402415;
}

.elo-range-btn:hover {
  border-color: #cf4b2b;
  box-shadow: 0 0 0 2px rgba(255, 120, 68, 0.18);
}

.elo-range-btn.active {
  border-color: #b51a1f;
  background: var(--accent-gradient);
  color: #fff;
  box-shadow: 0 0 0 2px rgba(216, 25, 33, 0.24);
}

.elo-chart {
  width: 100%;
  height: auto;
  aspect-ratio: 640 / 220;
  display: block;
  border: 1px solid #eadfcc;
  border-radius: 8px;
  background: linear-gradient(180deg, rgba(255, 250, 238, 0.96), rgba(255, 245, 231, 0.9));
}

.elo-grid {
  stroke: rgba(111, 88, 64, 0.24);
  stroke-width: 1;
}

.elo-line {
  stroke: #cf3f23;
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.elo-dot {
  fill: #d81921;
  stroke: #fff7ee;
  stroke-width: 2;
}

.elo-point {
  fill: rgba(175, 36, 20, 0.88);
}

.elo-point-hit {
  fill: transparent;
  cursor: pointer;
}

.elo-point-hit:focus {
  outline: none;
  stroke: rgba(184, 24, 34, 0.9);
  stroke-width: 2;
}

.elo-crosshair-line {
  stroke: rgba(168, 64, 32, 0.62);
  stroke-width: 1.6;
  stroke-dasharray: 3 3;
  pointer-events: none;
}

.elo-crosshair-dot {
  fill: #d81921;
  stroke: #fff7ee;
  stroke-width: 2;
  pointer-events: none;
}

.elo-crosshair-tip rect {
  fill: rgba(44, 24, 15, 0.92);
  stroke: rgba(255, 220, 190, 0.5);
  stroke-width: 1;
}

.elo-crosshair-value {
  fill: #ffe7cc;
  font-size: 12px;
  font-weight: 700;
  font-family: "Courier New", monospace;
}

.elo-crosshair-date {
  fill: #f6cfb2;
  font-size: 11px;
  font-family: "Courier New", monospace;
}

.elo-axis-label {
  fill: #6a4a2e;
  font-size: 12px;
  font-family: "Courier New", monospace;
}

.elo-last-label {
  fill: #7a1219;
  font-size: 12px;
  font-weight: 700;
  font-family: "Courier New", monospace;
}

.elo-chart-hint {
  margin: 8px 0 0;
}

.elo-extremes {
  margin-top: 10px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.elo-extreme-card {
  border: 1px solid #e0d4be;
  border-radius: 8px;
  padding: 8px 10px;
  background: #fffaf1;
  display: grid;
  gap: 2px;
}

.elo-extreme-card.up {
  border-color: rgba(20, 129, 71, 0.36);
}

.elo-extreme-card.down {
  border-color: rgba(176, 54, 44, 0.36);
}

.elo-extreme-label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: #6b4a2f;
}

.elo-extreme-value {
  font-size: 1.1rem;
  color: #3d2618;
}

.elo-extreme-date {
  font-size: 0.8rem;
}

.stat-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 16px;
  background: #f9f9f9;
  border-radius: 6px;
  border: 1px solid #eee;
}

.stat-label {
  font-size: 0.8rem;
  color: #666;
  text-transform: uppercase;
  margin-bottom: 8px;
}

.stat-value {
  font-size: 1.8rem;
  font-weight: bold;
  color: var(--accent);
}

.user-color-split {
  margin-top: 14px;
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

.color-split-card {
  border: 1px solid #e5dccb;
  border-radius: 8px;
  background: #fbf9f4;
  padding: 12px;
  display: grid;
  gap: 8px;
}

.color-split-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}

.result-bar {
  width: 100%;
  height: 12px;
  border-radius: 999px;
  overflow: hidden;
  display: flex;
  background: #ece7dc;
}

.result-segment {
  height: 100%;
  transition: width 0.28s ease;
}

.result-segment.win {
  background: #2e7d32;
}

.result-segment.draw {
  background: #a78554;
}

.result-segment.loss {
  background: #c62828;
}

.result-legend {
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: 0.85rem;
  color: #4f3b26;
}

.result-legend strong {
  color: #1f1f1f;
}

.preferences-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.preferences-inline-check {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
}

.preferences-inline-label {
  font-weight: 500;
  font-size: 0.9rem;
  color: #333;
  line-height: 1.3;
}

.toggle-switch {
  position: relative;
  display: inline-flex;
  width: 52px;
  height: 30px;
  flex: 0 0 auto;
  cursor: pointer;
}

.toggle-switch input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  inset: 0;
  border-radius: 999px;
  background: linear-gradient(180deg, #e9dac0 0%, #d8c2a0 100%);
  border: 1px solid #b69b73;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.14);
  transition: background 0.2s ease, border-color 0.2s ease;
}

.toggle-slider::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: linear-gradient(180deg, #fffdf9 0%, #f0e8dc 100%);
  border: 1px solid rgba(80, 51, 25, 0.28);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
  transition: transform 0.2s ease;
}

.toggle-switch input:checked + .toggle-slider {
  background: linear-gradient(180deg, #ffc47a 0%, #ff8d47 55%, #d81921 100%);
  border-color: #b51a1f;
}

.toggle-switch input:checked + .toggle-slider::after {
  transform: translateX(22px);
}

.toggle-switch input:focus-visible + .toggle-slider {
  box-shadow: 0 0 0 3px var(--accent-ring), inset 0 1px 2px rgba(0, 0, 0, 0.14);
}

select,
.history-select,
.form-group select,
.config-grid select {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  border: 1px solid #c59a6b;
  border-radius: 10px;
  background-color: #fff8ec;
  color: #3f2b14;
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  padding: 9px 36px 9px 12px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='9' viewBox='0 0 14 9'%3E%3Cpath d='M1 1l6 6 6-6' fill='none' stroke='%23793a1f' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 14px 9px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.62);
  transition: border-color 0.2s ease, box-shadow 0.2s ease, background-color 0.2s ease;
}

select:focus,
.history-select:focus,
.form-group select:focus,
.config-grid select:focus {
  outline: none;
  border-color: #b31d20;
  box-shadow: 0 0 0 3px var(--accent-ring), inset 0 1px 0 rgba(255, 255, 255, 0.62);
  background-color: #fff3df;
}

select::-ms-expand {
  display: none;
}

.user-test-board-wrap {
  border: 1px solid #cfbfa1;
  border-radius: 10px;
  background: rgba(255, 250, 238, 0.82);
  padding: 10px;
  display: grid;
  gap: 8px;
}

.user-test-board-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}

.user-test-board {
  width: min(100%, 360px);
  aspect-ratio: 1 / 1;
  border: 2px solid #6f5840;
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  grid-template-rows: repeat(8, 1fr);
}

.user-test-board.user-test-board-mini {
  width: min(100%, 220px);
  grid-template-columns: repeat(5, 1fr);
  grid-template-rows: repeat(5, 1fr);
}

.user-test-square {
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
  cursor: pointer;
}

.user-test-square.light {
  background: var(--user-preview-light, var(--light));
}

.user-test-square.dark {
  background: var(--user-preview-dark, var(--dark));
}

.user-test-square.selected {
  outline: 3px solid var(--select);
  outline-offset: -3px;
}

.user-test-square.drag-origin .user-test-piece {
  opacity: 0.28;
}

.user-test-square.drag-drop-hover {
  box-shadow: inset 0 0 0 4px rgba(72, 140, 235, 0.82), 0 0 0 1px rgba(72, 140, 235, 0.7);
}

.user-test-square.target-capture {
  box-shadow: inset 0 0 0 5px rgba(173, 45, 45, 0.55);
}

.user-test-square.last-move {
  box-shadow: inset 0 0 0 4px rgba(255, 238, 92, 0.78);
  animation: moveFlash 170ms ease-out 1;
}

.user-test-square.last-move-from {
  box-shadow: inset 0 0 0 4px rgba(255, 238, 92, 0.58);
  animation: moveFlash 170ms ease-out 1;
}

.user-test-piece {
  width: 84%;
  height: 84%;
  object-fit: contain;
  pointer-events: none;
}

.user-test-board-actions {
  display: flex;
  justify-content: flex-start;
}

.user-piece-palette {
  display: grid;
  gap: 6px;
}

.user-piece-palette-row {
  display: grid;
  grid-template-columns: repeat(6, minmax(28px, 40px));
  gap: 4px;
}

.user-piece-palette-square {
  aspect-ratio: 1 / 1;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(0, 0, 0, 0.14);
}

.user-piece-palette-square.light {
  background: var(--user-preview-light, var(--light));
}

.user-piece-palette-square.dark {
  background: var(--user-preview-dark, var(--dark));
}

.user-piece-style-minimal {
  filter: grayscale(0.65) contrast(1.05);
}

.user-piece-style-classic {
  filter: saturate(1.2) sepia(0.2);
}

.play-cta-logout {
  background: #c62828;
  color: white;
  border: none;
  cursor: pointer;
}

.play-cta-logout:hover {
  background: #b71c1c;
}

.user-history-pagination {
  margin-top: 10px;
}

.user-history-item {
  grid-template-columns: 1fr;
  grid-template-areas:
    "head"
    "mid"
    "bottom";
}

@media (max-width: 600px) {
  .auth-container,
  .user-container {
    padding: 20px;
  }
  
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .user-tabs .auth-tab {
    padding: 10px 8px;
    font-size: 0.84rem;
  }
}
