:root {
  --bg-color: #0f172a;
  --board-border: rgba(255, 255, 255, 0.1);
  --cell-border: rgba(255, 255, 255, 0.05);
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --accent-color: #3b82f6;
  --disc-black: #1e293b;
  --disc-white: #f1f5f9;
  --hover-hint: rgba(255, 255, 255, 0.15);
}

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

html, body {
  height: 100%;
  overflow: hidden;
}

body {
  font-family: 'Outfit', sans-serif;
  background-color: var(--bg-color);
  color: var(--text-primary);
  display: flex;
  justify-content: center;
  align-items: center;
  height: 100dvh;
  background-image:
    radial-gradient(at 0% 0%, rgba(59, 130, 246, 0.15) 0px, transparent 50%),
    radial-gradient(at 100% 100%, rgba(16, 185, 129, 0.15) 0px, transparent 50%);
}

.app-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  width: 100%;
  max-width: 400px;
  height: 100dvh;
}

header {
  text-align: center;
  width: 100%;
}

h1 {
  font-size: 1.2rem;
  font-weight: 800;
  letter-spacing: 0.15em;
  background: linear-gradient(to right, #60a5fa, #34d399);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-bottom: 0.4rem;
}

.settings-panel {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.35rem;
  padding: 0.45rem 0.6rem;
  background: rgba(15, 23, 42, 0.5);
  border-radius: 12px;
  border: 1px solid var(--board-border);
  margin-bottom: 0.4rem;
  width: 100%;
}

.setting-group {
  display: flex;
  align-items: center;
  transition: opacity 0.3s;
}

.toggle-group {
  display: flex;
  background: rgba(0, 0, 0, 0.25);
  border-radius: 6px;
  overflow: hidden;
}

.toggle-btn {
  background: transparent;
  color: var(--text-secondary);
  border: none;
  padding: 0.3rem 0.65rem;
  font-family: inherit;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.toggle-btn:hover {
  background: rgba(255, 255, 255, 0.05);
}

.toggle-btn.active {
  background: var(--accent-color);
  color: white;
}

.setting-group.disabled {
  opacity: 0.3;
  pointer-events: none;
}

.score-bar {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 0.3rem;
}

.score-card {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.3rem 0.85rem;
  background: rgba(15, 23, 42, 0.6);
  border-radius: 9999px;
  font-size: 1.1rem;
  font-weight: 600;
  border: 2px solid transparent;
  transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.score-card.active {
  border-color: var(--accent-color);
  box-shadow: 0 0 16px rgba(59, 130, 246, 0.3);
  transform: scale(1.08);
}

.disc {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  box-shadow: inset -2px -2px 4px rgba(0,0,0,0.5), 0 2px 4px rgba(0,0,0,0.3);
  flex-shrink: 0;
}

.disc.black {
  background: var(--disc-black);
  border: 1px solid #334155;
}

.disc.white {
  background: var(--disc-white);
  border: 1px solid #cbd5e1;
}

.btn-restart {
  background: rgba(15, 23, 42, 0.6);
  color: var(--text-secondary);
  border: 2px solid transparent;
  border-radius: 9999px;
  width: 36px;
  height: 36px;
  font-size: 1.1rem;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.btn-restart:hover {
  color: var(--text-primary);
  border-color: var(--accent-color);
  box-shadow: 0 0 10px rgba(59, 130, 246, 0.3);
  transform: rotate(90deg);
}

.status-message {
  font-size: 0.9rem;
  color: var(--text-secondary);
  height: 1.2rem;
  font-weight: 600;
  margin-bottom: 0.3rem;
}

.board-container {
  padding: 8px;
  background: rgba(16, 185, 129, 0.1);
  border-radius: 12px;
  border: 1px solid var(--board-border);
  box-shadow: inset 0 2px 10px rgba(0,0,0,0.2);
  flex-shrink: 0;
}

.board {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  grid-template-rows: repeat(8, 1fr);
  gap: 2px;
  width: min(312px, 90vw);
  height: min(312px, 90vw);
  background-color: var(--cell-border);
  border: 2px solid var(--cell-border);
  border-radius: 8px;
  overflow: hidden;
}

.cell {
  background-color: rgba(20, 184, 166, 0.2);
  display: flex;
  justify-content: center;
  align-items: center;
  cursor: pointer;
  transition: background-color 0.2s;
  position: relative;
  perspective: 600px;
}

.cell:hover {
  background-color: rgba(20, 184, 166, 0.35);
}

.cell.valid-move::after {
  content: '';
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background-color: var(--hover-hint);
  position: absolute;
  pointer-events: none;
  animation: pulse 1.5s infinite;
}

@keyframes pulse {
  0%   { transform: scale(0.9); opacity: 0.7; }
  50%  { transform: scale(1.1); opacity: 1; }
  100% { transform: scale(0.9); opacity: 0.7; }
}

.stone {
  width: 85%;
  height: 85%;
  border-radius: 50%;
  position: relative;
  transform-style: preserve-3d;
  transition: transform 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.stone-face {
  position: absolute;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  backface-visibility: hidden;
  box-shadow: inset -3px -3px 8px rgba(0,0,0,0.6), 0 4px 8px rgba(0,0,0,0.3);
}

.stone-black {
  background: var(--disc-black);
  border: 1px solid #334155;
  transform: rotateY(0deg);
}

.stone-white {
  background: var(--disc-white);
  border: 1px solid #cbd5e1;
  transform: rotateY(180deg);
}

.stone.is-black { transform: rotateY(0deg); }
.stone.is-white { transform: rotateY(180deg); }

@keyframes popIn {
  0%   { transform: scale(0) rotateY(0deg); opacity: 0; }
  80%  { transform: scale(1.1); }
  100% { transform: scale(1) rotateY(0deg); opacity: 1; }
}

@keyframes popInWhite {
  0%   { transform: scale(0) rotateY(180deg); opacity: 0; }
  80%  { transform: scale(1.1) rotateY(180deg); }
  100% { transform: scale(1) rotateY(180deg); opacity: 1; }
}

.stone.pop-black { animation: popIn 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards; }
.stone.pop-white { animation: popInWhite 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards; }

/* Bomb Styles */
.btn-bomb {
  background: rgba(15, 23, 42, 0.6);
  color: #ef4444;
  border: 2px solid transparent;
  border-radius: 9999px;
  width: 36px;
  height: 36px;
  font-size: 1.1rem;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.btn-bomb:hover:not(.used):not(.disabled) {
  border-color: #ef4444;
  box-shadow: 0 0 10px rgba(239, 68, 68, 0.4);
  transform: scale(1.1);
}
.btn-bomb.active {
  background: #ef4444;
  color: white;
  border-color: #fca5a5;
  box-shadow: 0 0 15px rgba(239, 68, 68, 0.6);
  animation: pulse 1s infinite alternate;
}
.btn-bomb.used {
  opacity: 0.3;
  cursor: not-allowed;
  filter: grayscale(1);
}
.btn-bomb.disabled {
  opacity: 0.3;
  cursor: not-allowed;
}
.btn-bomb.hidden {
  display: none !important;
}

.stone.is-bomb .stone-face::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 10px;
  height: 10px;
  background: radial-gradient(circle, #fca5a5 0%, #ef4444 60%, transparent 100%);
  border-radius: 50%;
  box-shadow: 0 0 8px #ef4444;
  animation: bombPulse 1s infinite alternate;
}
@keyframes bombPulse {
  0% { transform: translate(-50%, -50%) scale(0.8); opacity: 0.8; }
  100% { transform: translate(-50%, -50%) scale(1.2); opacity: 1; }
}

/* Explosion Animation */
.explosion-overlay {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 200%;
  height: 200%;
  transform: translate(-50%, -50%);
  background: radial-gradient(circle, rgba(239, 68, 68, 0.8) 0%, rgba(245, 158, 11, 0) 70%);
  border-radius: 50%;
  pointer-events: none;
  z-index: 10;
  opacity: 0;
  animation: explodeAnim 0.6s ease-out forwards;
}
@keyframes explodeAnim {
  0% { transform: translate(-50%, -50%) scale(0.2); opacity: 1; filter: brightness(2); }
  50% { opacity: 0.8; }
  100% { transform: translate(-50%, -50%) scale(2.5); opacity: 0; }
}

@keyframes destroyAnim {
  0% { transform: scale(1); opacity: 1; filter: brightness(1) sepia(0); }
  50% { transform: scale(1.2); opacity: 0.8; filter: brightness(2) sepia(1) hue-rotate(-50deg); }
  100% { transform: scale(0); opacity: 0; filter: brightness(0); }
}

.stone-destroy {
  animation: destroyAnim 0.35s ease-in forwards !important;
}

@media (max-height: 640px) {
  h1 { font-size: 1rem; margin-bottom: 0.2rem; }
  .settings-panel { padding: 0.3rem 0.5rem; margin-bottom: 0.25rem; }
  .toggle-btn { padding: 0.25rem 0.5rem; font-size: 0.72rem; }
  .score-bar { margin-bottom: 0.2rem; }
  .score-card { padding: 0.25rem 0.7rem; font-size: 1rem; }
  .status-message { font-size: 0.8rem; margin-bottom: 0.2rem; }
  .board { width: min(280px, 88vw); height: min(280px, 88vw); }
}