/* ── Game board SVG ───────────────────────────────────────── */
#game-svg {
  width: 100%;
  height: 100%;
  display: block;
  cursor: default;
}

#screen-game {
  overflow: hidden;
  overscroll-behavior: none;
}

.game-shell {
  height: 100vh;
  height: 100dvh;
  min-height: 0;
  overflow: hidden;
}

.game-board-area {
  overflow: hidden;
}

/* ── Confetti overlay (Lottie) ────────────────────────────── */
#confetti-overlay {
  transition: opacity 0.5s ease;
}

/* ── Victory screen ───────────────────────────────────────── */
.result-card {
  transition: box-shadow 0.3s ease;
}

.victory-title {
  text-shadow: 0 5px 0 #7b2f00;
  letter-spacing: 0.08em;
}

.bento-card {
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 6px 0 0 #DBC7AF;
  border: 2px solid #e4e2e2;
  padding: 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}
.bento-card.winner {
  border-color: #0e6779;
  box-shadow: 0 6px 0 0 #004e5d;
}

.winner-badge {
  background: #A4DE02;
  color: #1a3300;
  font-weight: 800;
  font-size: 11px;
  padding: 3px 10px;
  border-radius: 999px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

/* score number sizes */
.bento-score {
  font-size: clamp(2.5rem, 8vw, 3.5rem);
  font-weight: 900;
  line-height: 1;
  font-family: 'Lilita One', sans-serif;
}

/* ── Header bar (game screen) ─────────────────────────────── */
.game-header {
  background: #1e2e3d;
  padding: 10px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-shrink: 0;
}

/* ── Score row (avatars + turn pill) ─────────────────────── */
.score-row {
  padding: 10px 16px 6px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  flex-shrink: 0;
}

.player-card {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex: 0 1 auto;
}
.player-card--opp { flex-direction: row-reverse; }

.player-info { display: flex; flex-direction: column; min-width: 0; line-height: 1.05; }
.player-info--opp { align-items: flex-end; }

.player-name {
  font-weight: 800;
  font-size: 0.78rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 92px;
}

.player-score {
  font-family: 'Lilita One', sans-serif;
  font-weight: 900;
  font-size: 1.7rem;
  line-height: 1;
}

.turn-dot { display: none; }

/* Avatar ring */
.avatar-ring {
  position: relative;
  flex-shrink: 0;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 3px;
  background: #16222D;
  box-shadow: 0 3px 8px rgba(0,0,0,0.4);
  transition: box-shadow 0.25s ease, transform 0.25s ease;
}
.avatar-ring--me  { box-shadow: 0 0 0 3px rgba(117,189,209,0.55), 0 3px 8px rgba(0,0,0,0.4); }
.avatar-ring--opp { box-shadow: 0 0 0 3px rgba(255,106,0,0.55), 0 3px 8px rgba(0,0,0,0.4); }

.avatar-img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
  display: block;
}

.score-card.active-turn .avatar-ring--me {
  box-shadow: 0 0 0 3px #75bdd1, 0 0 14px 4px rgba(117,189,209,0.75);
  transform: scale(1.06);
}
.score-card.active-turn .avatar-ring--opp {
  box-shadow: 0 0 0 3px #ff6a00, 0 0 14px 4px rgba(255,106,0,0.75);
  transform: scale(1.06);
}
/* new card wrapper carries the active-turn class directly now */
.player-card.active-turn .avatar-ring--me {
  box-shadow: 0 0 0 3px #75bdd1, 0 0 14px 4px rgba(117,189,209,0.75);
  transform: scale(1.06);
}
.player-card.active-turn .avatar-ring--opp {
  box-shadow: 0 0 0 3px #ff6a00, 0 0 14px 4px rgba(255,106,0,0.75);
  transform: scale(1.06);
}

/* ── Turn indicator pill ──────────────────────────────────── */
.turn-indicator {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.turn-pill-label {
  font-family: 'Lilita One', sans-serif;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #A4DE02;
  text-shadow: 0 0 8px rgba(164,222,2,0.6);
  transition: color 0.25s ease, text-shadow 0.25s ease;
  white-space: nowrap;
}

.turn-track {
  position: relative;
  width: 84px;
  height: 24px;
  border-radius: 999px;
  background: #16222D;
  box-shadow: inset 0 2px 4px rgba(0,0,0,0.5), inset 0 0 0 1px rgba(255,255,255,0.06);
  flex-shrink: 0;
}

.turn-knob {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #A4DE02;
  box-shadow: 0 0 8px 2px rgba(164,222,2,0.85), 0 1px 2px rgba(0,0,0,0.4);
  transition: left 0.32s cubic-bezier(0.4,0,0.2,1), background 0.32s ease, box-shadow 0.32s ease;
}

#header-turn-badge[data-state="bot"] .turn-knob {
  left: calc(100% - 21px);
  background: #ff6a00;
  box-shadow: 0 0 8px 2px rgba(255,106,0,0.85), 0 1px 2px rgba(0,0,0,0.4);
}
#header-turn-badge[data-state="over"] .turn-knob {
  background: #9CA3AF;
  box-shadow: 0 0 6px 1px rgba(156,163,175,0.6);
}

.turn-pill-label[data-tone="bot"] {
  color: #ffb380;
  text-shadow: 0 0 8px rgba(255,106,0,0.6);
}
.turn-pill-label[data-tone="over"] {
  color: #9CA3AF;
  text-shadow: none;
}

/* ── Board line / box effects ────────────────────────────── */
.board-wrapper { position: relative; overflow: visible; }

@keyframes lineGlowFlash {
  0%   { filter: drop-shadow(0 0 0 var(--glow-color, #fff)); }
  35%  { filter: drop-shadow(0 0 9px var(--glow-color, #fff)) drop-shadow(0 0 3px var(--glow-color, #fff)); }
  100% { filter: drop-shadow(0 0 0 transparent); }
}
.line-flash { animation: lineGlowFlash 0.55s ease-out; }

.kbd-cursor-ring {
  animation: kbdCursorPulse 1s ease-in-out infinite;
  transform-box: fill-box;
  transform-origin: center;
}
@keyframes kbdCursorPulse {
  0%, 100% { opacity: 0.55; transform: scale(1); }
  50%      { opacity: 1;    transform: scale(1.12); }
}

.line-hint-pulse {
  animation: hintPulse 0.85s ease-in-out infinite;
}
@keyframes hintPulse {
  0%, 100% { filter: drop-shadow(0 0 3px #FFD700); opacity: 0.65; }
  50%      { filter: drop-shadow(0 0 10px #FFD700); opacity: 1; }
}

@keyframes boxFlare {
  0%   { filter: brightness(1) drop-shadow(0 0 0 rgba(255,255,255,0)); }
  30%  { filter: brightness(1.9) drop-shadow(0 0 14px currentColor); }
  100% { filter: brightness(1) drop-shadow(0 0 0 rgba(255,255,255,0)); }
}
.box-flare { animation: boxFlare 0.6s ease-out; }

.box-score-popup {
  position: absolute;
  transform: translate(-50%, -50%);
  font-family: 'Lilita One', sans-serif;
  font-weight: 900;
  font-size: 2.4rem;
  pointer-events: none;
  z-index: 20;
  animation: scorePopupFloat 1.4s ease-out forwards;
}
.popup-player { color: #75bdd1; text-shadow: 0 0 16px rgba(117,189,209,1), 0 0 4px #fff, 0 2px 3px rgba(0,0,0,0.6); }
.popup-bot    { color: #ff6a00; text-shadow: 0 0 16px rgba(255,106,0,1), 0 0 4px #fff, 0 2px 3px rgba(0,0,0,0.6); }
@keyframes scorePopupFloat {
  0%   { opacity: 0; transform: translate(-50%, -50%) scale(0.4); }
  25%  { opacity: 1; transform: translate(-50%, -50%) scale(1.35); }
  100% { opacity: 0; transform: translate(-50%, -140%) scale(1.1); }
}

.lottie-burst {
  position: absolute;
  width: 170px;
  height: 170px;
  transform: translate(-50%, -50%);
  pointer-events: none;
  z-index: 19;
}

/* ── Radial dot burst (box-complete feedback) ─────────────── */
.burst-dot {
  position: absolute;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  transform: translate(-50%, -50%) rotate(var(--angle)) translateX(0) scale(1);
  animation: burstFly 0.6s ease-out forwards;
  pointer-events: none;
  z-index: 18;
}
@keyframes burstFly {
  0%   { transform: translate(-50%, -50%) rotate(var(--angle)) translateX(0)    scale(1);   opacity: 1; }
  100% { transform: translate(-50%, -50%) rotate(var(--angle)) translateX(52px) scale(0.3); opacity: 0; }
}

/* ── Bottom action bar (Undo / Hint) ─────────────────────── */
.action-bar {
  display: flex;
  gap: 10px;
  padding: 10px 16px calc(10px + env(safe-area-inset-bottom, 0px));
}

.action-btn {
  flex: 1;
  position: relative;
  min-height: 50px;
  font-size: 0.95rem;
}

.action-badge {
  position: absolute;
  top: -7px;
  right: -6px;
  min-width: 20px;
  height: 20px;
  padding: 0 4px;
  border-radius: 999px;
  background: #ff4747;
  color: #fff;
  font-family: 'Lilita One', sans-serif;
  font-size: 0.72rem;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 4px rgba(0,0,0,0.4), 0 0 0 2px #1e2e3d;
}

@keyframes badgeGrantPop {
  0%   { transform: scale(1); }
  40%  { transform: scale(1.5); }
  100% { transform: scale(1); }
}
.action-badge.badge-grant { animation: badgeGrantPop 0.5s ease-out; }

.grant-popup {
  position: absolute;
  top: -18px;
  right: 4px;
  font-family: 'Lilita One', sans-serif;
  font-weight: 900;
  font-size: 0.85rem;
  color: #A4DE02;
  text-shadow: 0 0 8px rgba(164,222,2,0.8);
  pointer-events: none;
  animation: scorePopupFloat 0.95s ease-out forwards;
}

@media (min-width: 768px) {
  .game-header { padding: 10px 24px; }
  .score-row   { padding: 10px 24px 8px; }
  .bento-score { font-size: 3rem; }
  .avatar-ring { width: 60px; height: 60px; }
  .player-name { font-size: 0.85rem; max-width: 130px; }
  .player-score { font-size: 2rem; }
  .turn-track  { width: 96px; height: 28px; }
  .turn-knob   { width: 22px; height: 22px; }
  #header-turn-badge[data-state="bot"] .turn-knob { left: calc(100% - 25px); }
  .action-bar  { padding: 12px 24px calc(12px + env(safe-area-inset-bottom, 0px)); }
}

/* ═══════════════════════════════════════════════════════════════
   RESULT SCREEN — Victory / Defeat / Draw
   ═══════════════════════════════════════════════════════════════ */

#screen-result {
  overflow: hidden;
  overscroll-behavior: none;
}

.result-bg {
  background-color: #1a1208;
  background-image:
    linear-gradient(rgba(10,8,4,0.45), rgba(10,8,4,0.45)),
    url('../assets/bg-board.jpg');
  background-size: cover, cover;
  background-position: center, center;
  background-repeat: no-repeat, no-repeat;
  background-attachment: fixed, fixed;
}
@supports (-webkit-touch-callout: none) {
  .result-bg { background-attachment: scroll, scroll; }
}

.result-shell {
  height: 100vh;
  height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(8px, 2vh, 20px) 14px;
}

.result-card2 {
  position: relative;
  overflow: hidden;
  width: 100%;
  max-width: 420px;
  max-height: 100%;
  border-radius: 28px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: clamp(6px, 1.6vh, 14px);
  padding: clamp(14px, 3.5vh, 28px) clamp(16px, 5vw, 26px) clamp(30px, 7vh, 46px);
  box-shadow: 0 18px 40px rgba(0,0,0,0.45);
  transition: box-shadow 0.3s ease;
}

.result-card2--gold {
  background: linear-gradient(180deg, #FFFCF3 0%, #F6EBD8 100%);
  border: 2px solid rgba(219,199,175,0.6);
}
.result-card2--purple {
  background: linear-gradient(180deg, #4B3B73 0%, #362955 100%);
  border: 2px solid rgba(255,255,255,0.12);
}
.result-card2--tan {
  background: linear-gradient(180deg, #EDE0C8 0%, #DCC9A3 100%);
  border: 2px solid rgba(140,110,60,0.3);
}

.result-banner-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  margin-top: 2px;
}
.result-icon {
  width: clamp(46px, 11vh, 76px);
  height: auto;
  filter: drop-shadow(0 6px 10px rgba(0,0,0,0.35));
  animation: resultIconSway 2.2s ease-in-out infinite;
  transform-origin: 50% 85%;
}
.result-banner {
  width: clamp(180px, 46vw, 300px);
  height: auto;
  margin-top: -6px;
  filter: drop-shadow(0 4px 8px rgba(0,0,0,0.3));
  animation: resultBannerBounce 1.8s ease-in-out infinite;
}

@keyframes resultIconSway {
  0%, 100% { transform: translateX(-4px) rotate(-4deg); }
  50%      { transform: translateX(4px)  rotate(4deg); }
}
@keyframes resultBannerBounce {
  0%, 100% { transform: translateY(0)    scale(1); }
  50%      { transform: translateY(-3px) scale(1.03); }
}

.result-subtitle {
  font-family: 'Lilita One', sans-serif;
  font-size: clamp(0.8rem, 2.4vh, 0.95rem);
  letter-spacing: 0.02em;
  text-align: center;
  color: rgba(44,62,80,0.6);
}
.result-card2--purple .result-subtitle { color: rgba(255,255,255,0.7); }

.result-score-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  margin-top: 2px;
}

.result-player-card {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: clamp(10px, 2.4vh, 16px) 8px clamp(8px, 1.8vh, 12px);
  border-radius: 18px;
  background: rgba(255,255,255,0.55);
  border: 2px solid rgba(44,62,80,0.12);
}
.result-card2--purple .result-player-card {
  background: rgba(255,255,255,0.08);
  border-color: rgba(255,255,255,0.15);
}
.result-player-card.winner {
  border-color: #0e6779;
  box-shadow: 0 0 0 3px rgba(14,103,121,0.25);
}
.result-player-card--opp.winner {
  border-color: #ff6a00;
  box-shadow: 0 0 0 3px rgba(255,106,0,0.25);
}

.result-avatar-wrap {
  position: relative;
  display: block;
  width: clamp(48px, 11vh, 68px);
  height: clamp(48px, 11vh, 68px);
  flex-shrink: 0;
}
.result-avatar {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
  display: block;
  background: #16222D;
  box-shadow: 0 3px 8px rgba(0,0,0,0.35);
}
.result-crown {
  position: absolute;
  top: -32px;
  left: 50%;
  transform: translateX(-50%) rotate(-4deg);
  width: 50px;
  height: auto;
  filter: drop-shadow(0 3px 4px rgba(0,0,0,0.4));
  z-index: 2;
}

.result-name {
  font-weight: 800;
  font-size: 0.7rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}
.result-score-num {
  font-family: 'Lilita One', sans-serif;
  font-weight: 900;
  font-size: clamp(1.6rem, 5.5vh, 2.4rem);
  line-height: 1;
}

.result-winner-badge {
  font-weight: 800;
  font-size: 0.62rem;
  padding: 2px 9px;
  border-radius: 999px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #1a3300;
}
.result-winner-badge--green  { background: #A4DE02; color: #1a3300; }
.result-winner-badge--orange { background: #ff6a00; color: #fff; }

.result-vs-chip {
  flex-shrink: 0;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid rgba(44,62,80,0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Lilita One', sans-serif;
  font-size: 0.65rem;
  font-weight: 700;
  color: #2C3E50;
  box-shadow: 0 3px 6px rgba(0,0,0,0.2);
}

.result-buttons {
  display: flex;
  flex-direction: column;
  gap: clamp(11px, calc(1.6vh + 5px), 15px);
  width: 100%;
  margin-top: 2px;
}
.result-buttons .game-btn {
  min-height: clamp(44px, 7vh, 56px);
  font-size: clamp(0.9rem, 2.6vh, 1.05rem);
}

.result-grass {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  height: clamp(22px, 6vh, 40px);
  object-fit: cover;
  object-position: center top;
  pointer-events: none;
}
