:root {
  /* Colors */
  --bg-dark: #0a0a0c;
  --bg-card: rgba(25, 25, 30, 0.7);
  --bg-overlay: rgba(0, 0, 0, 0.6);
  
  --accent: #ca8a04;        /* Gold/Chess theme */
  --accent-glow: rgba(202, 138, 4, 0.3);
  --accent-light: #facc15;
  
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-dim: #64748b;
  
  --border: rgba(255, 255, 255, 0.08);
  --border-focus: rgba(202, 138, 4, 0.5);
  
  --success: #10b981;
  --danger: #ef4444;
  --info: #38bdf8;
  
  /* Shared values */
  --shadow-sm: 0 4px 6px -1px rgb(0 0 0 / 0.1);
  --shadow-md: 0 10px 15px -3px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 20px 25px -5px rgb(0 0 0 / 0.1);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 20px;
  --blur: 16px;
  
  /* Layout */
  --header-height: 80px;
}

/* Reset & Base */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  scrollbar-gutter: stable;
}

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background-color: var(--bg-dark);
  color: var(--text-main);
  line-height: 1.5;
  min-height: 100vh;
  overflow-x: hidden;
  background-image: 
    radial-gradient(circle at 10% 20%, rgba(202, 138, 4, 0.05) 0%, transparent 40%),
    radial-gradient(circle at 90% 80%, rgba(202, 138, 4, 0.05) 0%, transparent 40%);
  background-attachment: fixed;
}

h1, h2, h3, h4 {
  font-family: 'Outfit', sans-serif;
  font-weight: 700;
  letter-spacing: -0.02em;
}

a {
  color: inherit;
  text-decoration: none;
  transition: all 0.2s ease;
}

button {
  cursor: pointer;
  font-family: inherit;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Layout */
.app-container {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

main {
  flex: 1;
  padding: 2rem 1rem;
  max-width: 1280px;
  width: 100%;
  margin: 0 auto;
}

/* Header */
.main-header {
  height: var(--header-height);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(var(--blur));
  background: rgba(10, 10, 12, 0.8);
  position: sticky;
  top: 0;
  z-index: 50;
}

.header-content {
  max-width: 1280px;
  height: 100%;
  margin: 0 auto;
  padding: 0 1.5rem;
  display: flex;
  align-items: center;
  gap: 1.5rem;
}

.logo {
  font-size: 1.75rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.logo .premium {
  background: linear-gradient(135deg, var(--accent-light), var(--accent));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

/* Hamburger */
.hamburger-btn {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border);
  width: 44px;
  height: 44px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
}

.hamburger-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: var(--text-dim);
}

.hamburger-icon {
  width: 24px;
  height: 18px;
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.hamburger-icon span {
  display: block;
  width: 100%;
  height: 2px;
  background: var(--text-main);
  border-radius: 2px;
  transition: all 0.3s ease;
}

.hamburger-btn[aria-expanded="true"] .hamburger-icon span:nth-child(1) {
  transform: translateY(8px) rotate(45deg);
}

.hamburger-btn[aria-expanded="true"] .hamburger-icon span:nth-child(2) {
  opacity: 0;
}

.hamburger-btn[aria-expanded="true"] .hamburger-icon span:nth-child(3) {
  transform: translateY(-8px) rotate(-45deg);
}

/* Side Menu */
.side-menu {
  position: fixed;
  top: 0;
  left: -320px;
  width: 300px;
  height: 100%;
  background: #0f0f12;
  border-right: 1px solid var(--border);
  z-index: 100;
  padding: 2rem;
  transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 20px 0 50px rgba(0, 0, 0, 0.5);
}

.side-menu.active {
  transform: translateX(320px);
}

.menu-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2.5rem;
}

.close-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 2rem;
  line-height: 1;
}

.close-btn:hover {
  color: var(--text-main);
}

.menu-links {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.menu-links li a {
  display: block;
  padding: 1rem;
  border-radius: var(--radius-md);
  font-weight: 500;
  font-family: 'Outfit', sans-serif;
  font-size: 1.1rem;
}

.menu-links li a:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--accent);
  padding-left: 1.5rem;
}

.menu-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg-overlay);
  backdrop-filter: blur(4px);
  z-index: 90;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.menu-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

/* Screens */
.screen {
  display: none;
  animation: fadeIn 0.5s ease-out;
}

.screen.active {
  display: block;
}

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

/* Welcome Screen */
#welcome-screen {
  max-width: 520px;
  margin: 2rem auto;
}

.card {
  background: var(--bg-card);
  backdrop-filter: blur(var(--blur));
  border: 1px solid var(--border);
  padding: 2.5rem;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
}

.screen-title {
  font-size: 2rem;
  margin-bottom: 2rem;
  text-align: center;
}

/* Buttons */
.btn-primary {
  background: linear-gradient(135deg, var(--accent), #854d0e);
  color: #fff;
  border: none;
  padding: 0.75rem 1.5rem;
  border-radius: var(--radius-md);
  font-weight: 600;
  box-shadow: 0 4px 15px var(--accent-glow);
}

.btn-primary:hover {
  filter: brightness(1.1);
  transform: translateY(-2px);
  box-shadow: 0 8px 25px var(--accent-glow);
}

.btn-large {
  width: 100%;
  padding: 1.25rem;
  font-size: 1.1rem;
  letter-spacing: 0.1em;
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-main);
  border: 1px solid var(--border);
  padding: 0.75rem 1.5rem;
  border-radius: var(--radius-md);
  font-weight: 500;
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: var(--text-muted);
}

.btn-danger {
  background: rgba(239, 68, 68, 0.1);
  color: #ef4444;
  border: 1px solid rgba(239, 68, 68, 0.2);
  padding: 0.75rem;
  border-radius: var(--radius-md);
}

.btn-danger:hover {
  background: var(--danger);
  color: #fff;
}

.mode-buttons {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.mode-buttons.secondary {
  display: grid;
  grid-template-columns: 1fr 1fr;
}

/* Inputs & Forms */
.join-section {
  margin: 2rem 0;
}

.join-section label {
  display: block;
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.input-group {
  display: flex;
  gap: 0.5rem;
}

input[type="text"] {
  flex: 1;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0.75rem 1rem;
  color: #fff;
  font-size: 1rem;
  transition: all 0.2s;
}

input[type="text"]:focus {
  border-color: var(--accent);
  outline: none;
  background: rgba(0, 0, 0, 0.5);
  box-shadow: 0 0 0 4px var(--accent-glow);
}

.divider {
  display: flex;
  align-items: center;
  gap: 1rem;
  color: var(--text-dim);
  font-size: 0.75rem;
  text-transform: uppercase;
  margin: 1.5rem 0;
}

.divider::before, .divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* Code Display */
.code-display {
  background: rgba(0, 0, 0, 0.3);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  border: 1px dashed var(--border-focus);
  margin-top: 1rem;
}

.code-display label {
  display: block;
  font-size: 0.75rem;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-bottom: 0.5rem;
}

.code-wrapper {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.room-code {
  font-family: 'JetBrains Mono', monospace;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--accent-light);
  letter-spacing: 0.2em;
}

.copy-btn {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.5rem;
  font-size: 1rem;
}

.copy-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: var(--accent);
}

/* Game Layout */
.game-layout {
  display: grid;
  grid-template-columns: 1fr 380px;
  gap: 2.5rem;
  align-items: start;
}

@media (max-width: 1024px) {
  .game-layout {
    grid-template-columns: 1fr;
  }
}

.board-container {
  padding: 1rem;
  background: #1e1e24;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  border: 4px solid #2d2d3a;
}

/* Game Info Column */
.game-info {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

/* Timers */
.timers {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.timer {
  background: var(--bg-card);
  padding: 1rem;
  border-radius: var(--radius-md);
  border-left: 4px solid #334155;
  text-align: center;
  font-family: 'JetBrains Mono', monospace;
  font-size: 2rem;
  font-weight: 700;
  transition: all 0.3s;
}

.timer.player {
  border-left-color: var(--accent);
}

.timer.opponent {
  border-left-color: var(--text-dim);
}

.timer.active {
  background: rgba(202, 138, 4, 0.1);
  border-left-color: var(--accent-light);
  box-shadow: 0 0 20px var(--accent-glow);
  transform: scale(1.02);
}

/* Captured Pieces */
.captured-pieces {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  background: var(--bg-card);
  padding: 1rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
}

.captured-pieces h4 {
  font-size: 0.7rem;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-bottom: 0.5rem;
}

.captured-container {
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
  min-height: 24px;
}

.captured-piece {
  width: 24px;
  height: 24px;
  object-fit: contain;
  opacity: 0.8;
}

/* History */
.move-history {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  height: 280px;
  display: flex;
  flex-direction: column;
}

.pgn-container {
  flex: 1;
  overflow-y: auto;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.85rem;
  color: var(--text-muted);
  line-height: 1.6;
}

.pgn-container::-webkit-scrollbar {
  width: 6px;
}
.pgn-container::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 4px;
}

/* Status Panel */
.game-status {
  background: rgba(56, 189, 248, 0.05);
  border: 1px solid rgba(56, 189, 248, 0.2);
  padding: 1rem;
  border-radius: var(--radius-md);
  color: var(--info);
  text-align: center;
  font-weight: 600;
  letter-spacing: 0.02em;
}

/* Control Buttons */
.game-mgmt-controls {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.75rem;
}

.btn-control {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 0.6rem;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

.btn-control:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: var(--text-dim);
  color: var(--text-main);
}

.btn-control.paused {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent-light);
}

/* Room Code In-Game */
.room-code-box {
  background: rgba(202, 138, 4, 0.05);
  border: 1px dashed var(--accent);
  padding: 1rem;
  border-radius: var(--radius-md);
  text-align: center;
}

.room-label {
  font-size: 0.75rem;
  color: var(--accent);
  text-transform: uppercase;
  margin-bottom: 0.5rem;
}

/* Footer */
footer {
  text-align: center;
  padding: 3rem 1.5rem;
  color: var(--text-dim);
  font-size: 0.85rem;
  border-top: 1px solid var(--border);
}

footer a {
  color: var(--text-muted);
}

footer a:hover {
  color: var(--accent);
}

/* Chessboard.js overrides */
.board-b72b1 {
  border-radius: 4px;
  overflow: hidden;
  border: none !important;
}

.white-1e1d7 {
  background-color: #ebecd0 !important;
  color: #779556 !important;
}

.black-3c85d {
  background-color: #779556 !important;
  color: #ebecd0 !important;
}

.highlight-last-move {
  box-shadow: inset 0 0 3px 3px rgba(255, 255, 0, 0.7);
}

.hint-dot {
  position: relative;
}

.hint-dot::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 30%;
  height: 30%;
  background: rgba(0, 0, 0, 0.15);
  border-radius: 50%;
  pointer-events: none;
}

/* Mobile Adjustments */
@media (max-width: 600px) {
  .app-container {
    padding: 0;
  }
  
  .main-header {
    padding: 0;
  }
  
  .card {
    padding: 1.5rem;
  }
  
  .mode-buttons.secondary {
    grid-template-columns: 1fr;
  }
  
  .timers {
    grid-template-columns: 1fr 1fr;
  }
  
  .timer {
    font-size: 1.5rem;
  }
}
/* Public Rooms List */
.public-rooms-card {
  margin-top: 1.5rem;
  background: rgba(0, 0, 0, 0.2);
  border-radius: var(--radius-md);
  padding: 1.5rem;
  border: 1px solid var(--border);
  animation: slideDown 0.4s ease-out;
}

@keyframes slideDown {
  from { opacity: 0; transform: translateY(-10px); }
  to { opacity: 1; transform: translateY(0); }
}

.section-subtitle {
  font-size: 0.9rem;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 1rem;
  letter-spacing: 0.05em;
}

.rooms-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  max-height: 240px;
  overflow-y: auto;
  padding-right: 0.5rem;
  margin-bottom: 1rem;
}

.room-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--bg-card);
  padding: 1rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  transition: all 0.2s;
}

.room-item:hover {
  border-color: var(--accent);
  background: rgba(202, 138, 4, 0.05);
  transform: translateX(4px);
}

.room-info {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.room-code-tag {
  font-family: 'JetBrains Mono', monospace;
  font-weight: 700;
  color: var(--text-main);
}

.room-meta {
  font-size: 0.75rem;
  color: var(--text-dim);
}

.btn-join-room {
  background: var(--accent);
  color: #fff;
  border: none;
  padding: 0.5rem 1rem;
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  font-weight: 600;
}

.btn-join-room:hover {
  background: var(--accent-light);
  transform: scale(1.05);
}

.empty-msg {
  text-align: center;
  color: var(--text-dim);
  font-size: 0.9rem;
  padding: 2rem 0;
}

.btn-text {
  background: none;
  border: none;
  color: var(--accent);
  font-size: 0.85rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0 auto;
}

.btn-text:hover {
  color: var(--accent-light);
  text-decoration: underline;
}

.btn-control.active-public {
  background: var(--success);
  color: #fff;
  border-color: #34d399;
  box-shadow: 0 0 10px rgba(16, 185, 129, 0.3);
}
