/* =========================================================================
   LÀNG GAME VIỆT — STARLIGHT NEON PIXEL DARK THEME (DEFAULT) & CRISP HIGHLIGHTS
   ========================================================================= */

@import url('https://fonts.googleapis.com/css2?family=Press+Start+2P&family=Silkscreen:wght@400;700&family=Chakra+Petch:wght@600;700&family=Nunito:wght@700;800;900&display=swap');

.font-pixel {
  font-family: 'Press Start 2P', monospace;
  letter-spacing: -0.5px;
}
.font-retro {
  font-family: 'Silkscreen', 'Chakra Petch', sans-serif;
}

/* DARK MODE IS NOW THE PRIMARY DEFAULT THEME! */
:root,
html[data-theme="dark"] {
  --bg-main: #0c0918;
  --bg-glow-1: rgba(124, 58, 237, 0.25);
  --bg-glow-2: rgba(255, 92, 138, 0.18);
  --bg-grid: rgba(139, 120, 220, 0.12);
  --surface: #18132d;
  --surface-soft: #231c3f;
  --surface-elevated: #2f2553;
  --border-cute: #4a3a78;
  --shadow-pixel: #06040d;
  --text-main: #fdfaff;
  --text-muted: #b8addc;
  --primary: #ff5c8a;
  --secondary: #2dd4bf;
  --amber-cute: #ffd166;
  --spotlight-glow: rgba(255, 209, 102, 0.65);
}

html[data-theme="light"] {
  --bg-main: #fff6e8;
  --bg-glow-1: rgba(255, 183, 77, 0.18);
  --bg-glow-2: rgba(255, 92, 138, 0.12);
  --bg-grid: rgba(212, 163, 115, 0.18);
  --surface: #fffdf9;
  --surface-soft: #ffedd8;
  --surface-elevated: #ffffff;
  --border-cute: #3b232b;
  --shadow-pixel: #3b232b;
  --text-main: #2d1b24;
  --text-muted: #7d5a68;
  --primary: #ff5c8a;
  --secondary: #2ec4b6;
  --amber-cute: #ffca3a;
  --spotlight-glow: rgba(245, 158, 11, 0.45);
}

/* 1. Mobile-Native Platform Polish */
html {
  -webkit-tap-highlight-color: transparent;
  height: 100%;
}

html,
body {
  margin: 0;
  padding: 0;
  overscroll-behavior: none;
  background-color: var(--bg-main);
  background-image:
    radial-gradient(circle at 15% 15%, var(--bg-glow-1), transparent 42%),
    radial-gradient(circle at 85% 80%, var(--bg-glow-2), transparent 45%),
    linear-gradient(to right, var(--bg-grid) 1px, transparent 1px),
    linear-gradient(to bottom, var(--bg-grid) 1px, transparent 1px);
  background-size: 100% 100%, 100% 100%, 24px 24px, 24px 24px;
  color: var(--text-main);
  font-family: 'Chakra Petch', 'Nunito', monospace, sans-serif;
}

.starfield-canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 0;
}

header, main, nav { position: relative; z-index: 10; }

button,
a,
[role="button"],
.tappable,
.game-cell {
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

@media (pointer: coarse) {
  input,
  textarea,
  select {
    font-size: 16px !important;
  }
}

.scroll-contain {
  overflow-y: auto;
  overscroll-behavior: contain;
}

.safe-top { padding-top: env(safe-area-inset-top, 0px); }
.safe-bottom { padding-bottom: calc(0.45rem + env(safe-area-inset-bottom, 0px)); }
.app-main-pad { padding-bottom: calc(5.5rem + env(safe-area-inset-bottom, 0px)); }
@media (min-width: 768px) {
  .app-main-pad { padding-bottom: 2.4rem; }
}

/* =========================================================================
   2. CLEAR VISUAL HIERARCHY & TURN / MOVE SPOTLIGHT HIGHLIGHTS
   ========================================================================= */

.kawaii-card {
  background: var(--surface);
  border: 2.5px solid var(--border-cute);
  border-radius: 12px;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.14),
    0 6px 0 var(--shadow-pixel),
    0 12px 28px rgba(0, 0, 0, 0.28);
}

.kawaii-subcard {
  background: var(--surface-soft);
  border: 2px solid var(--border-cute);
  border-radius: 10px;
  box-shadow: 0 4px 0 var(--shadow-pixel);
}

/* Highlight cực rõ cho Người đang tới lượt! */
.turn-spotlight {
  background: linear-gradient(135deg, rgba(255, 209, 102, 0.24), rgba(255, 92, 138, 0.18)) !important;
  border-color: #ffd166 !important;
  box-shadow: 0 0 0 2px #ffd166, 0 0 22px var(--spotlight-glow), 0 4px 0 var(--shadow-pixel) !important;
  transform: translateY(-2px) scale(1.03);
  z-index: 5;
}

.turn-idle {
  opacity: 0.72;
  transition: opacity 0.25s ease, transform 0.25s ease;
}

/* Viền phát sáng khi tới lượt BẠN */
.my-turn-banner {
  background: linear-gradient(90deg, #ff5c8a, #ffd166, #2dd4bf);
  background-size: 200% 100%;
  animation: neonBannerFlow 3.5s linear infinite;
  color: #140f26;
  font-weight: 900;
  border: 2px solid #ffffff;
  box-shadow: 0 0 18px rgba(255, 92, 138, 0.55);
}
@keyframes neonBannerFlow {
  0% { background-position: 0% 50%; }
  100% { background-position: 200% 50%; }
}

/* Highlight rõ nét nước vừa đánh (Caro, Cờ Vua, Cờ Gánh, Ô Ăn Quan) */
.last-move-beacon {
  box-shadow: inset 0 0 0 3px #f59e0b, 0 0 16px rgba(251, 191, 36, 0.85) !important;
  z-index: 12;
  animation: beaconPulse 1.3s ease-in-out infinite;
}
@keyframes beaconPulse {
  0%, 100% { box-shadow: inset 0 0 0 3px #f59e0b, 0 0 10px rgba(251, 191, 36, 0.65); }
  50% { box-shadow: inset 0 0 0 3.5px #fde047, 0 0 20px rgba(250, 204, 21, 0.95); }
}

/* Tách bạch rõ lá bài / thẻ ĐÁNH ĐƯỢC vs KHÔNG ĐÁNH ĐƯỢC */
.card-playable-highlight {
  box-shadow: 0 0 0 2.5px #ffd166, 0 0 16px rgba(255, 209, 102, 0.6), 0 6px 0 #090712 !important;
  transform: translateY(-4px);
}
.card-unplayable-dim {
  opacity: 0.48;
  filter: saturate(0.65);
}

/* =========================================================================
   3. DELIBERATE, SMOOTH, EXPRESSIVE ANIMATIONS (NHỊP CHẬM RÃI & ĐẸP MẮT)
   ========================================================================= */

.pixel-spark {
  position: fixed;
  width: 7px;
  height: 7px;
  border-radius: 2px;
  pointer-events: none;
  z-index: 100;
  animation: sparkFly 580ms cubic-bezier(0.16, 1, 0.3, 1) forwards;
}
@keyframes sparkFly {
  0% { opacity: 1; transform: translate(-50%, -50%) scale(1.3) rotate(0deg); }
  100% { opacity: 0; transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy))) scale(0.2) rotate(120deg); }
}

.pixel-confetti {
  position: fixed;
  top: -16px;
  width: 10px;
  height: 10px;
  border-radius: 2px;
  pointer-events: none;
  z-index: 110;
  animation: confettiFall linear forwards;
}
@keyframes confettiFall {
  0% { opacity: 1; transform: translate3d(0, 0, 0) rotate(0deg); }
  85% { opacity: 1; }
  100% { opacity: 0; transform: translate3d(var(--drift), 102vh, 0) rotate(540deg); }
}

.floating-action-banner {
  position: fixed;
  z-index: 95;
  pointer-events: none;
  transform: translate(-50%, -50%);
  background: #1a1430;
  color: #ffffff;
  border: 3px solid #ffd166;
  padding: 10px 22px;
  border-radius: 14px;
  font-weight: 900;
  font-size: 16px;
  letter-spacing: 0.03em;
  white-space: nowrap;
  animation: bannerCinematic 2.05s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}
@keyframes bannerCinematic {
  0% { opacity: 0; transform: translate(-50%, 18px) scale(0.6); }
  16% { opacity: 1; transform: translate(-50%, -4px) scale(1.08); }
  28% { transform: translate(-50%, 0px) scale(1); }
  78% { opacity: 1; transform: translate(-50%, -14px) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -38px) scale(0.94); }
}

.coin-delta-pop {
  position: fixed;
  z-index: 95;
  pointer-events: none;
  font-weight: 900;
  font-size: 15px;
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.8);
  animation: coinPopUp 1.65s ease-out forwards;
}
@keyframes coinPopUp {
  0% { opacity: 0; transform: translateY(8px) scale(0.8); }
  20% { opacity: 1; transform: translateY(0) scale(1.18); }
  100% { opacity: 0; transform: translateY(-38px) scale(0.95); }
}

.fx-shake {
  animation: screenShake 0.56s cubic-bezier(0.36, 0.07, 0.19, 0.97);
}
@keyframes screenShake {
  0%, 100% { transform: translateX(0); }
  15% { transform: translateX(-9px) rotate(-0.8deg); }
  30% { transform: translateX(9px) rotate(0.8deg); }
  45% { transform: translateX(-7px); }
  60% { transform: translateX(7px); }
  75% { transform: translateX(-4px); }
}

.stagger-in {
  opacity: 0;
  animation: cardPopIn 0.48s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}
@keyframes cardPopIn {
  0% { opacity: 0; transform: translateY(16px) scale(0.95); }
  100% { opacity: 1; transform: translateY(0) scale(1); }
}

.icon-bobble {
  display: inline-block;
  animation: gentleBobble 3.0s ease-in-out infinite;
}
@keyframes gentleBobble {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  50% { transform: translateY(-4px) rotate(4deg); }
}

.badge-shimmer {
  position: relative;
  overflow: hidden;
}
.badge-shimmer::after {
  content: '';
  position: absolute;
  top: 0;
  left: -130%;
  width: 75%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.42), transparent);
  animation: shimmerSweep 3.8s infinite;
}
@keyframes shimmerSweep {
  0% { left: -130%; }
  45%, 100% { left: 170%; }
}

.btn-3d {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  font-weight: 800;
  border: 2px solid var(--border-cute);
  border-radius: 10px;
  cursor: pointer;
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, 0.28),
    0 4px 0 var(--shadow-pixel);
  transition: transform 120ms cubic-bezier(0.22, 1, 0.36, 1), box-shadow 120ms ease-out, filter 120ms;
}
.btn-3d:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none !important;
}
.btn-3d:active:not(:disabled) {
  transform: translateY(3px) scale(0.98);
  box-shadow: 0 1px 0 var(--shadow-pixel) !important;
}

.btn-pink { background: var(--primary); color: #ffffff; border-color: #ff8fad; }
.btn-mint { background: var(--secondary); color: #0b2220; border-color: #5eead4; }
.btn-amber { background: var(--amber-cute); color: #241606; border-color: #fde68a; }
.btn-soft { background: var(--surface-elevated); color: var(--text-main); }

@media (hover: hover) and (pointer: fine) {
  .btn-3d:hover:not(:disabled) {
    filter: brightness(1.08);
    transform: translateY(-2px);
    box-shadow:
      inset 0 2px 0 rgba(255, 255, 255, 0.35),
      0 6px 0 var(--shadow-pixel),
      0 0 14px rgba(255, 92, 138, 0.25);
  }
  .game-card-hover:hover {
    transform: translateY(-5px);
    border-color: #ffd166;
    box-shadow:
      0 8px 0 var(--shadow-pixel),
      0 0 22px rgba(255, 209, 102, 0.22);
  }
}

/* In-Game Token, Dice, Bowl & Card Deliberate Animations */
.avatar-token {
  background: #ffffff;
  box-shadow: 0 3px 6px rgba(0, 0, 0, 0.55);
  transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.pawn-bounce {
  animation: cuteSquishHop 1.35s ease-in-out infinite;
}
@keyframes cuteSquishHop {
  0%, 100% { transform: translateY(0) scale(1, 1); }
  30% { transform: translateY(1px) scale(1.07, 0.93); }
  60% { transform: translateY(-6px) scale(0.96, 1.07); }
}

.pawn-super-jump {
  animation: superJumpArc 0.85s cubic-bezier(0.22, 1, 0.36, 1);
}
@keyframes superJumpArc {
  0% { transform: translateY(-28px) scale(1.42); }
  60% { transform: translateY(2px) scale(1.14, 0.86); }
  100% { transform: translateY(0) scale(1); }
}

.tile-trail-step {
  animation: trailGlow 0.75s ease-out;
}
@keyframes trailGlow {
  0% { background-color: #f59e0b !important; color: #110d20 !important; box-shadow: 0 0 18px #ffd166 !important; transform: scale(1.09); z-index: 20; }
  100% { transform: scale(1); }
}

.tile-shockwave {
  animation: landShockwave 0.95s cubic-bezier(0.22, 1, 0.36, 1);
  box-shadow: inset 0 0 0 2.5px #ffd166, 0 0 16px rgba(255, 209, 102, 0.75) !important;
  z-index: 22;
}
@keyframes landShockwave {
  0% { box-shadow: 0 0 0 0 rgba(255, 209, 102, 0.95); transform: scale(1.12); }
  100% { box-shadow: inset 0 0 0 2.5px #ffd166, 0 0 0 16px rgba(255, 209, 102, 0); transform: scale(1); }
}

.dice-tumble {
  animation: diceSpinShake 0.52s linear infinite;
}
@keyframes diceSpinShake {
  0% { transform: rotate(0deg) scale(1.1); }
  25% { transform: rotate(22deg) translateY(-6px) scale(1.18); }
  50% { transform: rotate(-20deg) translateY(4px) scale(1.06); }
  75% { transform: rotate(15deg) translateY(-5px) scale(1.15); }
  100% { transform: rotate(0deg) scale(1.1); }
}

.dice-land-pop {
  animation: diceLandBounce 0.65s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes diceLandBounce {
  0% { transform: scale(1.42) rotate(-12deg); }
  65% { transform: scale(0.92) rotate(4deg); }
  100% { transform: scale(1) rotate(0deg); }
}

.bowl-shaking {
  animation: bowlRattle 0.16s ease-in-out infinite;
}
@keyframes bowlRattle {
  0%, 100% { transform: translate(0, 0) rotate(0deg); }
  25% { transform: translate(-8px, -4px) rotate(-9deg); }
  75% { transform: translate(8px, -3px) rotate(9deg); }
}

.stone-slam {
  animation: stoneDropSlam 0.52s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes stoneDropSlam {
  0% { opacity: 0; transform: scale(2.1) translateY(-10px); }
  68% { opacity: 1; transform: scale(0.88) translateY(0); }
  100% { transform: scale(1); }
}

.coin-flip-3d {
  animation: flipCapture3D 0.9s cubic-bezier(0.22, 1, 0.36, 1);
}
@keyframes flipCapture3D {
  0% { transform: perspective(360px) rotateY(0deg) scale(1); }
  50% { transform: perspective(360px) rotateY(180deg) scale(1.35); box-shadow: 0 0 22px #ffd166; }
  100% { transform: perspective(360px) rotateY(360deg) scale(1); }
}

.card-slap {
  animation: cardSlapDown 0.58s cubic-bezier(0.22, 1, 0.36, 1);
}
@keyframes cardSlapDown {
  0% { opacity: 0.3; transform: translateY(-38px) scale(1.38) rotate(-16deg); }
  100% { opacity: 1; transform: translateY(0) scale(1) rotate(2deg); }
}

/* 3D Flip Card for Memory Match */
.flip-scene { perspective: 700px; }
.flip-inner {
  position: relative;
  width: 100%;
  height: 100%;
  transition: transform 0.56s cubic-bezier(0.34, 1.35, 0.64, 1);
  transform-style: preserve-3d;
}
.flip-inner.is-flipped { transform: rotateY(180deg); }
.flip-face {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.flip-back { transform: rotateY(180deg); }

.tile-2048-pop {
  animation: pop2048 0.32s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes pop2048 {
  0% { transform: scale(0.45); }
  100% { transform: scale(1); }
}

.mine-reveal-pop {
  animation: mineWaveOpen 0.38s cubic-bezier(0.34, 1.56, 0.64, 1) backwards;
}
@keyframes mineWaveOpen {
  0% { opacity: 0.25; transform: scale(0.6); }
  100% { opacity: 1; transform: scale(1); }
}

.flying-sticker {
  position: fixed;
  z-index: 80;
  pointer-events: none;
  animation: floatSticker 2.6s ease-out forwards;
}
@keyframes floatSticker {
  0% { opacity: 0; transform: translateY(24px) scale(0.6); }
  15% { opacity: 1; transform: translateY(0px) scale(1.25); }
  80% { opacity: 1; transform: translateY(-95px) scale(1); }
  100% { opacity: 0; transform: translateY(-145px) scale(0.9); }
}

/* =========================================================================
   4. GAME BOARDS LAYOUTS
   ========================================================================= */

.mono-board-viewport {
  width: 100%;
  overflow-x: auto;
  overflow-y: visible;
  -webkit-overflow-scrolling: touch;
  padding: 4px 2px 10px;
  scrollbar-width: thin;
  scrollbar-color: #ec4899 #110d22;
}

.mono-grid {
  display: grid;
  grid-template-columns: 1.35fr repeat(9, 1fr) 1.35fr;
  grid-template-rows: 1.35fr repeat(9, 1fr) 1.35fr;
  aspect-ratio: 1 / 1;
  width: min(96vw, 980px);
  min-width: 780px;
  gap: 3px;
  padding: 6px;
  border: 3px solid var(--border-cute);
  border-radius: 14px;
  background: #110d22;
  box-shadow: 0 8px 0 var(--shadow-pixel), 0 0 36px rgba(124, 58, 237, 0.25);
  margin: 0 auto;
  transition: width 220ms ease, min-width 220ms ease;
}
.mono-grid.mono-zoom-large {
  width: 1140px;
  min-width: 1140px;
  gap: 4px;
  padding: 8px;
}
.mono-grid.mono-zoom-fit {
  width: min(96vw, 960px);
  min-width: 0;
  gap: 2px;
  padding: 4px;
}
.mono-tile {
  position: relative;
  background: linear-gradient(180deg, rgba(30, 27, 54, 0.96) 0%, rgba(19, 16, 38, 0.98) 100%);
  border: 1.5px solid rgba(167, 139, 250, 0.35);
  border-radius: 6px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: center;
  padding: 2px 2px 3px;
  text-align: center;
  overflow: hidden;
  cursor: pointer;
  transition: transform 150ms ease, background-color 220ms ease, box-shadow 220ms ease, border-color 150ms ease;
  user-select: none;
}
.mono-tile:hover {
  border-color: #f472b6;
  z-index: 12;
}
.mono-tile-name {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  word-break: break-word;
  font-size: 10.5px;
  line-height: 1.15;
  font-weight: 900;
  color: #f8fafc;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.95);
  padding: 0 2px;
  width: 100%;
}
.mono-grid.mono-zoom-large .mono-tile-name {
  font-size: 12.5px;
  line-height: 1.2;
}
.mono-grid.mono-zoom-fit .mono-tile-name {
  font-size: clamp(7.5px, 1.8vw, 11.5px);
}
.mono-tile-price {
  font-size: 9.5px;
  line-height: 1.1;
  font-weight: 800;
  color: #fde047;
  margin-bottom: 10px;
}
.mono-grid.mono-zoom-large .mono-tile-price {
  font-size: 11px;
  margin-bottom: 12px;
}
.mono-grid.mono-zoom-fit .mono-tile-price {
  font-size: clamp(7px, 1.6vw, 10px);
  margin-bottom: 8px;
}
.mono-center {
  grid-column: 2 / 11;
  grid-row: 2 / 11;
  background: radial-gradient(circle at 50% 45%, #1d1738 0%, #110d24 100%);
  border-radius: 10px;
  border: 2px dashed rgba(167, 139, 250, 0.45);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: center;
  padding: 12px;
  text-align: center;
  overflow: hidden;
}

.caro-grid {
  display: grid;
  grid-template-columns: repeat(15, 1fr);
  aspect-ratio: 1 / 1;
  width: min(94vw, 520px);
  background: #3b2a54;
  border: 4px solid var(--border-cute);
  border-radius: 12px;
  box-shadow: 0 8px 0 var(--shadow-pixel);
  gap: 1.5px;
  padding: 3px;
  margin: 0 auto;
}
.caro-cell {
  background: var(--surface);
  display: flex;
  align-items: center;
  justify-content: center;
  aspect-ratio: 1 / 1;
  cursor: pointer;
  position: relative;
  transition: background-color 140ms ease;
}
.caro-cell:active { background: var(--surface-soft); }

.chess-grid {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  aspect-ratio: 1 / 1;
  width: min(92vw, 460px);
  border: 4px solid var(--border-cute);
  border-radius: 12px;
  box-shadow: 0 8px 0 var(--shadow-pixel);
  overflow: hidden;
  margin: 0 auto;
}
.chess-sq {
  aspect-ratio: 1 / 1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: clamp(22px, 6vw, 36px);
  cursor: pointer;
  position: relative;
}

.uno-card {
  width: 68px;
  height: 98px;
  border-radius: 10px;
  border: 3px solid #ffffff;
  box-shadow: 0 5px 0 #090712;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-weight: 900;
  color: #ffffff;
  position: relative;
  transition: transform 160ms cubic-bezier(0.34, 1.56, 0.64, 1), opacity 160ms ease, box-shadow 160ms ease;
  flex-shrink: 0;
}
.uno-card.playable {
  cursor: pointer;
}
.uno-card.playable:active { transform: translateY(-8px) scale(0.96); }
@media (hover: hover) and (pointer: fine) {
  .uno-card.playable:hover { transform: translateY(-12px) rotate(-3deg); }
}

/* Khung Đếm Ngược 3 - 2 - 1 Neon Sân Khấu */
.countdown-orb {
  width: 128px;
  height: 128px;
  border-radius: 9999px;
  background: radial-gradient(circle at 30% 30%, #ff5c8a, #7c3aed 72%);
  border: 4px solid #ffd166;
  box-shadow:
    0 0 0 8px rgba(255, 209, 102, 0.16),
    0 0 42px rgba(255, 92, 138, 0.65),
    0 8px 0 var(--shadow-pixel);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto;
  animation: countdownPulse 0.92s cubic-bezier(0.22, 1, 0.36, 1) infinite;
}
@keyframes countdownPulse {
  0% { transform: scale(0.72); box-shadow: 0 0 0 0 rgba(255, 209, 102, 0.75), 0 0 45px rgba(255, 92, 138, 0.8); }
  55% { transform: scale(1.08); box-shadow: 0 0 0 18px rgba(255, 209, 102, 0), 0 0 55px rgba(255, 209, 102, 0.75); }
  100% { transform: scale(0.98); box-shadow: 0 0 0 24px rgba(255, 209, 102, 0), 0 0 30px rgba(124, 58, 237, 0.55); }
}

/* Phân tách rõ ràng từng khu vực trên sân khấu ("Cái gì ra cái đấy") */
.stage-zone {
  background: var(--surface-soft);
  border: 2px solid var(--border-cute);
  border-radius: 14px;
  padding: 0.85rem;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08), 0 5px 0 var(--shadow-pixel);
}

.setting-pill-active {
  background: linear-gradient(135deg, #ff5c8a, #ec4899) !important;
  color: #ffffff !important;
  border-color: #ffd166 !important;
  box-shadow: 0 0 14px rgba(255, 92, 138, 0.45), 0 3px 0 var(--shadow-pixel) !important;
}

/* =========================================================================
   5. SMART ĐẤU-TRÍ APP SHELL, PIXEL ROLE CARDS & COMPACT HUD
   ========================================================================= */

.dt-panel {
  background: rgba(18, 20, 34, 0.94);
  backdrop-filter: blur(10px);
  border: 1.5px solid rgba(124, 110, 182, 0.38);
  border-radius: 10px;
  box-shadow: 0 14px 36px rgba(0, 0, 0, 0.55);
}

html[data-theme="light"] .dt-panel {
  background: rgba(255, 252, 246, 0.96);
  border-color: #3b232b;
  box-shadow: 0 6px 0 #3b232b;
}

.role-card-tile {
  position: relative;
  aspect-ratio: 4 / 5.2;
  border-radius: 8px;
  overflow: hidden;
  cursor: pointer;
  border: 2px solid rgba(148, 163, 184, 0.25);
  background: #0f1322;
  transition: transform 140ms ease, filter 160ms ease, border-color 160ms ease, box-shadow 160ms ease;
}
.role-card-tile.is-off {
  filter: brightness(0.45) saturate(0.55);
}
.role-card-tile.is-on {
  border-color: #38bdf8;
  box-shadow: 0 0 0 1px rgba(56, 189, 248, 0.4), 0 6px 16px rgba(0, 0, 0, 0.45);
}
.role-card-tile.is-wolf.is-on {
  border-color: #f59e0b;
  box-shadow: 0 0 0 1px rgba(245, 158, 11, 0.45), 0 6px 16px rgba(0, 0, 0, 0.45);
}
@media (hover: hover) and (pointer: fine) {
  .role-card-tile:hover {
    transform: translateY(-2px);
    filter: brightness(1.05);
  }
}

.role-count-badge {
  position: absolute;
  top: 4px;
  right: 4px;
  min-width: 19px;
  height: 19px;
  padding: 0 5px;
  border-radius: 4px;
  background: #facc15;
  color: #0f172a;
  font-size: 11px;
  font-weight: 900;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.65);
  z-index: 5;
}

.role-minus-btn {
  position: absolute;
  top: 4px;
  left: 4px;
  width: 19px;
  height: 19px;
  border-radius: 4px;
  background: rgba(15, 23, 42, 0.88);
  color: #f87171;
  border: 1px solid rgba(248, 113, 113, 0.55);
  font-size: 12px;
  font-weight: 900;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 6;
}
.role-minus-btn:hover {
  background: #ef4444;
  color: #ffffff;
}

.sidebar-nav-btn {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  width: 100%;
  padding: 0.55rem 0.85rem;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 800;
  color: var(--text-muted);
  transition: background-color 140ms ease, color 140ms ease;
}
.sidebar-nav-btn:hover {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-main);
}
.sidebar-nav-btn.is-active {
  background: rgba(255, 92, 138, 0.16);
  color: #ffd166;
  border-left: 3px solid #ff5c8a;
}

/* =========================================================================
   6. ĐẤU TRÍ ARENA, FULL VICTORY RIBBON, TIẾN LÊN, CỜ TƯỚNG & DOMINO
   ========================================================================= */
.full-victory-ribbon {
  background: linear-gradient(90deg, rgba(20, 14, 8, 0) 0%, rgba(60, 42, 14, 0.96) 12%, rgba(100, 68, 20, 0.98) 50%, rgba(60, 42, 14, 0.96) 88%, rgba(20, 14, 8, 0) 100%);
  border-top: 2.5px solid #f59e0b;
  border-bottom: 2.5px solid #f59e0b;
  box-shadow: 0 0 40px rgba(245, 158, 11, 0.5), 0 0 80px rgba(0, 0, 0, 0.95);
}

.speech-bubble-pop {
  animation: bubblePopIn 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes bubblePopIn {
  0% { opacity: 0; transform: translate(-50%, 6px) scale(0.7); }
  100% { opacity: 1; transform: translate(-50%, 0) scale(1); }
}

.tl-card {
  width: 58px;
  height: 86px;
  border-radius: 9px;
  background: linear-gradient(145deg, #ffffff 0%, #f1f5f9 100%);
  border: 2px solid #cbd5e1;
  box-shadow: 0 4px 0 #0f172a, 0 8px 18px rgba(0, 0, 0, 0.45);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 4px 6px;
  font-weight: 900;
  flex-shrink: 0;
  cursor: pointer;
  user-select: none;
  transition: transform 180ms cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 180ms ease, border-color 180ms ease;
}
.tl-card.is-selected {
  transform: translateY(-16px) scale(1.05);
  border-color: #f59e0b;
  box-shadow: 0 0 0 2.5px #fde047, 0 14px 24px rgba(0, 0, 0, 0.7);
}
@media (hover: hover) and (pointer: fine) {
  .tl-card:hover:not(.is-selected) {
    transform: translateY(-8px);
    box-shadow: 0 8px 0 #0f172a, 0 12px 22px rgba(0, 0, 0, 0.5);
  }
}

.xiangqi-grid-wrap {
  position: relative;
  width: min(94vw, 460px);
  aspect-ratio: 9 / 10;
  margin: 0 auto;
  background: linear-gradient(135deg, #d49a5b 0%, #c28342 50%, #ae7133 100%);
  border: 5px solid #3b1b08;
  border-radius: 12px;
  box-shadow: 0 8px 0 #180903, 0 16px 36px rgba(0, 0, 0, 0.75);
  padding: 2%;
}

.domino-bone {
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  background: linear-gradient(135deg, #fefce8 0%, #fef08a 100%);
  color: #0f172a;
  border: 2px solid #334155;
  border-radius: 8px;
  box-shadow: 0 4px 0 #0f172a;
  font-weight: 900;
  transition: transform 140ms ease, box-shadow 140ms ease;
}

/* Poker & Bài Bịp Pixel Styles */
.poker-felt {
  background: radial-gradient(circle at 50% 50%, #0d5c36 0%, #063820 70%, #031e11 100%);
  border: 4px solid #b45309;
  border-radius: 28px;
  box-shadow: inset 0 0 30px rgba(0,0,0,0.6), 0 8px 24px rgba(0,0,0,0.5);
}

.card-reveal-flip {
  animation: cardFlip 320ms cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

@keyframes cardFlip {
  0% { transform: scale(0.85) rotateY(90deg); opacity: 0; }
  100% { transform: scale(1) rotateY(0deg); opacity: 1; }
}

.challenge-pulse-glow {
  animation: challengePulse 1.2s ease-in-out infinite;
}

@keyframes challengePulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.6); transform: scale(1); }
  50% { box-shadow: 0 0 20px 6px rgba(239, 68, 68, 0.8); transform: scale(1.02); }
}

/* =========================================================================
   MOVEMENT, WALKING, GALLOPING & SLAM ANIMATIONS ("ỨNG ĐI LẠI")
   ========================================================================= */

/* Tile-by-tile pawn hopping with squash & stretch */
@keyframes pawnHopStride {
  0% { transform: translateY(0) scale(1, 1); }
  28% { transform: translateY(-16px) scale(0.9, 1.18) rotate(4deg); }
  58% { transform: translateY(-7px) scale(1.05, 0.95) rotate(-2deg); }
  82% { transform: translateY(0) scale(1.18, 0.82); }
  100% { transform: translateY(0) scale(1, 1); }
}

.pawn-hop-stride {
  animation: pawnHopStride 260ms cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

/* Cờ Cá Ngựa Horse Galloping Leap */
@keyframes horseGallop {
  0% { transform: translateY(0) rotate(0deg) scale(1); }
  25% { transform: translateY(-22px) rotate(-14deg) scale(1.22); filter: drop-shadow(0 14px 10px rgba(0,0,0,0.45)); }
  60% { transform: translateY(-10px) rotate(8deg) scale(1.08); }
  85% { transform: translateY(0) rotate(0deg) scale(1.15, 0.85); }
  100% { transform: translateY(0) rotate(0deg) scale(1); }
}

.horse-gallop-leap {
  animation: horseGallop 360ms cubic-bezier(0.25, 1, 0.5, 1) forwards;
}

/* Chess & Board Piece Glide and Slam */
@keyframes pieceGlideSlam {
  0% { transform: translateY(-16px) scale(1.25); box-shadow: 0 16px 24px rgba(0,0,0,0.6); }
  65% { transform: translateY(-2px) scale(1.05); }
  85% { transform: translateY(0) scale(1.12, 0.88); box-shadow: 0 2px 4px rgba(0,0,0,0.5); }
  100% { transform: translateY(0) scale(1); box-shadow: 0 4px 10px rgba(0,0,0,0.4); }
}

.piece-glide-slam {
  animation: pieceGlideSlam 280ms cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

/* Piece Capture Cross Slash Effect */
@keyframes crossSlashLeft {
  0% { opacity: 0; transform: scaleX(0.2) rotate(-35deg); }
  50% { opacity: 1; transform: scaleX(1.3) rotate(-35deg); }
  100% { opacity: 0; transform: scaleX(1.6) rotate(-35deg); }
}

@keyframes crossSlashRight {
  0% { opacity: 0; transform: scaleX(0.2) rotate(35deg); }
  50% { opacity: 1; transform: scaleX(1.3) rotate(35deg); }
  100% { opacity: 0; transform: scaleX(1.6) rotate(35deg); }
}

.cross-slash-anim {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: center;
}

.cross-slash-anim::before,
.cross-slash-anim::after {
  content: '';
  position: absolute;
  width: 140%;
  height: 4px;
  background: linear-gradient(90deg, transparent, #ef4444, #ffffff, #ef4444, transparent);
  border-radius: 999px;
  box-shadow: 0 0 12px #ef4444;
}

.cross-slash-anim::before {
  animation: crossSlashLeft 280ms ease-out forwards;
}

.cross-slash-anim::after {
  animation: crossSlashRight 280ms ease-out 30ms forwards;
}

/* Card Deal Slide Animation */
@keyframes cardDealSlide {
  0% { opacity: 0; transform: translateY(-36px) scale(0.65) rotate(-12deg); }
  70% { opacity: 1; transform: translateY(3px) scale(1.03) rotate(2deg); }
  100% { opacity: 1; transform: translateY(0) scale(1) rotate(0deg); }
}

.card-dealt-slide {
  animation: cardDealSlide 240ms cubic-bezier(0.2, 0.8, 0.2, 1) forwards;
}

/* =========================================================================
   SCENE & VIEW TRANSITIONS ("CHUYỂN CẢNH ĐẸP")
   ========================================================================= */

@keyframes viewSlideFadeIn {
  0% { opacity: 0; transform: translateY(10px) scale(0.995); filter: blur(2px); }
  100% { opacity: 1; transform: translateY(0) scale(1); filter: blur(0); }
}

.view-enter-active {
  animation: viewSlideFadeIn 220ms cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes roomWarpIn {
  0% { opacity: 0; transform: scale(0.95); filter: brightness(1.25) blur(3px); }
  100% { opacity: 1; transform: scale(1); filter: brightness(1) blur(0); }
}

.room-warp-enter {
  animation: roomWarpIn 300ms cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes myTurnPulse {
  0%, 100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.6); }
  50% { transform: scale(1.02); box-shadow: 0 0 18px 5px rgba(245, 158, 11, 0.7); }
}

.my-turn-pulse {
  animation: myTurnPulse 1.4s ease-in-out infinite;
}

.werewolf-night-overlay {
  background: radial-gradient(circle at 50% 20%, rgba(30, 27, 75, 0.95) 0%, rgba(13, 11, 24, 0.98) 100%);
  transition: background 800ms ease;
}

.werewolf-day-overlay {
  background: radial-gradient(circle at 50% 20%, rgba(180, 83, 9, 0.25) 0%, rgba(13, 11, 24, 0.98) 100%);
  transition: background 800ms ease;
}

/* Werewolf Arrow Animations & Visuals */
@keyframes arrowDash {
  0% { stroke-dashoffset: 24; }
  100% { stroke-dashoffset: 0; }
}

.animated-arrow-line {
  stroke-dasharray: 5, 3.5;
  animation: arrowDash 0.9s linear infinite;
}

@keyframes arrowGlowPulse {
  0%, 100% { filter: drop-shadow(0 0 3px currentColor) drop-shadow(0 0 6px currentColor); opacity: 0.95; }
  50% { filter: drop-shadow(0 0 7px currentColor) drop-shadow(0 0 12px currentColor); opacity: 1; }
}

.arrow-glow-pulse {
  animation: arrowGlowPulse 1.6s ease-in-out infinite;
}

/* Hanging / Execution Gallows Swing */
@keyframes gallowsSwing {
  0% { transform: rotate(-8deg); }
  50% { transform: rotate(8deg); }
  100% { transform: rotate(-8deg); }
}

.gallows-swing {
  transform-origin: top center;
  animation: gallowsSwing 2.2s ease-in-out infinite;
}

@keyframes executionBannerPop {
  0% { opacity: 0; transform: translateY(-24px) scale(0.92); }
  60% { opacity: 1; transform: translateY(4px) scale(1.02); }
  100% { opacity: 1; transform: translateY(0) scale(1); }
}

.execution-banner-pop {
  animation: executionBannerPop 400ms cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

/* Day & Night Atmospheric Lighting */
.werewolf-night-sky {
  background: radial-gradient(circle at 50% 20%, rgba(30, 27, 75, 0.85) 0%, rgba(13, 11, 24, 0.95) 100%);
  transition: background 1.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.werewolf-day-sky {
  background: radial-gradient(circle at 50% 15%, rgba(251, 191, 36, 0.22) 0%, rgba(245, 158, 11, 0.08) 50%, rgba(13, 11, 24, 0.7) 100%);
  transition: background 1.2s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Monopoly stepping pawn pulse */
.pawn-stepping-active {
  box-shadow: 0 0 16px #fde047, 0 0 30px #f59e0b;
  transform: translateY(-8px) scale(1.25);
  z-index: 30 !important;
  transition: transform 120ms ease, box-shadow 120ms ease;
}

/* =========================================================================
   DEEP MOBILE OPTIMIZATION ("TỐI ƯU CHO MOBILE HƠN NỮA")
   ========================================================================= */

/* Prevent accidental tap delays & highlighting */
* {
  -webkit-tap-highlight-color: transparent;
}

html, body {
  overflow-x: hidden;
  max-width: 100vw;
}

button, .btn-3d, .tl-card, .dt-panel, [role="button"], .mono-cell, .xiangqi-sq {
  touch-action: manipulation;
}

.board-touch-safe {
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
}

.safe-bottom-pad {
  padding-bottom: max(env(safe-area-inset-bottom, 14px), 14px);
}

/* Mobile Hand Fan for Tien Len, Bai Bip, Uno */
.mobile-hand-fan {
  display: flex;
  justify-content: center;
  align-items: flex-end;
  overflow-x: auto;
  padding-top: 24px;
  padding-bottom: 8px;
  padding-left: 10px;
  padding-right: 10px;
  -webkit-overflow-scrolling: touch;
}

@media (max-width: 640px) {
  .mobile-hand-fan {
    justify-content: flex-start;
    padding-left: 14px;
    padding-right: 28px;
  }
  .mobile-hand-fan .tl-card {
    margin-right: -24px;
    transition: transform 180ms cubic-bezier(0.34, 1.56, 0.64, 1), margin 180ms ease, z-index 180ms ease, box-shadow 180ms ease;
  }
  .mobile-hand-fan .tl-card:last-child {
    margin-right: 0;
  }
  .mobile-hand-fan .tl-card.is-selected {
    transform: translateY(-22px) scale(1.12);
    margin-right: -10px;
    margin-left: 10px;
    z-index: 25;
    box-shadow: 0 0 0 3px #fde047, 0 16px 28px rgba(0, 0, 0, 0.8);
  }
  .mobile-hand-fan .tl-card:active {
    transform: translateY(-16px) scale(1.08);
  }
  
  /* Board responsives */
  .mono-grid.mono-zoom-fit {
    width: min(calc(100vw - 8px), 760px);
    min-width: 0;
    gap: 1.5px;
    padding: 3px;
  }
  .mono-grid.mono-zoom-fit .mono-tile {
    padding: 1px;
  }
  .poker-felt {
    border-radius: 18px;
    border-width: 3px;
    padding: 8px 4px;
  }
  .xiangqi-grid-wrap {
    width: min(calc(100vw - 16px), 440px);
  }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
