* { margin: 0; padding: 0; box-sizing: border-box; }
:root { --wood-light: #DEB887; --wood-medium: #D2691E; --wood-dark: #8B4513; --wood-border: #5D3A1A; --cream: #FFF8DC; }
body { font-family: Georgia, serif; background: linear-gradient(135deg, #2c1810 0%, #4a2c17 100%); min-height: 100vh; color: var(--cream); }
.container { max-width: 100%; margin: 0; padding: 10px 20px; }
header { display: flex; justify-content: space-between; align-items: center; padding: 5px 10px; background: linear-gradient(180deg, rgba(139,69,19,0.8) 0%, rgba(93,58,26,0.9) 100%); border-radius: 8px; margin-bottom: 10px; border: 1px solid var(--wood-border); position: sticky; top: 0; z-index: 100; }
h1 { font-size: 1.2rem; color: var(--wood-light); text-shadow: 2px 2px 4px rgba(0,0,0,0.5); }
nav a { color: var(--cream); text-decoration: none; margin-left: 10px; padding: 4px 8px; border-radius: 5px; transition: background 0.3s; }
nav a:hover { background: rgba(222,184,135,0.2); }
.auth-section, .dashboard-section, .game-section, .admin-section, .invite-section { background: rgba(139,69,19,0.6); padding: 20px; border-radius: 8px; border: 1px solid var(--wood-border); margin-bottom: 15px; }
.hidden { display: none !important; }
input, select, textarea { width: 100%; padding: 12px; margin: 10px 0; border: 2px solid var(--wood-border); border-radius: 5px; background: var(--cream); color: #2F2F2F; font-family: inherit; }
button { padding: 12px 24px; background: linear-gradient(180deg, var(--wood-light) 0%, var(--wood-medium) 100%); border: 2px solid var(--wood-border); border-radius: 5px; color: #2F2F2F; font-weight: bold; cursor: pointer; transition: transform 0.2s, box-shadow 0.2s; }
button:hover { transform: translateY(-2px); box-shadow: 0 4px 8px rgba(0,0,0,0.3); }
button.secondary { background: linear-gradient(180deg, #888 0%, #666 100%); color: white; }
button.danger { background: linear-gradient(180deg, #c44 0%, #922 100%); color: white; }
.admin-badge { background: #2196F3; color: white; padding: 2px 6px; border-radius: 4px; font-size: 0.85em; margin-right: 4px; }
.active-badge { background: #4CAF50; color: white; padding: 2px 6px; border-radius: 4px; font-size: 0.85em; margin-right: 4px; }
.disabled-badge { background: #f44336; color: white; padding: 2px 6px; border-radius: 4px; font-size: 0.85em; margin-right: 4px; }
.chess-container { display: flex; gap: 20px; flex-wrap: nowrap; justify-content: flex-start; align-items: flex-start; }
.board-wrapper { position: relative; display: flex; justify-content: center; flex-shrink: 0; }
.board-container { position: relative; display: grid; grid-template-columns: 20px 1fr 20px; grid-template-rows: 20px 1fr 20px; }
.board-container .coord-top { grid-column: 2; grid-row: 1; display: flex; justify-content: space-around; align-items: center; font-size: 0.75rem; color: var(--wood-light); padding-bottom: 2px; }
.board-container .coord-bottom { grid-column: 2; grid-row: 3; display: flex; justify-content: space-around; align-items: center; font-size: 0.75rem; color: var(--wood-light); padding-top: 2px; }
.board-container .coord-left { grid-column: 1; grid-row: 2; display: flex; flex-direction: column; justify-content: space-around; align-items: center; font-size: 0.75rem; color: var(--wood-light); padding-right: 2px; }
.board-container .coord-right { grid-column: 3; grid-row: 2; display: flex; flex-direction: column; justify-content: space-around; align-items: center; font-size: 0.75rem; color: var(--wood-light); padding-left: 2px; }
.coord-label { text-align: center; line-height: 1; }
#chessboard { grid-column: 2; grid-row: 2; display: grid; grid-template-columns: repeat(8, 1fr); grid-template-rows: repeat(8, 1fr); width: 84vmin; height: 84vmin; border: 4px solid var(--wood-dark); border-radius: 4px; box-shadow: 0 10px 30px rgba(0,0,0,0.5); box-sizing: border-box; }
.square { aspect-ratio: 1; display: flex; align-items: center; justify-content: center; cursor: pointer; position: relative; }
.square.light { background: linear-gradient(135deg, var(--cream) 0%, #f5e6c8 100%); }
.square.dark { background: linear-gradient(135deg, var(--wood-medium) 0%, var(--wood-dark) 100%); }
.square.selected { box-shadow: inset 0 0 0 4px #ffd700; }
.square.valid-move::after { content: ''; position: absolute; width: 30%; height: 30%; background: rgba(0,128,0,0.5); border-radius: 50%; }
.square.valid-capture { box-shadow: inset 0 0 0 4px rgba(255,0,0,0.5); }
.piece { width: 100%; height: 100%; user-select: none; display: flex; align-items: center; justify-content: center; }
.piece svg { width: 85%; height: 85%; }
.piece.white svg { }
.piece.black svg { }
.promotion-piece { cursor: pointer; padding: 8px 12px; border-radius: 5px; transition: background 0.2s; display: inline-flex; align-items: center; justify-content: center; }
.promotion-piece svg { width: 50px; height: 50px; }
.promotion-piece.white { }
.promotion-piece.black { }

.mobile-back { display: none; }
/* Mobile responsive styles */
@media (max-width: 768px) {
  .container { padding: 10px; }
  .mobile-back { display: block; text-align: center; margin-bottom: 10px; }
  .mobile-back a { color: var(--wood-light); text-decoration: none; font-size: 0.9rem; }
  header { display: none; }
  h1 { font-size: 1.5rem; }
  nav { display: flex; flex-wrap: wrap; justify-content: center; gap: 5px; }
  nav a { margin-left: 0; margin: 5px; padding: 6px 12px; font-size: 0.9rem; }
  .auth-section, .dashboard-section, .game-section, .admin-section, .invite-section { padding: 15px; margin-bottom: 15px; }
  .chess-container { flex-direction: column; align-items: center; gap: 15px; }
  .board-wrapper { width: 100%; display: flex; justify-content: center; min-width: auto; flex: none; }
  #chessboard { width: 90vmin; height: 90vmin; max-width: calc(100vw - 20px); max-height: calc(100vw - 20px); }
  .board-container .coord-top, .board-container .coord-bottom { flex-wrap: wrap; }
  .board-container .coord-label { font-size: 0.65rem; }
  .piece svg { width: 80%; height: 80%; }
  .game-info { min-width: auto; width: 100%; padding: 15px; }
  .move-history { max-height: 150px; }
  .controls { flex-direction: row; }
  .board-container .coord-top, .board-container .coord-bottom, .board-container .coord-left, .board-container .coord-right {
    font-size: 0.65rem;
  }
  .promotion-options { padding: 15px; gap: 10px; }
  .promotion-piece svg { width: 40px; height: 40px; }
  input, select, textarea { padding: 10px; }
  button { padding: 10px 16px; }
  .game-item { flex-direction: column; align-items: flex-start; gap: 8px; }
  table { font-size: 0.85rem; }
  th, td { padding: 8px; }
}

@media (max-width: 480px) {
  header { display: none; }
  h1 { font-size: 1.2rem; }
  nav a { padding: 5px 10px; font-size: 0.8rem; }
  .auth-section, .dashboard-section, .game-section, .admin-section, .invite-section { padding: 10px; }
  .controls button { padding: 8px 6px; font-size: 0.8rem; }
}
.game-info { flex: 1; min-width: 300px; max-width: 600px; background: rgba(0,0,0,0.3); padding: 15px; border-radius: 8px; border: 1px solid var(--wood-border); }
.move-history { max-height: 250px; overflow-y: auto; margin: 15px 0; padding: 8px; background: rgba(255,248,220,0.1); border-radius: 5px; }
.move-history table { width: 100%; border-collapse: collapse; }
.move-history tr { line-height: 1.6; }
.move-history td { padding: 2px 6px; display: table-cell !important; white-space: nowrap; }
.move-history td.move-number { width: 30px; color: var(--wood-light); font-weight: bold; font-size: 0.85rem; text-align: left; }
.move-history td.move-item { width: auto; cursor: pointer; border-radius: 4px; text-align: center; }
.move-history td.move-item:hover { background: rgba(222,184,135,0.2); }
.move-history td.move-item.active { background: rgba(222,184,135,0.4); }
.move-row { display: flex; align-items: center; padding: 4px 0; }
.move-num { width: 30px; color: var(--wood-light); font-weight: bold; font-size: 0.85rem; }
.move-row .move-item { flex: 1; padding: 4px 8px; margin: 0 2px; border-radius: 4px; cursor: pointer; text-align: center; transition: background 0.2s; }
.move-row .move-item:hover { background: rgba(222,184,135,0.2); }
.move-row .move-item.active { background: rgba(222,184,135,0.4); border-left: 3px solid var(--wood-light); }
.move-row { display: flex; align-items: center; padding: 4px 0; }
.move-num { width: 30px; color: var(--wood-light); font-weight: bold; font-size: 0.85rem; }
.move-row .move-item { flex: 1; padding: 4px 8px; margin: 0 2px; border-radius: 4px; cursor: pointer; text-align: center; transition: background 0.2s; }
.move-row .move-item:hover { background: rgba(222,184,135,0.2); }
.move-row .move-item.active { background: rgba(222,184,135,0.4); border-left: 3px solid var(--wood-light); }
.move-item { padding: 6px 10px; margin: 3px 0; border-radius: 4px; cursor: pointer; display: flex; justify-content: space-between; transition: background 0.2s; }
.move-item:hover { background: rgba(222,184,135,0.2); }
.move-item.active { background: rgba(222,184,135,0.4); border-left: 3px solid var(--wood-light); }
.move-number { color: var(--wood-light); font-weight: bold; }
.controls { display: flex; gap: 8px; flex-wrap: wrap; margin: 15px 0; }
.comment-section { margin-top: 15px; padding-top: 15px; border-top: 1px solid var(--wood-border); }
.comments-list { max-height: 120px; overflow-y: auto; margin: 8px 0; }
.comment { padding: 6px; margin: 4px 0; background: rgba(255,255,255,0.1); border-radius: 4px; font-size: 0.85rem; }
.chat-section { margin: 10px 0; }
.chat-list { max-height: 300px; overflow-y: auto; padding: 8px; background: rgba(0,0,0,0.3); border-radius: 6px; border: 1px solid var(--wood-border); }
.chat-message { padding: 6px 10px; margin: 4px 0; background: rgba(255,255,255,0.05); border-radius: 4px; }
.chat-message .chat-author { font-weight: bold; color: var(--wood-light); font-size: 0.85rem; }
.chat-message .chat-text { margin-left: 8px; }
.chat-message .chat-time { font-size: 0.7rem; color: rgba(255,255,220,0.5); margin-left: 8px; }
.chat-input-row { display: flex; gap: 8px; margin-top: 8px; }
.chat-input-row input { flex: 1; padding: 8px 12px; border: 1px solid var(--wood-border); border-radius: 4px; background: rgba(0,0,0,0.3); color: var(--cream); }
.chat-input-row button { padding: 8px 16px; }
.game-status { font-size: 1rem; margin: 10px 0; padding: 8px; background: rgba(0,0,0,0.3); border-radius: 5px; text-align: center; }
.game-list { list-style: none; }
.pending-label { background: #f0ad4e; color: #fff; padding: 4px 8px; border-radius: 4px; font-size: 0.8rem; margin-left: 10px; }
.game-item { padding: 15px; margin: 10px 0; background: rgba(255,255,255,0.1); border-radius: 5px; display: flex; justify-content: space-between; align-items: center; }
.game-item a { color: var(--wood-light); text-decoration: none; font-weight: bold; }
.game-item a:hover { text-decoration: underline; }
table { width: 100%; border-collapse: collapse; margin-top: 20px; }
th, td { padding: 12px; text-align: left; border-bottom: 1px solid var(--wood-border); }
th { background: rgba(0,0,0,0.3); color: var(--wood-light); }
.error { color: #ff6b6b; padding: 10px; background: rgba(255,0,0,0.2); border-radius: 5px; margin: 10px 0; }
.success { color: #6bff6b; padding: 10px; background: rgba(0,255,0,0.2); border-radius: 5px; margin: 10px 0; }
.notification { position: fixed; top: 20px; right: 20px; padding: 15px 25px; background: var(--wood-dark); border: 2px solid var(--wood-light); border-radius: 5px; z-index: 1000; animation: slideIn 0.3s ease; }
@keyframes slideIn { from { transform: translateX(400px); } to { transform: translateX(0); } }
.promotion-modal { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.8); display: flex; align-items: center; justify-content: center; z-index: 100; }
.promotion-options { display: flex; gap: 20px; background: var(--wood-dark); padding: 30px; border-radius: 10px; border: 3px solid var(--wood-light); }
.promotion-piece { font-size: 50px; cursor: pointer; padding: 10px; border-radius: 5px; transition: background 0.2s; }
.promotion-piece:hover { background: rgba(222,184,135,0.3); }
.turn-indicator { display: flex; align-items: center; gap: 10px; font-size: 1.1rem; margin-bottom: 15px; }
.turn-dot { width: 12px; height: 12px; border-radius: 50%; }
.turn-dot.white { background: white; border: 2px solid black; }
.turn-dot.black { background: black; }
.players-info { font-size: 0.95rem; margin: 8px 0; padding: 8px; background: rgba(0,0,0,0.2); border-radius: 5px; }
.players-info .player { font-weight: 500; }
.players-info .white-player { color: #f0f0f0; }
.players-info .black-player { color: #888; }
.players-info .vs { margin: 0 8px; color: var(--wood-light); }
.your-color { font-size: 0.9rem; margin-bottom: 10px; color: var(--wood-light); }
.challenge-row { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 10px; }
.challenge-row > div { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; }
.back-link { display: inline-block; margin-left: 10px; color: var(--wood-light); text-decoration: none; font-size: 0.9rem; }
.back-link:hover { text-decoration: underline; }
.comment-buttons { display: flex; justify-content: space-between; align-items: center; margin-top: 10px; }
.back-btn { text-decoration: none; }
.requests-section { margin-top: 20px; }
.scroll-section { max-height: 200px; overflow-y: auto; border: 1px solid var(--wood-dark); border-radius: 4px; }
.scroll-section table { margin: 0; }
.scroll-section thead { position: sticky; top: 0; background: var(--wood-dark); z-index: 1; }
.scroll-section th { color: var(--paper); }
.request-item { padding: 10px; margin: 10px 0; background: rgba(255,255,255,0.1); border-radius: 5px; display: flex; justify-content: space-between; align-items: center; }
.request-actions { display: flex; gap: 10px; }