/* Reset & Global Styles */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none;
  -webkit-user-select: none;
}

body {
  background-color: #16161a;
  color: #f3f4f6;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Apple SD Gothic Neo", sans-serif;
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  padding: 20px;
}

/* Game Container */
.game-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  max-width: 620px;
  background: rgba(30, 30, 40, 0.7);
  border-radius: 24px;
  padding: 30px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.game-header {
  text-align: center;
  margin-bottom: 20px;
}

.game-header h1 {
  font-size: 2.4rem;
  font-weight: 900;
  letter-spacing: -1px;
  background: linear-gradient(135deg, #ff8c00, #ffbb00);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-bottom: 4px;
  text-transform: uppercase;
}

.subtitle {
  font-size: 0.95rem;
  color: #a1a1aa;
  font-weight: 500;
}

/* Status Panel */
.status-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  margin-bottom: 25px;
  gap: 10px;
}

.turn-indicator {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 1.2rem;
  font-weight: 700;
  background: rgba(255, 255, 255, 0.06);
  padding: 10px 24px;
  border-radius: 40px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  transition: all 0.3s ease;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
}

.stone-preview {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: inline-block;
  box-shadow: 0 2px 4px rgba(0,0,0,0.4);
}

.stone-preview.black {
  background: radial-gradient(circle at 30% 30%, #555, #111, #000);
}

.stone-preview.white {
  background: radial-gradient(circle at 30% 30%, #fff, #ddd, #bbb);
  border: 1px solid rgba(0,0,0,0.15);
}

.game-message {
  font-size: 1rem;
  color: #e4e4e7;
  min-height: 24px;
  text-align: center;
  transition: color 0.2s ease;
}

.game-message.error {
  color: #f87171;
  font-weight: 700;
  text-shadow: 0 0 10px rgba(248, 113, 113, 0.3);
  animation: shake 0.35s ease;
}

.game-message.win-black {
  color: #60a5fa;
  font-weight: bold;
  text-shadow: 0 0 12px rgba(96, 165, 250, 0.4);
}

.game-message.win-white {
  color: #34d399;
  font-weight: bold;
  text-shadow: 0 0 12px rgba(52, 211, 153, 0.4);
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-6px); }
  40% { transform: translateX(6px); }
  60% { transform: translateX(-4px); }
  80% { transform: translateX(4px); }
}

/* Board styling */
.board-wrapper {
  width: 100%;
  aspect-ratio: 1 / 1;
  /* Beautiful layered CSS wood-texture */
  background: 
    linear-gradient(rgba(244, 192, 122, 0.9), rgba(212, 154, 79, 0.95)),
    repeating-linear-gradient(90deg, transparent, transparent 4px, rgba(139, 90, 43, 0.08) 4px, rgba(139, 90, 43, 0.08) 8px),
    repeating-linear-gradient(0deg, transparent, transparent 5px, rgba(139, 90, 43, 0.06) 5px, rgba(139, 90, 43, 0.06) 10px);
  border-radius: 12px;
  padding: 14px; /* Margin from border edge to grid lines */
  box-shadow: 
    inset 0 0 30px rgba(0, 0, 0, 0.3), 
    0 15px 35px rgba(0, 0, 0, 0.5),
    0 5px 15px rgba(0, 0, 0, 0.2);
  border: 8px solid #7c4714;
  margin-bottom: 25px;
}

.board {
  display: grid;
  grid-template-columns: repeat(15, 1fr);
  grid-template-rows: repeat(15, 1fr);
  width: 100%;
  height: 100%;
}

.cell {
  position: relative;
  width: 100%;
  height: 100%;
  cursor: pointer;
  display: flex;
  justify-content: center;
  align-items: center;
}

/* Grid Lines inside Cell */
.cell::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 0;
  right: 0;
  height: 1px;
  background-color: rgba(60, 40, 20, 0.75);
  transform: translateY(-50%);
  z-index: 1;
}

.cell::after {
  content: '';
  position: absolute;
  left: 50%;
  top: 0;
  bottom: 0;
  width: 1px;
  background-color: rgba(60, 40, 20, 0.75);
  transform: translateX(-50%);
  z-index: 1;
}

/* Adjust grid boundary lines so they stop at the outermost intersections */
.cell[data-y="0"]::after { top: 50%; }
.cell[data-y="14"]::after { bottom: 50%; }
.cell[data-x="0"]::before { left: 50%; }
.cell[data-x="14"]::before { right: 50%; }

.star-marker {
  position: absolute;
  width: 8px;
  height: 8px;
  background-color: rgba(60, 40, 20, 0.95);
  border-radius: 50%;
  z-index: 2;
  pointer-events: none;
}

/* Stones */
.stone {
  position: absolute;
  width: 90%;
  height: 90%;
  border-radius: 50%;
  z-index: 3;
  pointer-events: none;
  animation: placeStone 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

.stone.black-stone {
  background: radial-gradient(circle at 35% 35%, #555 0%, #1a1a1a 45%, #000 80%, #000 100%);
  box-shadow: 2px 3px 5px rgba(0, 0, 0, 0.5), inset -1px -1px 3px rgba(0, 0, 0, 0.8);
}

.stone.white-stone {
  background: radial-gradient(circle at 35% 35%, #ffffff 0%, #f4f4f4 35%, #dadada 70%, #b0b0b0 100%);
  box-shadow: 2px 3px 5px rgba(0, 0, 0, 0.35), inset -1px -1px 2px rgba(0, 0, 0, 0.25);
  border: 1px solid rgba(0, 0, 0, 0.15);
}

@keyframes placeStone {
  from {
    transform: scale(1.4);
    opacity: 0;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}

/* Last Move Indicator */
.stone.last-move::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  z-index: 4;
}

.stone.black-stone.last-move::after {
  background-color: #ffaa00;
  box-shadow: 0 0 5px #ffaa00;
}

.stone.white-stone.last-move::after {
  background-color: #ef4444;
  box-shadow: 0 0 5px #ef4444;
}

/* Hover stone previews */
.cell:not(.has-stone):hover::before,
.cell:not(.has-stone):hover::after {
  background-color: rgba(0, 0, 0, 0.95);
}

.ghost-stone {
  position: absolute;
  width: 90%;
  height: 90%;
  border-radius: 50%;
  z-index: 2;
  opacity: 0.45;
  pointer-events: none;
  transition: opacity 0.1s ease;
}

.ghost-stone.black-ghost {
  background: radial-gradient(circle at 30% 30%, #555 0%, #111 60%, #000 100%);
}

.ghost-stone.white-ghost {
  background: radial-gradient(circle at 30% 30%, #fff 0%, #eee 40%, #ccc 80%, #bbb 100%);
  border: 1px solid rgba(0, 0, 0, 0.15);
}

/* Forbidden marker X */
.forbidden-marker {
  position: absolute;
  width: 20px;
  height: 20px;
  z-index: 4;
  pointer-events: none;
  display: flex;
  justify-content: center;
  align-items: center;
  color: #ef4444;
  font-weight: 900;
  font-size: 16px;
  text-shadow: 0 0 3px rgba(0, 0, 0, 0.9), 0 0 6px #ef4444;
  transition: all 0.2s ease;
}

.forbidden-marker.pulse {
  animation: pulseForbidden 1.5s infinite alternate;
}

.forbidden-marker.passive {
  opacity: 0.3; /* faint look for general previews */
  font-size: 14px;
}

.cell:hover .forbidden-marker.passive {
  opacity: 1;
  transform: scale(1.2);
  font-size: 16px;
}

@keyframes pulseForbidden {
  from { transform: scale(0.9); opacity: 0.7; }
  to { transform: scale(1.15); opacity: 1; }
}

/* Control Panel Buttons */
.control-panel {
  display: flex;
  gap: 15px;
  width: 100%;
}

.btn {
  flex: 1;
  padding: 14px;
  border: none;
  border-radius: 12px;
  font-size: 1.05rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
  color: #e4e4e7;
  background-color: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.1);
  outline: none;
}

.btn:hover:not(:disabled) {
  background-color: rgba(255, 255, 255, 0.15);
  transform: translateY(-2px);
  color: #ffffff;
}

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

.btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.btn.primary {
  background: linear-gradient(135deg, #ff8c00, #ffbb00);
  border: none;
  color: #16161a;
  box-shadow: 0 4px 14px rgba(255, 140, 0, 0.3);
}

.btn.primary:hover {
  background: linear-gradient(135deg, #ff9e1b, #ffcc1b);
  box-shadow: 0 6px 18px rgba(255, 140, 0, 0.45);
}

/* Responsive Scaling */
@media (max-width: 480px) {
  .game-container {
    padding: 20px 15px;
  }
  .game-header h1 {
    font-size: 1.9rem;
  }
  .board-wrapper {
    padding: 8px;
    border-width: 5px;
  }
  .star-marker {
    width: 6px;
    height: 6px;
  }
  .forbidden-marker {
    font-size: 12px;
  }
  .forbidden-marker.passive {
    font-size: 10px;
  }
}
