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

body {
  margin: 0;
  font-family: "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  background: radial-gradient(circle at top, #1f2937, #0f172a 55%);
  color: #f8fafc;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

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

.layout {
  width: min(96vw, 1200px);
}

.board-panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.board-toolbar {
  display: flex;
  justify-content: flex-end;
}

.board-toolbar button {
  appearance: none;
  border: none;
  border-radius: 999px;
  padding: 8px 16px;
  font-size: 0.9rem;
  font-weight: 600;
  background: rgba(148, 187, 233, 0.2);
  color: #e2e8f0;
  letter-spacing: 0.02em;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease;
}

.board-toolbar button:hover {
  background: rgba(148, 187, 233, 0.35);
  color: #ffffff;
}

.board {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  /* Red background from board theme, shows as letterbox bars */
  background: #ff2000 url("board.jpg") center / contain no-repeat;
  border-radius: 0;
  box-shadow: none;
  overflow: hidden;
  touch-action: none;
  --chip-size: clamp(68px, 9vw, 110px);
}

/* Optional board overlay removed to keep full-screen image clear */

.player {
  position: absolute;
  width: var(--chip-size, clamp(64px, 8vw, 92px));
  height: var(--chip-size, clamp(64px, 8vw, 92px));
  --player-primary: #2563eb;
  --player-secondary: #1d4ed8;
  --player-accent: color-mix(in srgb, var(--player-primary) 70%, white 30%);
  border-radius: 50%;
  background:
    radial-gradient(circle at 35% 28%, rgba(255, 255, 255, 0.35), rgba(255, 255, 255, 0) 60%),
    linear-gradient(160deg, var(--player-primary), var(--player-secondary));
  box-shadow:
    0 16px 34px rgba(15, 23, 42, 0.45),
    inset 0 4px 10px rgba(255, 255, 255, 0.35),
    inset 0 -8px 12px rgba(15, 23, 42, 0.3);
  border: 3px solid rgba(255, 255, 255, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: "Heebo", "Rubik", "Noto Sans Hebrew", "Segoe UI", Arial, sans-serif;
  font-weight: 800;
  font-size: clamp(10px, calc(var(--chip-size, 80px) * 0.40), 48px);
  line-height: 1;
  color: #ffffff;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.55);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  cursor: grab;
  user-select: none;
  touch-action: none;
  transform: translate(-50%, -50%);
  transition: transform 0.2s ease, box-shadow 0.25s ease;
  direction: rtl;
  z-index: 2;
}

.player::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: radial-gradient(circle at 50% 12%, rgba(255, 255, 255, 0.35), transparent 60%);
  opacity: 0.5;
  transition: opacity 0.18s ease;
  pointer-events: none;
}

.player::after {
  content: "";
  position: absolute;
  inset: 8%;
  border-radius: inherit;
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.25);
  pointer-events: none;
}

.player:focus-visible {
  outline: none;
  box-shadow:
    0 0 0 6px rgba(148, 187, 233, 0.45),
    0 20px 42px rgba(15, 23, 42, 0.55);
}

.player:active,
.player.dragging {
  cursor: grabbing;
  transform: translate(-50%, -50%) scale(1.05);
  box-shadow:
    0 20px 40px rgba(15, 23, 42, 0.55),
    inset 0 6px 14px rgba(255, 255, 255, 0.6),
    inset 0 -10px 18px rgba(2, 6, 23, 0.35);
}

.player.dragging::after,
.player:active::after {
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.35);
}

.player.dragging::before,
.player:active::before {
  opacity: 1;
}

.player:not(.dragging) {
  transition: transform 0.2s ease, box-shadow 0.25s ease;
}

/* Visual snap-point markers removed */

@media (max-width: 720px) {
  body {
    padding: 0;
  }

  .board-toolbar {
    justify-content: center;
  }
}

/* Fullscreen corner button */
.fs-btn {
  position: fixed;
  top: 12px;
  right: 12px;
  z-index: 1000;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.5);
  background: rgba(15, 23, 42, 0.55);
  color: #ffffff;
  font-size: 18px;
  line-height: 1;
  display: grid;
  place-items: center;
  cursor: pointer;
  backdrop-filter: blur(4px);
  transition: background 0.2s ease, transform 0.15s ease, opacity 0.2s ease;
}
.fs-btn:hover { background: rgba(15, 23, 42, 0.7); }
.fs-btn:active { transform: scale(0.96); }
.fs-btn.hidden { opacity: 0; pointer-events: none; }

/* Winner banner */
/* old top banner removed */

/* Full-screen win overlay with animation */
.win-overlay {
  position: fixed;
  inset: 0;
  z-index: 3000;
  display: none;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background: radial-gradient(1200px 800px at 50% 50%, rgba(255,255,255,0.04), rgba(0,0,0,0.9));
}
.win-overlay.show { display: flex; animation: fadeIn 300ms ease-out both; }

.win-overlay::before {
  content: "";
  position: absolute;
  inset: -20%;
  background: conic-gradient(from 0deg, #f59e0b, #ef4444, #3b82f6, #22c55e, #f59e0b);
  filter: blur(60px);
  opacity: 0.18;
  animation: panGradient 6s linear infinite;
}

.win-content {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.win-title {
  position: absolute;
  font-family: "Heebo", "Rubik", "Noto Sans Hebrew", "Segoe UI", Arial, sans-serif;
  font-weight: 800;
  /* Make the winning text larger */
  font-size: clamp(36px, 8vw, 110px);
  line-height: 1.1;
  color: #ffffff;
  text-shadow: 0 10px 30px rgba(0,0,0,0.4), 0 2px 6px rgba(0,0,0,0.5);
  letter-spacing: 0.02em;
  /* Keep glow only; movement handled by JS */
  animation: pulseGlow 2.4s ease-in-out infinite 600ms;
  will-change: transform;
  pointer-events: none;
}

#confettiCanvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

@keyframes fadeIn { from { opacity: 0 } to { opacity: 1 } }
@keyframes popIn { from { transform: scale(.9); opacity: 0 } to { transform: scale(1); opacity: 1 } }
@keyframes pulseGlow { 0%,100% { text-shadow: 0 0 0 rgba(255,255,255,0.4), 0 0 0 rgba(255,255,255,0.2) } 50% { text-shadow: 0 0 24px rgba(255,255,255,0.65), 0 0 8px rgba(255,255,255,0.45) } }
@keyframes panGradient { 0% { transform: rotate(0deg) } 100% { transform: rotate(360deg) } }
