/**
 * ChessVora - Game styles
 * Used only by index.html (loading, menu, game screens)
 * Documentation styles are in css/documentation.css
 */

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --sky-top: #5bb8f5;
  --sky-bottom: #a8dff8;
  --grass: #5cb85c;
  --board-light: #f0d9b5;
  --board-dark: #b58863;
  --board-border: #8b6914;
  --player-blue: #3b7dd8;
  --player-blue-dark: #2563b8;
  --opponent-red: #e74c5c;
  --opponent-red-dark: #c0392b;
  --btn-blue: #4a90e2;
  --btn-blue-dark: #357abd;
  --btn-yellow: #f5a623;
  --btn-yellow-dark: #d4891a;
  --highlight-move: rgba(155, 199, 0, 0.5);
  --highlight-select: rgba(255, 255, 0, 0.5);
  --highlight-check: rgba(255, 0, 0, 0.6);
  --highlight-last: rgba(155, 199, 0, 0.35);
  --shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
  --radius: 16px;
  --font: 'Fredoka', 'Nunito', sans-serif;
  --game-font: var(--font);
  --stroke-blue: #1d4f91;
  --stroke-blue-deep: #12386b;
  --stroke-red: #9b2335;
  --stroke-red-deep: #6b1825;
  --stroke-brown: #5c3a18;
  --stroke-dark: #1a1a2e;
}

html, body {
  height: 100%;
  overflow: hidden;
  font-family: var(--font);
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

body {
  background: linear-gradient(180deg, var(--sky-top) 0%, var(--sky-bottom) 60%, var(--grass) 100%);
}

.backend-status {
  position: fixed;
  top: max(8px, env(safe-area-inset-top));
  left: 50%;
  transform: translateX(-50%);
  z-index: 50;
  width: min(720px, calc(100% - 24px));
  padding: 10px 14px;
  border: 2px solid var(--stroke-brown);
  border-radius: 12px;
  background: #fff8e4;
  color: var(--stroke-brown);
  font-family: var(--game-font);
  font-size: 0.82rem;
  font-weight: 800;
  line-height: 1.3;
  box-shadow: 0 4px 0 var(--stroke-brown), 0 8px 22px rgba(92, 58, 24, 0.28);
}

/* Screens */
.screen {
  position: fixed;
  inset: 0;
  display: none;
  flex-direction: column;
  z-index: 1;
}

.screen.active {
  display: flex;
}

/* ========== LOADING ========== */
.loading-bg, .menu-bg, .game-bg {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.loading-bg::before,
.menu-bg::before,
.game-bg::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    url('../assets/game-bg-pattern.svg') repeat,
    linear-gradient(180deg, #6ecff5 0%, #3d9fd9 55%, #2a7fbe 100%);
  background-size: 112px 112px, 100% 100%;
}

.loading-bg::after,
.menu-bg::after,
.game-bg::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 24%;
  background: linear-gradient(180deg, transparent 0%, rgba(72, 160, 72, 0.45) 55%, rgba(46, 125, 50, 0.75) 100%);
  pointer-events: none;
}

#loading-screen .loading-content {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  padding: 32px 24px;
  max-width: 400px;
  margin: 0 auto;
  width: 100%;
}

#loading-screen .loading-header {
  text-align: center;
  margin-bottom: 20px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
}

#loading-screen .loading-logo {
  width: clamp(120px, 36vw, 168px);
  height: clamp(120px, 36vw, 168px);
  object-fit: contain;
  margin-bottom: 14px;
  flex-shrink: 0;
  filter: drop-shadow(0 4px 12px rgba(92, 58, 24, 0.3));
  animation: loading-logo-pulse 1.8s ease-in-out infinite;
}

@keyframes loading-logo-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.1); }
}

#loading-screen .loading-header h1 {
  font-family: var(--game-font);
  font-size: 2rem;
  font-weight: 700;
  color: #fff;
  letter-spacing: 0.03em;
  -webkit-text-stroke: 2px var(--stroke-brown);
  paint-order: stroke fill;
  text-shadow: 0 3px 0 var(--stroke-brown), 0 5px 12px rgba(92, 58, 24, 0.35);
}

#loading-screen .loading-panel {
  width: 100%;
  background: linear-gradient(180deg, rgba(255, 248, 228, 0.95) 0%, rgba(255, 232, 178, 0.92) 100%);
  border: 3px solid var(--stroke-brown);
  border-radius: 20px;
  padding: 24px 20px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  box-shadow:
    0 6px 0 var(--stroke-brown),
    0 12px 28px rgba(92, 58, 24, 0.28),
    inset 0 1px 0 rgba(255, 255, 255, 0.55);
}

#loading-screen .loading-bar-wrap {
  width: 100%;
  height: 14px;
  padding: 3px;
  background: rgba(92, 58, 24, 0.14);
  border: 2px solid rgba(92, 58, 24, 0.28);
  border-radius: 14px;
  overflow: hidden;
  box-shadow: inset 0 2px 5px rgba(92, 58, 24, 0.12);
}

#loading-screen .loading-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(180deg, #ffe566 0%, #ffb347 48%, #ff9f2e 100%);
  border-radius: 9px;
  transition: width 0.3s ease;
  box-shadow:
    0 2px 0 var(--stroke-brown),
    inset 0 1px 0 rgba(255, 255, 255, 0.45);
}

#loading-screen .loading-text {
  color: var(--stroke-brown);
  font-family: var(--game-font);
  font-size: 0.74rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  -webkit-text-stroke: 0.5px rgba(92, 58, 24, 0.35);
  paint-order: stroke fill;
  text-shadow: none;
}

#loading-screen.ready {
  cursor: pointer;
}

#loading-screen.ready .loading-text {
  animation: loading-tap-hint 1.2s ease-in-out infinite;
}

@keyframes loading-tap-hint {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.55; }
}

/* ========== MENU ========== */
#menu-screen .menu-content {
  position: relative;
  z-index: 2;
  height: 100%;
  min-height: 0;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding:
    max(16px, env(safe-area-inset-top))
    max(20px, env(safe-area-inset-right))
    max(20px, env(safe-area-inset-bottom))
    max(20px, env(safe-area-inset-left));
  max-width: 400px;
  margin: 0 auto;
  width: 100%;
  box-sizing: border-box;
}

#menu-screen .menu-header {
  text-align: center;
  margin-bottom: 22px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
}

#menu-screen .menu-logo {
  width: clamp(148px, 42vw, 200px);
  height: clamp(148px, 42vw, 200px);
  object-fit: contain;
  margin-bottom: 12px;
  flex-shrink: 0;
  filter: drop-shadow(0 4px 12px rgba(92, 58, 24, 0.3));
}

#menu-screen .menu-header h1 {
  font-family: var(--game-font);
  font-size: 2rem;
  font-weight: 700;
  color: #fff;
  letter-spacing: 0.03em;
  -webkit-text-stroke: 2px var(--stroke-brown);
  paint-order: stroke fill;
  text-shadow: 0 3px 0 var(--stroke-brown), 0 5px 12px rgba(92, 58, 24, 0.35);
}

#menu-screen .menu-panel {
  background: linear-gradient(180deg, rgba(255, 248, 228, 0.95) 0%, rgba(255, 232, 178, 0.92) 100%);
  border: 3px solid var(--stroke-brown);
  border-radius: 20px;
  padding: 22px 18px;
  display: flex;
  flex-direction: column;
  gap: 22px;
  box-shadow:
    0 6px 0 var(--stroke-brown),
    0 12px 28px rgba(92, 58, 24, 0.28),
    inset 0 1px 0 rgba(255, 255, 255, 0.55);
}

#menu-screen .menu-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

#menu-screen .menu-label {
  font-family: var(--game-font);
  font-size: 0.74rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--stroke-brown);
  padding-left: 4px;
  -webkit-text-stroke: 0.5px rgba(92, 58, 24, 0.35);
  paint-order: stroke fill;
}

#menu-screen .segmented {
  display: flex;
  gap: 5px;
  padding: 5px;
  background: rgba(92, 58, 24, 0.14);
  border: 2px solid rgba(92, 58, 24, 0.28);
  border-radius: 14px;
  box-shadow: inset 0 2px 5px rgba(92, 58, 24, 0.12);
}

#menu-screen .diff-card,
#menu-screen .time-card,
#menu-screen .color-card {
  flex: 1;
  border: 2px solid rgba(92, 58, 24, 0.2);
  border-radius: 11px;
  padding: 11px 6px;
  background: rgba(255, 255, 255, 0.45);
  font-family: var(--game-font);
  font-weight: 700;
  font-size: 0.82rem;
  color: rgba(92, 58, 24, 0.82);
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
  text-align: center;
  -webkit-text-stroke: 0;
  text-shadow: none;
}

#menu-screen .color-card {
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

#menu-screen .diff-card:hover,
#menu-screen .time-card:hover,
#menu-screen .color-card:hover {
  transform: translateY(-1px);
  background: rgba(255, 255, 255, 0.65);
  border-color: rgba(92, 58, 24, 0.35);
}

#menu-screen .diff-card.selected,
#menu-screen .time-card.selected,
#menu-screen #setting-color:checked ~ .color-grid .pick-white,
#menu-screen #setting-color:not(:checked) ~ .color-grid .pick-black {
  color: #fff;
  background: linear-gradient(180deg, #ffe566 0%, #ffb347 48%, #ff9f2e 100%);
  border-color: var(--stroke-brown);
  box-shadow:
    0 3px 0 var(--stroke-brown),
    inset 0 1px 0 rgba(255, 255, 255, 0.45);
  -webkit-text-stroke: 0.8px var(--stroke-brown);
  paint-order: stroke fill;
  text-shadow: 0 1px 0 rgba(92, 58, 24, 0.4);
}

#menu-screen .diff-card:active,
#menu-screen .time-card:active,
#menu-screen .color-card:active {
  transform: translateY(1px);
  box-shadow: 0 1px 0 var(--stroke-brown);
}

.settings-list {
  background: rgba(92, 58, 24, 0.1);
  border: 2px solid rgba(92, 58, 24, 0.22);
  border-radius: 14px;
  padding: 8px 14px;
  box-shadow: inset 0 2px 5px rgba(92, 58, 24, 0.08);
}

.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0;
  border-bottom: 1px solid rgba(92, 58, 24, 0.15);
  cursor: pointer;
  font-family: var(--game-font);
  font-weight: 600;
  font-size: 0.92rem;
  color: var(--stroke-brown);
  gap: 8px;
}

.setting-row:last-child { border-bottom: none; }

.setting-row input { display: none; }

.toggle {
  width: 48px;
  height: 26px;
  background: rgba(92, 58, 24, 0.18);
  border: 1px solid rgba(92, 58, 24, 0.28);
  border-radius: 13px;
  position: relative;
  transition: background 0.2s, border-color 0.2s;
  flex-shrink: 0;
}

.toggle::after {
  content: '';
  position: absolute;
  width: 22px;
  height: 22px;
  background: #fff;
  border-radius: 50%;
  top: 1px;
  left: 2px;
  transition: transform 0.2s;
  box-shadow: 0 1px 3px rgba(92, 58, 24, 0.35);
}

.setting-row input:checked + .toggle {
  background: linear-gradient(180deg, #ffe566 0%, #ffb347 48%, #ff9f2e 100%);
  border-color: var(--stroke-brown);
}

.setting-row input:checked + .toggle::after {
  transform: translateX(22px);
}

#menu-screen .btn-play {
  width: 100%;
  padding: 18px 16px;
  margin-top: 20px;
  margin-bottom: 4px;
  flex-shrink: 0;
  border: 3px solid var(--stroke-brown);
  border-radius: 16px;
  font-family: var(--game-font);
  font-size: 1.15rem;
  font-weight: 700;
  color: #fff;
  cursor: pointer;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  transition: transform 0.15s ease, box-shadow 0.15s ease, filter 0.15s ease;
  background: linear-gradient(180deg, #ffe566 0%, #ffb347 48%, #ff9f2e 100%);
  box-shadow:
    0 5px 0 var(--stroke-brown),
    0 8px 22px rgba(92, 58, 24, 0.35),
    inset 0 1px 0 rgba(255, 255, 255, 0.45);
  -webkit-text-stroke: 1.2px var(--stroke-brown);
  paint-order: stroke fill;
  text-shadow: 0 2px 0 rgba(92, 58, 24, 0.45);
  position: relative;
  overflow: hidden;
}

#menu-screen .btn-play::before {
  content: '';
  position: absolute;
  inset: 0 0 50%;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.38) 0%, transparent 100%);
  border-radius: 12px 12px 50% 50%;
  pointer-events: none;
}

#menu-screen .btn-play:hover {
  transform: translateY(-2px);
  filter: brightness(1.05);
  box-shadow:
    0 7px 0 var(--stroke-brown),
    0 12px 26px rgba(92, 58, 24, 0.4),
    inset 0 1px 0 rgba(255, 255, 255, 0.45);
}

#menu-screen .btn-play:active {
  transform: translateY(3px);
  filter: brightness(0.98);
  box-shadow:
    0 2px 0 var(--stroke-brown),
    0 4px 10px rgba(92, 58, 24, 0.28),
    inset 0 1px 0 rgba(255, 255, 255, 0.25);
}

/* ========== META GAME SHELL ========== */
.shell-screen {
  overflow: hidden;
}

.shell-screen .menu-bg {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.shell-content {
  position: relative;
  z-index: 2;
  width: min(1120px, 100%);
  height: 100%;
  margin: 0 auto;
  padding:
    max(14px, env(safe-area-inset-top))
    max(16px, env(safe-area-inset-right))
    max(18px, env(safe-area-inset-bottom))
    max(16px, env(safe-area-inset-left));
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

.dashboard-content {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.shell-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.shell-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.shell-logo {
  width: 72px;
  height: 72px;
  object-fit: contain;
  filter: drop-shadow(0 4px 10px rgba(92, 58, 24, 0.28));
  flex-shrink: 0;
}

.shell-brand h1,
.shell-page-head h1 {
  color: #fff;
  font-family: var(--game-font);
  font-size: clamp(1.45rem, 4vw, 2.35rem);
  font-weight: 700;
  line-height: 1.05;
  -webkit-text-stroke: 1.5px var(--stroke-brown);
  paint-order: stroke fill;
  text-shadow: 0 3px 0 var(--stroke-brown), 0 5px 12px rgba(92, 58, 24, 0.32);
}

.shell-brand p,
.shell-page-head p,
#menu-screen .menu-subtitle {
  color: #fff8e4;
  font-size: 0.9rem;
  font-weight: 700;
  line-height: 1.35;
  text-shadow: 0 2px 4px rgba(92, 58, 24, 0.45);
}

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

.btn-compact,
.link-btn,
.shell-nav-btn {
  border: 2px solid var(--stroke-brown);
  background: rgba(255, 248, 228, 0.92);
  color: var(--stroke-brown);
  font-family: var(--game-font);
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 3px 0 var(--stroke-brown);
}

.btn-compact {
  border-radius: 12px;
  padding: 9px 12px;
  font-size: 0.82rem;
}

.btn-compact:hover,
.link-btn:hover,
.shell-nav-btn:hover {
  transform: translateY(-1px);
}

.shell-nav {
  display: flex;
  gap: 7px;
  padding: 6px;
  border: 2px solid rgba(92, 58, 24, 0.28);
  border-radius: 14px;
  background: rgba(92, 58, 24, 0.14);
  overflow-x: auto;
  flex-shrink: 0;
}

.shell-nav-btn {
  border-radius: 10px;
  padding: 8px 11px;
  font-size: 0.78rem;
  white-space: nowrap;
}

.shell-nav-btn.active {
  color: #fff;
  background: linear-gradient(180deg, #ffe566 0%, #ffb347 48%, #ff9f2e 100%);
  -webkit-text-stroke: 0.6px var(--stroke-brown);
  paint-order: stroke fill;
}

.dashboard-grid,
.profile-grid {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 12px;
  align-items: stretch;
}

.shell-panel {
  background: linear-gradient(180deg, rgba(255, 248, 228, 0.96) 0%, rgba(255, 232, 178, 0.93) 100%);
  border: 3px solid var(--stroke-brown);
  border-radius: 16px;
  padding: 16px;
  box-shadow:
    0 5px 0 var(--stroke-brown),
    0 10px 24px rgba(92, 58, 24, 0.24),
    inset 0 1px 0 rgba(255, 255, 255, 0.5);
  min-width: 0;
}

.panel-label {
  display: block;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(92, 58, 24, 0.75);
  margin-bottom: 7px;
}

.shell-panel h2 {
  color: var(--stroke-brown);
  font-size: clamp(1.25rem, 3vw, 2rem);
  line-height: 1.05;
  margin-bottom: 7px;
}

.shell-panel p,
.shell-panel span {
  color: var(--stroke-brown);
}

.prize-panel {
  grid-column: span 5;
}

.profile-summary {
  grid-column: span 4;
}

.rank-card {
  grid-column: span 3;
}

.next-unlock-panel {
  grid-column: span 3;
}

.quests-preview,
.leaderboard-preview {
  grid-column: span 6;
}

.recent-practice-panel {
  grid-column: span 12;
}

.summary-row,
.panel-head,
.leader-row,
.quest-row,
.profile-hero {
  display: flex;
  align-items: center;
  gap: 12px;
}

.panel-head {
  justify-content: space-between;
}

.profile-avatar {
  width: 58px;
  height: 58px;
  border-radius: 50%;
  border: 2px solid var(--stroke-brown);
  background: rgba(255, 255, 255, 0.55);
  object-fit: cover;
  flex-shrink: 0;
}

.profile-avatar-frame {
  --frame-a: rgba(92, 58, 24, 0.5);
  --frame-b: rgba(255, 255, 255, 0.8);
  position: relative;
  display: grid;
  place-items: center;
  width: 118px;
  height: 118px;
  border-radius: 50%;
  padding: 8px;
  background: conic-gradient(from 45deg, var(--frame-a), var(--frame-b), var(--frame-a));
  box-shadow: 0 4px 0 var(--stroke-brown), 0 10px 20px rgba(92, 58, 24, 0.24);
  flex: 0 0 auto;
}

.profile-avatar-frame .profile-avatar.large {
  width: 96px;
  height: 96px;
}

.frame-default {
  --frame-a: rgba(92, 58, 24, 0.45);
  --frame-b: rgba(255, 248, 228, 0.95);
}

.frame-bronze {
  --frame-a: #a46536;
  --frame-b: #ffd0a3;
}

.frame-silver {
  --frame-a: #8f9aa9;
  --frame-b: #eef5ff;
}

.frame-gold {
  --frame-a: #f0aa2d;
  --frame-b: #fff0a8;
}

.frame-royal {
  --frame-a: #6f4dd7;
  --frame-b: #ffd86b;
}

.profile-avatar.large {
  width: 96px;
  height: 96px;
}

.level-line,
.pool-stats {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  margin: 12px 0 7px;
  font-weight: 800;
}

.progress-track {
  width: 100%;
  height: 13px;
  padding: 3px;
  border-radius: 12px;
  background: rgba(92, 58, 24, 0.16);
  border: 1px solid rgba(92, 58, 24, 0.24);
  overflow: hidden;
}

.progress-fill {
  width: 0%;
  height: 100%;
  border-radius: 8px;
  background: linear-gradient(180deg, #8bd450 0%, #4caf50 100%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.4);
}

.trust-note {
  margin-top: 9px;
  font-size: 0.78rem;
  line-height: 1.35;
  color: rgba(92, 58, 24, 0.78) !important;
}

.quest-list,
.leader-list,
.practice-match-list,
.unlock-list,
.cosmetic-grid,
.medal-grid,
.leaderboard-table {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.quest-row,
.leader-row,
.practice-match-row,
.cosmetic-item,
.medal-item,
.unlock-item {
  border: 2px solid rgba(92, 58, 24, 0.18);
  border-radius: 12px;
  padding: 10px;
  background: rgba(255, 255, 255, 0.42);
}

.visual-cosmetic-item,
.visual-unlock-item {
  display: flex;
  align-items: center;
  gap: 10px;
}

.visual-unlock-item {
  position: relative;
}

.quest-row {
  justify-content: space-between;
}

.unlock-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.unlock-actions {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-left: auto;
}

.unlock-preview {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border: 2px solid rgba(92, 58, 24, 0.18);
  border-radius: 12px;
  padding: 10px;
  background: rgba(255, 255, 255, 0.42);
}

.cosmetic-preview {
  width: 56px;
  height: 56px;
  border: 2px solid rgba(92, 58, 24, 0.22);
  border-radius: 10px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.58);
  color: var(--stroke-brown);
  font-weight: 900;
}

.cosmetic-preview.small {
  width: 44px;
  height: 44px;
  border-radius: 9px;
}

.cosmetic-preview img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.cosmetic-preview-board_skin {
  grid-template-columns: repeat(4, 1fr);
  grid-template-rows: repeat(4, 1fr);
  gap: 0;
  padding: 4px;
}

.cosmetic-preview-board_skin span {
  display: block;
  width: 100%;
  height: 100%;
}

.cosmetic-preview-board_skin span:nth-child(8n+1),
.cosmetic-preview-board_skin span:nth-child(8n+3),
.cosmetic-preview-board_skin span:nth-child(8n+6),
.cosmetic-preview-board_skin span:nth-child(8n+8) {
  background: var(--board-light, #f4d79a);
}

.cosmetic-preview-board_skin span:nth-child(8n+2),
.cosmetic-preview-board_skin span:nth-child(8n+4),
.cosmetic-preview-board_skin span:nth-child(8n+5),
.cosmetic-preview-board_skin span:nth-child(8n+7) {
  background: var(--board-dark, #7a9c54);
}

.board-classic {
  --board-light: #f1d9b5;
  --board-dark: #8d6a49;
}

.board-royal-meadow {
  --board-light: #f6e7ad;
  --board-dark: #7aa55e;
}

.board-midnight {
  --board-light: #9fb0c8;
  --board-dark: #253045;
}

.board-royal {
  --board-light: #f8df8a;
  --board-dark: #6945a8;
}

.board-emerald {
  --board-light: #d8f4c8;
  --board-dark: #18885d;
}

.cosmetic-preview-piece_skin {
  display: flex;
  gap: 2px;
  font-size: 1rem;
}

.pieces-marble {
  background: linear-gradient(135deg, #ffffff, #cfd6df);
}

.pieces-shadow {
  background: linear-gradient(135deg, #2b2c34, #6a6d78);
  color: #f4f4f4;
}

.pieces-crown {
  background: linear-gradient(135deg, #fff1a6, #a76924);
}

.cosmetic-preview-badge,
.cosmetic-preview-medal,
.cosmetic-preview-title,
.cosmetic-preview-checkmate_effect {
  border-radius: 50%;
  background: radial-gradient(circle at 30% 25%, rgba(255, 255, 255, 0.85), rgba(255, 179, 71, 0.45));
}

.cosmetic-preview-title {
  border-radius: 10px;
}

.cosmetic-preview-checkmate_effect {
  background: radial-gradient(circle, rgba(255, 229, 102, 0.95), rgba(111, 77, 215, 0.42));
}

.rarity-uncommon {
  border-color: rgba(37, 135, 91, 0.45);
}

.rarity-rare {
  border-color: rgba(29, 79, 145, 0.5);
}

.rarity-epic {
  border-color: rgba(111, 77, 215, 0.58);
}

.rarity-legendary {
  border-color: rgba(240, 170, 45, 0.74);
}

.unlock-item.equipped {
  border-color: rgba(76, 175, 80, 0.72);
  box-shadow: inset 0 0 0 2px rgba(139, 212, 80, 0.22);
}

.unlock-item.next-unlock-marker::after {
  content: "Next";
  position: absolute;
  top: -8px;
  left: 12px;
  padding: 3px 7px;
  border-radius: 999px;
  background: #ffe566;
  border: 1px solid rgba(92, 58, 24, 0.34);
  color: var(--stroke-brown);
  font-size: 0.62rem;
  font-weight: 900;
}

.unlock-item.locked::before {
  content: "Locked";
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  border-radius: 10px;
  background: rgba(255, 248, 228, 0.62);
  color: rgba(92, 58, 24, 0.72);
  font-size: 0.72rem;
  font-weight: 900;
  pointer-events: none;
}

.unlock-item.locked > * {
  opacity: 0.48;
}

.equipped-pill {
  border-radius: 999px;
  padding: 5px 8px;
  background: rgba(139, 212, 80, 0.28);
  border: 1px solid rgba(92, 58, 24, 0.22);
  font-size: 0.68rem;
  font-weight: 900;
}

.locked-action {
  opacity: 0.7;
  cursor: not-allowed;
}

.practice-match-row {
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.practice-match-title {
  color: var(--stroke-brown);
  font-size: 0.86rem;
  font-weight: 800;
}

.practice-match-meta,
.practice-match-result {
  color: rgba(92, 58, 24, 0.72);
  font-size: 0.74rem;
  font-weight: 800;
}

.practice-match-result {
  flex: 0 0 auto;
  text-transform: uppercase;
}

.practice-match-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
}

.mini-action-btn {
  min-width: 52px;
  min-height: 30px;
  border: 2px solid rgba(92, 58, 24, 0.28);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.72);
  color: var(--stroke-brown);
  font-family: var(--game-font);
  font-size: 0.72rem;
  font-weight: 800;
  cursor: pointer;
}

.inventory-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 10px;
}

.inventory-tab {
  min-height: 30px;
  border: 2px solid rgba(92, 58, 24, 0.24);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.58);
  color: var(--stroke-brown);
  font-family: var(--game-font);
  font-size: 0.68rem;
  font-weight: 800;
  cursor: pointer;
}

.inventory-tab.active {
  background: rgba(139, 212, 80, 0.34);
  border-color: rgba(92, 58, 24, 0.48);
}

.quest-title,
.leader-name,
.cosmetic-title,
.medal-title,
.unlock-title {
  font-weight: 800;
  color: var(--stroke-brown);
}

.quest-meta,
.leader-meta,
.cosmetic-meta,
.medal-meta,
.unlock-meta {
  font-size: 0.78rem;
  font-weight: 700;
  color: rgba(92, 58, 24, 0.72);
}

.quest-reward {
  flex-shrink: 0;
  border-radius: 999px;
  padding: 5px 8px;
  background: rgba(255, 179, 71, 0.28);
  border: 1px solid rgba(92, 58, 24, 0.22);
  font-size: 0.76rem;
  font-weight: 800;
  color: var(--stroke-brown);
}

.quest-row.completed {
  background: rgba(139, 212, 80, 0.23);
}

.leader-row {
  justify-content: space-between;
}

.link-btn {
  border-radius: 10px;
  padding: 6px 9px;
  font-size: 0.76rem;
}

.shell-main-play {
  width: min(420px, 100%);
  align-self: center;
  padding: 18px 16px;
  border: 3px solid var(--stroke-brown);
  border-radius: 16px;
  font-family: var(--game-font);
  font-size: 1.1rem;
  font-weight: 800;
  color: #fff;
  cursor: pointer;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  background: linear-gradient(180deg, #ffe566 0%, #ffb347 48%, #ff9f2e 100%);
  box-shadow:
    0 5px 0 var(--stroke-brown),
    0 8px 22px rgba(92, 58, 24, 0.35),
    inset 0 1px 0 rgba(255, 255, 255, 0.45);
  -webkit-text-stroke: 1.1px var(--stroke-brown);
  paint-order: stroke fill;
}

.shell-page-head {
  margin: 14px 0;
}

.profile-hero,
.profile-quests {
  grid-column: span 12;
}

.profile-grid .shell-panel:not(.profile-hero):not(.profile-quests) {
  grid-column: span 4;
}

.cosmetic-grid,
.medal-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.medal-item.locked,
.unlock-item.locked {
  opacity: 0.55;
}

.leaderboard-page {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.leaderboard-tabs {
  display: flex;
  gap: 7px;
  overflow-x: auto;
  padding-bottom: 3px;
}

.leaderboard-tab {
  border: 2px solid rgba(92, 58, 24, 0.28);
  border-radius: 10px;
  padding: 8px 10px;
  background: rgba(255, 255, 255, 0.45);
  color: var(--stroke-brown);
  font-family: var(--game-font);
  font-weight: 800;
  white-space: nowrap;
  cursor: pointer;
}

.leaderboard-tab.active {
  color: #fff;
  border-color: var(--stroke-brown);
  background: linear-gradient(180deg, #ffe566 0%, #ffb347 48%, #ff9f2e 100%);
  -webkit-text-stroke: 0.6px var(--stroke-brown);
  paint-order: stroke fill;
}

.leaderboard-entry {
  display: grid;
  grid-template-columns: 54px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  border: 2px solid rgba(92, 58, 24, 0.18);
  border-radius: 12px;
  padding: 10px;
  background: rgba(255, 255, 255, 0.42);
}

.leaderboard-entry .place {
  font-weight: 900;
  color: var(--stroke-brown);
}

#menu-screen .mode-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

#menu-screen .mode-card {
  min-height: 76px;
  border: 2px solid rgba(92, 58, 24, 0.22);
  border-radius: 12px;
  padding: 10px;
  background: rgba(255, 255, 255, 0.45);
  color: var(--stroke-brown);
  font-family: var(--game-font);
  text-align: left;
  cursor: pointer;
  box-shadow: 0 2px 0 rgba(92, 58, 24, 0.28);
}

#menu-screen .mode-card strong {
  display: block;
  margin-bottom: 4px;
  color: var(--stroke-brown);
  font-size: 0.86rem;
}

#menu-screen .mode-card span {
  display: block;
  color: rgba(92, 58, 24, 0.72);
  font-size: 0.74rem;
  line-height: 1.25;
  font-weight: 700;
}

#menu-screen .mode-card.selected {
  color: #fff;
  border-color: var(--stroke-brown);
  background: linear-gradient(180deg, #ffe566 0%, #ffb347 48%, #ff9f2e 100%);
}

#menu-screen .mode-card.selected strong,
#menu-screen .mode-card.selected span {
  color: #fff;
  -webkit-text-stroke: 0.45px var(--stroke-brown);
  paint-order: stroke fill;
}

.matchmaking-modal {
  max-width: 360px;
}

.matchmaking-bars {
  display: flex;
  gap: 7px;
  justify-content: center;
  margin: 18px 0 4px;
}

.matchmaking-bars span {
  width: 12px;
  height: 32px;
  border-radius: 7px;
  background: linear-gradient(180deg, #ffe566 0%, #ff9f2e 100%);
  border: 1px solid var(--stroke-brown);
  animation: match-pulse 0.75s ease-in-out infinite;
}

.matchmaking-bars span:nth-child(2) { animation-delay: 0.12s; }
.matchmaking-bars span:nth-child(3) { animation-delay: 0.24s; }

@keyframes match-pulse {
  0%, 100% { transform: scaleY(0.45); opacity: 0.65; }
  50% { transform: scaleY(1); opacity: 1; }
}

.wallet-modal {
  max-width: 420px;
  text-align: left;
}

.public-match-modal {
  max-width: 680px;
  text-align: left;
}

.public-match-layout {
  display: grid;
  grid-template-columns: minmax(220px, 320px) 1fr;
  gap: 16px;
  align-items: start;
}

.public-board {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  width: min(320px, 100%);
  aspect-ratio: 1;
  border: 3px solid var(--stroke-brown);
  border-radius: 8px;
  overflow: hidden;
}

.public-square {
  display: grid;
  place-items: center;
}

.public-square.light {
  background: #f6d79b;
}

.public-square.dark {
  background: #b7743f;
}

.public-square .piece {
  width: 72%;
  height: 72%;
}

.public-moves {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  max-height: 320px;
  overflow: auto;
}

.public-moves span {
  border: 1px solid rgba(92, 58, 24, 0.22);
  border-radius: 8px;
  padding: 5px 7px;
  color: rgba(92, 58, 24, 0.82);
  font-size: 0.76rem;
  font-weight: 800;
}

@media (max-width: 720px) {
  .public-match-layout {
    grid-template-columns: 1fr;
  }

  .public-board {
    width: min(320px, 100%);
    justify-self: center;
  }
}

.wallet-modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 8px;
}

.wallet-modal h3 {
  margin-bottom: 0;
}

.modal-icon-btn {
  width: 36px;
  height: 36px;
  border: 2px solid rgba(92, 58, 24, 0.35);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.55);
  color: var(--stroke-brown);
  font-family: var(--game-font);
  font-size: 1.25rem;
  font-weight: 800;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 2px 0 rgba(92, 58, 24, 0.22);
}

.wallet-list {
  display: grid;
  gap: 8px;
  margin: 14px 0 12px;
}

.wallet-option {
  width: 100%;
  min-height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
  border: 2px solid rgba(92, 58, 24, 0.35);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.58);
  color: var(--stroke-brown);
  font-family: var(--game-font);
  text-align: left;
  cursor: pointer;
  box-shadow: 0 3px 0 rgba(92, 58, 24, 0.22);
}

.wallet-option:hover {
  background: rgba(255, 255, 255, 0.76);
}

.wallet-option:disabled {
  cursor: wait;
  opacity: 0.72;
}

.wallet-option.busy {
  border-color: var(--stroke-blue);
  background: rgba(223, 246, 255, 0.82);
}

.wallet-option.preferred {
  border-color: #ffca3a;
  background: rgba(255, 244, 207, 0.9);
  box-shadow:
    0 3px 0 rgba(92, 58, 24, 0.22),
    0 0 0 3px rgba(255, 202, 58, 0.24) inset;
}

.wallet-meta {
  display: flex;
  align-items: center;
  gap: 10px;
}

.wallet-mark {
  width: 38px;
  height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  border: 2px solid rgba(92, 58, 24, 0.35);
  background: #ffffff;
  color: var(--stroke-blue-deep);
  font-weight: 800;
}

.wallet-mark img {
  width: 27px;
  height: 27px;
  object-fit: contain;
}

.wallet-name {
  display: block;
  font-size: 0.94rem;
  font-weight: 800;
}

.wallet-state {
  display: block;
  margin-top: 2px;
  color: rgba(92, 58, 24, 0.72);
  font-size: 0.76rem;
  font-weight: 700;
}

.wallet-action-label {
  flex: 0 0 auto;
  color: var(--stroke-blue-deep);
  font-size: 0.78rem;
  font-weight: 800;
}

.wallet-status,
.wallet-error {
  margin: 8px 0 12px;
  padding: 10px;
  border-radius: 8px;
  font-size: 0.8rem;
  font-weight: 800;
  line-height: 1.35;
}

.wallet-status {
  border: 2px solid rgba(29, 79, 145, 0.4);
  background: rgba(223, 246, 255, 0.78);
  color: var(--stroke-blue-deep);
}

.wallet-error {
  border: 2px solid rgba(155, 35, 53, 0.45);
  background: rgba(255, 235, 238, 0.78);
  color: var(--stroke-red);
}

.wallet-diagnostics {
  margin: 8px 0 12px;
  padding: 10px;
  border: 2px dashed rgba(92, 58, 24, 0.35);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.44);
  color: var(--stroke-brown);
  font-size: 0.78rem;
  font-weight: 800;
}

.wallet-diagnostics summary {
  cursor: pointer;
}

.wallet-diagnostics pre {
  margin-top: 8px;
  max-height: 180px;
  overflow: auto;
  white-space: pre-wrap;
  user-select: text;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.68rem;
  line-height: 1.4;
}

.wallet-actions {
  display: flex;
  gap: 10px;
}

.wallet-disconnect-link {
  margin: 6px 0 8px;
}

@media (max-width: 840px) {
  .shell-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .shell-actions {
    justify-content: flex-start;
  }

  .prize-panel,
  .profile-summary,
  .rank-card,
  .next-unlock-panel,
  .quests-preview,
  .leaderboard-preview,
  .profile-grid .shell-panel:not(.profile-hero):not(.profile-quests) {
    grid-column: span 12;
  }
}

@media (max-width: 520px) {
  .shell-logo {
    width: 58px;
    height: 58px;
  }

  .shell-panel {
    padding: 13px;
    border-radius: 14px;
  }

  .cosmetic-grid,
  .medal-grid,
  #menu-screen .mode-grid {
    grid-template-columns: 1fr;
  }

  .profile-hero {
    align-items: flex-start;
    flex-direction: column;
  }

  .quest-row {
    align-items: flex-start;
    flex-direction: column;
  }
}

/* ========== GAME ========== */
#game-screen {
  height: 100%;
  height: 100dvh;
  overflow: hidden;
  font-family: var(--game-font);
}

#game-screen.active .game-container {
  flex: 1;
  min-height: 0;
}

#game-screen .game-container {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  height: 100%;
  max-height: 100dvh;
  min-height: 0;
  max-width: 520px;
  margin: 0 auto;
  width: 100%;
  padding:
    max(8px, env(safe-area-inset-top))
    max(12px, env(safe-area-inset-right))
    max(8px, env(safe-area-inset-bottom))
    max(12px, env(safe-area-inset-left));
  overflow: hidden;
}

#game-screen .game-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 6px 8px;
  position: relative;
  margin-bottom: 8px;
  flex-shrink: 0;
}

#game-screen .player-card {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-radius: 14px;
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
  background: linear-gradient(180deg, rgba(255, 248, 228, 0.95) 0%, rgba(255, 232, 178, 0.92) 100%);
  border: 2px solid var(--stroke-brown);
  box-shadow:
    0 4px 0 var(--stroke-brown),
    0 6px 16px rgba(92, 58, 24, 0.22);
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

#game-screen .player-card.active-turn {
  background: linear-gradient(180deg, #ffe566 0%, #ffb347 48%, #ff9f2e 100%);
  border-color: var(--stroke-brown);
  box-shadow:
    0 4px 0 var(--stroke-brown),
    inset 0 1px 0 rgba(255, 255, 255, 0.45),
    0 6px 16px rgba(92, 58, 24, 0.28);
}

#game-screen .player-card.opponent,
#game-screen .player-card.player {
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}

#game-screen .player-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
  border: 2px solid var(--stroke-brown);
  overflow: hidden;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.5);
}

#game-screen .player-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

#game-screen .player-info {
  min-width: 0;
  flex: 1;
}

#game-screen .player-name {
  display: block;
  color: var(--stroke-brown);
  font-weight: 700;
  font-size: 0.92rem;
  letter-spacing: 0.02em;
  -webkit-text-stroke: 0.5px rgba(92, 58, 24, 0.35);
  paint-order: stroke fill;
  text-shadow: none;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#game-screen .player-card.active-turn .player-name {
  color: #fff;
  -webkit-text-stroke: 0.8px var(--stroke-brown);
  text-shadow: 0 1px 0 rgba(92, 58, 24, 0.4);
}

#game-screen .player-card.player .player-name,
#game-screen .player-card.opponent .player-name {
  -webkit-text-stroke-color: rgba(92, 58, 24, 0.35);
}

#game-screen .player-stats {
  display: flex;
  gap: 2px;
  margin-top: 2px;
  min-width: 0;
  max-width: 100%;
  flex-wrap: wrap;
  justify-content: flex-start;
}

#game-screen .stat {
  color: var(--stroke-brown);
  font-size: 0.75rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 2px;
  min-width: 0;
  max-width: 100%;
  flex: 0 1 auto;
}

#game-screen .stat.rating,
#game-screen .stat.timer {
  flex: 0 1 auto;
}

#game-screen .stat #player-rating,
#game-screen .stat #opponent-rating,
#game-screen .stat #player-timer,
#game-screen .stat #opponent-timer {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#game-screen .stat.rating #player-rating,
#game-screen .stat.rating #opponent-rating {
  color: #c8860a;
  -webkit-text-stroke: 0.6px #8b6914;
  paint-order: stroke fill;
  text-shadow: 0 1px 0 rgba(139, 105, 20, 0.25);
}

#game-screen .stat.timer #player-timer,
#game-screen .stat.timer #opponent-timer {
  color: var(--stroke-brown);
  -webkit-text-stroke: 0.5px rgba(92, 58, 24, 0.35);
  paint-order: stroke fill;
  text-shadow: none;
}

#game-screen .player-card.active-turn .stat.rating #player-rating,
#game-screen .player-card.active-turn .stat.rating #opponent-rating {
  color: #fff;
  -webkit-text-stroke: 0.6px var(--stroke-brown);
  text-shadow: 0 1px 0 rgba(92, 58, 24, 0.35);
}

#game-screen .player-card.active-turn .stat.timer #player-timer,
#game-screen .player-card.active-turn .stat.timer #opponent-timer {
  color: #fff;
  -webkit-text-stroke: 0.6px var(--stroke-brown);
  text-shadow: 0 1px 0 rgba(92, 58, 24, 0.35);
}

#game-screen .player-card.opponent .stat.timer #opponent-timer {
  -webkit-text-stroke-color: rgba(92, 58, 24, 0.35);
  text-shadow: none;
}

#game-screen .stat-icon {
  font-size: 0.65rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  flex-shrink: 0;
}

#game-screen .stat-icon img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

#game-screen .vs-badge {
  position: relative;
  justify-self: center;
  align-self: center;
  flex-shrink: 0;
  background: linear-gradient(180deg, #ffe566 0%, #ffb347 55%, #ff9f2e 100%);
  color: #fff;
  font-weight: 700;
  font-size: 0.82rem;
  padding: 5px 11px;
  border-radius: 10px;
  border: 2px solid var(--stroke-brown);
  letter-spacing: 0.08em;
  white-space: nowrap;
  -webkit-text-stroke: 1.5px var(--stroke-brown);
  paint-order: stroke fill;
  text-shadow: 0 2px 0 rgba(92, 58, 24, 0.45);
  box-shadow: 0 3px 0 var(--stroke-brown), 0 4px 10px rgba(92, 58, 24, 0.28);
}

#game-screen .btn-settings {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: linear-gradient(180deg, #ffe566 0%, #ffb347 48%, #ff9f2e 100%);
  border: 2px solid var(--stroke-brown);
  color: #fff;
  font-size: 15px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s ease, filter 0.15s ease, box-shadow 0.15s ease;
  flex-shrink: 0;
  align-self: center;
  justify-self: end;
  box-shadow:
    0 3px 0 var(--stroke-brown),
    inset 0 1px 0 rgba(255, 255, 255, 0.4);
}

#game-screen .btn-settings img {
  width: 22px;
  height: 22px;
  object-fit: contain;
  object-position: center;
  display: block;
}

#game-screen .btn-settings:hover {
  filter: brightness(1.05);
  transform: translateY(-1px);
}

#game-screen .btn-settings:active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 var(--stroke-brown);
}

#game-screen .status-bar {
  text-align: center;
  padding: 9px 14px;
  margin-bottom: 8px;
  flex-shrink: 0;
  background: linear-gradient(180deg, rgba(255, 248, 228, 0.95) 0%, rgba(255, 232, 178, 0.92) 100%);
  border: 2px solid var(--stroke-brown);
  border-radius: 12px;
  font-weight: 700;
  font-size: 0.78rem;
  color: var(--stroke-brown);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  transition: all 0.3s ease;
  -webkit-text-stroke: 0.5px rgba(92, 58, 24, 0.35);
  paint-order: stroke fill;
  text-shadow: none;
  box-shadow: 0 3px 0 var(--stroke-brown);
}

#game-screen .status-bar.check {
  background: linear-gradient(180deg, #ffd6d6 0%, #ffb4b4 100%);
  border-color: #8b2020;
  color: #6b1515;
  box-shadow: 0 3px 0 #6b1515;
  -webkit-text-stroke-color: rgba(107, 21, 21, 0.35);
  animation: pulse-check 1s ease infinite;
}

#game-screen .status-bar.checkmate {
  background: linear-gradient(180deg, #ffe08a 0%, #ffc857 100%);
  border-color: #8b6914;
  color: #6b4f10;
  box-shadow: 0 3px 0 #8b6914;
  -webkit-text-stroke-color: rgba(107, 79, 16, 0.35);
}

@keyframes pulse-check {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}

#game-screen .board-wrapper {
  flex: 1;
  display: flex;
  align-items: stretch;
  justify-content: center;
  min-height: 0;
  width: 100%;
  overflow: hidden;
}

#game-screen .board-layout {
  --board-size: min(calc(100cqw - 23px), calc(100cqh - 26px), 440px);
  --coord-font: clamp(0.42rem, calc(var(--board-size) / 8 * 0.38), 0.72rem);
  width: min(100%, 463px);
  height: 100%;
  min-height: 0;
  container-type: size;
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr);
  grid-template-rows: auto auto;
  column-gap: 5px;
  row-gap: 4px;
  align-content: center;
  align-self: center;
}

#game-screen .board-coords-left {
  grid-column: 1;
  grid-row: 1;
  display: grid;
  grid-template-rows: repeat(8, 1fr);
  align-items: center;
  justify-items: center;
  align-self: stretch;
  font-size: var(--coord-font);
  font-weight: 700;
  font-family: var(--game-font);
  color: #e8c99a;
  -webkit-text-stroke: 0.6px #5c3a18;
  paint-order: stroke fill;
  text-shadow: 0 1px 0 rgba(60, 30, 0, 0.35);
  pointer-events: none;
  user-select: none;
}

#game-screen .board-coords-bottom {
  grid-column: 2;
  grid-row: 2;
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  align-items: center;
  justify-items: center;
  width: var(--board-size);
  justify-self: center;
  font-size: var(--coord-font);
  font-weight: 700;
  font-family: var(--game-font);
  color: #e8c99a;
  -webkit-text-stroke: 0.6px #5c3a18;
  paint-order: stroke fill;
  text-shadow: 0 1px 0 rgba(60, 30, 0, 0.35);
  pointer-events: none;
  user-select: none;
}

#game-screen .coord-label {
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  width: 100%;
  height: 100%;
}

#game-screen .board-area {
  grid-column: 2;
  grid-row: 1;
  width: var(--board-size);
  aspect-ratio: 1;
  height: auto;
  justify-self: center;
  align-self: start;
  container-type: size;
}

#game-screen .chess-board {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  grid-template-rows: repeat(8, 1fr);
  width: 100%;
  height: 100%;
  border: 3px solid var(--stroke-brown);
  border-radius: 12px;
  overflow: hidden;
  box-shadow:
    0 6px 0 var(--stroke-brown),
    0 10px 28px rgba(92, 58, 24, 0.35);
  background: var(--board-light);
}

#game-screen .square {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.15s;
}

#game-screen .square.light { background: var(--board-light); }
#game-screen .square.dark { background: var(--board-dark); }

#game-screen .square.selected { background: var(--highlight-select) !important; }
#game-screen .square.legal-move::after {
  content: '';
  position: absolute;
  width: 28%;
  height: 28%;
  border-radius: 50%;
  background: rgba(120, 180, 255, 0.55);
}
#game-screen .square.legal-capture::after {
  content: '';
  position: absolute;
  width: 82%;
  height: 82%;
  border-radius: 50%;
  border: 3px solid rgba(120, 180, 255, 0.55);
  background: transparent;
}
#game-screen .square.last-move { background: rgba(120, 180, 255, 0.25) !important; }
#game-screen .square.in-check { background: rgba(255, 80, 80, 0.45) !important; }

#game-screen .piece {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  font-size: 11cqmin;
  line-height: 1;
  z-index: 2;
  transition: transform 0.15s ease;
  filter: drop-shadow(1px 2px 3px rgba(0, 0, 0, 0.5));
  pointer-events: none;
}

#game-screen .piece img,
#game-screen .piece-img {
  width: 88%;
  height: 88%;
  object-fit: contain;
  display: block;
}

#game-screen .piece.moving {
  transition: transform 0.3s cubic-bezier(0.25, 0.8, 0.25, 1) !important;
  z-index: 10;
}

#game-screen .square:hover:not(.disabled) .piece.moving {
  transform: translate(0, 0);
}

#game-screen .piece.white {
  color: #fff;
  -webkit-text-stroke: 1.5px #333;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

#game-screen .piece.black {
  color: #222;
  -webkit-text-stroke: 1px #555;
}

#game-screen .square:hover:not(.disabled) .piece {
  transform: scale(1.06);
}

#game-screen .game-controls {
  display: flex;
  gap: 5px;
  padding: 5px;
  margin-top: 8px;
  flex-shrink: 0;
  background: rgba(92, 58, 24, 0.14);
  border: 2px solid rgba(92, 58, 24, 0.28);
  border-radius: 14px;
  align-items: stretch;
  width: 100%;
  box-shadow: inset 0 2px 5px rgba(92, 58, 24, 0.12);
}

#game-screen .ctrl-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 10px 2px;
  background: rgba(255, 255, 255, 0.45);
  border: 2px solid rgba(92, 58, 24, 0.2);
  border-radius: 11px;
  color: rgba(92, 58, 24, 0.82);
  cursor: pointer;
  font-family: var(--game-font);
  position: relative;
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease, border-color 0.15s ease;
}

#game-screen .ctrl-btn:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.65);
  border-color: rgba(92, 58, 24, 0.35);
  transform: translateY(-1px);
}

#game-screen .ctrl-btn:active:not(:disabled) {
  transform: translateY(1px);
  background: linear-gradient(180deg, #ffe566 0%, #ffb347 48%, #ff9f2e 100%);
  border-color: var(--stroke-brown);
  box-shadow: 0 1px 0 var(--stroke-brown);
  color: #fff;
}

#game-screen .ctrl-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

#game-screen .ctrl-btn-main {
  flex: 1.1;
  background: linear-gradient(180deg, #ffe566 0%, #ffb347 48%, #ff9f2e 100%);
  border-color: var(--stroke-brown);
  box-shadow:
    0 2px 0 var(--stroke-brown),
    inset 0 1px 0 rgba(255, 255, 255, 0.4);
  color: #fff;
}

#game-screen .ctrl-icon {
  font-size: 1.1rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
}

#game-screen .ctrl-icon img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

#game-screen .ctrl-label {
  font-size: 0.52rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: rgba(92, 58, 24, 0.82);
  -webkit-text-stroke: 0;
  text-shadow: none;
}

#game-screen .ctrl-btn-main .ctrl-label,
#game-screen .ctrl-btn:active:not(:disabled) .ctrl-label {
  color: #fff;
  -webkit-text-stroke: 0.6px var(--stroke-brown);
  paint-order: stroke fill;
  text-shadow: 0 1px 0 rgba(92, 58, 24, 0.4);
}

/* ========== MODALS ========== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 20px;
}

.modal-overlay.active {
  display: flex;
}

.modal {
  background: linear-gradient(180deg, rgba(255, 248, 228, 0.98) 0%, rgba(255, 232, 178, 0.96) 100%);
  border: 3px solid var(--stroke-brown);
  border-radius: 20px;
  padding: 26px 22px;
  max-width: 360px;
  width: 100%;
  text-align: center;
  box-shadow:
    0 6px 0 var(--stroke-brown),
    0 12px 32px rgba(92, 58, 24, 0.35);
  animation: modal-in 0.3s ease;
  font-family: var(--game-font);
}

@keyframes modal-in {
  from { transform: scale(0.8); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.modal h2 {
  font-size: 1.65rem;
  font-weight: 700;
  color: var(--stroke-brown);
  margin-bottom: 8px;
  -webkit-text-stroke: 0.6px rgba(92, 58, 24, 0.35);
  paint-order: stroke fill;
  text-shadow: none;
}

.modal h3 {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--stroke-brown);
  margin-bottom: 16px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  -webkit-text-stroke: 0.5px rgba(92, 58, 24, 0.35);
  paint-order: stroke fill;
  text-shadow: none;
}

.modal p {
  color: rgba(92, 58, 24, 0.88);
  font-weight: 600;
  font-size: 0.95rem;
  margin-bottom: 20px;
  line-height: 1.45;
}

.gameover-icon {
  font-size: 72px;
  margin-bottom: 8px;
  min-height: 72px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.gameover-icon img {
  width: 72px;
  height: 72px;
  object-fit: contain;
  display: block;
}

.gameover-actions {
  display: flex;
  gap: 10px;
}

.btn-primary, .btn-secondary {
  flex: 1;
  padding: 14px;
  border-radius: 12px;
  font-family: var(--game-font);
  font-weight: 700;
  font-size: 1rem;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease, filter 0.15s ease;
  letter-spacing: 0.04em;
}

.btn-primary {
  border: 2px solid var(--stroke-brown);
  background: linear-gradient(180deg, #ffe566 0%, #ffb347 48%, #ff9f2e 100%);
  color: #fff;
  box-shadow:
    0 4px 0 var(--stroke-brown),
    inset 0 1px 0 rgba(255, 255, 255, 0.4);
  -webkit-text-stroke: 1px var(--stroke-brown);
  paint-order: stroke fill;
  text-shadow: 0 1px 0 rgba(92, 58, 24, 0.4);
}

.btn-primary:hover {
  filter: brightness(1.04);
}

.btn-primary:active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 var(--stroke-brown);
}

.btn-secondary {
  border: 2px solid rgba(92, 58, 24, 0.35);
  background: rgba(255, 255, 255, 0.55);
  color: var(--stroke-brown);
  box-shadow: 0 3px 0 rgba(92, 58, 24, 0.22);
  -webkit-text-stroke: 0;
  text-shadow: none;
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.72);
}

.btn-secondary:active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 rgba(92, 58, 24, 0.22);
}

.promotion-pieces {
  display: flex;
  gap: 12px;
  justify-content: center;
}

.promo-piece {
  font-size: 48px;
  padding: 12px 16px;
  background: rgba(255, 255, 255, 0.55);
  border: 2px solid rgba(92, 58, 24, 0.3);
  border-radius: 12px;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease, border-color 0.15s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 0 rgba(92, 58, 24, 0.2);
}

.promo-piece img {
  width: 48px;
  height: 48px;
  object-fit: contain;
  display: block;
}

.promo-piece:hover {
  transform: translateY(-2px) scale(1.04);
  background: linear-gradient(180deg, #ffe566 0%, #ffb347 48%, #ff9f2e 100%);
  border-color: var(--stroke-brown);
  box-shadow: 0 4px 0 var(--stroke-brown);
}

.settings-modal .settings-list {
  margin-bottom: 16px;
}

.settings-modal .btn-primary {
  width: 100%;
}

/* AI thinking indicator */
.thinking .opponent-avatar {
  animation: think-pulse 0.8s ease infinite;
  will-change: transform;
}

#game-screen.ai-thinking .status-bar {
  color: var(--stroke-brown);
  animation: pulse-check 1.2s ease infinite;
}

#game-screen.ai-thinking .chess-board {
  opacity: 0.92;
  transition: opacity 0.2s ease;
}

@keyframes think-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.1); }
}

/* Responsive — menu screen */
@media (max-width: 480px), (max-height: 740px) {
  #menu-screen .menu-header {
    margin-bottom: 14px;
  }

  #menu-screen .menu-logo {
    width: clamp(108px, 32vw, 148px);
    height: clamp(108px, 32vw, 148px);
    margin-bottom: 8px;
  }

  #menu-screen .menu-header h1 {
    font-size: 1.65rem;
  }

  #menu-screen .menu-panel {
    padding: 16px 14px;
    gap: 14px;
    flex-shrink: 0;
  }

  #menu-screen .menu-group {
    gap: 6px;
  }

  #menu-screen .diff-card,
  #menu-screen .time-card,
  #menu-screen .color-card {
    padding: 9px 4px;
    font-size: 0.76rem;
  }

  #menu-screen .btn-play {
    margin-top: 14px;
    margin-bottom: max(8px, env(safe-area-inset-bottom));
    padding: 15px 14px;
    font-size: 1.05rem;
  }
}

@media (max-height: 620px) {
  #menu-screen .menu-logo {
    width: clamp(88px, 26vw, 120px);
    height: clamp(88px, 26vw, 120px);
  }

  #menu-screen .menu-header h1 {
    font-size: 1.45rem;
  }

  #menu-screen .menu-panel {
    padding: 12px 12px;
    gap: 10px;
  }

  #menu-screen .btn-play {
    margin-top: 10px;
    padding: 13px 12px;
  }
}

/* Responsive — game screen */
@media (max-width: 480px) {
  #game-screen .game-header {
    gap: 4px 5px;
  }

  #game-screen .player-card {
    padding: 7px 8px;
    gap: 5px;
  }

  #game-screen .player-avatar {
    width: 38px;
    height: 38px;
  }

  #game-screen .player-name {
    font-size: 0.72rem;
  }

  #game-screen .player-stats {
    flex-direction: column;
    align-items: flex-start;
    gap: 1px;
  }

  #game-screen .stat {
    font-size: 0.62rem;
    gap: 2px;
    flex: none;
    width: 100%;
  }

  #game-screen .stat-icon {
    width: 16px;
    height: 16px;
  }

  #game-screen .vs-badge {
    font-size: 0.68rem;
    padding: 4px 7px;
  }

  #game-screen .btn-settings {
    width: 38px;
    height: 38px;
  }

  #game-screen .btn-settings img {
    width: 20px;
    height: 20px;
  }
}

@media (max-width: 400px) {
  #game-screen .ctrl-label { display: none; }
  #game-screen .ctrl-btn { padding: 10px 2px; }
  #game-screen .player-card { padding: 6px 7px; gap: 4px; }
  #game-screen .player-avatar { width: 34px; height: 34px; font-size: 16px; }
  #game-screen .stat { font-size: 0.58rem; }
  #game-screen .stat-icon { width: 14px; height: 14px; }
}

@media (max-height: 700px) {
  #game-screen .game-container { padding: 6px 10px 8px; }
  #game-screen .game-header { margin-bottom: 6px; }
  #game-screen .status-bar { padding: 6px 10px; margin-bottom: 6px; font-size: 0.62rem; }
  #game-screen .player-card { padding: 7px 8px; }
  #game-screen .player-avatar { width: 40px; height: 40px; font-size: 15px; }
  #game-screen .player-name { font-size: 0.72rem; }
  #game-screen .stat { font-size: 0.62rem; }
  #game-screen .game-controls { margin-top: 6px; }
  #game-screen .ctrl-btn { padding: 8px 2px; }
}

@media (max-height: 520px) {
  #game-screen .status-bar { padding: 4px 8px; }
}

@media (orientation: landscape) and (max-height: 500px) {
  #game-screen .game-container {
    max-width: 100%;
    flex-direction: row;
    flex-wrap: wrap;
    align-content: center;
    justify-content: center;
    gap: 0 12px;
    padding: 6px 12px;
  }

  #game-screen .game-header {
    order: 1;
    width: 100%;
    margin-bottom: 4px;
  }

  #game-screen .status-bar {
    order: 2;
    width: 100%;
    margin-bottom: 4px;
  }

  #game-screen .board-wrapper {
    order: 3;
    flex: 1 1 55%;
    min-width: 0;
    min-height: 180px;
    max-width: calc(100% - 190px);
    align-self: stretch;
  }

  #game-screen .board-layout {
    width: min(100%, 463px);
    height: 100%;
  }

  #game-screen .game-controls {
    order: 4;
    flex: 0 0 180px;
    flex-direction: column;
    margin-top: 0;
    align-self: center;
    max-height: calc(100dvh - 24px);
  }

  #game-screen .ctrl-btn {
    flex: 1;
    flex-direction: row;
    gap: 6px;
    padding: 8px 10px;
  }

  #game-screen .ctrl-label { display: inline; }
}

@media (min-width: 600px) and (min-height: 700px) {
  #game-screen .game-container { max-width: 540px; }
}

@supports not (container-type: size) {
  #game-screen .board-layout {
    --board-size: min(calc(100vw - 52px), calc(100dvh - 210px), 440px);
  }

  #game-screen .piece {
    font-size: clamp(20px, 9vw, 46px);
  }
}

@media (min-width: 600px) {
  #menu-screen .menu-content {
    justify-content: center;
    padding: 40px 32px;
    max-width: 420px;
  }

  #menu-screen .menu-panel { padding: 28px 24px; }
}

/* ========== PHASE 6A PIXEL ART THEME ========== */
:root {
  --font-pixel: 'Courier New', 'Lucida Console', Monaco, monospace;
  --font: var(--font-pixel);
  --game-font: var(--font-pixel);
  --sky-top: #182b4d;
  --sky-bottom: #2f7f86;
  --grass: #2f8a4c;
  --board-light: var(--pixel-board-light, #f2d58a);
  --board-dark: var(--pixel-board-dark, #9f6135);
  --stroke-brown: #2b1a12;
  --stroke-dark: #111827;
  --stroke-blue: #225b8f;
  --stroke-blue-deep: #102c4c;
  --stroke-red: #8d2730;
  --stroke-red-deep: #4f141d;
  --pixel-ink: #1b1522;
  --pixel-panel: #f5deb3;
  --pixel-panel-dark: #c88b4b;
  --pixel-paper: #fff0c7;
  --pixel-green: #56a764;
  --pixel-blue: #4f91c9;
  --pixel-purple: #7655aa;
  --pixel-gold: #f1b73b;
  --pixel-red: #cc4a4a;
  --pixel-shadow: 0 4px 0 #111827, 0 8px 0 rgba(17, 24, 39, 0.18);
  --pixel-shadow-small: 0 3px 0 #111827;
  --radius: 0;
  --shadow: var(--pixel-shadow);
}

html,
body,
button,
input,
select,
textarea {
  font-family: var(--font-pixel);
  letter-spacing: 0;
}

img,
canvas,
.piece,
.piece img,
.cosmetic-preview img,
.piece-preview-sprite,
.shell-logo,
.menu-logo,
.loading-logo,
.profile-avatar {
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

body {
  color: var(--pixel-ink);
  background:
    linear-gradient(45deg, rgba(255, 255, 255, 0.04) 25%, transparent 25%) 0 0 / 24px 24px,
    linear-gradient(45deg, transparent 75%, rgba(0, 0, 0, 0.12) 75%) 0 0 / 24px 24px,
    linear-gradient(180deg, #182b4d 0%, #245f74 48%, #2f8a4c 100%);
}

.loading-bg::before,
.menu-bg::before,
.game-bg::before {
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.05) 1px, transparent 1px) 0 0 / 18px 18px,
    linear-gradient(0deg, rgba(255, 255, 255, 0.04) 1px, transparent 1px) 0 0 / 18px 18px,
    linear-gradient(180deg, #17264a 0%, #255f76 56%, #2f8a4c 100%);
  background-size: 18px 18px, 18px 18px, 100% 100%;
}

.loading-bg::after,
.menu-bg::after,
.game-bg::after {
  height: 20%;
  background:
    linear-gradient(90deg, rgba(27, 21, 34, 0.18) 1px, transparent 1px) 0 0 / 16px 16px,
    linear-gradient(180deg, transparent 0%, rgba(55, 125, 61, 0.72) 55%, rgba(32, 84, 48, 0.92) 100%);
}

.backend-status,
.loading-panel,
.shell-panel,
#menu-screen .menu-panel,
.modal,
.mode-card,
.diff-card,
.time-card,
.quest-row,
.leader-row,
.leaderboard-entry,
.visual-cosmetic-item,
.visual-unlock-item,
.practice-match-row,
.wallet-provider-row,
.pvp-status-card,
.public-match-layout,
#game-screen .player-card,
#game-screen .status-bar,
#game-screen .ctrl-btn,
#game-screen .btn-settings,
.promo-piece {
  border-radius: 0 !important;
  border: 3px solid var(--pixel-ink) !important;
  box-shadow: var(--pixel-shadow-small) !important;
  background: var(--pixel-paper) !important;
}

.shell-panel,
#menu-screen .menu-panel,
.modal,
.loading-panel {
  background:
    linear-gradient(180deg, rgba(255, 245, 204, 0.96), rgba(226, 165, 91, 0.94)) !important;
}

.shell-header,
.menu-header,
.profile-header,
.leaderboard-header,
.panel-head,
.wallet-modal-head {
  color: #fff3cf;
  text-shadow: 2px 2px 0 var(--pixel-ink);
}

.shell-brand h1,
.menu-header h1,
.loading-header h1,
.profile-header h1,
.leaderboard-header h1 {
  color: #fff3cf;
  text-shadow: 3px 3px 0 var(--pixel-ink);
  text-transform: uppercase;
}

.shell-brand p,
.menu-subtitle,
.trust-note,
.panel-label,
.unlock-meta,
.quest-meta,
.leader-meta,
.wallet-status {
  letter-spacing: 0;
}

.panel-label,
.menu-label {
  color: #6b2f2f;
  text-transform: uppercase;
}

.btn-play,
.btn-compact,
.shell-nav-btn,
.link-btn,
.mini-action-btn,
.btn-primary,
.btn-secondary,
.leaderboard-tab,
.modal-icon-btn {
  border-radius: 0 !important;
  border: 3px solid var(--pixel-ink) !important;
  box-shadow: var(--pixel-shadow-small) !important;
  background: var(--pixel-gold) !important;
  color: var(--pixel-ink) !important;
  font-family: var(--font-pixel) !important;
  text-shadow: none !important;
  transition: transform 0.08s steps(1), filter 0.08s steps(1), box-shadow 0.08s steps(1) !important;
}

.btn-compact,
.shell-nav-btn,
.link-btn,
.mini-action-btn,
.btn-primary,
.btn-secondary,
.leaderboard-tab {
  min-height: 38px;
}

.btn-play {
  background: linear-gradient(180deg, #f6d85b, #e88935) !important;
}

.btn-compact:hover,
.shell-nav-btn:hover,
.link-btn:hover,
.mini-action-btn:hover,
.btn-primary:hover,
.btn-secondary:hover,
.leaderboard-tab:hover,
#game-screen .ctrl-btn:hover,
#game-screen .btn-settings:hover,
.promo-piece:hover {
  filter: brightness(1.08);
  transform: translateY(-2px);
}

.btn-compact:active,
.shell-nav-btn:active,
.link-btn:active,
.mini-action-btn:active,
.btn-primary:active,
.btn-secondary:active,
.leaderboard-tab:active,
#game-screen .ctrl-btn:active,
#game-screen .btn-settings:active,
.promo-piece:active {
  transform: translateY(3px);
  box-shadow: 0 0 0 var(--pixel-ink) !important;
}

.shell-nav-btn.active,
.leaderboard-tab.active,
#menu-screen .mode-card.selected,
.time-card.selected,
.diff-card.selected,
.unlock-item.equipped {
  background: #7dd87d !important;
  border-color: #102c4c !important;
  outline: 3px solid #fff0c7;
  outline-offset: -6px;
}

.progress-track,
.loading-bar-wrap,
.matchmaking-track {
  border-radius: 0 !important;
  border: 3px solid var(--pixel-ink);
  background: #1d2433 !important;
  overflow: hidden;
}

.progress-fill,
.loading-bar,
.matchmaking-fill {
  border-radius: 0 !important;
  background: repeating-linear-gradient(
    90deg,
    #6ee082 0 12px,
    #47b95e 12px 24px
  ) !important;
}

.profile-avatar,
#game-screen .player-avatar {
  border-radius: 0 !important;
  background: #fff0c7;
  border-color: var(--pixel-ink) !important;
}

.profile-avatar-frame {
  border-radius: 0 !important;
  box-shadow: var(--pixel-shadow-small) !important;
}

.cosmetic-preview {
  border-radius: 0 !important;
  border: 3px solid var(--pixel-ink);
  background:
    linear-gradient(45deg, rgba(255, 255, 255, 0.2) 25%, transparent 25%) 0 0 / 10px 10px,
    #2b3444 !important;
  box-shadow: inset 0 0 0 3px rgba(255, 255, 255, 0.12);
  overflow: hidden;
}

.cosmetic-preview-board_skin img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  padding: 4px;
}

.cosmetic-preview-piece_skin {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 4px;
  padding: 4px;
}

.cosmetic-preview-piece_skin > img:not(.piece-preview-sprite) {
  display: none;
}

.piece-preview-sprite {
  width: auto;
  object-fit: contain;
  object-position: bottom center;
  flex: 0 0 auto;
}

.piece-preview-sprite.pixel-piece-16 { height: 34px; }
.piece-preview-sprite.pixel-piece-32 { height: 46px; }
.piece-preview-sprite.pixel-piece-48 { height: 58px; }

.rarity-common { border-color: #335241 !important; }
.rarity-uncommon { border-color: #24784f !important; }
.rarity-rare { border-color: #245f9e !important; }
.rarity-epic { border-color: #7048aa !important; }
.rarity-legendary { border-color: #b66b22 !important; }

#game-screen .game-container {
  filter: none;
}

#game-screen .board-wrapper,
#game-screen .board-layout,
#game-screen .board-area {
  overflow: visible;
}

body[data-board-skin] #game-screen .chess-board {
  position: relative;
  overflow: visible;
  padding: clamp(5px, 2.25%, 12px);
  border-radius: 0;
  border: 4px solid var(--pixel-ink);
  background:
    var(--pixel-board-image) center / 100% 100% no-repeat,
    var(--board-light);
  box-shadow: 0 5px 0 var(--pixel-ink), 0 10px 0 rgba(17, 24, 39, 0.24);
  image-rendering: pixelated;
}

body[data-board-skin] #game-screen .square {
  overflow: visible;
  transition: none;
}

body[data-board-skin] #game-screen .square.light {
  background: rgba(255, 245, 202, 0.12);
}

body[data-board-skin] #game-screen .square.dark {
  background: rgba(0, 0, 0, 0.1);
}

#game-screen .square.selected {
  background: rgba(255, 221, 73, 0.48) !important;
  box-shadow: inset 0 0 0 4px #f6d85b;
}

#game-screen .square.last-move {
  background: rgba(111, 206, 130, 0.4) !important;
}

#game-screen .square.in-check {
  background: rgba(204, 74, 74, 0.62) !important;
}

#game-screen .square.legal-move::after {
  width: 28%;
  height: 28%;
  border-radius: 0;
  background: #72df87;
  box-shadow: 0 2px 0 var(--pixel-ink);
}

#game-screen .square.legal-capture::after {
  width: 78%;
  height: 78%;
  border-radius: 0;
  border: 4px solid #e85c5c;
}

#game-screen .piece.pixel-piece,
.public-square .piece.pixel-piece {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  font-size: 0;
  filter: drop-shadow(2px 3px 0 rgba(17, 24, 39, 0.48));
  transform-origin: center center;
}

#game-screen .piece.pixel-piece img,
.public-square .piece.pixel-piece img {
  position: absolute;
  left: 50%;
  bottom: 44%;
  transform: translateX(-50%);
  width: auto;
  max-width: 120%;
  height: 100%;
  max-height: none;
  object-fit: contain;
  object-position: bottom center;
}

#game-screen .piece.pixel-piece-16 img,
.public-square .piece.pixel-piece-16 img {
  height: 74%;
}

#game-screen .piece.pixel-piece-32 img,
.public-square .piece.pixel-piece-32 img {
  height: 128%;
}

#game-screen .piece.pixel-piece-48 img,
.public-square .piece.pixel-piece-48 img {
  height: 182%;
}

#game-screen .square:hover:not(.disabled) .piece.pixel-piece {
  transform: translateY(-2px);
}

#game-screen .piece.pixel-piece.moving {
  z-index: 20;
}

.promo-piece.pixel-piece,
.promo-piece .piece-sprite {
  image-rendering: pixelated;
}

.promo-piece {
  min-width: 64px;
  min-height: 70px;
  background: #fff0c7 !important;
  overflow: visible;
}

.promo-piece.pixel-piece-16 img { height: 42px; }
.promo-piece.pixel-piece-32 img { height: 58px; }
.promo-piece.pixel-piece-48 img { height: 72px; }

#game-screen .ctrl-btn {
  background: #f5deb3 !important;
}

#game-screen .ctrl-btn:disabled,
.mini-action-btn:disabled,
.btn-compact:disabled {
  background: #8f8f8f !important;
  color: #2f2f2f !important;
  box-shadow: none !important;
  opacity: 0.72;
}

#game-screen .status-bar {
  background: #fff0c7 !important;
  color: var(--pixel-ink);
  text-transform: uppercase;
}

#game-screen .player-card.active-turn {
  background: #7dd87d !important;
}

#game-screen .player-card.opponent.active-turn {
  background: #f0a05c !important;
}

#game-screen .player-name,
#game-screen .stat,
#game-screen .status-bar {
  -webkit-text-stroke: 0 !important;
  text-shadow: none !important;
}

.public-board {
  border-radius: 0;
  overflow: visible;
  border: 4px solid var(--pixel-ink);
  padding: clamp(4px, 2%, 8px);
  background:
    var(--pixel-board-image) center / 100% 100% no-repeat,
    var(--board-light);
  image-rendering: pixelated;
}

.public-square {
  position: relative;
  overflow: visible;
}

.public-square.light,
.public-square.dark {
  background: transparent;
}

.wallet-provider-row,
.wallet-status,
.wallet-error,
.wallet-diagnostics pre {
  border-radius: 0 !important;
}

@media (max-width: 720px) {
  .shell-brand h1,
  .menu-header h1,
  .loading-header h1 {
    font-size: clamp(1.25rem, 7vw, 2.2rem);
  }

  .piece-preview-sprite.pixel-piece-48 { height: 48px; }
}

/* ========== PHASE 6B VIEWPORT-FIT PIXEL GAME LAYOUT ========== */

:root {
  --pixel-screen-pad-x: clamp(8px, 1.4vw, 18px);
  --pixel-screen-pad-y: clamp(8px, 1.3dvh, 16px);
  --pixel-panel-gap: clamp(8px, 1.25dvh, 13px);
  --pixel-compact-pad: clamp(9px, 1.4dvh, 13px);
}

html,
body,
.pixel-app-shell {
  width: 100%;
  height: 100%;
  min-height: 100%;
  max-height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
}

.pixel-app-shell {
  position: fixed;
  inset: 0;
  touch-action: manipulation;
}

.screen,
.pixel-screen {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100vh;
  height: 100dvh;
  max-height: 100vh;
  max-height: 100dvh;
  min-height: 0;
  overflow: hidden;
}

.pixel-screen-header,
.shell-header,
.shell-page-head,
#menu-screen .menu-header,
.game-header,
.game-controls,
.status-bar {
  flex: 0 0 auto;
}

.pixel-screen-main,
.dashboard-grid,
.profile-grid,
.leaderboard-page,
#menu-screen .menu-panel,
#game-screen .board-wrapper {
  min-height: 0;
}

.shell-screen,
.shell-content,
#menu-screen .menu-content {
  overflow: hidden !important;
}

.shell-content,
#menu-screen .menu-content {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  width: min(1180px, 100%);
  height: 100dvh;
  max-height: 100dvh;
  min-height: 0;
  gap: var(--pixel-panel-gap);
  margin: 0 auto;
  padding:
    max(var(--pixel-screen-pad-y), env(safe-area-inset-top))
    max(var(--pixel-screen-pad-x), env(safe-area-inset-right))
    max(var(--pixel-screen-pad-y), env(safe-area-inset-bottom))
    max(var(--pixel-screen-pad-x), env(safe-area-inset-left));
}

.shell-header {
  min-height: 0;
}

.shell-brand h1,
.shell-page-head h1 {
  font-size: clamp(1.15rem, 2.8dvh, 2rem);
}

.shell-brand p,
.shell-page-head p,
#menu-screen .menu-subtitle {
  font-size: clamp(0.7rem, 1.35dvh, 0.9rem);
}

.shell-logo {
  width: clamp(42px, 7dvh, 64px);
  height: clamp(42px, 7dvh, 64px);
}

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

.btn-compact,
.shell-nav-btn,
.link-btn {
  border-radius: 0 !important;
}

.shell-nav {
  min-height: 0;
  padding: 4px;
  border-radius: 0 !important;
  scrollbar-width: none;
}

.shell-nav::-webkit-scrollbar {
  display: none;
}

.shell-nav-btn {
  padding: clamp(6px, 1dvh, 8px) clamp(8px, 1vw, 12px);
  font-size: clamp(0.64rem, 1.15dvh, 0.78rem);
}

.shell-page-head {
  margin: 0;
}

.backend-status {
  top: auto;
  right: max(10px, env(safe-area-inset-right));
  bottom: max(10px, env(safe-area-inset-bottom));
  left: auto;
  width: min(360px, calc(100% - 20px));
  max-height: min(28dvh, 180px);
  overflow: hidden;
  transform: none;
  pointer-events: none;
  border-radius: 0 !important;
}

.shell-panel,
.pixel-panel {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  border-radius: 0 !important;
  padding: var(--pixel-compact-pad);
}

.pixel-compact-card {
  padding: clamp(8px, 1.1dvh, 11px);
}

.shell-panel h2 {
  font-size: clamp(1rem, 2.15dvh, 1.55rem);
  margin-bottom: 4px;
}

.panel-label {
  margin-bottom: 5px;
  font-size: clamp(0.58rem, 1dvh, 0.7rem);
}

.trust-note {
  margin-top: auto;
  font-size: clamp(0.58rem, 1dvh, 0.72rem);
  line-height: 1.25;
}

.pixel-panel-scroll,
.quest-list,
.leader-list,
.practice-match-list,
.unlock-list,
.leaderboard-table,
.wallet-list,
.settings-list,
.public-moves,
.wallet-diagnostics pre {
  min-height: 0;
  overflow: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--pixel-ink) rgba(255, 240, 199, 0.38);
}

.pixel-panel-scroll::-webkit-scrollbar,
.quest-list::-webkit-scrollbar,
.leader-list::-webkit-scrollbar,
.practice-match-list::-webkit-scrollbar,
.unlock-list::-webkit-scrollbar,
.leaderboard-table::-webkit-scrollbar,
.wallet-list::-webkit-scrollbar,
.settings-list::-webkit-scrollbar,
.public-moves::-webkit-scrollbar,
.wallet-diagnostics pre::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

.pixel-panel-scroll::-webkit-scrollbar-track,
.quest-list::-webkit-scrollbar-track,
.leader-list::-webkit-scrollbar-track,
.practice-match-list::-webkit-scrollbar-track,
.unlock-list::-webkit-scrollbar-track,
.leaderboard-table::-webkit-scrollbar-track,
.wallet-list::-webkit-scrollbar-track,
.settings-list::-webkit-scrollbar-track,
.public-moves::-webkit-scrollbar-track,
.wallet-diagnostics pre::-webkit-scrollbar-track {
  background: rgba(255, 240, 199, 0.38);
  border: 2px solid var(--pixel-ink);
}

.pixel-panel-scroll::-webkit-scrollbar-thumb,
.quest-list::-webkit-scrollbar-thumb,
.leader-list::-webkit-scrollbar-thumb,
.practice-match-list::-webkit-scrollbar-thumb,
.unlock-list::-webkit-scrollbar-thumb,
.leaderboard-table::-webkit-scrollbar-thumb,
.wallet-list::-webkit-scrollbar-thumb,
.settings-list::-webkit-scrollbar-thumb,
.public-moves::-webkit-scrollbar-thumb,
.wallet-diagnostics pre::-webkit-scrollbar-thumb {
  background: var(--pixel-ink);
  border: 2px solid rgba(255, 240, 199, 0.85);
}

/* Dashboard: one-viewport command center, with lists scrolling inside cards. */
.dashboard-content {
  gap: var(--pixel-panel-gap);
}

.dashboard-grid,
.pixel-grid-dashboard {
  flex: 1 1 auto;
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  grid-template-rows: minmax(0, 0.9fr) minmax(0, 1.15fr);
  gap: var(--pixel-panel-gap);
  align-items: stretch;
  overflow: hidden;
}

.dashboard-grid > .shell-panel {
  grid-row: auto;
}

.prize-panel {
  grid-column: span 5;
}

.profile-summary {
  grid-column: span 4;
}

.rank-card {
  grid-column: span 3;
}

.next-unlock-panel {
  grid-column: span 3;
}

.quests-preview,
.leaderboard-preview,
.recent-practice-panel {
  grid-column: span 3;
}

.summary-row {
  align-items: center;
}

.pool-stats,
.level-line {
  margin: clamp(5px, 1dvh, 9px) 0 5px;
}

.profile-avatar {
  width: clamp(42px, 6dvh, 56px);
  height: clamp(42px, 6dvh, 56px);
}

.quest-list,
.leader-list,
.practice-match-list,
.unlock-list {
  flex: 1 1 auto;
}

.quest-row,
.leader-row,
.unlock-item,
.practice-match-card {
  padding: clamp(6px, 1dvh, 9px);
  gap: 8px;
}

.quest-title,
.leader-name,
.unlock-title {
  font-size: clamp(0.68rem, 1.15dvh, 0.84rem);
}

.quest-meta,
.leader-meta,
.unlock-meta {
  font-size: clamp(0.58rem, 1dvh, 0.74rem);
}

.shell-main-play,
.pixel-action-bar,
.pixel-fixed-footer-actions {
  flex: 0 0 auto;
}

.shell-main-play {
  width: min(360px, 100%);
  padding: clamp(10px, 1.5dvh, 15px) 14px;
  border-radius: 0 !important;
  font-size: clamp(0.78rem, 1.6dvh, 1rem);
}

/* Profile: three-column console with only dense side sections scrolling. */
.profile-grid,
.pixel-profile-layout {
  flex: 1 1 auto;
  display: grid;
  grid-template-columns: minmax(240px, 0.9fr) minmax(360px, 1.1fr);
  grid-template-rows: minmax(0, 1fr);
  gap: var(--pixel-panel-gap);
  align-items: stretch;
  overflow: hidden;
}

.profile-side-stack,
.profile-activity-stack,
.pixel-side-panel {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  gap: var(--pixel-panel-gap);
  overflow: auto;
}

.profile-side-stack > .shell-panel,
.profile-activity-stack > .shell-panel {
  flex: 0 0 auto;
}

.profile-side-stack .profile-hero {
  flex-direction: column;
  align-items: flex-start;
}

.profile-avatar-frame {
  width: clamp(78px, 11dvh, 110px);
  height: clamp(78px, 11dvh, 110px);
  padding: 6px;
}

.profile-avatar-frame .profile-avatar.large,
.profile-avatar.large {
  width: clamp(62px, 9dvh, 90px);
  height: clamp(62px, 9dvh, 90px);
}

.cosmetic-grid,
.medal-grid {
  gap: 8px;
}

.profile-inventory-panel {
  grid-column: auto !important;
}

.profile-inventory-panel .inventory-tabs {
  flex: 0 0 auto;
}

.profile-inventory-panel .unlock-list {
  flex: 1 1 auto;
}

.profile-quests .quest-list,
.profile-quests .practice-match-list {
  max-height: clamp(110px, 19dvh, 210px);
}

/* Play menu: compact arcade selection panel, fixed footer action. */
#menu-screen .menu-content {
  justify-content: flex-start;
}

#menu-screen .menu-header {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  text-align: left;
  margin: 0;
}

#menu-screen .menu-logo {
  width: clamp(44px, 8dvh, 72px);
  height: clamp(44px, 8dvh, 72px);
}

#menu-screen .menu-header h1 {
  font-size: clamp(1.15rem, 3dvh, 2.1rem);
}

#menu-screen .menu-subtitle {
  grid-column: 2;
  margin: 0;
}

#menu-screen .menu-panel {
  flex: 1 1 auto;
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(220px, 0.8fr);
  grid-auto-rows: minmax(0, auto);
  align-content: start;
  gap: var(--pixel-panel-gap);
  padding: var(--pixel-compact-pad);
  overflow: hidden;
}

#menu-screen .menu-group {
  min-height: 0;
}

#menu-screen .menu-group:first-child {
  grid-row: span 3;
}

#menu-screen .mode-grid {
  max-height: 100%;
  overflow: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--pixel-ink) rgba(255, 240, 199, 0.38);
}

#menu-screen .mode-card,
#menu-screen .diff-card,
#menu-screen .time-card,
#menu-screen .color-card {
  min-height: 0;
  border-radius: 0 !important;
  padding: clamp(8px, 1.25dvh, 12px);
}

#menu-screen .btn-play {
  flex: 0 0 auto;
  width: min(390px, 100%);
  margin: 0 auto;
  padding: clamp(12px, 1.8dvh, 17px) 16px;
  border-radius: 0 !important;
  font-size: clamp(0.82rem, 1.65dvh, 1.05rem);
}

/* Leaderboard: table owns scroll, screen does not. */
.leaderboard-page {
  flex: 1 1 auto;
  padding: var(--pixel-compact-pad);
}

.leaderboard-tabs {
  flex: 0 0 auto;
}

.leaderboard-table {
  flex: 1 1 auto;
}

.leaderboard-tab {
  border-radius: 0 !important;
}

/* Game: board grows on desktop while staying inside short and mobile viewports. */
#game-screen .game-container {
  display: flex;
  flex-direction: column;
  width: min(940px, 100%);
  height: 100dvh;
  max-height: 100dvh;
  min-height: 0;
  gap: clamp(7px, 1.15dvh, 12px);
  padding:
    max(7px, env(safe-area-inset-top))
    max(8px, env(safe-area-inset-right))
    max(8px, env(safe-area-inset-bottom))
    max(8px, env(safe-area-inset-left));
  overflow: hidden;
}

#game-screen .game-header {
  padding: clamp(6px, 1.1dvh, 10px);
  gap: 8px;
}

#game-screen .player-card {
  min-width: 0;
  padding: clamp(6px, 1dvh, 10px);
  border-radius: 0 !important;
}

#game-screen .player-info,
#game-screen .player-stats {
  min-width: 0;
}

#game-screen .status-bar {
  min-height: 0;
  padding: clamp(7px, 1dvh, 10px) 12px;
  border-radius: 0 !important;
}

#game-screen .board-wrapper {
  flex: 1 1 auto;
  display: grid;
  place-items: center;
  overflow: visible;
  container-type: size;
}

#game-screen .board-layout {
  --board-size: min(calc(100cqw - 24px), calc(100cqh - 24px), 560px);
  width: calc(var(--board-size) + 24px);
  height: calc(var(--board-size) + 24px);
  min-width: 0;
  min-height: 0;
}

#game-screen .game-controls {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: clamp(5px, 0.8dvh, 8px);
}

#game-screen .ctrl-btn {
  min-width: 0;
  min-height: 0;
  padding: clamp(7px, 1dvh, 10px) 6px;
  border-radius: 0 !important;
}

#game-screen .ctrl-label {
  font-size: clamp(0.58rem, 1.05dvh, 0.75rem);
}

/* Modals: lock viewport; modal bodies scroll internally when content is tall. */
.modal-overlay {
  overflow: hidden;
  padding:
    max(12px, env(safe-area-inset-top))
    max(12px, env(safe-area-inset-right))
    max(12px, env(safe-area-inset-bottom))
    max(12px, env(safe-area-inset-left));
}

.modal,
.pixel-modal-body-scroll {
  max-height: calc(100dvh - 24px);
  min-height: 0;
  overflow: hidden;
  border-radius: 0 !important;
}

.modal {
  display: flex;
  flex-direction: column;
}

.wallet-modal .wallet-list,
.settings-modal .settings-list,
.public-match-modal .public-match-layout,
.wallet-diagnostics pre {
  flex: 1 1 auto;
  max-height: min(58dvh, 520px);
  overflow: auto;
}

.wallet-actions,
.gameover-actions {
  flex: 0 0 auto;
}

@media (max-height: 780px) and (min-width: 901px) {
  :root {
    --pixel-screen-pad-y: 7px;
    --pixel-panel-gap: 8px;
    --pixel-compact-pad: 9px;
  }

  .shell-brand p,
  .shell-page-head p,
  .trust-note {
    display: none;
  }

  .dashboard-grid {
    grid-template-rows: minmax(0, 0.85fr) minmax(0, 1fr);
  }

  .quest-row,
  .leader-row,
  .unlock-item,
  .practice-match-card {
    padding: 6px;
  }
}

@media (max-width: 1040px) {
  .dashboard-grid,
  .pixel-grid-dashboard {
    grid-template-columns: repeat(6, minmax(0, 1fr));
    grid-template-rows: repeat(3, minmax(0, 1fr));
  }

  .prize-panel,
  .profile-summary,
  .rank-card,
  .next-unlock-panel,
  .quests-preview,
  .leaderboard-preview,
  .recent-practice-panel {
    grid-column: span 2;
  }

  .profile-grid,
  .pixel-profile-layout {
    grid-template-columns: minmax(210px, 0.9fr) minmax(300px, 1.1fr);
  }
}

@media (max-width: 820px) {
  .shell-content,
  #menu-screen .menu-content {
    width: 100%;
  }

  .shell-header {
    align-items: flex-start;
  }

  .shell-actions {
    overflow-x: auto;
    max-width: 100%;
    padding-bottom: 3px;
  }

  .dashboard-grid,
  .pixel-grid-dashboard {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-template-rows: repeat(4, minmax(0, 1fr));
  }

  .prize-panel,
  .profile-summary,
  .rank-card,
  .next-unlock-panel,
  .quests-preview,
  .leaderboard-preview,
  .recent-practice-panel {
    grid-column: span 1;
  }

  .profile-grid,
  .pixel-profile-layout {
    grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr);
    grid-template-rows: minmax(0, 1fr);
  }

  .profile-side-stack {
    grid-column: 1;
    grid-row: 1;
  }

  .profile-activity-stack {
    grid-column: 2;
    grid-row: 1;
  }

  #menu-screen .menu-panel {
    grid-template-columns: 1fr;
  }

  #menu-screen .menu-group:first-child {
    grid-row: auto;
  }
}

@media (max-width: 560px) {
  :root {
    --pixel-screen-pad-x: 7px;
    --pixel-screen-pad-y: 7px;
    --pixel-panel-gap: 7px;
    --pixel-compact-pad: 8px;
  }

  .shell-header {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
  }

  .shell-brand {
    gap: 8px;
  }

  .shell-logo {
    width: 40px;
    height: 40px;
  }

  .shell-actions {
    justify-content: flex-start;
  }

  .dashboard-grid,
  .pixel-grid-dashboard {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-template-rows: repeat(4, minmax(0, 1fr));
  }

  .dashboard-grid > .shell-panel {
    padding: 7px;
  }

  .rank-card .trust-note,
  .leaderboard-preview .trust-note,
  .recent-practice-panel .trust-note,
  #pool-review-message {
    display: none;
  }

  .profile-grid,
  .pixel-profile-layout {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(0, 0.7fr) minmax(0, 1fr);
  }

  .profile-side-stack,
  .profile-activity-stack {
    grid-column: 1;
  }

  .profile-side-stack {
    grid-row: 1;
  }

  .profile-activity-stack {
    grid-row: 2;
  }

  .profile-side-stack .profile-hero {
    flex-direction: row;
    align-items: center;
  }

  #menu-screen .menu-header {
    grid-template-columns: auto minmax(0, 1fr);
  }

  #menu-screen .menu-subtitle {
    display: none;
  }

  #menu-screen .mode-grid {
    grid-template-columns: 1fr;
  }

  #game-screen .game-container {
    width: 100%;
  }

  #game-screen .game-header {
    grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr) auto;
  }

  #game-screen .player-avatar {
    width: 34px;
    height: 34px;
  }

  #game-screen .ctrl-label {
    display: none;
  }
}
