/* ==================== GAME BOARD ==================== */
#game-container {
  width: 100vw;
  height: 100vh;
  position: fixed;
  top: 0;
  left: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

#board {
  position: relative;
  width: 95vw;
  max-width: 1400px;
  height: 85vh;
  max-height: 900px;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.12);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
  overflow: visible;
}

#board-center {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(255, 255, 255, 0.95);
  padding: 25px;
  border-radius: 20px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
  z-index: 100;
  min-width: 200px;
}

/* ==================== CELLS ==================== */
.cell {
  position: absolute;
  width: 88px;
  height: 88px;
  border-radius: 16px;
  background: linear-gradient(135deg, #e3f2fd 0%, #bbdefb 100%);
  border: 3px solid #42a5f5;
  transition: all 0.3s;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  box-shadow: 
    0 4px 12px rgba(33, 150, 243, 0.3),
    inset 0 2px 4px rgba(255, 255, 255, 0.5);
  overflow: visible;
  z-index: 10;
}

.cell::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 70%;
  height: 70%;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.6) 0%, transparent 70%);
  border-radius: 50%;
  pointer-events: none;
  z-index: 1;
}

/* Start Cell */
.start-cell {
  background: linear-gradient(135deg, #4CAF50 0%, #81C784 100%);
  border: 4px solid #2E7D32;
  box-shadow: 
    0 0 20px rgba(76, 175, 80, 0.6),
    0 4px 15px rgba(46, 125, 50, 0.4),
    inset 0 2px 6px rgba(255, 255, 255, 0.4);
  animation: pulse-start 2s infinite;
  z-index: 15;
}

.start-icon {
  font-size: 36px;
  animation: bounce-flag 1.5s infinite;
  z-index: 2;
}

@keyframes pulse-start {
  0%, 100% { 
    box-shadow: 
      0 0 20px rgba(76, 175, 80, 0.6),
      0 4px 15px rgba(46, 125, 50, 0.4),
      inset 0 2px 6px rgba(255, 255, 255, 0.4);
  }
  50% { 
    box-shadow: 
      0 0 30px rgba(76, 175, 80, 0.9),
      0 6px 20px rgba(46, 125, 50, 0.6),
      inset 0 2px 6px rgba(255, 255, 255, 0.6);
  }
}

@keyframes bounce-flag {
  0%, 100% { transform: translateY(0) scale(1); }
  50% { transform: translateY(-5px) scale(1.1); }
}

/* Bot Cell */
.cell.bot {
  border: 4px solid #FF6F00;
  background: radial-gradient(circle at 30% 30%, #FFD54F 0%, #FFB300 50%, #FF8F00 100%);
  animation: pulse-bot 2s infinite ease-in-out;
  position: absolute;
  overflow: visible;
  z-index: 50 !important;
}

.bot-icon {
  font-size: 42px;
  animation: robot-shake 1s infinite;
  z-index: 2;
  margin-top: -5px;
}

.bot-label {
  position: absolute;
  bottom: 8px;
  color: white;
  font-size: 13px;
  font-weight: 900;
  text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.7);
  z-index: 2;
}

@keyframes pulse-bot {
  0% { 
    transform: scale(1); 
    box-shadow: 
      0 0 25px rgba(255, 152, 0, 0.8),
      0 4px 15px rgba(245, 124, 0, 0.6);
  }
  50% { 
    transform: scale(1.08); 
    box-shadow: 
      0 0 40px rgba(255, 193, 7, 1),
      0 6px 20px rgba(255, 152, 0, 0.8);
  }
  100% { 
    transform: scale(1); 
    box-shadow: 
      0 0 25px rgba(255, 152, 0, 0.8),
      0 4px 15px rgba(245, 124, 0, 0.6);
  }
}

@keyframes robot-shake {
  0%, 100% { transform: rotate(-3deg); }
  50% { transform: rotate(3deg); }
}

/* Player Piece */
.player {
  width: 60px;
  height: 60px;
  position: absolute;
  border-radius: 50%;
  transition: all 0.25s ease;
  z-index: 200;
  pointer-events: none;
  border: 3px solid white;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
}

.player-label {
  position: absolute;
  bottom: -22px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.8);
  color: white;
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 0.75em;
  font-weight: bold;
  white-space: nowrap;
  z-index: 201;
  box-shadow: 0 2px 4px rgba(0,0,0,0.3);
}

/* ==================== RESPONSIVE CELLS ==================== */
@media (max-width: 1024px) and (orientation: portrait) {
  #board {
    width: 95vw;
    height: 80vh;
  }
  
  .cell {
    width: 65px;
    height: 65px;
  }
  
  .player {
    width: 45px;
    height: 45px;
  }
}

@media (max-width: 896px) and (orientation: landscape) {
  #board {
    width: 98vw;
    height: 92vh;
  }
  
  #board-center {
    padding: 12px;
  }
  
  .cell {
    width: 50px;
    height: 50px;
    border-radius: 10px;
  }
  
  .start-icon {
    font-size: 22px;
  }
  
  .bot-icon {
    font-size: 24px;
  }
  
  .bot-label {
    font-size: 8px;
    bottom: 3px;
  }
  
  .player {
    width: 35px;
    height: 35px;
  }
  
  .player-label {
    font-size: 0.6em;
    bottom: -18px;
    padding: 2px 6px;
  }
}

@media (max-width: 768px) and (orientation: portrait) {
  #board {
    width: 98vw;
    height: 88vh;
    border-radius: 10px;
  }
  
  #board-center {
    padding: 15px;
    min-width: 140px;
    border-radius: 12px;
  }
  
  .cell {
    width: 42px;
    height: 42px;
    border-radius: 8px;
    border: 2px solid #42a5f5;
  }
  
  .start-icon {
    font-size: 18px;
  }
  
  .bot-icon {
    font-size: 20px;
    margin-top: -2px;
  }
  
  .bot-label {
    font-size: 7px;
    bottom: 2px;
  }
  
  .player {
    width: 28px;
    height: 28px;
    border: 2px solid white;
  }
  
  .player-label {
    bottom: -16px;
    padding: 2px 6px;
    font-size: 0.55em;
  }
}

@media (max-width: 480px) {
  #board-center {
    padding: 10px;
    min-width: 120px;
  }
  
  .cell {
    width: 38px;
    height: 38px;
  }
  
  .start-icon {
    font-size: 16px;
  }
  
  .bot-icon {
    font-size: 18px;
  }
  
  .bot-label {
    font-size: 6px;
  }
  
  .player {
    width: 25px;
    height: 25px;
  }
  
  .player-label {
    font-size: 0.5em;
    bottom: -14px;
    padding: 1px 4px;
  }
}

@media (max-width: 812px) and (orientation: landscape) and (max-height: 420px) {
  #board {
    width: 98vw;
    height: 96vh;
  }
  
  #board-center {
    padding: 6px;
  }
  
  .cell {
    width: 40px;
    height: 40px;
  }
  
  .bot-icon {
    font-size: 18px;
  }
  
  .bot-label {
    font-size: 6px;
  }
  
  .start-icon {
    font-size: 16px;
  }
  
  .player {
    width: 28px;
    height: 28px;
  }
  
  .player-label {
    font-size: 0.5em;
    bottom: -14px;
  }
}

@media (max-height: 400px) and (orientation: landscape) {
  #board-center {
    padding: 5px;
    min-width: 90px;
  }
}

@media (min-width: 813px) and (max-width: 896px) and (orientation: landscape) {
  .cell {
    width: 52px;
    height: 52px;
  }
  
  .player {
    width: 36px;
    height: 36px;
  }
}

@media (min-width: 768px) and (max-width: 1024px) and (orientation: landscape) {
  #board {
    width: 95vw;
    height: 88vh;
  }
  
  .cell {
    width: 60px;
    height: 60px;
  }
  
  .player {
    width: 42px;
    height: 42px;
  }
  
  #board-center {
    padding: 18px;
  }
}

@media (max-width: 320px) {
  .cell {
    width: 35px;
    height: 35px;
  }
  
  .player {
    width: 22px;
    height: 22px;
  }
}

@media (max-width: 480px) {
  .cell.bot {
    border-width: 3px;
  }
  
  .start-cell {
    border-width: 3px;
  }
  
  .bot-label {
    display: none;
  }
  
  .player-label {
    display: none;
  }
}

@media (max-width: 768px) {
  #board, .cell, .player {
    transform-style: preserve-3d;
    perspective: 1000px;
  }
  
  .cell, .player, #board {
    transform: translateZ(0);
    -webkit-transform: translateZ(0);
    will-change: transform;
  }
  
  .player {
    transition: left 0.22s ease-out, top 0.22s ease-out;
  }
  
  #board {
    will-change: transform;
  }
  
  .player {
    will-change: left, top;
  }
  
  .cell::before {
    display: none;
  }
}

@media (orientation: landscape) and (max-height: 500px) {
  #board {
    width: 98vw;
    height: 94vh;
  }
  
  #board-center {
    padding: 8px;
    min-width: 100px;
  }
  
  .cell {
    width: 45px;
    height: 45px;
  }
  
  .player {
    width: 32px;
    height: 32px;
  }
  
  .player-label {
    font-size: 0.55em;
    bottom: -16px;
  }
}

@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
  .cell {
    box-shadow: 
      0 4px 12px rgba(33, 150, 243, 0.3),
      inset 0 2px 4px rgba(255, 255, 255, 0.5);
  }
  
  .player {
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
  }
  
  .start-cell {
    box-shadow: 
      0 0 20px rgba(76, 175, 80, 0.6),
      0 4px 15px rgba(46, 125, 50, 0.4),
      inset 0 2px 6px rgba(255, 255, 255, 0.4);
  }
}

@media (prefers-contrast: high) {
  .cell {
    border-width: 3px;
  }
  
  .player {
    border-width: 3px;
  }
}

@media (prefers-contrast: more) {
  .start-cell {
    border: 4px solid #000;
  }
}

@supports (padding: env(safe-area-inset-top)) {
  #game-container {
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
  }
}

@supports (-webkit-touch-callout: none) {
  #game-container {
    height: -webkit-fill-available;
  }
  
  #board {
    max-height: -webkit-fill-available;
  }
}

@supports (padding: max(0px)) {
  @media (max-width: 812px) and (orientation: landscape) {
    #board {
      margin-left: env(safe-area-inset-left);
      margin-right: env(safe-area-inset-right);
    }
  }
}

@media (min-width: 768px) and (max-width: 1024px) and (orientation: landscape) {
  #board {
    max-width: 95vw;
  }
}

.cell, .player {
  contain: layout style paint;
}
/* Improved BOT icons */
.cell.bot {
  background: radial-gradient(circle at 30% 25%, #ffffff 0%, #e3f2fd 38%, #90caf9 100%) !important;
  border: 3px solid #1976d2 !important;
  box-shadow: 0 0 0 4px rgba(25,118,210,.12), 0 10px 24px rgba(25,118,210,.28) !important;
}
.smart-bot-icon {
  width: 72%;
  height: 72%;
  margin: 4% auto 0;
  border-radius: 50%;
  display: flex !important;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #ffffff, #bbdefb);
  box-shadow: inset 0 -4px 8px rgba(25,118,210,.20), 0 6px 12px rgba(0,0,0,.12);
  font-size: calc(var(--cell-size, 60px) * .42) !important;
  animation: bot-glow 1.7s infinite ease-in-out !important;
}
.bot-label span {
  font-size: .72em;
  letter-spacing: .04em;
  color: #0d47a1;
}
.player-label {
  background: rgba(13, 71, 161, .92) !important;
  color: #fff !important;
  border: 1px solid rgba(255,255,255,.9);
  box-shadow: 0 4px 10px rgba(0,0,0,.18);
  max-width: 90px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
