:root {
  --bg-primary: #0d1117;
  --bg-secondary: #161b22;
  --bg-tertiary: #21262d;
  --bg-glass: rgba(22, 27, 34, 0.85);
  
  --border-color: #30363d;
  --border-highlight: #484f58;

  --text-primary: #f0f6fc;
  --text-secondary: #8b949e;
  --text-muted: #6e7681;

  --color-red: #e63946;
  --color-red-light: #ff6b6b;
  --color-black-piece: #1a1a1a;
  --color-gold: #f59e0b;
  --color-gold-light: #fbbf24;
  --color-green: #10b981;
  --color-blue: #3b82f6;

  --board-wood: #ddb17b;
  --board-wood-dark: #b8864b;

  --font-main: 'Be Vietnam Pro', system-ui, -apple-system, sans-serif;
  --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.6);
  --shadow-glow-red: 0 0 16px rgba(230, 57, 70, 0.4);
  --shadow-glow-gold: 0 0 16px rgba(245, 158, 11, 0.4);

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-full: 9999px;
}

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

body {
  font-family: var(--font-main);
  background-color: var(--bg-primary);
  color: var(--text-primary);
  height: 100vh;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  line-height: 1.5;
  overflow: hidden;
  background-image: 
    radial-gradient(circle at 10% 20%, rgba(230, 57, 70, 0.08) 0%, transparent 40%),
    radial-gradient(circle at 90% 80%, rgba(245, 158, 11, 0.08) 0%, transparent 40%);
}

.app-container {
  max-width: 1280px;
  width: 100%;
  margin: 0 auto;
  padding: 12px 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  height: 100vh;
  max-height: 100vh;
  overflow: hidden;
}

/* Header */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-glass);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-color);
  padding: 12px 20px;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  flex-wrap: wrap;
  gap: 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo-icon {
  font-size: 28px;
  background: linear-gradient(135deg, var(--color-red), var(--color-gold));
  -webkit-background-clip: text;
  background-clip: text;
  filter: drop-shadow(0 2px 4px rgba(230, 57, 70, 0.3));
}

.brand-text h1 {
  font-size: 1.15rem;
  font-weight: 800;
  letter-spacing: 0.5px;
  background: linear-gradient(90deg, #fff, #c9d1d9);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.badge-sub {
  font-size: 0.72rem;
  color: var(--text-secondary);
  font-weight: 500;
}

.header-center {
  display: flex;
  align-items: center;
}

.room-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  padding: 6px 14px;
  border-radius: var(--radius-full);
}

.room-label {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.room-code {
  font-family: monospace;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--color-gold);
}

.btn-icon {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4px;
  border-radius: var(--radius-sm);
  transition: all 0.2s;
}

.btn-icon:hover {
  color: var(--text-primary);
  background: var(--border-color);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 14px;
}

.connection-status {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.82rem;
  color: var(--text-secondary);
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  transition: background-color 0.3s;
}

.status-dot.connected {
  background-color: var(--color-green);
  box-shadow: 0 0 8px rgba(16, 185, 129, 0.6);
}

.status-dot.connecting {
  background-color: var(--color-gold);
  box-shadow: 0 0 8px rgba(245, 158, 11, 0.6);
}

.status-dot.disconnected {
  background-color: var(--color-red);
  box-shadow: 0 0 8px rgba(230, 57, 70, 0.6);
}

/* Header & Navigation */
.btn-home-nav {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: var(--radius-full);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-home-nav:hover {
  background: var(--border-color);
  transform: translateY(-1px);
}

.brand {
  cursor: pointer;
}

/* ----------------------------------------------------
   1. Home View Styles (Trang chủ riêng biệt)
   ---------------------------------------------------- */
.home-view {
  display: flex;
  flex-direction: column;
  gap: 24px;
  max-width: 960px;
  width: 100%;
  margin: 10px auto 0;
  animation: fadeIn 0.4s ease-out;
  overflow-y: auto;
  padding-bottom: 20px;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.home-hero {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 16px 16px 6px;
}

.hero-badge {
  display: inline-block;
  padding: 6px 16px;
  border-radius: var(--radius-full);
  background: rgba(245, 158, 11, 0.12);
  border: 1px solid rgba(245, 158, 11, 0.3);
  color: var(--color-gold-light);
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 0.5px;
}

.hero-title {
  font-size: 2.2rem;
  font-weight: 800;
  background: linear-gradient(135deg, #ffffff 0%, #d2d6dc 50%, var(--color-gold) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  line-height: 1.2;
}

.hero-subtitle {
  font-size: 1rem;
  color: var(--text-secondary);
  max-width: 580px;
}

/* Player Profile Bar on Home View */
.player-profile-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-glass);
  border: 1px solid var(--border-highlight);
  padding: 8px 16px;
  border-radius: var(--radius-full);
  box-shadow: var(--shadow-sm);
  margin-top: 4px;
}

.profile-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
  white-space: nowrap;
}

.profile-input {
  background: transparent;
  border: none;
  color: var(--color-gold);
  font-weight: 700;
  font-size: 0.95rem;
  padding: 4px 8px;
  width: 180px;
}

.profile-input:focus {
  border-bottom: 1px solid var(--color-gold);
}

.home-cards-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
  width: 100%;
}

@media (max-width: 850px) {
  .home-cards-grid {
    grid-template-columns: 1fr;
  }
}

.home-card {
  background: var(--bg-glass);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  transition: all 0.3s ease;
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
}

.home-card:hover {
  border-color: var(--border-highlight);
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
}

.home-card.primary-card {
  border-color: rgba(230, 57, 70, 0.4);
  background: linear-gradient(180deg, rgba(230, 57, 70, 0.08) 0%, var(--bg-glass) 100%);
}

.home-card.primary-card:hover {
  border-color: var(--color-red);
  box-shadow: var(--shadow-glow-red);
}

.card-icon {
  font-size: 2rem;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-tertiary);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
}

.home-card h3 {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-primary);
}

.home-card p {
  font-size: 0.85rem;
  color: var(--text-secondary);
  line-height: 1.4;
  flex: 1;
}

.btn-lg {
  padding: 12px 20px;
  font-size: 0.98rem;
}

.join-input-group {
  display: flex;
  gap: 8px;
  margin-top: 4px;
}

/* Time Setting Group on Home View */
.time-setting-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 4px;
}

.time-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.time-pills {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
}

.btn-time-pill {
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  font-size: 0.78rem;
  font-weight: 600;
  padding: 5px 4px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-time-pill:hover {
  border-color: var(--border-highlight);
  color: var(--text-primary);
}

.btn-time-pill.active {
  background: rgba(245, 158, 11, 0.15);
  border-color: var(--color-gold);
  color: var(--color-gold-light);
  font-weight: 700;
  box-shadow: 0 0 8px rgba(245, 158, 11, 0.2);
}

.home-features {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-top: 8px;
  padding-top: 20px;
  border-top: 1px solid var(--border-color);
  width: 100%;
}

@media (max-width: 850px) {
  .home-features {
    grid-template-columns: 1fr;
  }
}

.feature-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px;
  background: rgba(255, 255, 255, 0.02);
  border-radius: var(--radius-md);
  border: 1px solid rgba(255, 255, 255, 0.04);
}

.feature-icon {
  font-size: 1.4rem;
}

.feature-item h4 {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 2px;
}

.feature-item p {
  font-size: 0.78rem;
  color: var(--text-secondary);
}

/* ----------------------------------------------------
   Global Dark Scrollbar Customization (Fix White Scrollbar)
   ---------------------------------------------------- */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: rgba(13, 17, 23, 0.5);
  border-radius: var(--radius-full);
}

::-webkit-scrollbar-thumb {
  background: rgba(240, 246, 252, 0.18);
  border-radius: var(--radius-full);
  transition: background 0.2s ease;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--color-gold);
}

/* ----------------------------------------------------
   2. Game View Styles (Nút bên TÁI - Bàn cờ TO & Chat TO bên PHẢI)
   ---------------------------------------------------- */
.game-view {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 16px;
  align-items: stretch;
  width: 100%;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  animation: fadeIn 0.3s ease-out;
}

@media (max-width: 950px) {
  .game-view {
    grid-template-columns: 1fr;
    overflow-y: auto;
  }
}

/* --- Left Panel: Controls, Status & Players --- */
.game-left-panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
  height: 100%;
  min-height: 0;
  overflow-y: auto;
}

.panel-card {
  background: var(--bg-glass);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 12px 14px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.panel-card-title {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.status-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.turn-indicator {
  font-size: 0.95rem;
  font-weight: 800;
  color: var(--color-red-light);
}

.turn-indicator.turn-black {
  color: #93c5fd;
}

.alert-box {
  font-size: 0.82rem;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  background: rgba(59, 130, 246, 0.1);
  color: #93c5fd;
  border: 1px solid rgba(59, 130, 246, 0.2);
}

.alert-box.danger {
  background: rgba(230, 57, 70, 0.15);
  color: var(--color-red-light);
  border-color: rgba(230, 57, 70, 0.3);
}

.players-card {
  gap: 8px;
}

.player-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px;
  background: var(--bg-tertiary);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  transition: all 0.3s ease;
}

.player-bar.active-turn {
  border-color: var(--color-gold);
  background: rgba(245, 158, 11, 0.12);
  box-shadow: 0 0 10px rgba(245, 158, 11, 0.2);
}

.player-info {
  display: flex;
  align-items: center;
  gap: 8px;
}

.player-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.95rem;
  background: var(--bg-primary);
  border: 2px solid var(--border-color);
}

.player-avatar.red-avatar { border-color: var(--color-red); }
.player-avatar.black-avatar { border-color: #555; }

.player-meta {
  display: flex;
  flex-direction: column;
}

.player-name {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-primary);
  max-width: 110px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.player-role-badge {
  font-size: 0.7rem;
  color: var(--text-secondary);
}

.timer-badge {
  font-family: monospace;
  font-size: 1.05rem;
  font-weight: 800;
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
}

.active-turn .timer-badge {
  color: var(--color-gold);
  border-color: var(--color-gold);
}

/* Start Match Button */
.btn-start-match {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  padding: 12px 14px;
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  color: #ffffff;
  font-size: 0.95rem;
  font-weight: 700;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: var(--radius-md);
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
  transition: all 0.2s ease;
}

.btn-start-match:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(16, 185, 129, 0.4);
}

.btn-start-match:disabled {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(255, 255, 255, 0.1);
  color: var(--text-muted);
  cursor: not-allowed;
  box-shadow: none;
  opacity: 0.6;
}

/* Left Action Buttons List */
.left-action-grid {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.btn-action-left {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 14px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  font-size: 0.88rem;
  font-weight: 600;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: left;
}

.btn-action-left:hover {
  background: var(--border-color);
  border-color: var(--border-highlight);
  transform: translateX(2px);
}

.btn-action-danger {
  color: var(--color-red-light);
  border-color: rgba(230, 57, 70, 0.3);
}

.btn-action-danger:hover {
  background: rgba(230, 57, 70, 0.15);
  border-color: var(--color-red);
}

.btn-action-success {
  color: var(--color-gold-light);
  border-color: rgba(245, 158, 11, 0.3);
}

.btn-action-success:hover {
  background: rgba(245, 158, 11, 0.15);
  border-color: var(--color-gold);
}

/* --- Right Section: Large Board + Large Side Chat --- */
.game-right-section {
  display: grid;
  grid-template-columns: minmax(400px, 1fr) minmax(280px, 340px);
  gap: 16px;
  height: 100%;
  min-height: 0;
  overflow: hidden;
  align-items: stretch;
}

@media (max-width: 1100px) {
  .game-right-section {
    grid-template-columns: 1fr;
    overflow-y: auto;
  }
}

/* Large Board Wrapper - Fits Perfectly in Viewport */
.large-board-wrapper {
  background: var(--bg-glass);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 8px;
  box-shadow: var(--shadow-md);
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  min-height: 0;
  overflow: hidden;
}

.board-frame {
  position: relative;
  background: #deb887;
  padding: 8px;
  border-radius: var(--radius-md);
  box-shadow: inset 0 0 15px rgba(0,0,0,0.3), var(--shadow-md);
  border: 4px solid #8b5a2b;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow: hidden;
  height: calc(100vh - 150px);
  max-height: calc(100vh - 150px);
  width: calc((100vh - 150px) * 0.9);
  max-width: 100%;
  aspect-ratio: 9/10;
  margin: 0 auto;
  box-sizing: border-box;
}

#board {
  max-height: 100% !important;
  max-width: 100% !important;
  width: 100% !important;
  aspect-ratio: 9/10;
  margin: 0 auto;
}

/* Overlay Modal on Board */
.board-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(13, 17, 23, 0.88);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.overlay-modal {
  background: var(--bg-secondary);
  border: 1px solid var(--border-highlight);
  padding: 24px 32px;
  border-radius: var(--radius-lg);
  text-align: center;
  box-shadow: var(--shadow-lg);
  max-width: 360px;
  animation: popIn 0.3s ease-out;
}

@keyframes popIn {
  from { transform: scale(0.85); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.overlay-modal h2 {
  font-size: 1.4rem;
  color: var(--color-gold);
  margin-bottom: 8px;
}

.overlay-modal p {
  color: var(--text-secondary);
  font-size: 0.95rem;
  margin-bottom: 20px;
}

/* Large Chat Panel */
.large-chat-wrapper {
  height: 100%;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.chat-card {
  background: var(--bg-glass);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 14px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 10px;
  height: 100%;
  min-height: 0;
  overflow: hidden;
}

.chat-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-shrink: 0;
}

.chat-status {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.chat-messages {
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 10px;
  flex: 1;
  min-height: 0;
  max-height: none;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 0.85rem;
}

.chat-msg {
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  line-height: 1.4;
  word-break: break-word;
  background: var(--bg-secondary);
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.chat-msg.system {
  background: rgba(59, 130, 246, 0.08);
  color: #93c5fd;
  font-size: 0.8rem;
  font-style: italic;
  text-align: center;
  border-color: rgba(59, 130, 246, 0.2);
}

.chat-msg-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 3px;
}

.chat-author {
  font-weight: 700;
  font-size: 0.82rem;
}

.chat-author.author-red {
  color: #f87171 !important;
  text-shadow: 0 0 6px rgba(248, 113, 113, 0.3);
}

.chat-author.author-black {
  color: #38bdf8 !important;
  text-shadow: 0 0 6px rgba(56, 189, 248, 0.3);
}

.chat-author.author-spectator {
  color: #fbbf24 !important;
  text-shadow: 0 0 6px rgba(251, 191, 36, 0.3);
}

.chat-time {
  font-size: 0.7rem;
  color: var(--text-muted);
  font-family: monospace;
}

.chat-text {
  color: var(--text-primary);
}

.chat-input-form {
  display: flex;
  gap: 8px;
}

.chat-input-form .form-input {
  padding: 8px 12px;
  font-size: 0.85rem;
}

.chat-input-form button {
  padding: 8px 16px;
}

/* Standard Buttons & Input Utilities */
.form-input {
  flex: 1;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  padding: 8px 12px;
  border-radius: var(--radius-md);
  font-family: inherit;
  font-size: 0.9rem;
  outline: none;
  transition: border-color 0.2s;
}

.form-input:focus {
  border-color: var(--color-blue);
}

button {
  font-family: inherit;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  border-radius: var(--radius-md);
  padding: 9px 16px;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.btn-primary {
  background: linear-gradient(135deg, var(--color-red), #c1121f);
  color: #fff;
  box-shadow: 0 2px 8px rgba(230, 57, 70, 0.3);
}

.btn-primary:hover {
  background: linear-gradient(135deg, #ff4d4f, var(--color-red));
  box-shadow: var(--shadow-glow-red);
  transform: translateY(-1px);
}

.btn-secondary {
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
}

.btn-secondary:hover {
  background: var(--border-color);
  border-color: var(--border-highlight);
}

.btn-block {
  width: 100%;
}

.btn-sound-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.82rem;
  font-weight: 600;
  padding: 6px 14px;
  border-radius: var(--radius-full);
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  transition: all 0.2s ease;
}

.btn-sound-toggle.muted {
  opacity: 0.7;
  color: var(--text-muted);
}

.btn-sound-toggle:hover {
  border-color: var(--color-gold);
}

/* Status Box */
.turn-indicator {
  font-size: 0.82rem;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: var(--radius-full);
  background: rgba(230, 57, 70, 0.15);
  color: var(--color-red-light);
  border: 1px solid rgba(230, 57, 70, 0.3);
  white-space: nowrap;
}

.turn-indicator.turn-black {
  background: rgba(139, 148, 158, 0.15);
  color: var(--text-primary);
  border-color: var(--border-color);
}

.alert-box {
  padding: 6px 12px;
  border-radius: var(--radius-md);
  font-size: 0.88rem;
  line-height: 1.4;
}

.alert-box.info {
  color: #93c5fd;
}

.alert-box.warning {
  color: var(--color-gold-light);
}

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

/* Toast Container */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 9999;
}

.toast {
  background: var(--bg-secondary);
  border: 1px solid var(--border-highlight);
  color: var(--text-primary);
  padding: 10px 16px;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  font-size: 0.88rem;
  animation: slideUp 0.3s ease-out;
}

@keyframes slideUp {
  from { transform: translateY(20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

/* Xiangqiboard Custom Modifications */
.board-b72b1 {
  border: none !important;
}

.highlight-square {
  box-shadow: inset 0 0 0 3px var(--color-gold) !important;
  border-radius: 50%;
}

.valid-move-dest {
  position: relative;
}

.valid-move-dest::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 14px;
  height: 14px;
  background: rgba(16, 185, 129, 0.7);
  border-radius: 50%;
  pointer-events: none;
  box-shadow: 0 0 6px rgba(16, 185, 129, 0.9);
}

/* Nổi bật nước đi vừa đi (Last Move Highlights) */
.last-move-from {
  background-color: rgba(245, 158, 11, 0.45) !important;
  box-shadow: inset 0 0 10px rgba(245, 158, 11, 0.8) !important;
  border-radius: 6px;
}

.last-move-to {
  background-color: rgba(16, 185, 129, 0.5) !important;
  box-shadow: inset 0 0 12px rgba(16, 185, 129, 0.9) !important;
  border-radius: 6px;
}

/* King in check - red pulse highlight & RED KING PIECE font glow */
.in-check-king {
  background-color: rgba(230, 57, 70, 0.65) !important;
  box-shadow: inset 0 0 16px rgba(230, 57, 70, 0.9), 0 0 24px rgba(230, 57, 70, 0.8) !important;
  border-radius: 6px;
  animation: checkPulse 0.8s ease-in-out infinite alternate;
}

/* Make the King piece text and graphic glow in vibrant fiery RED when in check */
.in-check-king img {
  filter: drop-shadow(0 0 8px #ff0000) drop-shadow(0 0 16px #ff0000) sepia(1) hue-rotate(-50deg) saturate(12) brightness(1.2) !important;
  transform: scale(1.1);
  animation: kingRedFontGlow 0.6s ease-in-out infinite alternate !important;
  transition: all 0.2s ease;
}

@keyframes checkPulse {
  from {
    box-shadow: inset 0 0 12px rgba(230, 57, 70, 0.7), 0 0 16px rgba(230, 57, 70, 0.4) !important;
  }
  to {
    box-shadow: inset 0 0 20px rgba(230, 57, 70, 1), 0 0 28px rgba(230, 57, 70, 0.7) !important;
  }
}

@keyframes kingRedFontGlow {
  from {
    filter: drop-shadow(0 0 6px #ff0000) drop-shadow(0 0 12px #ff2222) sepia(1) hue-rotate(-50deg) saturate(10) brightness(1.1) !important;
    transform: scale(1.08);
  }
  to {
    filter: drop-shadow(0 0 14px #ff0000) drop-shadow(0 0 24px #ff0000) drop-shadow(0 0 32px #ff0000) sepia(1) hue-rotate(-50deg) saturate(16) brightness(1.4) !important;
    transform: scale(1.15);
  }
}

/* Selected square for click-to-move */
.selected-square {
  box-shadow: inset 0 0 0 3px var(--color-gold), 0 0 12px rgba(245, 158, 11, 0.4) !important;
  border-radius: 6px;
}

/* Success alert box (for "ready to start" messages) */
.alert-box.success {
  color: #6ee7b7;
}

@media (max-width: 600px) {
  .sound-text-label {
    display: none;
  }
  .compact-action-toolbar {
    grid-template-columns: 1fr 1fr;
  }
  .hero-title {
    font-size: 1.8rem;
  }
}

/* ----------------------------------------------------
   3. Mobile Touch & Responsive Optimizations
   ---------------------------------------------------- */

/* Prevent page scrolling or zooming while dragging chess pieces on mobile touchscreens */
#board, #board .square-2b8ce, #board img {
  touch-action: none !important;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

.mobile-tabs-bar {
  display: none;
  gap: 8px;
  width: 100%;
  margin-bottom: 8px;
}

.mobile-tab-btn {
  flex: 1;
  padding: 10px;
  font-size: 0.9rem;
  font-weight: 700;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  background: var(--bg-secondary);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s ease;
}

.mobile-tab-btn.active {
  background: var(--color-gold);
  color: #000000;
  border-color: var(--color-gold);
  box-shadow: 0 0 12px rgba(245, 158, 11, 0.3);
}

@media (max-width: 768px) {
  body {
    overflow-y: auto;
    height: auto;
  }

  .app-container {
    height: auto;
    max-height: none;
    padding: 8px;
    gap: 8px;
  }

  .app-header {
    padding: 8px 12px;
    gap: 8px;
  }

  .brand-text h1 {
    font-size: 1rem;
  }

  .badge-sub {
    display: none;
  }

  .mobile-tabs-bar {
    display: flex;
  }

  .game-view {
    display: flex;
    flex-direction: column;
    overflow: visible;
  }

  .game-right-section {
    display: flex;
    flex-direction: column;
    overflow: visible;
    gap: 12px;
  }

  /* Default mobile view: show board tab first */
  .game-view.show-chat-tab .large-board-wrapper {
    display: none !important;
  }

  .game-view.show-chat-tab .game-left-panel,
  .game-view.show-chat-tab .large-chat-wrapper {
    display: flex !important;
  }

  .game-view.show-board-tab .large-chat-wrapper,
  .game-view.show-board-tab .game-left-panel {
    display: none !important;
  }

  .large-board-wrapper {
    padding: 4px;
    height: auto;
  }

  .board-frame {
    height: auto !important;
    max-height: none !important;
    width: 100% !important;
    padding: 4px;
    border-width: 2px;
  }
}

