@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:wght@400;600;700&family=Inter:wght@300;400;500;600&display=swap');

:root {
  --wood-deep: #2a1608;
  --wood-dark: #3d2510;
  --wood-mid: #6b4226;
  --wood-light: #8b5a2b;
  --wood-surface: #c4956a;
  --wood-highlight: #d4a87a;
  --felt-green: #2d5a3d;
  --text-cream: #fcecd2;
  --text-gold: #e8c170;
  --accent-emerald: #27ae60;
  --accent-emerald-hover: #2ecc71;
  --accent-ruby: #c0392b;
  --checker-white: #f5efe6;
  --checker-black: #1a1a1a;
  --shadow-heavy: rgba(0, 0, 0, 0.7);
  --shadow-medium: rgba(0, 0, 0, 0.4);
  --shadow-light: rgba(0, 0, 0, 0.2);
}

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

body {
  font-family: 'Inter', 'Segoe UI', sans-serif;
  background: linear-gradient(145deg, #1a0d05 0%, #2a1608 30%, #3d2510 60%, #2a1608 100%);
  color: var(--text-cream);
  display: flex;
  justify-content: center;
  align-items: flex-start;
  min-height: 100vh;
  padding: 20px;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* Subtle background texture */
body::before {
  content: '';
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background-image:
    radial-gradient(ellipse at 20% 50%, rgba(139, 90, 43, 0.08) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 20%, rgba(139, 90, 43, 0.06) 0%, transparent 50%);
  pointer-events: none;
  z-index: 0;
}

#app {
  width: 100%;
  max-width: 1000px;
  position: relative;
  z-index: 1;
}

/* ══════════════════════════════════════
   MENU OVERLAY
   ══════════════════════════════════════ */
#menu-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  z-index: 1000;
  background: linear-gradient(145deg, rgba(26, 13, 5, 0.97), rgba(42, 22, 8, 0.98));
  display: flex;
  justify-content: center;
  align-items: center;
  backdrop-filter: blur(10px);
}

.menu-content {
  text-align: center;
  width: 100%;
  max-width: 460px;
  padding: 50px 40px;
  background: linear-gradient(180deg, var(--wood-dark) 0%, #1a0d05 100%);
  border: 2px solid var(--wood-mid);
  border-radius: 16px;
  box-shadow:
    0 0 0 1px rgba(139, 90, 43, 0.3),
    0 20px 60px rgba(0, 0, 0, 0.8),
    inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.logo-area {
  margin-bottom: 35px;
}

.logo-icon {
  margin-bottom: 20px;
  display: flex;
  justify-content: center;
  animation: float 3s ease-in-out infinite;
}

.infinity-logo {
  display: flex;
  position: relative;
  width: 90px;
  height: 50px;
  align-items: center;
  justify-content: center;
}

.logo-checker-white, .logo-checker-black {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  position: absolute;
  box-shadow: 
    0 4px 10px rgba(0,0,0,0.5),
    inset 0 0 10px rgba(0,0,0,0.2);
  border: 1.5px solid rgba(0,0,0,0.1);
}

.logo-checker-white {
  background: radial-gradient(circle at 35% 35%, #fff 0%, var(--checker-white) 100%);
  left: 0;
  z-index: 2;
}

.logo-checker-black {
  background: radial-gradient(circle at 35% 35%, #444 0%, var(--checker-black) 100%);
  right: 0;
  z-index: 1;
}

@keyframes float {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  50% { transform: translateY(-8px) rotate(1deg); }
}

h1 {
  font-family: 'Playfair Display', serif;
  font-size: 3.5rem;
  font-weight: 700;
  letter-spacing: 12px;
  color: var(--text-gold);
  text-shadow: 0 4px 8px rgba(0, 0, 0, 0.6);
  margin: 0;
  background: linear-gradient(180deg, var(--text-gold) 0%, #b8860b 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.subtitle {
  font-size: 0.85rem;
  color: rgba(252, 236, 210, 0.5);
  letter-spacing: 2px;
  margin-top: 8px;
  font-weight: 300;
}

.form-group {
  margin-bottom: 20px;
  text-align: left;
}

.form-group label {
  display: block;
  font-size: 0.8rem;
  margin-bottom: 8px;
  color: var(--wood-highlight);
  text-transform: uppercase;
  letter-spacing: 1.5px;
  font-weight: 500;
}

select, .lobby-input {
  width: 100%;
  padding: 14px 16px;
  font-size: 1rem;
  font-family: 'Inter', sans-serif;
  border-radius: 8px;
  border: 1px solid var(--wood-mid);
  background: var(--wood-dark);
  color: var(--text-cream);
  cursor: pointer;
  transition: all 0.2s ease;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23c4956a' fill='none' stroke-width='2'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 16px center;
}

select:hover, select:focus, .lobby-input:hover, .lobby-input:focus {
  border-color: var(--wood-light);
  outline: none;
  box-shadow: 0 0 0 3px rgba(139, 90, 43, 0.2);
}

.lobby-input {
  padding: 10px 14px;
  font-size: 0.9rem;
  border-radius: 8px;
  border: 1px solid var(--wood-mid);
  background: rgba(0, 0, 0, 0.3);
  color: var(--text-cream);
}

#startBtn {
  width: 100%;
  padding: 16px;
  font-size: 1.1rem;
  font-family: 'Inter', sans-serif;
  font-weight: 600;
  letter-spacing: 2px;
  text-transform: uppercase;
  border: none;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--accent-emerald), #1e8449);
  color: #fff;
  cursor: pointer;
  margin-top: 25px;
  transition: all 0.25s ease;
  box-shadow: 0 4px 15px rgba(39, 174, 96, 0.3);
}

#startBtn:hover {
  background: linear-gradient(135deg, var(--accent-emerald-hover), #27ae60);
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(39, 174, 96, 0.4);
}

#startBtn:active {
  transform: translateY(0);
}

/* ══════════════════════════════════════
   GAME UI
   ══════════════════════════════════════ */
#game-ui {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  gap: 0;
}

/* Header */
#game-header {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 20px;
  background: linear-gradient(180deg, var(--wood-dark), #1a0d05);
  border: 1px solid var(--wood-mid);
  border-bottom: none;
  border-radius: 12px 12px 0 0;
  gap: 12px;
  flex-wrap: wrap;
}

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

.mode-badge {
  background: var(--wood-mid);
  color: var(--text-gold);
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.turn-indicator {
  font-size: 0.9rem;
  font-weight: 500;
  padding: 4px 14px;
  border-radius: 6px;
  transition: all 0.3s ease;
}

.turn-p1 {
  background: rgba(245, 239, 230, 0.15);
  color: var(--checker-white);
  border: 1px solid rgba(245, 239, 230, 0.3);
}

.turn-p2 {
  background: rgba(50, 50, 50, 0.6);
  color: #bbb;
  border: 1px solid rgba(100, 100, 100, 0.4);
}

.header-center {
  display: flex;
  gap: 20px;
}

.score-block {
  text-align: center;
}

.score-label {
  font-size: 0.6rem;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: rgba(252, 236, 210, 0.5);
  margin-bottom: 2px;
}

.score-value {
  font-family: 'Playfair Display', serif;
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--text-gold);
}

.header-right {
  display: flex;
  gap: 8px;
}

/* Buttons */
.action-btn {
  padding: 10px 18px;
  font-family: 'Inter', sans-serif;
  font-size: 0.85rem;
  font-weight: 600;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  width: auto;
}

.roll-btn {
  background: linear-gradient(135deg, var(--accent-emerald), #1e8449);
  color: #fff;
  box-shadow: 0 3px 10px rgba(39, 174, 96, 0.3);
}

.roll-btn:hover:not(:disabled) {
  background: linear-gradient(135deg, var(--accent-emerald-hover), #27ae60);
  transform: translateY(-1px);
  box-shadow: 0 5px 15px rgba(39, 174, 96, 0.4);
}

.roll-btn:disabled {
  background: #444;
  color: #888;
  cursor: not-allowed;
  box-shadow: none;
  transform: none;
}

.rotate-btn {
  background: var(--wood-mid);
  color: var(--text-cream);
}

.rotate-btn:hover {
  background: var(--wood-light);
  transform: translateY(-1px);
}

.pass-btn {
  background: linear-gradient(135deg, #7f5c2e, #5a3d1a);
  color: var(--text-cream);
  border: 1px solid var(--wood-light);
}

.pass-btn:hover {
  background: linear-gradient(135deg, #9b7040, #7a5528);
  transform: translateY(-1px);
}

#svg-board {
  cursor: default;
}

#svg-board [data-point], #svg-board rect[cursor="pointer"] {
  cursor: pointer;
}

.secondary-btn {
  background: var(--wood-mid);
  color: var(--text-cream);
  margin-top: 0;
}

.secondary-btn:hover {
  background: var(--wood-light);
}

/* Board Container */
#board-container {
  width: 100%;
  aspect-ratio: 4 / 3;
  max-height: 70vh;
  margin: 0 auto;
  background: var(--wood-surface);
  border: 3px solid var(--wood-dark);
  border-top: none;
  box-shadow:
    0 20px 60px rgba(0, 0, 0, 0.6),
    inset 0 0 30px rgba(0, 0, 0, 0.1);
  position: relative;
  overflow: hidden;
  transition: transform 0.5s ease;
}

#svg-board {
  width: 100%;
  height: 100%;
  display: block;
}

.rotated-board {
  transform: rotate(180deg);
}

/* Message Bar */
#message-bar {
  width: 100%;
  padding: 10px 20px;
  background: linear-gradient(180deg, #1a0d05, var(--wood-dark));
  border: 1px solid var(--wood-mid);
  border-top: none;
  border-radius: 0 0 12px 12px;
  text-align: center;
  font-size: 0.85rem;
  color: rgba(252, 236, 210, 0.7);
  letter-spacing: 0.5px;
}

/* ══════════════════════════════════════
   GAME OVER MODAL
   ══════════════════════════════════════ */
#game-over-modal {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  z-index: 2000;
  background: rgba(0, 0, 0, 0.75);
  display: flex;
  justify-content: center;
  align-items: center;
  backdrop-filter: blur(5px);
}

.modal-content {
  background: linear-gradient(180deg, var(--wood-dark) 0%, #1a0d05 100%);
  border: 2px solid var(--wood-mid);
  border-radius: 16px;
  padding: 40px;
  text-align: center;
  max-width: 420px;
  width: 90%;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.8);
  animation: modalIn 0.3s ease;
}

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

.modal-icon {
  font-size: 3rem;
  margin-bottom: 12px;
}

.modal-content h2 {
  font-family: 'Playfair Display', serif;
  font-size: 1.6rem;
  color: var(--text-gold);
  margin-bottom: 10px;
}

.modal-content p {
  color: rgba(252, 236, 210, 0.7);
  margin-bottom: 20px;
  font-size: 0.95rem;
}

.modal-scores {
  background: rgba(0, 0, 0, 0.3);
  padding: 12px 20px;
  border-radius: 8px;
  margin-bottom: 24px;
  font-size: 0.9rem;
  line-height: 1.8;
  color: var(--text-cream);
}

.modal-content .action-btn {
  width: 100%;
  margin-top: 8px;
  padding: 14px;
}

.modal-content .action-btn:first-of-type {
  background: linear-gradient(135deg, var(--accent-emerald), #1e8449);
  color: #fff;
}

.modal-content .secondary-btn {
  background: var(--wood-mid);
  margin-top: 8px;
}

/* ══════════════════════════════════════
   RESPONSIVE
   ══════════════════════════════════════ */
@media (max-width: 700px) {
  body { padding: 10px; }
  
  .menu-content { padding: 30px 24px; }
  
  h1 { font-size: 2.4rem; letter-spacing: 5px; }
  
  #game-header {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
    padding: 10px 12px;
  }
  
  .header-left, .header-center, .header-right {
    justify-content: center;
  }
  
  .header-right {
    flex-wrap: wrap;
  }
  
  .score-value { font-size: 1.1rem; }
}
