/* QuickChess Design System — Cafe Rustic Theme */
:root {
  --bg: #faf6f1;
  --bg-elevated: #ffffff;
  --surface: #f3ede4;
  --surface-hover: #ebe4d8;
  --border: #d4c9b8;
  --border-subtle: #e5ddd0;
  --primary: #8b5e3c;
  --primary-hover: #6d4a2f;
  --primary-muted: rgba(139, 94, 60, 0.08);
  --accent: #c4956a;
  --accent-light: #e8d5c0;
  --danger: #b44a3f;
  --danger-hover: #943a31;
  --warning: #c48840;
  --text: #2c2016;
  --text-secondary: #5c4a38;
  --text-muted: #8a7a68;
  --text-dim: #b0a290;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 18px;
  --radius-full: 9999px;
  --font: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: "JetBrains Mono", "Fira Code", ui-monospace, monospace;
  --transition: 150ms ease;
  --shadow-sm: 0 1px 3px rgba(44, 32, 22, 0.06);
  --shadow-md: 0 3px 12px rgba(44, 32, 22, 0.08);
  --shadow-lg: 0 6px 24px rgba(44, 32, 22, 0.1);
}

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

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

a {
  color: var(--primary);
  text-decoration: none;
  transition: color var(--transition);
}
a:hover { color: var(--primary-hover); }

/* ─── Nav ─── */
.nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  height: 52px;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  margin: 10px 12px 0;
  position: sticky;
  top: 10px;
  z-index: 100;
  backdrop-filter: blur(12px);
  background: rgba(250, 246, 241, 0.92);
  box-shadow: var(--shadow-sm);
}
@media (min-width: 640px) {
  .nav { padding: 0 24px; height: 56px; margin: 12px 20px 0; }
}
@media (min-width: 1024px) {
  .nav { margin: 14px 28px 0; }
}
.nav-left {
  display: flex;
  align-items: center;
  gap: 24px;
}
.nav-logo {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.3px;
  text-decoration: none;
}
.nav-mid {
  display: flex;
  align-items: center;
  gap: 8px;
}
.nav-link {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-muted);
  text-decoration: none;
  transition: color var(--transition);
}
.nav-link:hover { color: var(--text); }
.nav-link-active { color: var(--text); font-weight: 600; }
.nav-sep {
  color: var(--text-dim);
  font-size: 13px;
  user-select: none;
}
.nav-links {
  display: flex;
  align-items: center;
  gap: 6px;
}

/* ─── Buttons ─── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 18px;
  font-size: 14px;
  font-weight: 500;
  font-family: var(--font);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-elevated);
  color: var(--text);
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
  text-decoration: none;
}
.btn:hover {
  background: var(--surface-hover);
  border-color: var(--border);
}
.btn-primary {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
  font-weight: 600;
}
.btn-primary:hover {
  background: var(--primary-hover);
  border-color: var(--primary-hover);
  color: #fff;
}
.btn-danger {
  background: var(--bg-elevated);
  border-color: var(--danger);
  color: var(--danger);
}
.btn-danger:hover {
  background: var(--danger);
  color: #fff;
}
.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--text-secondary);
}
.btn-ghost:hover {
  background: var(--surface);
  color: var(--text);
}
.btn-lg {
  padding: 12px 28px;
  font-size: 16px;
  border-radius: var(--radius-lg);
}
.btn-sm {
  padding: 5px 14px;
  font-size: 13px;
}
.btn-icon {
  padding: 8px;
  width: 36px;
  height: 36px;
}

/* ─── Cards ─── */
.card {
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 20px;
}
.card-hover:hover {
  border-color: var(--border);
  box-shadow: var(--shadow-sm);
}

/* ─── Inputs ─── */
.input {
  width: 100%;
  padding: 10px 14px;
  font-size: 14px;
  font-family: var(--font);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text);
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
}
.input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-muted);
}
.input::placeholder { color: var(--text-dim); }

/* ─── Labels ─── */
.label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

/* ─── Layout ─── */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 16px;
}
@media (min-width: 640px) {
  .container { padding: 0 24px; }
}
.page {
  padding: 24px 0;
}
@media (min-width: 640px) {
  .page { padding: 40px 0; }
}

/* ─── Home Layout (3-col with rails) ─── */
.home-layout {
  display: flex;
  justify-content: center;
  min-height: calc(100vh - 80px);
  padding: 0;
  position: relative;
  overflow-x: hidden;
}

/* ─── Home Tabs ─── */
.home-tabs {
  display: flex;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  padding: 4px;
  margin-bottom: 24px;
  gap: 0;
}
.home-tab {
  flex: 1;
  padding: 11px 20px;
  font-size: 14px;
  font-weight: 500;
  font-family: var(--font);
  background: transparent;
  border: none;
  border-radius: var(--radius-full);
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
  text-align: center;
}
.home-tab:hover {
  color: var(--text);
}
.home-tab-active {
  background: var(--bg-elevated);
  color: var(--text);
  font-weight: 600;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-subtle);
}

/* ─── TC Card ─── */
.tc-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 20px;
}
@media (min-width: 640px) {
  .tc-card { padding: 28px; }
}

/* ─── Time Control Buttons ─── */
.tc-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  max-width: 480px;
  margin: 0 auto;
}
.tc-grid-6 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}
@media (max-width: 400px) {
  .tc-grid { gap: 8px; }
  .tc-grid-6 { gap: 8px; }
}
.tc-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 18px 10px;
  background: var(--bg-elevated);
  border: 2px solid var(--border);
  border-radius: 16px;
  cursor: pointer;
  transition: all var(--transition);
  text-decoration: none;
  color: var(--text);
  font-family: var(--font);
}
@media (min-width: 640px) {
  .tc-btn { padding: 24px 14px; }
}
.tc-btn:hover {
  border-color: var(--primary);
  background: var(--primary-muted);
  color: var(--text);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}
.tc-btn-selected {
  border-color: var(--primary);
  background: var(--primary-muted);
  box-shadow: 0 0 0 1px var(--primary);
}
.tc-btn-time {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.5px;
  line-height: 1;
}
@media (min-width: 640px) {
  .tc-btn-time { font-size: 28px; }
}
.tc-btn-label {
  font-size: 10px;
  color: var(--text-muted);
  margin-top: 6px;
  text-transform: uppercase;
  letter-spacing: 1px;
}
.tc-submit {
  margin-top: 16px;
  border-radius: var(--radius-full);
}

/* ─── Shortlink Section ─── */
.shortlink-section {
  margin-top: 24px;
  text-align: center;
}
.shortlink-hint {
  font-size: 13px;
  color: var(--text-dim);
  margin-bottom: 10px;
}
.shortlink-box {
  display: flex;
  align-items: center;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  padding: 6px 6px 6px 18px;
  gap: 8px;
}
.shortlink-input {
  flex: 1;
  border: none;
  background: transparent;
  font-family: var(--font-mono);
  font-size: 14px;
  color: var(--text);
  outline: none;
  min-width: 0;
  font-weight: 500;
}
.shortlink-copy-btn {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all var(--transition);
}
.shortlink-copy-btn:hover {
  background: var(--surface-hover);
  color: var(--text);
}

/* ─── Create Game ─── */
.create-game-section {
  max-width: 480px;
  margin: 32px auto 0;
  text-align: center;
}
.invite-link-box {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  margin-top: 12px;
}
.invite-link-box input {
  flex: 1;
  border: none;
  background: transparent;
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--text);
  outline: none;
  min-width: 0;
}
.invite-link-box .btn { flex-shrink: 0; }

/* ─── Home Page — Center Column ─── */
.home-center {
  width: 100%;
  max-width: 520px;
  padding: 0 16px;
  position: relative;
  z-index: 1;
  margin: 0 auto;
}
@media (min-width: 640px) {
  .home-center { padding: 0 20px; }
}
@media (min-width: 900px) {
  .home-center { max-width: 480px; }
}
.home-hero {
  text-align: center;
  padding: 48px 0 32px;
}
@media (min-width: 640px) {
  .home-hero { padding: 56px 0 40px; }
}
.home-brand {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  margin-bottom: 12px;
}
.home-moustache {
  flex-shrink: 0;
}
.home-title {
  font-size: 44px;
  font-weight: 800;
  letter-spacing: -2px;
  line-height: 1;
  color: var(--text);
}
@media (min-width: 640px) {
  .home-title { font-size: 52px; letter-spacing: -2.5px; }
}
.home-tagline {
  font-size: 15px;
  color: var(--text-muted);
  max-width: 340px;
  margin: 0 auto;
  line-height: 1.55;
}
@media (min-width: 640px) {
  .home-tagline { font-size: 16px; }
}

.home-section {
  margin-bottom: 32px;
}
.home-section-title {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: var(--text-dim);
  margin-bottom: 12px;
  text-align: center;
}
.tc-btn-ranked {
  border-color: var(--primary);
}

/* ─── Side Rail Cards ─── */
.side-rail {
  display: none;
  flex-direction: column;
  gap: 16px;
  padding: 24px 0;
  position: fixed;
  top: 80px;
  z-index: 0;
}
@media (min-width: 900px) {
  .side-rail { display: flex; width: 120px; }
}
@media (min-width: 1100px) {
  .side-rail { width: 150px; gap: 18px; }
}
@media (min-width: 1400px) {
  .side-rail { width: 180px; gap: 20px; }
}
.side-rail-left { left: 12px; }
.side-rail-right { right: 12px; }
@media (min-width: 1100px) {
  .side-rail-left { left: 20px; }
  .side-rail-right { right: 20px; }
}
@media (min-width: 1400px) {
  .side-rail-left { left: 32px; }
  .side-rail-right { right: 32px; }
}

/* Flip card container */
.rail-card {
  width: 100%;
  aspect-ratio: 1;
  perspective: 600px;
  animation: railFloat 5s ease-in-out infinite;
}
@keyframes railFloat {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}
.rail-card-inner {
  width: 100%;
  height: 100%;
  position: relative;
  transform-style: preserve-3d;
  animation: cardFlip 8s ease-in-out infinite;
}
@keyframes cardFlip {
  0%, 42% { transform: rotateY(0deg); }
  50%, 92% { transform: rotateY(180deg); }
  100% { transform: rotateY(360deg); }
}
.rail-card-front,
.rail-card-back {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10px;
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.rail-card-back {
  transform: rotateY(180deg);
}

/* Mini chessboard on rail cards */
.rail-mini-board {
  width: 100%;
  aspect-ratio: 1;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  grid-template-rows: repeat(4, 1fr);
  border-radius: 8px;
  overflow: hidden;
}
.rail-mini-board .sq {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0;
  line-height: 1;
}
.rail-mini-board .sq svg {
  width: 70%;
  height: 70%;
}

/* (skin strip removed — using side rails instead) */

/* ─── Invite Lobby ─── */
.lobby-container {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: calc(100vh - 60px);
  padding: 24px 16px;
}
.lobby-card {
  width: 100%;
  max-width: 480px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 28px 24px;
}
@media (min-width: 640px) {
  .lobby-card { padding: 40px 36px; }
}
.lobby-creator {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 24px;
}
.lobby-status-dot {
  width: 10px;
  height: 10px;
  background: var(--primary);
  border-radius: var(--radius-full);
  flex-shrink: 0;
}
.lobby-creator-name {
  font-size: 22px;
  font-weight: 600;
}
@media (min-width: 640px) {
  .lobby-creator-name { font-size: 26px; }
}
.lobby-creator-rating {
  font-size: 20px;
  color: var(--text-muted);
}
.lobby-details {
  background: var(--primary-muted);
  border: 1px solid rgba(139, 94, 60, 0.15);
  border-radius: var(--radius-lg);
  padding: 20px;
  margin-bottom: 24px;
}
.lobby-detail-main {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 12px;
}
.lobby-icon { flex-shrink: 0; }
.lobby-detail-label {
  font-size: 16px;
  color: var(--text-secondary);
}
.lobby-detail-value {
  font-size: 20px;
  font-weight: 700;
  font-family: var(--font-mono);
}
.lobby-detail-meta {
  display: flex;
  justify-content: flex-end;
  gap: 16px;
  font-size: 13px;
  color: var(--primary);
  font-weight: 500;
}
.btn-join {
  width: 100%;
  padding: 16px 24px;
  font-size: 17px;
  font-weight: 700;
  border-radius: var(--radius-lg);
  gap: 10px;
  margin-bottom: 20px;
}
.lobby-share {
  padding-top: 16px;
  border-top: 1px solid var(--border-subtle);
}

/* ─── Creator Waiting Room ─── */
.waiting-room {
  display: flex;
  flex-direction: column;
  align-items: center;
  max-width: 420px;
  margin: 0 auto;
  padding: 48px 20px 40px;
  min-height: calc(100vh - 60px);
}
.wr-header {
  text-align: center;
  margin-bottom: 32px;
}
.wr-tc {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 8px;
  margin-bottom: 4px;
}
.wr-tc-label {
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
}
.wr-tc-value {
  font-size: 15px;
  font-family: var(--font-mono);
  color: var(--text-muted);
}
.wr-meta {
  font-size: 13px;
  color: var(--text-dim);
}
.wr-sep { margin: 0 4px; }

.wr-status {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  margin-bottom: 32px;
}
.wr-spinner {
  width: 32px;
  height: 32px;
  border: 2.5px solid var(--border);
  border-top-color: var(--primary);
  border-radius: var(--radius-full);
  animation: wr-spin 0.8s linear infinite;
}
@keyframes wr-spin {
  to { transform: rotate(360deg); }
}
.wr-status-text {
  font-size: 14px;
  color: var(--text-muted);
}

.wr-link-section {
  width: 100%;
  margin-bottom: 32px;
}
.wr-link-label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-dim);
  margin-bottom: 6px;
}

.wr-skins {
  width: 100%;
  margin-bottom: 24px;
}
.wr-skins-title {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-dim);
  margin-bottom: 10px;
}
.wr-skin-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
}
@media (max-width: 480px) {
  .wr-skin-grid { grid-template-columns: repeat(4, 1fr); }
}
.wr-skin-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 8px 4px;
  background: none;
  border: 2px solid transparent;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: border-color var(--transition), background var(--transition);
}
.wr-skin-btn:hover {
  background: var(--surface);
}
.wr-skin-active {
  border-color: var(--primary);
  background: var(--primary-muted);
}
.wr-skin-preview {
  display: grid;
  grid-template-columns: 1fr 1fr;
  width: 32px;
  height: 32px;
  border-radius: 4px;
  overflow: hidden;
}
.wr-skin-preview > div { aspect-ratio: 1; }
.wr-skin-name {
  font-size: 10px;
  color: var(--text-muted);
  white-space: nowrap;
}

.wr-cancel {
  font-size: 13px;
  color: var(--text-dim);
  text-decoration: none;
  transition: color var(--transition);
}
.wr-cancel:hover {
  color: var(--text-secondary);
}

/* ─── Game Page (3-column responsive) ─── */
.game-page {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-width: 1200px;
  margin: 0 auto;
  padding: 12px;
}
@media (min-width: 768px) {
  .game-page {
    padding: 16px;
  }
}
@media (min-width: 1024px) {
  .game-page {
    display: grid;
    grid-template-columns: 240px 1fr 280px;
    gap: 16px;
    padding: 16px 24px;
    align-items: start;
  }
}
@media (min-width: 1200px) {
  .game-page {
    grid-template-columns: 260px 1fr 300px;
    gap: 20px;
  }
}

/* Left panel */
.game-left {
  display: flex;
  flex-direction: column;
  gap: 8px;
  order: 3;
}
@media (min-width: 1024px) {
  .game-left { order: 1; }
}

/* Center */
.game-center {
  order: 1;
  max-width: 600px;
  width: 100%;
  margin: 0 auto;
}
@media (min-width: 1024px) {
  .game-center { order: 2; max-width: none; }
}

/* Right panel */
.game-right {
  display: flex;
  flex-direction: column;
  gap: 8px;
  order: 2;
}
@media (min-width: 1024px) {
  .game-right { order: 3; }
}

/* Game info card */
.game-info-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 12px 14px;
}
.game-info-header {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 8px;
}
.game-info-players {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.game-info-player {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 500;
}
.game-info-dot {
  width: 8px;
  height: 8px;
  border-radius: var(--radius-full);
  background: var(--border);
  flex-shrink: 0;
}
.game-info-dot.online {
  background: #5a9a4a;
}
.game-info-rating {
  color: var(--text-muted);
  font-size: 12px;
}

/* Chat panel */
.chat-panel {
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  display: flex;
  flex-direction: column;
  background: var(--bg-elevated);
  overflow: hidden;
}
@media (min-width: 1024px) {
  .chat-panel { min-height: 280px; flex: 1; }
}
.chat-header {
  padding: 8px 12px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px solid var(--border-subtle);
}
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 8px 10px;
  font-size: 13px;
  line-height: 1.5;
  min-height: 100px;
  max-height: 220px;
}
@media (min-width: 1024px) {
  .chat-messages { min-height: 180px; max-height: none; }
}
.chat-messages:empty::before {
  content: "";
}
.chat-msg {
  margin-bottom: 2px;
  word-break: break-word;
}
.chat-msg-sender {
  font-weight: 600;
  font-size: 12px;
  margin-right: 4px;
}
.chat-msg-sender.white { color: var(--text); }
.chat-msg-sender.black { color: var(--primary); }
.chat-msg-text {
  color: var(--text-secondary);
}
.chat-input-row {
  display: flex;
  gap: 4px;
  padding: 6px 8px;
  border-top: 1px solid var(--border-subtle);
  background: var(--bg-elevated);
}
.chat-input {
  flex: 1;
  padding: 6px 8px !important;
  font-size: 13px !important;
  min-height: auto !important;
  border: none !important;
  background: transparent !important;
}
.chat-input:focus {
  box-shadow: none !important;
}
.chat-send-btn {
  padding: 6px 10px !important;
}
.board-container {
  position: relative;
  width: 100%;
  max-width: 600px;
  margin: 0 auto;
}
.board-wrapper {
  width: 100%;
  aspect-ratio: 1;
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-md);
}

/* ─── Player Bar ─── */
.player-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  margin: 6px 0;
}
@media (min-width: 640px) {
  .player-bar { padding: 10px 14px; margin: 8px 0; }
}
.player-info {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.player-avatar {
  width: 30px;
  height: 30px;
  border-radius: var(--radius-full);
  background: var(--surface);
  border: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  flex-shrink: 0;
}
@media (min-width: 640px) {
  .player-avatar { width: 32px; height: 32px; font-size: 14px; }
}
.player-name {
  font-size: 13px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
@media (min-width: 640px) {
  .player-name { font-size: 14px; }
}
.player-rating {
  font-size: 12px;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

/* ─── Clock ─── */
.clock {
  font-family: var(--font-mono);
  font-size: 18px;
  font-weight: 700;
  padding: 5px 12px;
  border-radius: var(--radius-md);
  min-width: 72px;
  text-align: center;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
}
@media (min-width: 640px) {
  .clock { font-size: 20px; padding: 6px 14px; min-width: 80px; }
}
.clock-active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}
.clock-low {
  background: var(--danger);
  color: #fff;
  border-color: var(--danger);
  animation: clock-pulse 1s ease infinite;
}
@keyframes clock-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}

/* ─── Sidebar ─── */
.sidebar {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* ─── Move List ─── */
.move-list {
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  max-height: 300px;
  overflow-y: auto;
}
@media (min-width: 768px) {
  .move-list { max-height: 400px; }
}
.move-list-header {
  padding: 10px 14px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border-subtle);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.move-row {
  display: grid;
  grid-template-columns: 28px 1fr 1fr;
  padding: 3px 14px;
  font-size: 13px;
  font-family: var(--font-mono);
}
.move-row:hover { background: var(--surface-hover); }
.move-num {
  color: var(--text-dim);
  font-size: 11px;
}
.move-san {
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  cursor: pointer;
}
.move-san:hover { background: var(--primary-muted); }
.move-san-last { color: var(--primary); font-weight: 600; }

/* ─── Game Controls ─── */
.game-controls {
  display: flex;
  gap: 8px;
}
.game-controls .btn { flex: 1; }

/* ─── Profile ─── */
.profile-header {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 24px;
}
@media (min-width: 640px) {
  .profile-header { gap: 24px; margin-bottom: 32px; }
}
.profile-avatar-lg {
  width: 56px;
  height: 56px;
  border-radius: var(--radius-full);
  background: var(--surface);
  border: 2px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  font-weight: 700;
  color: var(--primary);
  flex-shrink: 0;
}
@media (min-width: 640px) {
  .profile-avatar-lg { width: 80px; height: 80px; font-size: 32px; }
}
.profile-stats {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin-bottom: 24px;
}
@media (min-width: 480px) {
  .profile-stats { grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 32px; }
}
.stat-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 12px;
  text-align: center;
}
@media (min-width: 640px) {
  .stat-card { padding: 16px; }
}
.stat-value {
  font-size: 20px;
  font-weight: 700;
  font-family: var(--font-mono);
}
@media (min-width: 640px) {
  .stat-value { font-size: 24px; }
}
.stat-label {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 4px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* ─── Game History ─── */
.game-history {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.game-history-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  text-decoration: none;
  color: var(--text);
  transition: all var(--transition);
  flex-wrap: wrap;
}
@media (min-width: 640px) {
  .game-history-item {
    display: grid;
    grid-template-columns: 56px 1fr 80px 56px;
    gap: 12px;
    padding: 12px 16px;
    flex-wrap: nowrap;
  }
}
.game-history-item:hover {
  border-color: var(--border);
  box-shadow: var(--shadow-sm);
  color: var(--text);
}
.game-result-badge {
  font-size: 12px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  text-align: center;
}
.badge-win { background: rgba(90, 154, 74, 0.1); color: #5a9a4a; }
.badge-loss { background: rgba(180, 74, 63, 0.1); color: var(--danger); }
.badge-draw { background: rgba(138, 122, 104, 0.1); color: var(--text-secondary); }

/* ─── Auth ─── */
.auth-container {
  max-width: 400px;
  margin: 48px auto 0;
  padding: 0 16px;
}
@media (min-width: 640px) {
  .auth-container { margin: 80px auto 0; padding: 0 24px; }
}
.auth-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  padding: 24px;
  box-shadow: var(--shadow-sm);
}
@media (min-width: 640px) {
  .auth-card { padding: 32px; }
}
.auth-card h2 {
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 6px;
}
.auth-card p {
  color: var(--text-muted);
  font-size: 14px;
  margin-bottom: 24px;
}
.form-group {
  margin-bottom: 16px;
}
.form-group:last-child { margin-bottom: 0; }

/* Alerts */
.alert {
  padding: 10px 14px;
  border-radius: var(--radius-md);
  font-size: 13px;
  margin-bottom: 16px;
  line-height: 1.5;
}
.alert-error {
  background: rgba(180, 74, 63, 0.06);
  border: 1px solid rgba(180, 74, 63, 0.15);
  color: var(--danger);
}
.alert-success {
  background: rgba(90, 154, 74, 0.06);
  border: 1px solid rgba(90, 154, 74, 0.15);
  color: #5a9a4a;
}

/* ─── Waiting ─── */
.waiting-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 60vh;
  text-align: center;
  padding: 0 16px;
}
.waiting-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: var(--radius-full);
  animation: spin 0.8s linear infinite;
  margin-bottom: 24px;
}
@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ─── Settings Tab ─── */
.settings-panel {
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.settings-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  cursor: pointer;
  user-select: none;
}
.settings-header:hover { background: var(--surface-hover); }
.settings-header-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.settings-body {
  padding: 12px 14px;
  border-top: 1px solid var(--border-subtle);
}
.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.settings-row:last-child { margin-bottom: 0; }
.settings-label {
  font-size: 13px;
  color: var(--text-secondary);
}
.settings-section-title {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}

/* ─── Skin Store ─── */
.skin-store {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
@media (min-width: 1024px) {
  .skin-store { grid-template-columns: 1fr; }
}
.skin-card {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: var(--bg-elevated);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition);
  text-align: left;
  font-family: var(--font);
}
.skin-card:hover {
  border-color: var(--primary);
  box-shadow: 0 2px 8px rgba(139, 94, 60, 0.08);
}
.skin-card-active {
  border-color: var(--primary);
  background: var(--primary-muted);
}
.skin-card-preview {
  width: 36px;
  height: 36px;
  border-radius: 4px;
  overflow: hidden;
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr 1fr;
  flex-shrink: 0;
}
.skin-card-info {
  flex: 1;
  min-width: 0;
}
.skin-card-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.2;
}
.skin-card-price {
  font-size: 11px;
  color: var(--text-muted);
  font-family: var(--font-mono);
  margin-top: 1px;
}
.skin-card-tag {
  position: absolute;
  top: -1px;
  right: 8px;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  padding: 2px 6px;
  border-radius: 0 0 4px 4px;
}
.skin-card-check {
  width: 20px;
  height: 20px;
  border-radius: var(--radius-full);
  background: var(--primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

/* ─── Toast ─── */
.toast {
  position: fixed;
  bottom: 16px;
  left: 16px;
  right: 16px;
  padding: 12px 16px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  font-size: 14px;
  z-index: 1000;
  animation: toast-in 200ms ease;
}
@media (min-width: 640px) {
  .toast { left: auto; right: 24px; bottom: 24px; max-width: 360px; }
}
@keyframes toast-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ─── Modal ─── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(44, 32, 22, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 16px;
  animation: fade-in 150ms ease;
}
@keyframes fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}
.modal {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 24px;
  max-width: 360px;
  width: 100%;
  box-shadow: var(--shadow-lg);
}
.modal h3 {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 8px;
}
.modal p {
  color: var(--text-muted);
  font-size: 14px;
  margin-bottom: 20px;
}
.modal-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

/* ─── Utilities ─── */
.text-center { text-align: center; }
.text-muted { color: var(--text-muted); }
.text-sm { font-size: 13px; }
.text-xs { font-size: 11px; }
.mt-2 { margin-top: 8px; }
.mt-4 { margin-top: 16px; }
.mt-6 { margin-top: 24px; }
.mb-2 { margin-bottom: 8px; }
.mb-4 { margin-bottom: 16px; }
.gap-2 { gap: 8px; }
.flex { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.w-full { width: 100%; }
.hidden { display: none; }

/* ─── Color Picker Modal ─── */
.color-pick-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-top: 4px;
}
.color-pick-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 16px 8px;
  background: var(--bg-elevated);
  border: 2px solid var(--border);
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition: all var(--transition);
  font-family: var(--font);
}
.color-pick-btn:hover {
  border-color: var(--primary);
  background: var(--primary-muted);
}
.color-pick-selected {
  border-color: var(--primary);
  background: var(--primary-muted);
  box-shadow: 0 0 0 1px var(--primary);
}
.color-pick-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface);
}
.color-pick-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

/* ─── Game Over Buttons ─── */
.game-over-actions {
  display: flex;
  gap: 10px;
  margin-top: 8px;
}
.game-over-actions .btn {
  min-width: 120px;
}

/* ─── About Page ─── */
.about-page {
  max-width: 680px;
  margin: 0 auto;
  padding: 0 20px 60px;
}
.about-hero {
  text-align: center;
  padding: 48px 0 36px;
}
@media (min-width: 640px) {
  .about-hero { padding: 64px 0 48px; }
}
.about-moustache {
  margin-bottom: 16px;
}
.about-title {
  font-size: 36px;
  font-weight: 800;
  letter-spacing: -1.5px;
  margin-bottom: 10px;
}
@media (min-width: 640px) {
  .about-title { font-size: 44px; }
}
.about-subtitle {
  font-size: 16px;
  color: var(--text-muted);
  max-width: 400px;
  margin: 0 auto;
  line-height: 1.6;
}
.about-content {
  display: flex;
  flex-direction: column;
  gap: 36px;
}
.about-section h2 {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 10px;
  letter-spacing: -0.3px;
}
.about-section p {
  font-size: 15px;
  color: var(--text-secondary);
  line-height: 1.7;
}
.about-features {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}
@media (min-width: 520px) {
  .about-features { grid-template-columns: 1fr 1fr; }
}
.about-feature {
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 20px;
}
.about-feature-icon {
  width: 40px;
  height: 40px;
  background: var(--primary-muted);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 12px;
}
.about-feature h3 {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 6px;
}
.about-feature p {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.5;
}
.about-cta {
  text-align: center;
  padding-top: 12px;
}

/* ─── Scrollbar ─── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: var(--radius-full); }
::-webkit-scrollbar-thumb:hover { background: var(--text-dim); }

/* ─── Online indicator ─── */
.online-dot {
  width: 8px;
  height: 8px;
  background: #5a9a4a;
  border-radius: var(--radius-full);
  display: inline-block;
  animation: pulse-dot 2s ease infinite;
}
@keyframes pulse-dot {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* ─── Game Over Overlay ─── */
.game-over-overlay {
  position: absolute;
  inset: 0;
  background: rgba(250, 246, 241, 0.9);
  backdrop-filter: blur(4px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-lg);
  z-index: 10;
  animation: fade-in 300ms ease;
}
.game-over-result {
  font-size: 24px;
  font-weight: 800;
  margin-bottom: 4px;
  color: var(--text);
}
@media (min-width: 640px) {
  .game-over-result { font-size: 32px; margin-bottom: 8px; }
}
.game-over-reason {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 20px;
}

/* ─── Section Divider ─── */
.divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 24px 0;
  color: var(--text-dim);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.divider::before, .divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border-subtle);
}
