:root {
  --bg-page: var(--bg-primary);
  --bg-panel: var(--bg-glass, var(--bg-secondary));
  --bg-hover: var(--bg-tertiary);
  --border-color: var(--border-secondary);
  --text-primary: var(--text-primary, #e8eaed);
  --text-secondary: var(--text-secondary, #8a9ba8);
  --accent: var(--accent-primary, #f59e0b);
  --accent-hover: var(--accent-hover, #d97706);
  --danger: var(--error, #ef4444);
  --board-shadow: var(--shadow-xl);
}

/* play.html overrides: body should NOT be flex-centered or overflow:hidden by default */
body {
  margin: 0;
  padding: 0;
  background-color: var(--bg-page);
  color: var(--text-primary);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  /* No height, no overflow, no flex here — let play.html control this */
}

/* Scrollbar */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #4d4d4d; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #666666; }

/* Base Layout */
.cl-layout {
  display: flex;
  width: 100%;
  max-width: 1400px;
  height: 100%;
  padding: 16px 16px 16px 0;
  gap: 16px;
  box-sizing: border-box;
}

@media (max-width: 992px) {
  .cl-layout {
    flex-direction: column;
    padding: 12px;
    gap: 12px;
    height: auto;
  }
}

/* Left Column: Board Area */
.cl-board-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-width: 0;
}

.cl-board-wrapper {
  width: 100%;
  max-width: 640px; /* default cap — resize JS overrides this to grow the board */
  display: flex;
  flex-direction: column;
}

.board-row-container {
  width: 100%;
  /* Removed max-width constraint to let the board stretch to cl-board-wrapper size */
  margin: 0 auto;
}

/* Player Banners */
.cl-player-banner {
  display: flex;
  align-items: center;
  padding: 12px 0;
  gap: 16px;
  width: 100%;
}

.cl-avatar {
  width: 44px;
  height: 44px;
  border-radius: 4px;
  background-color: var(--bg-hover);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  color: var(--text-secondary);
  box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.cl-player-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 2px;
}

.cl-player-name {
  font-weight: 700;
  font-size: 16px;
  color: var(--text-primary);
}

.cl-player-status {
  font-size: 13px;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 6px;
}

.live-dot { color: var(--danger); font-size: 10px; }

.cl-timer {
  background-color: var(--bg-panel);
  padding: 8px 16px;
  border-radius: 4px;
  font-family: 'Roboto Mono', monospace;
  font-weight: 700;
  font-size: 24px;
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  box-shadow: inset 0 2px 4px rgba(0,0,0,0.2);
}

/* Board Container */
.cl-board-container {
  width: 100%;
  aspect-ratio: 1/1;
  box-shadow: var(--board-shadow);
  border-radius: 4px;
  position: relative;
  background: var(--bg-panel);
}

#board { width: 100%; height: 100%; }

.cl-streak-badge {
  position: absolute;
  top: -12px;
  right: -12px;
  background: var(--danger);
  color: white;
  padding: 4px 12px;
  border-radius: 12px;
  font-weight: 700;
  font-size: 14px;
  box-shadow: 0 4px 12px rgba(226, 59, 59, 0.4);
  z-index: 10;
}

/* Tools & Reactions */
.cl-board-tools {
  display: flex;
  gap: 8px;
}

.cl-icon-btn {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-size: 20px;
  cursor: pointer;
  padding: 8px;
  border-radius: 4px;
  transition: all 0.1s;
  display: flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}

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

/* Dropdown Reactions Menu */
.cl-dropdown {
  position: relative;
  display: inline-block;
}

.cl-dropdown-menu {
  display: none;
  position: absolute;
  bottom: 100%; /* Drop UP */
  right: 0;
  margin-bottom: 8px;
  background-color: var(--bg-panel);
  min-width: 160px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.6);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  z-index: 100;
  overflow: hidden;
}

.cl-dropdown:hover .cl-dropdown-menu {
  display: flex;
  flex-direction: column;
}

.cl-dropdown-item {
  background: transparent;
  color: var(--text-primary);
  padding: 10px 16px;
  border: none;
  text-align: left;
  cursor: pointer;
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  transition: background 0.2s;
}

.cl-dropdown-item i {
  color: var(--text-secondary);
  width: 16px;
  text-align: center;
}

.cl-dropdown-item:hover {
  background-color: var(--bg-hover);
}

.cl-dropdown-item:hover i {
  color: var(--accent);
}

/* Right Column: Interaction */
.cl-side-col {
  width: 400px;
  display: flex;
  flex-direction: column;
  background-color: var(--bg-panel);
  border-radius: 8px;
  overflow: hidden;
  box-shadow: var(--board-shadow);
  border: 1px solid var(--border-color);
}

@media (max-width: 992px) {
  .cl-side-col { width: 100%; flex: 1; }
}

/* Video Area */
.cl-video-module {
  background-color: #000;
  position: relative;
  min-height: 240px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-bottom: 1px solid var(--border-color);
}

.cl-video-grid {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.cl-video-grid video { width: 100%; height: 100%; object-fit: cover; }

.cl-video-actions {
  position: absolute;
  bottom: 12px;
  left: 0;
  right: 0;
  display: flex;
  justify-content: center;
  gap: 12px;
  z-index: 10;
}

.cl-vid-btn {
  background: rgba(33, 32, 29, 0.8);
  border: 1px solid rgba(255,255,255,0.1);
  color: white;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  cursor: pointer;
  transition: background 0.2s;
}
.cl-vid-btn:hover { background: rgba(33, 32, 29, 1); }

/* Tabs */
.cl-tabs-module {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 300px;
}

.cl-tabs-header {
  display: flex;
  background-color: var(--bg-panel);
  border-bottom: 1px solid var(--border-color);
}

.cl-tab {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text-secondary);
  padding: 16px 0;
  font-size: 14px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  cursor: pointer;
  position: relative;
  transition: color 0.2s;
}

.cl-tab:hover { color: var(--text-primary); }
.cl-tab.active { color: var(--text-primary); }
.cl-tab.active::after {
  content: ''; position: absolute; bottom: -1px; left: 0; right: 0; height: 3px; background-color: var(--accent);
}

.cl-tab-body {
  flex: 1;
  overflow-y: auto;
  display: none; 
  flex-direction: column;
  background: var(--bg-page);
}
.cl-tab-body.active { display: flex; }

/* Move List */
.cl-moves-scroll {
  display: grid;
  grid-template-columns: 48px 1fr 1fr;
  font-weight: 600;
  font-size: 15px;
}

.cl-moves-scroll > div { padding: 6px 16px; display: flex; align-items: center; }

.move-num {
  background: var(--bg-panel);
  color: var(--text-secondary);
  justify-content: center;
  border-right: 1px solid var(--border-color);
  border-bottom: 1px solid var(--border-color);
}

.move-san {
  color: var(--text-primary);
  cursor: pointer;
  border-bottom: 1px solid var(--border-color);
}
.move-san:hover { background: var(--bg-hover); }
.move-san.active { background: var(--bg-hover); border-bottom: 3px solid var(--accent); }

/* Chat */
#chatMessages {
  flex: 1;
  padding: 16px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

#chatMessages div {
  font-size: 14px;
  line-height: 1.5;
  word-wrap: break-word;
}
#chatMessages b { color: var(--accent); margin-right: 4px; }

.cl-chat-input-area {
  padding: 16px;
  border-top: 1px solid var(--border-color);
  background: var(--bg-panel);
  display: flex;
  gap: 12px;
}

.cl-chat-input {
  flex: 1;
  background: var(--bg-page);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  padding: 10px 16px;
  color: var(--text-primary);
  font-size: 14px;
  outline: none;
}
.cl-chat-input:focus { border-color: var(--text-secondary); }

.cl-chat-send {
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 4px;
  padding: 0 20px;
  font-weight: bold;
  cursor: pointer;
  font-size: 16px;
}
.cl-chat-send:hover { background: var(--accent-hover); }

/* Status Bar */
.cl-status-bar {
  display: flex; justify-content: space-between; padding: 12px 16px; font-size: 12px;
  color: var(--text-secondary); background: var(--bg-panel); border-top: 1px solid var(--border-color);
}
.cl-status-item { display: flex; align-items: center; gap: 6px; }

/* Overlays / Modals */
.cl-join-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.85);
  z-index: 1000; display: flex; align-items: center; justify-content: center;
}
.cl-join-card {
  background: var(--bg-panel); padding: 40px; border-radius: 8px;
  text-align: center; width: 100%; max-width: 400px;
  box-shadow: 0 16px 32px rgba(0,0,0,0.5); border: 1px solid var(--border-color);
}
.cl-join-icon { font-size: 48px; margin-bottom: 16px; color: var(--accent); }
.cl-join-title { font-size: 24px; font-weight: 700; margin-bottom: 8px; }
.cl-join-sub { color: var(--text-secondary); margin-bottom: 24px; font-size: 14px; }
.cl-join-row { display: flex; gap: 8px; }
.cl-join-input {
  flex: 1; background: var(--bg-page); border: 1px solid var(--border-color);
  color: white; padding: 12px; border-radius: 4px; font-size: 18px;
  text-align: center; font-family: 'Roboto Mono', monospace; outline: none;
}
.cl-join-input:focus { border-color: var(--accent); }
.cl-btn-primary {
  background: var(--gradient-accent, var(--accent)); 
  color: var(--bg-primary, #ffffff); 
  border: none;
  padding: 0 24px; border-radius: 6px; font-weight: 700; cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}
.cl-btn-primary:hover { 
  transform: translateY(-2px);
  filter: brightness(1.1);
}
.cl-btn-primary:active {
  transform: scale(0.96);
}

/* Puzzle Banner */
#puzzleBanner {
  background: var(--bg-hover); border-left: 4px solid var(--accent);
  padding: 12px; margin: 16px; border-radius: 4px;
}
#puzzleModeLabel { font-weight: bold; color: var(--accent); font-size: 14px; }
#puzzleTitleDisplay { font-size: 13px; color: var(--text-primary); margin-top: 4px; }

/* Toast */
.cl-toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(100px);
  background: var(--accent); padding: 12px 24px; border-radius: 30px;
  font-size: 14px; font-weight: 600; color: white; box-shadow: 0 4px 12px rgba(0,0,0,0.3);
  transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275); z-index: 3000; opacity: 0;
}
.cl-toast.show { transform: translateX(-50%) translateY(0); opacity: 1; }
