:root {
  --bg1: #f2f5f9;
  --card: rgba(255, 255, 255, 0.95);
  --accent: #7ecbff;
  --wood-top: #f9ead0;
  --wood-bottom: #e8d0a3;
}

/* RESET */
* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  font-family: Inter, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background:
    radial-gradient(1200px 400px at 10% 10%, #eaf6ff 0%, transparent 12%),
    radial-gradient(1200px 500px at 95% 90%, #fff6e8 0%, transparent 18%),
    var(--bg1);
  padding: 28px;
}

.shell {
  width: 980px;
  max-width: 98%;
}

/* =========================
     TOP UI
========================= */

.top {
  display: flex;
  gap: 14px;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
}

.logo {
  width: 52px;
  height: 52px;
  border-radius: 12px;
  background: linear-gradient(145deg, #7ecbff, #5aaae6);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 700;
  box-shadow:
    0 8px 22px rgba(90, 130, 170, 0.18),
    inset 0 -6px 12px rgba(0, 0, 0, 0.08);
  font-size: 20px;
}

.brand h1 {
  margin: 0;
  font-size: 18px;
  color: #22333b;
}

.brand p {
  margin: 0;
  font-size: 12px;
  color: #60707b;
}

.controls {
  display: flex;
  gap: 12px;
  align-items: center;
}

.panel {
  background: var(--card);
  padding: 10px 14px;
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(18, 24, 32, 0.06);
  display: flex;
  align-items: center;
  gap: 12px;
}

#turnText {
  font-weight: 700;
  color: #123;
  font-size: 16px;
}

.scoreBox {
  text-align: center;
  min-width: 96px;
}

.scoreBox .lbl {
  font-size: 12px;
  color: #6c7a82;
}

.scoreBox .num {
  font-size: 20px;
  font-weight: 800;
  color: #24333b;
}

button.btn {
  border: 0;
  background: linear-gradient(180deg, #fff, #f1f1f1);
  padding: 8px 12px;
  border-radius: 10px;
  cursor: pointer;
  font-weight: 700;
  box-shadow: 0 6px 16px rgba(10, 20, 30, 0.06);
  transition: 0.1s ease-in-out;
}

button.btn:active {
  transform: translateY(1px);
}

/* =========================
     BOARD + CANVAS
========================= */

.board-wrap {
  display: block;
  margin-top: 16px;
  text-align: center;
}

/* ❗ CANVAS UTAMA FIX — tidak melar */
#game {
  width: 900px;
  height: 420px;
  border-radius: 18px;
  display: block;
  margin: 0 auto;
  box-shadow: 0 18px 45px rgba(20, 30, 40, 0.12);
  border: 2px solid rgba(0, 0, 0, 0.03);
  background: linear-gradient(180deg, var(--wood-top), var(--wood-bottom));
}

/* =========================
   POPUP BACKDROP
========================= */
#winPopup {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 999;
  backdrop-filter: blur(4px);
}

#winPopup.hidden {
  display: none !important;
}

/* =========================
   POPUP BOX
========================= */
.popup-content {
  background: linear-gradient(135deg, #ffffff, #e8e8ff);
  padding: 30px 45px;
  border-radius: 16px;
  text-align: center;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.25);
  font-size: 24px;
  color: #333;
  animation: winZoom 0.55s cubic-bezier(.17,.89,.34,1.35);
  border: 2px solid #c4c4ff;
}

/* WIN MESSAGE */
.popup-content p {
  margin-bottom: 22px;
  font-weight: bold;
  font-size: 26px;
  color: #4a3eff;
  text-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

/* =========================
   BUTTON STYLE
========================= */
#closeWin {
  background: linear-gradient(135deg, #5c4bff, #8073ff);
  color: white;
  border: none;
  padding: 14px 26px;
  border-radius: 12px;
  font-size: 20px;
  cursor: pointer;
  font-weight: bold;
  box-shadow: 0 4px 10px rgba(0,0,0,0.25);
  transition: 0.25s ease;
}

#closeWin:hover {
  background: linear-gradient(135deg, #4738e6, #6a56ff);
  transform: scale(1.05);
  box-shadow: 0 8px 20px rgba(0,0,0,0.35);
}

/* Icon spacing */
#closeWin i {
  margin-right: 6px;
  font-size: 20px;
}

/* =========================
   FIREWORK CANVAS
========================= */
#fireCanvas {
  position: absolute;
  top: -20px;
  left: 50%;
  transform: translateX(-50%);
  width: 900px;
  height: 140px;
  pointer-events: none;
  z-index: 20;
  display: none;
  background: transparent !important;
}

/* =========================
   CONFETTI CANVAS
========================= */
#confettiCanvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
  z-index: 9999;
  display: none;
}

/* =========================
   FLASH EFFECT
========================= */
#flashEffect {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: white;
  opacity: 0;
  pointer-events: none;
  z-index: 99999999;
}

/* =========================
   ANIMATION
========================= */
@keyframes winZoom {
  0% {
    transform: scale(0.1) rotate(-20deg);
    opacity: 0;
  }
  60% {
    transform: scale(1.15) rotate(4deg);
    opacity: 1;
  }
  100% {
    transform: scale(1) rotate(0deg);
  }
}


