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

body {
  min-height: 100vh;
  font-family: 'Nunito', sans-serif;
  background:
    radial-gradient(circle at 15% 10%, rgba(255, 157, 92, 0.18), transparent 40%),
    radial-gradient(circle at 85% 15%, rgba(110, 214, 168, 0.14), transparent 38%),
    radial-gradient(circle at 90% 90%, rgba(255, 157, 206, 0.12), transparent 42%),
    radial-gradient(ellipse at top, #8a5230 0%, #5c331d 70%, #3f2113 100%);
  color: #fff4e6;
  padding: 2rem 1rem 4rem;
  position: relative;
  overflow-x: hidden;
}

/* scattered craft-table props, purely decorative */
body::before,
body::after {
  content: '';
  position: fixed;
  width: 90px;
  height: 90px;
  border-radius: 50% 45% 55% 50% / 50% 55% 45% 50%;
  pointer-events: none;
  z-index: 0;
  opacity: 0.5;
  filter: blur(0.5px);
}

body::before {
  top: 6%;
  left: 4%;
  background: radial-gradient(circle at 35% 30%, rgba(200,255,210,0.55), rgba(46,154,88,0.35) 60%, transparent 75%);
}

body::after {
  bottom: 8%;
  right: 5%;
  width: 110px;
  height: 110px;
  background: radial-gradient(circle at 40% 35%, rgba(255,217,138,0.5), rgba(255,157,206,0.3) 60%, transparent 75%);
}

main {
  max-width: 900px;
  margin: 0 auto;
  position: relative;
  z-index: 1;
}

header {
  text-align: center;
  margin-bottom: 1.75rem;
}

h1 {
  font-family: 'Baloo 2', sans-serif;
  font-size: clamp(2.2rem, 6vw, 3.2rem);
  letter-spacing: 0.5px;
  color: #ffd98a;
  text-shadow: 0 3px 0 rgba(0,0,0,0.35), 0 0 24px rgba(255, 200, 100, 0.35);
}

.subtitle {
  margin-top: 0.4rem;
  font-weight: 700;
  color: #f0d9c0;
  opacity: 0.9;
}

.scoreboard {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: clamp(1rem, 4vw, 2.5rem);
  margin-top: 1.5rem;
}

.score {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 70px;
}

.score .label {
  font-weight: 800;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  opacity: 0.75;
}

.score .value {
  font-family: 'Baloo 2', sans-serif;
  font-size: 2.2rem;
}

.score.you .value { color: #8ee6a3; }
.score.them .value { color: #ff9d8a; }

.turn-info {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
  min-width: 160px;
}

#turnCounter {
  font-weight: 700;
  font-size: 0.85rem;
  opacity: 0.85;
}

.cells-left {
  font-size: 0.72rem;
  font-weight: 700;
  opacity: 0.6;
}

.timer-bar {
  width: 160px;
  height: 8px;
  border-radius: 999px;
  background: rgba(0,0,0,0.35);
  overflow: hidden;
  box-shadow: inset 0 1px 3px rgba(0,0,0,0.5);
}

.timer-fill {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, #ffd98a, #ff9d5c);
  transition: width 1s linear;
}

.mode-toggle {
  display: flex;
  justify-content: center;
  gap: 0.7rem;
  margin-bottom: 1.25rem;
}

.mode-btn {
  font-family: 'Baloo 2', sans-serif;
  font-size: 0.95rem;
  padding: 0.6rem 1.3rem;
  border: none;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  color: #f0d9c0;
  font-weight: 700;
  cursor: pointer;
  box-shadow: inset 0 0 0 1.5px rgba(255,255,255,0.18);
  transition: transform 0.1s ease, background 0.15s ease, box-shadow 0.15s ease;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.mode-btn:hover { transform: translateY(-1px); }

.mode-btn.active {
  background: linear-gradient(160deg, #ffd98a, #ff9d5c);
  color: #4a2a10;
  box-shadow: 0 4px 0 #b5622a, 0 6px 14px rgba(0,0,0,0.3);
}

.mode-check {
  font-size: 0.85rem;
  color: #2e9a58;
}

.board-panel {
  background:
    radial-gradient(circle, rgba(255,255,255,0.07) 1.5px, transparent 1.5px) 0 0/16px 16px,
    linear-gradient(160deg, #b97a4a, #96582f);
  border-radius: 22px;
  padding: 1.1rem;
  box-shadow:
    0 10px 30px rgba(0,0,0,0.35),
    inset 0 0 0 3px rgba(255,255,255,0.1),
    inset 0 0 0 7px rgba(58, 30, 12, 0.35);
  max-width: 460px;
  margin: 0 auto;
}

.grid {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 5px;
  aspect-ratio: 1;
}

.cell {
  position: relative;
  border-radius: 38% 62% 55% 45% / 45% 40% 60% 55%;
  background: linear-gradient(160deg, #d9ac78, #c48f56);
  box-shadow: inset 0 2px 4px rgba(255,255,255,0.35), inset 0 -3px 6px rgba(70,40,15,0.35);
  cursor: pointer;
  transition: transform 0.12s ease, filter 0.12s ease;
}

.cell:hover:not(.burned):not(.disabled) {
  transform: scale(1.06);
  filter: brightness(1.08);
}

.cell.pending-place {
  box-shadow: 0 0 0 3px #6be08a, inset 0 2px 4px rgba(255,255,255,0.35);
}

.cell.pending-shoot {
  box-shadow: 0 0 0 3px #ff7a5c, inset 0 2px 4px rgba(255,255,255,0.35);
}

.cell.pending-place.pending-shoot {
  box-shadow: 0 0 0 3px #6be08a, 0 0 0 6px #ff7a5c, inset 0 2px 4px rgba(255,255,255,0.35);
}

.cell.disabled {
  cursor: default;
}

/* --- guys / materials (cosmetic only, each a little character) --- */
.guy {
  position: absolute;
  inset: 12%;
  border-radius: 45% 55% 60% 40% / 55% 45% 55% 45%;
  animation: pop 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes pop {
  from { transform: scale(0.2); opacity: 0; }
  to   { transform: scale(1); opacity: 1; }
}

/* shared face parts -- positioned/shaped per material below */
.eye {
  position: absolute;
  width: 16%;
  height: 16%;
  top: 36%;
  background: #2a1810;
  border-radius: 50%;
}
.eye-l { left: 26%; }
.eye-r { right: 26%; }

.mouth {
  position: absolute;
  left: 50%;
  top: 58%;
  width: 26%;
  height: 12%;
  transform: translateX(-50%);
  background: #2a1810;
  border-radius: 0 0 999px 999px;
}

/* --- slime: melty, googly, wide grin --- */
.guy.slime {
  background: radial-gradient(circle at 35% 30%, rgba(200,255,210,0.9), #4ecb7a 55%, #2e9a58 100%);
  box-shadow: inset 0 -4px 6px rgba(0,60,20,0.4), 0 0 10px rgba(120,255,160,0.5);
  animation: pop 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), wobble 2.4s ease-in-out infinite 0.3s;
}
.guy.slime::after {
  content: '';
  position: absolute;
  left: 30%;
  bottom: -18%;
  width: 22%;
  height: 26%;
  background: #2e9a58;
  border-radius: 0 50% 50% 50%;
}
.guy.slime .eye {
  width: 24%;
  height: 24%;
  top: 26%;
  background: #fff;
  box-shadow: inset 0 0 0 2px rgba(0,0,0,0.08);
}
.guy.slime .eye::after {
  content: '';
  position: absolute;
  width: 55%;
  height: 55%;
  top: 22%;
  left: 22%;
  background: #17331f;
  border-radius: 50%;
}
.guy.slime .mouth {
  width: 32%;
  height: 20%;
  top: 56%;
  border-radius: 50%;
  background: #134025;
}

/* --- putty: smooth, sleepy-happy, blushing --- */
.guy.putty {
  background: linear-gradient(160deg, #e8b4e0, #c77bc0);
  border-radius: 60% 40% 45% 55% / 40% 55% 45% 60%;
  box-shadow: inset 0 -3px 5px rgba(90,20,80,0.35);
}
.guy.putty::before,
.guy.putty::after {
  content: '';
  position: absolute;
  width: 16%;
  height: 9%;
  top: 54%;
  border-radius: 50%;
  background: rgba(160, 30, 90, 0.3);
}
.guy.putty::before { left: 10%; }
.guy.putty::after { right: 10%; }
.guy.putty .eye {
  width: 16%;
  height: 9%;
  top: 38%;
  background: transparent;
  border-top: 2.5px solid #5a1f52;
  border-radius: 999px 999px 0 0;
}
.guy.putty .mouth {
  width: 18%;
  height: 9%;
  top: 55%;
  border-radius: 0 0 999px 999px;
  background: transparent;
  border-bottom: 2.5px solid #5a1f52;
}

/* --- clay: coil-built pinch pot, pinched nose, flat stare --- */
.guy.clay {
  background:
    repeating-radial-gradient(circle at 50% 45%, rgba(0,0,0,0.08) 0, rgba(0,0,0,0.08) 1.5px, transparent 1.5px, transparent 7px),
    radial-gradient(circle at 25% 25%, rgba(255,255,255,0.18) 0 6%, transparent 7%),
    linear-gradient(160deg, #d97b4a, #a8502a);
  box-shadow: inset 0 -3px 5px rgba(80,30,10,0.4);
}
.guy.clay::before {
  content: '';
  position: absolute;
  left: 50%;
  top: 46%;
  width: 12%;
  height: 12%;
  transform: translateX(-50%);
  background: #8a4322;
  border-radius: 50%;
  box-shadow: inset 0 1px 2px rgba(0,0,0,0.3);
}
.guy.clay .eye {
  width: 12%;
  height: 12%;
  top: 32%;
}
.guy.clay .mouth {
  width: 22%;
  height: 3px;
  top: 62%;
  border-radius: 3px;
}

/* --- fuzzy: pom-pom with ears --- */
.guy.fuzzy {
  background: #f2e2c4;
  box-shadow:
    0 0 0 3px #f2e2c4,
    2px -3px 0 2px #f2e2c4,
    -3px 2px 0 2px #f2e2c4,
    3px 3px 0 1px #f2e2c4,
    -2px -3px 0 1px #f2e2c4,
    inset 0 -3px 5px rgba(150,120,60,0.3);
}
.guy.fuzzy::before,
.guy.fuzzy::after {
  content: '';
  position: absolute;
  top: -16%;
  width: 26%;
  height: 26%;
  background: #f2e2c4;
  border-radius: 50%;
  box-shadow: inset 0 -2px 3px rgba(150,120,60,0.3);
}
.guy.fuzzy::before { left: 4%; }
.guy.fuzzy::after { right: 4%; }
.guy.fuzzy .eye {
  width: 13%;
  height: 13%;
  top: 38%;
}
.guy.fuzzy .mouth {
  width: 14%;
  height: 8%;
  top: 58%;
  border-radius: 50%;
  background: #7a5c2e;
}

/* --- sparkly: glam gem with a crown and glitter glints --- */
.guy.sparkly {
  background: linear-gradient(135deg, #ffd98a, #ff9dce, #9dc4ff, #ffd98a);
  background-size: 300% 300%;
  box-shadow: 0 0 12px rgba(255, 220, 150, 0.7);
  animation: pop 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), shimmer 3s ease infinite;
}
.guy.sparkly::before {
  content: '';
  position: absolute;
  left: 50%;
  top: -22%;
  width: 0;
  height: 0;
  transform: translateX(-50%);
  border-left: 10% solid transparent;
  border-right: 10% solid transparent;
  border-bottom: 16% solid #ffe6a8;
}
.guy.sparkly::after {
  content: '\2726';
  position: absolute;
  right: -8%;
  top: -6%;
  font-size: 0.7rem;
  color: #fff8e0;
  animation: twinkle-glint 1.6s ease-in-out infinite;
}
.guy.sparkly .eye {
  width: 13%;
  height: 13%;
  top: 36%;
  background: #4a2a52;
  box-shadow: 0 0 4px rgba(255,255,255,0.8);
}
.guy.sparkly .mouth {
  width: 20%;
  height: 8%;
  top: 58%;
  border-radius: 0 0 999px 999px;
  background: #4a2a52;
}

@keyframes wobble {
  0%, 100% { border-radius: 45% 55% 60% 40% / 55% 45% 55% 45%; }
  50%      { border-radius: 55% 45% 45% 55% / 45% 55% 45% 55%; }
}

@keyframes shimmer {
  0%   { background-position: 0% 50%; }
  50%  { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

@keyframes twinkle-glint {
  0%, 100% { opacity: 0.3; transform: scale(0.8); }
  50%      { opacity: 1; transform: scale(1.15); }
}

/* burned cells */
.cell.burned {
  background: linear-gradient(160deg, #4a362a, #2a1e16);
  box-shadow: inset 0 3px 6px rgba(0,0,0,0.6);
  cursor: default;
}

.cell.burned::after {
  content: '';
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(35deg, transparent 46%, rgba(0,0,0,0.6) 47%, transparent 48%),
    linear-gradient(-50deg, transparent 46%, rgba(0,0,0,0.6) 47%, transparent 48%);
}

.cell.burned.kill-scored::before {
  content: '\1F4A5';
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  z-index: 1;
}

.cell.burned.kill-lost::after {
  content: '\1F480';
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  z-index: 1;
  background-image: none;
}

.controls {
  text-align: center;
  margin-top: 1.75rem;
}

#statusMsg {
  font-weight: 700;
  margin-bottom: 0.9rem;
  min-height: 1.4em;
}

button {
  font-family: 'Baloo 2', sans-serif;
  font-size: 1.05rem;
  padding: 0.7rem 1.8rem;
  border: none;
  border-radius: 999px;
  background: linear-gradient(160deg, #ffd98a, #ff9d5c);
  color: #4a2a10;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 6px 0 #b5622a, 0 8px 16px rgba(0,0,0,0.35);
  transition: transform 0.1s ease, box-shadow 0.1s ease;
}

button:not(:disabled):hover { transform: translateY(-2px); }
button:not(:disabled):active { transform: translateY(2px); box-shadow: 0 3px 0 #b5622a; }

button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  box-shadow: 0 6px 0 rgba(0,0,0,0.2);
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(15, 8, 4, 0.72);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
}

.modal.hidden { display: none; }

.modal-card {
  background: linear-gradient(160deg, #b97a4a, #7a4526);
  border-radius: 24px;
  padding: 2.2rem 2.5rem;
  text-align: center;
  max-width: 360px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}

.modal-card h2 {
  font-family: 'Baloo 2', sans-serif;
  font-size: 1.7rem;
  color: #ffd98a;
  margin-bottom: 0.6rem;
}

.modal-card p {
  margin-bottom: 1.4rem;
  font-weight: 700;
}

@media (max-width: 640px) {
  .board-panel { max-width: 100%; width: 100%; }
  .mode-toggle { flex-wrap: wrap; }
}
