/* ================================================
   DAMAS BRASILEIRAS - Estilos
   ================================================ */

:root {
  --bg-primary: #1a1a2e;
  --bg-secondary: #16213e;
  --bg-card: #0f3460;
  --text-primary: #e8e8e8;
  --text-secondary: #a0a0b0;
  --accent: #e94560;
  --accent-hover: #ff6b81;
  --success: #2ed573;
  --warning: #ffa502;

  --board-dark: #8B4513;
  --board-light: #DEB887;
  --board-border: #5C3317;
  --board-highlight: rgba(255, 215, 0, 0.4);

  --piece-dark: #1a1a1a;
  --piece-dark-border: #333;
  --piece-dark-shine: #444;
  --piece-light: #f0e6d3;
  --piece-light-border: #c4a882;
  --piece-light-shine: #fff;

  --move-indicator: rgba(76, 175, 80, 0.5);
  --capture-indicator: rgba(244, 67, 54, 0.5);
  --selected-glow: rgba(255, 215, 0, 0.6);

  --square-size: min(10vw, 70px);
}

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

body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
}

/* ==================== SCREENS ==================== */

.screen {
  display: none;
  min-height: 100vh;
}

.screen.active {
  display: flex;
  justify-content: center;
  align-items: center;
}

/* ==================== MENU ==================== */

.menu-container {
  text-align: center;
  padding: 2rem;
  max-width: 450px;
  width: 100%;
}

.logo {
  margin-bottom: 2.5rem;
}

.logo-board {
  display: inline-flex;
  gap: 8px;
  margin-bottom: 1rem;
}

.mini-piece {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  box-shadow: 0 3px 8px rgba(0,0,0,0.3);
}

.mini-piece.dark {
  background: radial-gradient(circle at 35% 35%, var(--piece-dark-shine), var(--piece-dark));
  border: 2px solid var(--piece-dark-border);
}

.mini-piece.light {
  background: radial-gradient(circle at 35% 35%, var(--piece-light-shine), var(--piece-light));
  border: 2px solid var(--piece-light-border);
}

.logo h1 {
  font-size: 3.5rem;
  font-weight: 800;
  letter-spacing: 0.3em;
  background: linear-gradient(135deg, #fff, #e94560);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  text-shadow: none;
}

.subtitle {
  font-size: 1.1rem;
  color: var(--text-secondary);
  letter-spacing: 0.5em;
  text-transform: uppercase;
  margin-top: 0.25rem;
}

/* Botões */
.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  width: 100%;
  padding: 1rem 1.5rem;
  border: none;
  border-radius: 12px;
  font-size: 1.1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  color: #fff;
  position: relative;
  overflow: hidden;
}

.btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0,0,0,0.3);
}

.btn:active {
  transform: translateY(0);
}

.btn-icon {
  font-size: 1.3rem;
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent), #c0392b);
}

.btn-secondary {
  background: linear-gradient(135deg, #3498db, #2980b9);
}

.btn-online {
  background: linear-gradient(135deg, var(--success), #27ae60);
}

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

/* Submenu */
.submenu {
  background: var(--bg-secondary);
  border-radius: 16px;
  padding: 1.5rem;
  margin-bottom: 1rem;
  border: 1px solid rgba(255,255,255,0.1);
  animation: slideIn 0.3s ease;
}

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

.submenu h3 {
  margin-bottom: 1rem;
  font-size: 1.1rem;
  color: var(--text-secondary);
}

.difficulty-buttons {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.btn-small {
  flex: 1;
  padding: 0.75rem;
  border: none;
  border-radius: 8px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  color: #fff;
  transition: all 0.2s ease;
}

.btn-small:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

.btn-easy { background: var(--success); }
.btn-medium { background: var(--warning); }
.btn-hard { background: var(--accent); }
.btn-create { background: linear-gradient(135deg, #9b59b6, #8e44ad); width: 100%; padding: 0.85rem; margin-bottom: 0.8rem; }
.btn-join { background: var(--success); padding: 0.75rem 1.2rem; border-radius: 0 8px 8px 0; white-space: nowrap; }

.btn-back {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 0.9rem;
  padding: 0.5rem;
  transition: color 0.2s;
}

.btn-back:hover {
  color: var(--text-primary);
}

/* Online options */
.online-options {
  margin-bottom: 0.5rem;
}

.join-room {
  display: flex;
  gap: 0;
}

.join-room input {
  flex: 1;
  padding: 0.75rem 1rem;
  border: 2px solid rgba(255,255,255,0.1);
  border-right: none;
  border-radius: 8px 0 0 8px;
  background: rgba(0,0,0,0.3);
  color: var(--text-primary);
  font-size: 0.95rem;
  outline: none;
  transition: border-color 0.2s;
  font-family: monospace;
  letter-spacing: 2px;
}

.join-room input:focus {
  border-color: var(--success);
}

.join-room input::placeholder {
  font-family: 'Segoe UI', system-ui, sans-serif;
  letter-spacing: normal;
}

/* Room info */
.room-info {
  margin-top: 1rem;
  padding: 1rem;
  background: rgba(0,0,0,0.2);
  border-radius: 8px;
  animation: slideIn 0.3s ease;
}

.room-code-display {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  margin: 0.8rem 0;
}

.room-code-display span {
  font-family: monospace;
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: 3px;
  color: var(--warning);
  background: rgba(0,0,0,0.3);
  padding: 0.5rem 1rem;
  border-radius: 6px;
  user-select: all;
}

.btn-copy {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1.2rem;
  padding: 0.5rem;
  transition: transform 0.2s;
}

.btn-copy:hover {
  transform: scale(1.2);
}

.waiting {
  color: var(--text-secondary);
  font-size: 0.9rem;
  margin-top: 0.5rem;
}

.loading-dots {
  display: flex;
  justify-content: center;
  gap: 6px;
  margin-top: 0.5rem;
}

.loading-dots span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-secondary);
  animation: bounce 1.4s infinite ease-in-out both;
}

.loading-dots span:nth-child(1) { animation-delay: -0.32s; }
.loading-dots span:nth-child(2) { animation-delay: -0.16s; }

@keyframes bounce {
  0%, 80%, 100% { transform: scale(0); }
  40% { transform: scale(1); }
}

.online-status {
  color: var(--text-secondary);
  font-size: 0.85rem;
  margin-top: 0.5rem;
  min-height: 1.2em;
}

.menu-footer {
  margin-top: 2rem;
  color: var(--text-secondary);
  font-size: 0.75rem;
  opacity: 0.7;
}

.hidden {
  display: none !important;
}

/* ==================== GAME SCREEN ==================== */

#game-screen.active {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 1rem;
}

.game-layout {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  width: 100%;
  max-width: 600px;
}

/* Player info */
.player-info {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  max-width: 520px;
  padding: 0.6rem 1rem;
  border-radius: 10px;
  background: var(--bg-secondary);
  border: 2px solid transparent;
  transition: all 0.3s ease;
}

.player-info.active-turn {
  border-color: var(--warning);
  box-shadow: 0 0 15px rgba(255, 165, 0, 0.2);
}

.player-pieces {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.piece-indicator {
  width: 24px;
  height: 24px;
  border-radius: 50%;
}

.dark-piece {
  background: radial-gradient(circle at 35% 35%, var(--piece-dark-shine), var(--piece-dark));
  border: 2px solid var(--piece-dark-border);
}

.light-piece {
  background: radial-gradient(circle at 35% 35%, var(--piece-light-shine), var(--piece-light));
  border: 2px solid var(--piece-light-border);
}

.player-name {
  font-weight: 600;
  font-size: 0.95rem;
}

.player-stats {
  display: flex;
  gap: 1rem;
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.turn-indicator {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: transparent;
  transition: background 0.3s;
}

.active-turn .turn-indicator {
  background: var(--warning);
  box-shadow: 0 0 8px var(--warning);
  animation: pulse 1.5s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* ==================== BOARD ==================== */

.board-wrapper {
  user-select: none;
  -webkit-user-select: none;
}

.board-frame {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.board-labels {
  display: flex;
  justify-content: space-around;
  width: calc(var(--square-size) * 8);
  font-size: 0.7rem;
  color: var(--text-secondary);
  padding: 0 2px;
}

.board-labels span {
  width: var(--square-size);
  text-align: center;
}

.board-labels-left,
.board-labels-right {
  display: flex;
  flex-direction: column;
  justify-content: space-around;
  height: calc(var(--square-size) * 8);
  width: 16px;
}

.board-labels-left span,
.board-labels-right span {
  height: var(--square-size);
  display: flex;
  align-items: center;
  justify-content: center;
  width: auto;
}

.board-with-numbers {
  display: flex;
  align-items: center;
  gap: 2px;
}

.board {
  display: grid;
  grid-template-columns: repeat(8, var(--square-size));
  grid-template-rows: repeat(8, var(--square-size));
  border: 3px solid var(--board-border);
  border-radius: 4px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5), inset 0 0 10px rgba(0,0,0,0.2);
  overflow: hidden;
}

.square {
  width: var(--square-size);
  height: var(--square-size);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  cursor: default;
  transition: background-color 0.15s;
}

.square-light {
  background: var(--board-light);
}

.square-dark {
  background: var(--board-dark);
}

.square.valid-move {
  cursor: pointer;
}

.square.valid-move::after {
  content: '';
  position: absolute;
  width: 30%;
  height: 30%;
  border-radius: 50%;
  background: var(--move-indicator);
  animation: fadeIn 0.2s ease;
}

.square.valid-capture::after {
  content: '';
  position: absolute;
  width: 85%;
  height: 85%;
  border-radius: 50%;
  border: 3px solid var(--capture-indicator);
  background: rgba(244, 67, 54, 0.1);
  animation: fadeIn 0.2s ease;
}

.square.last-move {
  background: rgba(255, 235, 59, 0.15);
}

@keyframes fadeIn {
  from { opacity: 0; transform: scale(0.5); }
  to { opacity: 1; transform: scale(1); }
}

/* ==================== PIECES ==================== */

.piece {
  width: 80%;
  height: 80%;
  border-radius: 50%;
  cursor: pointer;
  position: relative;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  z-index: 2;
}

.piece:hover {
  transform: scale(1.08);
}

.piece.dark {
  background: radial-gradient(circle at 38% 38%, #555, var(--piece-dark));
  border: 2px solid var(--piece-dark-border);
  box-shadow: 0 3px 6px rgba(0,0,0,0.4), inset 0 -2px 4px rgba(0,0,0,0.3);
}

.piece.light {
  background: radial-gradient(circle at 38% 38%, #fff, var(--piece-light));
  border: 2px solid var(--piece-light-border);
  box-shadow: 0 3px 6px rgba(0,0,0,0.3), inset 0 -2px 4px rgba(139,109,80,0.2);
}

.piece.selected {
  transform: scale(1.1);
  box-shadow: 0 0 20px var(--selected-glow), 0 5px 10px rgba(0,0,0,0.4);
  animation: selectedPulse 1s infinite;
}

@keyframes selectedPulse {
  0%, 100% { box-shadow: 0 0 15px var(--selected-glow), 0 5px 10px rgba(0,0,0,0.4); }
  50% { box-shadow: 0 0 25px var(--selected-glow), 0 5px 10px rgba(0,0,0,0.4); }
}

.piece.must-capture {
  animation: mustCapture 0.8s infinite;
}

@keyframes mustCapture {
  0%, 100% { box-shadow: 0 0 8px rgba(244, 67, 54, 0.5), 0 3px 6px rgba(0,0,0,0.4); }
  50% { box-shadow: 0 0 16px rgba(244, 67, 54, 0.8), 0 3px 6px rgba(0,0,0,0.4); }
}

/* Crown for king pieces */
.piece.king::before {
  content: '♛';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: calc(var(--square-size) * 0.38);
  line-height: 1;
}

.piece.dark.king::before {
  color: #ffd700;
  text-shadow: 0 1px 3px rgba(0,0,0,0.5);
}

.piece.light.king::before {
  color: #b8860b;
  text-shadow: 0 1px 3px rgba(0,0,0,0.3);
}

.piece.disabled {
  opacity: 0.6;
  cursor: default;
  pointer-events: none;
}

/* Move animation */
.piece.moving {
  transition: none;
  z-index: 10;
}

/* Capture animation */
.piece.captured {
  animation: captureAnim 0.3s ease forwards;
}

@keyframes captureAnim {
  to {
    transform: scale(0);
    opacity: 0;
  }
}

/* ==================== GAME CONTROLS ==================== */

.game-controls {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.btn-control {
  padding: 0.5rem 1rem;
  border: none;
  border-radius: 8px;
  background: var(--bg-secondary);
  color: var(--text-primary);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  border: 1px solid rgba(255,255,255,0.1);
}

.btn-control:hover {
  background: var(--bg-card);
  transform: translateY(-1px);
}

/* ==================== MODAL ==================== */

.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0,0,0,0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  backdrop-filter: blur(4px);
  animation: fadeIn 0.3s ease;
}

.modal-content {
  background: var(--bg-secondary);
  padding: 2rem;
  border-radius: 16px;
  text-align: center;
  max-width: 400px;
  width: 90%;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
  animation: modalIn 0.3s ease;
}

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

.modal-content h2 {
  font-size: 1.8rem;
  margin-bottom: 0.5rem;
}

.modal-content p {
  color: var(--text-secondary);
  margin-bottom: 1.5rem;
  font-size: 1.05rem;
}

.modal-buttons {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.modal-buttons .btn {
  font-size: 0.95rem;
  padding: 0.8rem;
}

/* ==================== TOAST ==================== */

.toast {
  position: fixed;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-card);
  color: var(--text-primary);
  padding: 0.8rem 1.5rem;
  border-radius: 10px;
  font-size: 0.9rem;
  z-index: 200;
  box-shadow: 0 4px 20px rgba(0,0,0,0.4);
  border: 1px solid rgba(255,255,255,0.1);
  animation: toastIn 0.3s ease;
  max-width: 90vw;
  text-align: center;
}

@keyframes toastIn {
  from { opacity: 0; transform: translateX(-50%) translateY(10px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

.toast.hiding {
  animation: toastOut 0.3s ease forwards;
}

@keyframes toastOut {
  to { opacity: 0; transform: translateX(-50%) translateY(10px); }
}

/* ==================== RESPONSIVE ==================== */

@media (max-width: 480px) {
  :root {
    --square-size: calc((100vw - 3rem) / 8);
  }

  .menu-container {
    padding: 1.5rem 1rem;
  }

  .logo h1 {
    font-size: 2.5rem;
  }

  .btn {
    padding: 0.85rem 1rem;
    font-size: 1rem;
  }

  .player-info {
    padding: 0.5rem 0.75rem;
    flex-wrap: wrap;
    gap: 0.3rem;
  }

  .player-stats {
    font-size: 0.8rem;
    gap: 0.5rem;
  }

  .board-labels {
    font-size: 0.6rem;
  }

  .board-labels-left,
  .board-labels-right {
    width: 12px;
  }
}

@media (min-width: 481px) and (max-width: 768px) {
  :root {
    --square-size: min(9vw, 60px);
  }
}

@media (min-width: 769px) {
  :root {
    --square-size: 65px;
  }
}

@media (min-height: 800px) {
  .game-layout {
    gap: 1rem;
  }
}
