/* ==========================================================
   QNAN DETECTIVE MINI GAME - STYLESHEET
   Aesthetic: Detective Mystery / Cozy Classroom / QNAN UI
   ========================================================== */

:root {
  --font-main: 'Prompt', 'Kanit', sans-serif;
  --font-heading: 'Kanit', sans-serif;

  /* Color Palette */
  --bg-dark: #12151c;
  --chalkboard-green: #254437;
  --chalkboard-border: #5c3a21;
  --wood-dark: #3a2012;
  --wood-light: #6e4325;
  --gold-accent: #f5b041;
  --gold-glow: #f9e79f;
  --card-ivory: #fffdf8;
  --card-edge: #c7af8b;
  --card-shadow: rgba(0, 0, 0, 0.45);
  
  /* Tile Sizing */
  --tile-w: 56px;
  --tile-h: 56px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  touch-action: manipulation;
}

/* Orientation Warning Overlay for Portrait Handhelds */
.orientation-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: radial-gradient(circle at center, #1e2638 0%, #0d1017 100%);
  z-index: 99999;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 24px;
}

@media screen and (orientation: portrait) and (max-width: 900px) {
  .orientation-overlay {
    display: flex !important;
  }
}

.orientation-content {
  background: rgba(22, 28, 42, 0.95);
  border: 2px solid #f5b041;
  border-radius: 20px;
  padding: 28px 24px;
  max-width: 340px;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.8), 0 0 24px rgba(245, 176, 65, 0.35);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.orientation-phone-icon {
  font-size: 3.2rem;
  animation: rotatePhone 2s ease-in-out infinite alternate;
}

@keyframes rotatePhone {
  0% { transform: rotate(0deg) scale(1); }
  50% { transform: rotate(90deg) scale(1.1); }
  100% { transform: rotate(90deg) scale(1.1); }
}

.orientation-content h3 {
  font-family: var(--font-heading);
  font-size: 1.25rem;
  color: #ffd166;
  font-weight: 700;
}

.orientation-content p {
  font-size: 0.84rem;
  color: #b0bec5;
  line-height: 1.5;
}

html, body {
  width: 100%;
  max-width: 100vw;
  height: 100%;
  height: 100dvh;
  overflow: hidden;
  overflow-x: hidden;
  background-color: var(--bg-dark);
  font-family: var(--font-main);
  color: #fff;
  overscroll-behavior: none;
  -webkit-touch-callout: none;
}

#game-app {
  width: 100%;
  max-width: 100vw;
  height: 100%;
  height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at center, #1b202e 0%, #0d0f14 100%);
  position: relative;
  overflow: hidden;
  overflow-x: hidden;
}

/* Base Viewport: full flex column */
#game-viewport {
  position: relative;
  width: 100%;
  max-width: 1280px;
  min-width: 0;
  height: 100%;
  max-height: 720px;
  overflow: hidden;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.8), 0 0 0 2px rgba(255, 255, 255, 0.05);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

/* Desktop widescreen framing: 16:9 aspect ratio */
@media (min-width: 901px) and (min-aspect-ratio: 16/10) {
  #game-viewport {
    aspect-ratio: 16 / 9;
  }
}

/* Background Layer */
#bg-layer {
  position: absolute;
  inset: 0;
  background-image: url('assets/bg.jpg');
  background-size: cover;
  background-position: center;
  z-index: 1;
  filter: brightness(0.92);
}

#bg-layer::after {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 50% 40%, rgba(0, 0, 0, 0.15) 0%, rgba(0, 0, 0, 0.55) 100%);
}

/* ==========================================================
   HEADER
   ========================================================== */
#game-header {
  position: relative;
  z-index: 20;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 14px 24px 0 24px;
  min-height: 56px;
}

/* Hanging Wooden Board (Difficulty) */
.hanging-board {
  position: relative;
  cursor: pointer;
  perspective: 600px;
  transition: transform 0.2s ease;
}

.hanging-board:hover {
  transform: translateY(2px);
}

.rope {
  position: absolute;
  top: -14px;
  width: 3px;
  height: 16px;
  background: repeating-linear-gradient(45deg, #c49a45, #a37827 4px, #5c3e10 8px);
  box-shadow: 1px 1px 2px rgba(0,0,0,0.4);
  z-index: 2;
}
.rope-left { left: 16px; }
.rope-right { right: 16px; }

.board-body {
  position: relative;
  background: linear-gradient(180deg, #62b1a8 0%, #3e857c 100%);
  border: 3px solid #e8d0a9;
  border-radius: 12px;
  padding: 8px 16px;
  box-shadow: 0 6px 12px rgba(0, 0, 0, 0.4), inset 0 2px 4px rgba(255, 255, 255, 0.4);
  min-width: 140px;
  text-align: center;
}

.board-tag {
  font-family: var(--font-heading);
  font-size: 1.05rem;
  font-weight: 700;
  color: #fff;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
  letter-spacing: 0.5px;
}

.board-reward {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  font-size: 0.75rem;
  color: #fceecb;
  font-weight: 500;
  margin-top: 2px;
}

.gold-coin-icon {
  font-size: 0.9rem;
  filter: drop-shadow(0 2px 3px rgba(0,0,0,0.4));
}

/* Dropdown */
.diff-dropdown {
  position: absolute;
  top: 110%;
  left: 0;
  width: 180px;
  background: rgba(25, 30, 42, 0.95);
  border: 2px solid #b38b4d;
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.7);
  display: none;
  flex-direction: column;
  overflow: hidden;
  backdrop-filter: blur(8px);
  z-index: 50;
}

.hanging-board:hover .diff-dropdown,
.diff-dropdown.show {
  display: flex;
}

.diff-opt {
  padding: 8px 14px;
  font-size: 0.85rem;
  font-weight: 600;
  color: #ddd;
  text-align: left;
  transition: all 0.15s ease;
}

.diff-opt:hover, .diff-opt.active {
  background: rgba(245, 176, 65, 0.25);
  color: #ffd875;
}

/* Center Title Banner */
#title-banner {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  top: 14px;
  z-index: 25;
  display: flex;
  flex-direction: column;
  align-items: center;
  background: rgba(18, 22, 33, 0.7);
  border: 1px solid rgba(245, 176, 65, 0.35);
  border-radius: 14px;
  padding: 3px 14px;
  backdrop-filter: blur(6px);
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.5);
  pointer-events: auto;
  white-space: nowrap;
}

.banner-badge {
  font-size: 0.62rem;
  font-weight: 800;
  letter-spacing: 1.2px;
  color: #f5b041;
  background: rgba(245, 176, 65, 0.15);
  padding: 1px 7px;
  border-radius: 20px;
  margin-bottom: 1px;
}

.banner-title {
  font-size: 0.98rem;
  font-weight: 700;
  color: #fff;
  letter-spacing: 0.4px;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.7);
}

.banner-sub {
  display: flex;
  gap: 6px;
  font-size: 0.75rem;
  color: #cfd8dc;
  margin-top: 1px;
}

.banner-sub b {
  color: #ffd166;
}

.sub-short {
  display: none;
}

.sub-full {
  display: inline;
}

.divider {
  opacity: 0.4;
}

/* Header Controls */
#header-controls {
  display: flex;
  align-items: center;
  gap: 5px;
}

.player-wallet {
  display: flex;
  align-items: center;
  gap: 5px;
  background: rgba(18, 22, 33, 0.9);
  border: 1.5px solid #f5b041;
  border-radius: 20px;
  padding: 3px 10px;
  color: #ffd166;
  font-weight: 700;
  font-size: 0.88rem;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4), inset 0 1px 2px rgba(255, 255, 255, 0.2);
  cursor: pointer;
  transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.2s ease;
  user-select: none;
}

.player-wallet:hover {
  transform: scale(1.06);
  box-shadow: 0 6px 16px rgba(245, 176, 65, 0.4);
}

.player-wallet:active {
  transform: scale(0.96);
}

.wallet-icon {
  font-size: 1.05rem;
  filter: drop-shadow(0 1px 2px rgba(0,0,0,0.5));
}

.btn-icon {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1.5px solid rgba(255, 255, 255, 0.3);
  background: rgba(30, 36, 50, 0.8);
  color: #fff;
  font-size: 0.95rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.4);
}

.btn-icon:hover {
  transform: scale(1.1);
  border-color: #f5b041;
  background: rgba(50, 60, 85, 0.9);
  box-shadow: 0 6px 14px rgba(245, 176, 65, 0.4);
}

.btn-icon:active {
  transform: scale(0.95);
}

/* ==========================================================
   BOARD CONTAINER & CHALKBOARD
   ========================================================== */
#board-container {
  position: relative;
  z-index: 10;
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 20px;
  overflow: visible;
}

#chalkboard-frame {
  position: relative;
  width: 92%;
  height: 94%;
  max-width: 900px;
  max-height: 420px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
}

#board-grid {
  position: relative;
  width: 100%;
  height: 100%;
}

/* ==========================================================
   TILES (CARDS) STYLING - 3D QNAN STYLE
   ========================================================== */
.tile {
  position: absolute;
  width: var(--tile-w);
  height: var(--tile-h);
  border-radius: 0px;
  background: linear-gradient(180deg, #fffdf8 0%, #f7efe4 100%);
  border: 1.5px solid #dcd0bc;
  box-shadow: 
    inset 0 -2.5px 0 #c7af8b,
    inset 0 1px 0 rgba(255, 255, 255, 0.95),
    0 2px 4px rgba(0, 0, 0, 0.16);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s cubic-bezier(0.2, 0.9, 0.4, 1.2), box-shadow 0.15s ease, filter 0.2s ease;
  user-select: none;
  touch-action: manipulation;
  overflow: hidden;
  padding: 3px;
  box-sizing: border-box;
  margin: 0;
}

/* Inner Face with properly contained icon */
.tile-face {
  width: 100%;
  height: 100%;
  background-size: contain;
  background-position: center;
  background-repeat: no-repeat;
  border-radius: 0px;
  pointer-events: none;
}

/* Unlocked (Top) Tile State */
.tile.active {
  filter: brightness(1) drop-shadow(0 1px 3px rgba(255, 230, 150, 0.2));
}

.tile.active:hover {
  transform: translateY(-3px) scale(1.05);
  box-shadow: 
    inset 0 -2.5px 0 #c7af8b,
    0 6px 14px rgba(0, 0, 0, 0.35);
  border-color: #ffd57e;
  z-index: 1000 !important;
}

/* Covered (Locked) Tile State */
.tile.locked {
  filter: brightness(0.55) contrast(0.9);
  cursor: not-allowed;
  box-shadow: 
    inset 0 -2px 0 #857259,
    0 1px 3px rgba(0, 0, 0, 0.25);
}

.tile.locked::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 0px;
  background: rgba(15, 20, 25, 0.35);
  pointer-events: none;
}

/* Subtle stacked depth indicators */
.tile-stack-shadow {
  position: absolute;
  inset: 0;
  pointer-events: none;
  box-shadow: inset 0 -2px 4px rgba(0,0,0,0.15);
}

/* ==========================================================
   TEMPORARY HOLDING SHELF (FOR "นำออก" BOOSTER)
   Positioned compactly directly above the tray rack
   ========================================================== */
.tray-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  max-width: 100%;
}

#holding-area-container {
  position: relative;
  flex-shrink: 0;
  display: flex;
  align-items: center;
}

#holding-shelf {
  pointer-events: auto;
  background: linear-gradient(180deg, #432410 0%, #261307 100%);
  border: 2px solid #d4af37;
  border-radius: 14px;
  padding: 5px 10px;
  display: flex;
  align-items: center;
  box-shadow: 
    0 6px 18px rgba(0, 0, 0, 0.7),
    inset 0 1px 2px rgba(255, 235, 150, 0.3),
    inset 0 -2px 4px rgba(0, 0, 0, 0.8);
  animation: shelfPop 0.25s cubic-bezier(0.18, 0.89, 0.32, 1.28);
}

#holding-shelf.hidden {
  display: none;
}

#holding-slots {
  display: flex;
  gap: 8px;
  min-height: var(--tile-h);
  justify-content: center;
  align-items: center;
}

.shelf-tile {
  position: relative !important;
  top: auto !important;
  left: auto !important;
  width: var(--tile-w) !important;
  height: var(--tile-h) !important;
  animation: bounceIn 0.3s cubic-bezier(0.18, 0.89, 0.32, 1.28);
}

/* ==========================================================
   FOOTER AREA (MASCOT, TRAY, BOOSTERS)
   ========================================================== */
#game-footer {
  position: relative;
  z-index: 20;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  padding: 0 24px 14px 24px;
  gap: 16px;
}

/* Mascot Wrapper */
#mascot-wrapper {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  width: 180px;
  pointer-events: none;
}

#speech-bubble {
  position: relative;
  background: rgba(255, 255, 255, 0.95);
  color: #2c3e50;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: 12px;
  margin-bottom: 6px;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
  max-width: 170px;
  line-height: 1.3;
  animation: floatChat 3s ease-in-out infinite;
  pointer-events: auto;
}

#speech-bubble::after {
  content: '';
  position: absolute;
  bottom: -6px;
  left: 36px;
  border-width: 6px 6px 0;
  border-style: solid;
  border-color: rgba(255, 255, 255, 0.95) transparent;
  display: block;
  width: 0;
}

#mascot-avatar-box {
  position: relative;
  width: 95px;
  height: 95px;
  animation: mascotBreathe 3.5s ease-in-out infinite;
}

#mascot-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  filter: drop-shadow(0 6px 12px rgba(0,0,0,0.45));
}

.mascot-shadow {
  position: absolute;
  bottom: 0px;
  left: 15%;
  width: 70%;
  height: 10px;
  background: radial-gradient(ellipse at center, rgba(0,0,0,0.5) 0%, transparent 70%);
  z-index: -1;
}

/* ==========================================================
   CENTER TRAY (7 SLOTS) - LUXURY QNAN WOOD/GOLD FRAME
   ========================================================== */
#tray-outer {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  width: auto;
}

.tray-wood-frame {
  position: relative;
  width: auto;
  height: calc(var(--tile-h) + 20px);
  background: linear-gradient(180deg, #4d2a13 0%, #2f180a 100%);
  border: 3.5px solid #c29955;
  border-radius: 18px;
  box-shadow: 
    0 8px 24px rgba(0, 0, 0, 0.7),
    inset 0 2px 4px rgba(255, 255, 255, 0.25),
    inset 0 -4px 8px rgba(0, 0, 0, 0.6);
  padding: 6px 14px;
  display: flex;
  align-items: center;
}

/* Decorative rivets/corners */
.tray-wood-frame::before {
  content: '';
  position: absolute;
  inset: 2px;
  border: 1px solid rgba(245, 176, 65, 0.4);
  border-radius: 14px;
  pointer-events: none;
}

.tray-inner {
  position: relative;
  height: 100%;
  background: rgba(18, 9, 4, 0.75);
  border-radius: 12px;
  box-shadow: inset 0 3px 8px rgba(0, 0, 0, 0.85);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 8px;
}

.slot-marker {
  width: var(--tile-w);
  height: var(--tile-h);
  border-radius: 2px;
  border: 1.5px dashed rgba(245, 176, 65, 0.25);
  background: rgba(0, 0, 0, 0.3);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  box-sizing: border-box;
}

.slot-marker.filled {
  border-style: solid;
  border-color: transparent;
  background: transparent;
}

/* Tiles inside Tray */
.tray-tile {
  position: relative !important;
  top: 0 !important;
  left: 0 !important;
  width: 100% !important;
  height: 100% !important;
  box-shadow: 0 4px 0 #bda17e, 0 5px 8px rgba(0,0,0,0.4) !important;
  animation: traySnap 0.22s cubic-bezier(0.34, 1.56, 0.64, 1);
  flex-shrink: 0;
}

.tray-warning-bar {
  font-size: 0.75rem;
  font-weight: 700;
  color: #ff5252;
  margin-top: 4px;
  opacity: 0;
  transform: translateY(-4px);
  transition: all 0.25s ease;
  text-shadow: 0 1px 3px rgba(0,0,0,0.8);
}

.tray-warning-bar.show {
  opacity: 1;
  transform: translateY(0);
  animation: pulseWarning 1s infinite alternate;
}

/* ==========================================================
   BOOSTERS (3 QNAN SKILLS)
   ========================================================== */
#boosters-container {
  display: flex;
  gap: 12px;
  align-items: center;
  height: calc(var(--tile-h) + 20px);
  margin-bottom: 22px; /* Exactly matches #tray-outer offset so bottoms align perfectly */
}

.booster-card {
  position: relative;
  background: linear-gradient(180deg, #f7efe1 0%, #ebd7ba 100%);
  border: 2px solid #bfa075;
  border-radius: 12px;
  padding: 4px 10px;
  height: calc(var(--tile-h) + 12px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  cursor: pointer;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.4), inset 0 2px 2px #fff;
  transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
  min-width: 62px;
  box-sizing: border-box;
}

.booster-card:hover:not(.disabled) {
  transform: translateY(-4px) scale(1.05);
  border-color: #ffd57e;
  box-shadow: 0 8px 16px rgba(245, 176, 65, 0.4), inset 0 2px 2px #fff;
}

.booster-card:active:not(.disabled) {
  transform: translateY(1px) scale(0.97);
}

.booster-card.disabled {
  filter: grayscale(0.9) opacity(0.5);
  cursor: not-allowed;
}

.booster-icon-box {
  position: relative;
  width: 38px;
  height: 38px;
  background: #3c546b;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.4);
}

.booster-symbol {
  font-size: 1.3rem;
  filter: drop-shadow(0 2px 3px rgba(0,0,0,0.5));
}

.booster-badge {
  position: absolute;
  top: -6px;
  right: -6px;
  background: #e74c3c;
  color: #fff;
  font-size: 0.68rem;
  font-weight: 800;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1.5px solid #fff;
  box-shadow: 0 2px 4px rgba(0,0,0,0.4);
}

.booster-name {
  font-size: 0.75rem;
  font-weight: 700;
  color: #5c3e10;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.8);
}

/* ==========================================================
   MODALS
   ========================================================== */
.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(8, 10, 16, 0.85);
  backdrop-filter: blur(8px);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.3s ease;
}

.modal-backdrop.hidden {
  display: none;
}

.game-modal {
  position: relative;
  background: linear-gradient(180deg, #252e3d 0%, #161b24 100%);
  border: 3px solid #d4af37;
  border-radius: 20px;
  width: 90%;
  max-width: 480px;
  padding: 24px;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.8), 0 0 20px rgba(212, 175, 55, 0.3);
  animation: modalScale 0.3s cubic-bezier(0.18, 0.89, 0.32, 1.28);
}

.hidden,
.game-modal.hidden {
  display: none !important;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1.5px solid rgba(212, 175, 55, 0.3);
  padding-bottom: 12px;
  margin-bottom: 16px;
}

.modal-header h2 {
  font-size: 1.25rem;
  color: #ffd875;
  font-weight: 700;
}

.btn-close-modal {
  background: transparent;
  border: none;
  color: #aaa;
  font-size: 1.4rem;
  cursor: pointer;
  transition: color 0.2s;
}

.btn-close-modal:hover {
  color: #fff;
}

.modal-body {
  color: #e0e0e0;
  font-size: 0.9rem;
  line-height: 1.6;
}

.text-center {
  text-align: center;
}

.rules-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.rules-list ul {
  list-style: disc;
  margin-left: 24px;
  margin-top: 6px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.defeat-icon, .victory-trophy {
  font-size: 3.5rem;
  margin-bottom: 10px;
  animation: bounceTrophy 1.5s infinite alternate;
}

.victory-title {
  color: #ffd875;
  font-size: 1.35rem;
  margin-bottom: 16px;
}

.victory-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  background: rgba(0, 0, 0, 0.35);
  border-radius: 12px;
  padding: 12px 8px;
  margin: 16px 0;
}

.stat-item {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.stat-label {
  font-size: 0.75rem;
  color: #aaa;
}

.stat-val {
  font-size: 1.1rem;
  font-weight: 700;
  color: #fff;
}

.text-gold {
  color: #ffd700;
}

.modal-footer {
  display: flex;
  gap: 12px;
  justify-content: center;
  margin-top: 20px;
}

/* Button styles */
.btn-primary, .btn-secondary, .btn-revive {
  padding: 10px 22px;
  border-radius: 25px;
  font-family: var(--font-heading);
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
  border: none;
}

.btn-primary {
  background: linear-gradient(180deg, #f5b041 0%, #d35400 100%);
  color: #fff;
  box-shadow: 0 4px 14px rgba(211, 84, 0, 0.5);
}

.btn-primary:hover {
  transform: translateY(-2px) scale(1.05);
  box-shadow: 0 6px 18px rgba(211, 84, 0, 0.7);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.15);
  color: #eee;
  border: 1px solid rgba(255, 255, 255, 0.25);
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.25);
  transform: translateY(-2px);
}

.btn-revive {
  background: linear-gradient(180deg, #2ecc71 0%, #27ae60 100%);
  color: #fff;
  box-shadow: 0 4px 14px rgba(46, 204, 113, 0.5);
}

.btn-revive:hover {
  transform: translateY(-2px) scale(1.05);
  box-shadow: 0 6px 18px rgba(46, 204, 113, 0.7);
}

/* ==========================================================
   PARTICLE & ANIMATION EFFECTS
   ========================================================== */
#fx-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 90;
  overflow: hidden;
}

.fx-star {
  position: absolute;
  font-size: 1.5rem;
  animation: starBurst 0.6s forwards ease-out;
  pointer-events: none;
}

.tile-fly-clone {
  position: fixed;
  z-index: 9999;
  pointer-events: none;
  transition: all 0.25s cubic-bezier(0.2, 0.8, 0.3, 1);
}

.tile-match-burst {
  animation: matchVanish 0.35s forwards cubic-bezier(0.3, 1.4, 0.5, 1);
}

/* Keyframes */
@keyframes floatChat {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-4px); }
}

@keyframes mascotBreathe {
  0%, 100% { transform: scale(1) translateY(0); }
  50% { transform: scale(1.02) translateY(-3px); }
}

@keyframes shelfPop {
  0% { transform: scale(0.85); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

@keyframes bounceIn {
  0% { transform: scale(0.6); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

@keyframes traySnap {
  0% { transform: scale(1.15) translateY(-8px); }
  100% { transform: scale(1) translateY(0); }
}

@keyframes matchVanish {
  0% { transform: scale(1); filter: brightness(1.8); }
  50% { transform: scale(1.35) rotate(8deg); filter: brightness(2.5); box-shadow: 0 0 25px #ffd700; }
  100% { transform: scale(0) rotate(-15deg); opacity: 0; }
}

@keyframes starBurst {
  0% { transform: translate(0, 0) scale(0.4) rotate(0deg); opacity: 1; }
  100% { transform: translate(var(--tx), var(--ty)) scale(1.4) rotate(180deg); opacity: 0; }
}

@keyframes modalScale {
  0% { transform: scale(0.8); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

@keyframes pulseWarning {
  0% { transform: scale(1); opacity: 0.8; }
  100% { transform: scale(1.05); opacity: 1; text-shadow: 0 0 10px #ff3b30; }
}

@keyframes bounceTrophy {
  0% { transform: translateY(0) scale(1); }
  100% { transform: translateY(-8px) scale(1.06); }
}

/* Daily Dropdown Option */
.diff-opt-daily {
  color: #ff9f43 !important;
  border-top: 1px solid rgba(245, 176, 65, 0.2);
  display: flex;
  align-items: center;
  gap: 6px;
}
.diff-opt-daily:hover, .diff-opt-daily.active {
  background: rgba(255, 107, 107, 0.25) !important;
  color: #ff6b6b !important;
}

/* Real-Time Combo Banner */
.combo-banner {
  position: absolute;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 8px;
  background: linear-gradient(135deg, #ff4500 0%, #ff9f43 100%);
  color: #fff;
  padding: 4px 18px;
  border-radius: 30px;
  border: 2px solid #fff;
  box-shadow: 0 0 20px rgba(255, 69, 0, 0.85), 0 4px 12px rgba(0, 0, 0, 0.6);
  z-index: 25;
  pointer-events: none;
  font-family: var(--font-heading);
  font-weight: 800;
  animation: comboPop 0.35s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.combo-title {
  font-size: 0.88rem;
  letter-spacing: 1px;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.6);
}

.combo-badge {
  font-size: 1.15rem;
  color: #ffeb3b;
  text-shadow: 0 2px 5px rgba(0, 0, 0, 0.8);
}

@keyframes comboPop {
  0% { transform: translateX(-50%) scale(0.5); opacity: 0; }
  70% { transform: translateX(-50%) scale(1.2); }
  100% { transform: translateX(-50%) scale(1); opacity: 1; }
}

/* ==========================================================
   TILE SKINS (THEMES)
   ========================================================== */
body.skin-emerald .tile {
  background: linear-gradient(180deg, #1b4937 0%, #0d281e 100%);
  border: 1.5px solid #38b27a;
  box-shadow: inset 0 -2.5px 0 #13422d, inset 0 1px 0 rgba(100, 255, 180, 0.4), 0 2px 4px rgba(0, 0, 0, 0.25);
}
body.skin-emerald .tile.active:hover {
  border-color: #6ee7b7;
  box-shadow: inset 0 -2.5px 0 #13422d, 0 0 12px rgba(52, 211, 153, 0.5);
}

body.skin-obsidian .tile {
  background: linear-gradient(180deg, #2c303d 0%, #171922 100%);
  border: 1.5px solid #eab308;
  box-shadow: inset 0 -2.5px 0 #926f0c, inset 0 1px 0 rgba(255, 230, 150, 0.4), 0 2px 4px rgba(0, 0, 0, 0.35);
}
body.skin-obsidian .tile.active:hover {
  border-color: #fde047;
  box-shadow: inset 0 -2.5px 0 #926f0c, 0 0 12px rgba(234, 179, 8, 0.6);
}

body.skin-cyber .tile {
  background: linear-gradient(180deg, #161b33 0%, #0b0d1e 100%);
  border: 1.5px solid #06b6d4;
  box-shadow: inset 0 -2.5px 0 #0e7490, inset 0 1px 0 rgba(100, 230, 255, 0.4), 0 2px 4px rgba(0, 0, 0, 0.35);
}
body.skin-cyber .tile.active:hover {
  border-color: #67e8f9;
  box-shadow: inset 0 -2.5px 0 #0e7490, 0 0 12px rgba(6, 182, 212, 0.7);
}

/* ==========================================================
   MODAL: DETECTIVE SHOP (🛍️)
   ========================================================== */
.modal-shop {
  width: 900px;
  max-width: min(920px, 94vw);
  max-height: 92vh;
  padding: 16px 24px;
  display: flex;
  flex-direction: column;
}

.modal-shop .modal-header {
  margin-bottom: 8px;
  padding-bottom: 6px;
}

.modal-shop .modal-footer {
  margin-top: 10px;
}

.modal-shop .modal-body {
  overflow-y: auto;
  max-height: calc(90vh - 110px);
  padding-right: 4px;
}

/* Custom Sleek Scrollbar */
.modal-body::-webkit-scrollbar {
  width: 4px;
}
.modal-body::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.2);
  border-radius: 4px;
}
.modal-body::-webkit-scrollbar-thumb {
  background: rgba(245, 176, 65, 0.35);
  border-radius: 4px;
}
.modal-body::-webkit-scrollbar-thumb:hover {
  background: rgba(245, 176, 65, 0.7);
}

/* Shopkeeper Hero Banner */
.shop-hero-banner {
  position: relative;
  width: 100%;
  height: 86px;
  border-radius: 10px;
  overflow: hidden;
  border: 1.5px solid rgba(245, 176, 65, 0.4);
  margin-bottom: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
  background: #111;
}

.shop-hero-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 28%;
  filter: brightness(0.92);
  transition: transform 0.4s ease;
}

.shop-hero-banner:hover .shop-hero-img {
  transform: scale(1.03);
}

.shop-hero-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.05) 0%, rgba(14, 17, 24, 0.88) 85%);
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: 6px 10px;
}

.shop-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: linear-gradient(90deg, #f5b041 0%, #e67e22 100%);
  color: #12151c;
  font-size: 0.62rem;
  font-weight: 800;
  padding: 1px 6px;
  border-radius: 4px;
  width: fit-content;
  letter-spacing: 0.5px;
  margin-bottom: 2px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
}

.shop-quote {
  font-size: 0.75rem;
  color: #fffdf8;
  font-weight: 500;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.9);
  line-height: 1.25;
}

.shop-balance-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: rgba(0, 0, 0, 0.45);
  border: 1px solid rgba(245, 176, 65, 0.3);
  border-radius: 10px;
  padding: 4px 12px;
  margin-bottom: 6px;
  font-size: 0.88rem;
}

.shop-gold-total {
  font-size: 1.1rem;
  color: #ffd166;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 5px;
}

.shop-tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 6px;
}

.shop-tab {
  flex: 1;
  padding: 6px 10px;
  background: rgba(255, 255, 255, 0.08);
  border: 1.5px solid rgba(255, 255, 255, 0.15);
  border-radius: 8px;
  color: #ddd;
  font-family: var(--font-heading);
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

.shop-tab:hover {
  background: rgba(255, 255, 255, 0.15);
}

.shop-tab.active {
  background: linear-gradient(180deg, rgba(245, 176, 65, 0.3) 0%, rgba(211, 84, 0, 0.3) 100%);
  border-color: #f5b041;
  color: #ffd166;
  box-shadow: 0 4px 10px rgba(0,0,0,0.3);
}

/* Skins Grid */
.skins-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}

.skin-card {
  background: rgba(255, 255, 255, 0.04);
  border: 1.5px solid rgba(255, 255, 255, 0.12);
  border-radius: 12px;
  padding: 10px 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 6px;
  transition: all 0.2s ease;
}

.skin-card:hover {
  border-color: rgba(245, 176, 65, 0.5);
  transform: translateY(-2px);
  background: rgba(255, 255, 255, 0.07);
}

.skin-preview {
  width: 58px;
  height: 58px;
  border-radius: 8px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.5);
  border: 1.5px solid rgba(255, 255, 255, 0.2);
  transition: transform 0.2s ease;
}

.skin-card:hover .skin-preview {
  transform: scale(1.04);
}

.skin-img-preview {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.skin-preview-classic {
  border-color: #dcd0bc;
  box-shadow: 0 0 10px rgba(220, 208, 188, 0.25);
}

.skin-preview-emerald {
  border-color: #38b27a;
  box-shadow: 0 0 12px rgba(56, 178, 122, 0.35);
}

.skin-preview-obsidian {
  border-color: #eab308;
  box-shadow: 0 0 12px rgba(234, 179, 8, 0.35);
}

.skin-preview-cyber {
  border-color: #06b6d4;
  box-shadow: 0 0 14px rgba(6, 182, 212, 0.45);
}

.skin-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.skin-name {
  font-size: 0.85rem;
  font-weight: 700;
  color: #fff;
}

.skin-desc {
  font-size: 0.68rem;
  color: #aaa;
}

.btn-skin-action {
  width: 100%;
  padding: 6px 10px;
  border-radius: 8px;
  font-size: 0.82rem;
  font-weight: 700;
  font-family: var(--font-heading);
  cursor: pointer;
  border: none;
  background: rgba(245, 176, 65, 0.2);
  color: #ffd166;
  border: 1px solid #f5b041;
  transition: all 0.2s ease;
}

.btn-skin-action:hover {
  background: #f5b041;
  color: #12151c;
}

.btn-skin-action.equipped {
  background: rgba(46, 204, 113, 0.2);
  border-color: #2ecc71;
  color: #2ecc71;
  cursor: default;
}

/* Booster Shop List */
.booster-shop-list {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
}

.booster-shop-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 10px;
  background: rgba(255, 255, 255, 0.04);
  border: 1.5px solid rgba(255, 255, 255, 0.1);
  border-radius: 14px;
  padding: 16px 14px;
  transition: all 0.2s ease;
}

.booster-shop-item:hover {
  background: rgba(255, 255, 255, 0.07);
  border-color: rgba(245, 176, 65, 0.45);
  transform: translateY(-2px);
}

.booster-shop-img-box {
  width: 64px;
  height: 64px;
  border-radius: 12px;
  overflow: hidden;
  border: 1.5px solid rgba(245, 176, 65, 0.4);
  flex-shrink: 0;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
  background: #000;
}

.booster-shop-thumb {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.booster-shop-detail {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  width: 100%;
}

.booster-shop-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: #fff;
}

.booster-shop-desc {
  font-size: 0.75rem;
  color: #aaa;
  line-height: 1.35;
  min-height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn-buy-booster {
  width: 100%;
  padding: 8px 16px;
  border-radius: 10px;
  font-size: 0.9rem;
  font-weight: 700;
  font-family: var(--font-heading);
  cursor: pointer;
  background: linear-gradient(180deg, #f5b041 0%, #d35400 100%);
  color: #fff;
  border: none;
  box-shadow: 0 4px 10px rgba(211, 84, 0, 0.4);
  transition: all 0.2s ease;
  white-space: nowrap;
}

.btn-buy-booster:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 14px rgba(211, 84, 0, 0.6);
}

/* ==========================================================
   MODAL: DETECTIVE DOSSIER & RECORDS (🏆)
   ========================================================== */
.modal-stats {
  width: 900px;
  max-width: min(920px, 94vw);
  max-height: 92vh;
  padding: 16px 24px;
  display: flex;
  flex-direction: column;
}

.modal-stats .modal-body {
  overflow-y: auto;
  max-height: calc(90vh - 110px);
  padding-right: 4px;
}

/* Horizontal Grid for Tab 1 (Dossier) */
.dossier-grid-horizontal {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 16px;
  align-items: start;
}

.dossier-col-left {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.dossier-col-right {
  display: flex;
  flex-direction: column;
}

/* Leaderboard Header Bar (Horizontal Controls) */
.lb-header-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 12px;
}

.lb-header-bar .player-name-bar {
  margin-bottom: 0;
  flex: 0 0 auto;
}

.lb-header-bar .lb-filter-tabs {
  margin-bottom: 0;
  flex: 1;
}

.stats-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.stats-tab {
  flex: 1;
  padding: 7px 12px;
  background: rgba(255, 255, 255, 0.08);
  border: 1.5px solid rgba(255, 255, 255, 0.15);
  border-radius: 10px;
  color: #ddd;
  font-family: var(--font-heading);
  font-weight: 600;
  font-size: 0.88rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

.stats-tab:hover {
  background: rgba(255, 255, 255, 0.15);
}

.stats-tab.active {
  background: linear-gradient(180deg, rgba(245, 176, 65, 0.3) 0%, rgba(211, 84, 0, 0.3) 100%);
  border-color: #f5b041;
  color: #ffd166;
  box-shadow: 0 4px 10px rgba(0,0,0,0.3);
}

/* Player Name Bar */
.player-name-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(245, 176, 65, 0.3);
  border-radius: 10px;
  padding: 6px 12px;
  margin-bottom: 10px;
  gap: 8px;
}

/* Header Player Detective Badge */
.player-badge {
  display: flex;
  align-items: center;
  gap: 5px;
  background: rgba(18, 22, 33, 0.9);
  border: 1.5px solid rgba(245, 176, 65, 0.6);
  border-radius: 20px;
  padding: 3px 10px;
  color: #fff;
  font-weight: 600;
  font-size: 0.82rem;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
  cursor: pointer;
  transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1), border-color 0.2s ease, box-shadow 0.2s ease;
  user-select: none;
}

.player-badge:hover {
  transform: scale(1.05);
  border-color: #ffd166;
  box-shadow: 0 6px 16px rgba(245, 176, 65, 0.35);
  background: rgba(30, 36, 52, 0.95);
}

.player-name-display {
  color: #ffd166;
  font-weight: 700;
  max-width: 88px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.player-badge-edit {
  font-size: 0.85rem;
  opacity: 0.75;
  transition: opacity 0.2s;
}

.player-badge:hover .player-badge-edit {
  opacity: 1;
}

/* Player Name Setup inside Leaderboard */
.player-name-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.1);
  padding: 8px 12px;
  border-radius: 10px;
  gap: 10px;
}

.player-name-label {
  font-size: 0.82rem;
  color: #90a4ae;
  font-weight: 600;
}

.name-display-badge {
  display: flex;
  align-items: center;
  gap: 8px;
}

.name-badge-text {
  font-size: 0.92rem;
  font-weight: 700;
  color: #ffd166;
}

.btn-change-name {
  padding: 4px 10px;
  background: rgba(245, 176, 65, 0.2);
  border: 1px solid #f5b041;
  color: #ffd166;
  font-weight: 700;
  font-size: 0.75rem;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-change-name:hover {
  background: #f5b041;
  color: #12151c;
  transform: scale(1.04);
}

/* Leaderboard Filter Tabs */
.lb-filter-tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 8px;
}

.lb-filter-btn {
  flex: 1;
  padding: 5px 8px;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.05);
  color: #bbb;
  font-size: 0.76rem;
  font-family: var(--font-heading);
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.lb-filter-btn:hover {
  background: rgba(255, 255, 255, 0.1);
}

.lb-filter-btn.active {
  background: rgba(245, 176, 65, 0.25);
  border-color: #f5b041;
  color: #ffd166;
  font-weight: 700;
}

/* Weekly Sub-difficulty Filter Bar */
.lb-weekly-subtabs {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
  background: rgba(14, 17, 24, 0.7);
  border: 1px dashed rgba(245, 176, 65, 0.35);
  padding: 6px 12px;
  border-radius: 8px;
}

.weekly-sub-label {
  font-size: 0.78rem;
  font-weight: 700;
  color: #ffd166;
  white-space: nowrap;
}

.lb-weekly-sub-btn {
  padding: 3px 9px;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  background: rgba(255, 255, 255, 0.05);
  color: #cfd8dc;
  font-size: 0.74rem;
  font-family: var(--font-heading);
  cursor: pointer;
  transition: all 0.2s ease;
}

.lb-weekly-sub-btn:hover {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
}

.lb-weekly-sub-btn.active {
  background: #f5b041;
  color: #12151c;
  border-color: #f5b041;
  font-weight: 700;
  box-shadow: 0 2px 6px rgba(245, 176, 65, 0.4);
}

.country-flag-badge {
  font-size: 1.15rem;
  filter: drop-shadow(0 1px 2px rgba(0,0,0,0.4));
  display: inline-block;
  vertical-align: middle;
}

/* Leaderboard Table Specifics */
.lb-table-container {
  max-height: 215px;
  overflow-y: auto;
  padding: 4px 8px;
}

.lb-table {
  width: 100%;
  border-collapse: collapse;
}

.lb-table th {
  position: sticky;
  top: 0;
  background: #1a1e27;
  z-index: 2;
  padding: 8px 12px;
  font-size: 0.85rem;
}

.lb-table td {
  padding: 8px 12px;
  font-size: 0.86rem;
}

.lb-rank-1 td {
  background: rgba(255, 215, 0, 0.14) !important;
  font-weight: 700;
  color: #fff;
}
.lb-rank-2 td {
  background: rgba(192, 192, 192, 0.1) !important;
  font-weight: 700;
}
.lb-rank-3 td {
  background: rgba(205, 127, 50, 0.1) !important;
  font-weight: 700;
}
.lb-row-me td {
  border-left: 3px solid #f5b041;
  background: rgba(245, 176, 65, 0.22) !important;
  font-weight: 700;
}

.lb-me-tag {
  font-size: 0.75rem;
  color: #ffd875;
  font-weight: 700;
  margin-left: 6px;
}

.lb-skin-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 12px;
  padding: 2px 10px;
  font-size: 0.78rem;
  font-weight: 600;
  color: #e0e0e0;
}

.vic-your-rank {
  background: linear-gradient(135deg, rgba(245, 176, 65, 0.25) 0%, rgba(255, 110, 0, 0.25) 100%);
  border: 1.5px solid #f5b041;
  color: #ffd166;
  font-size: 0.92rem;
  font-weight: 700;
  padding: 6px 16px;
  border-radius: 14px;
  display: inline-block;
  margin-bottom: 12px;
  box-shadow: 0 4px 14px rgba(245, 176, 65, 0.25);
}

/* Dedicated Player's Own Rank Card - Gaming Best Practice */
.lb-my-rank-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 10px;
  padding: 8px 16px;
  background: linear-gradient(135deg, rgba(32, 40, 58, 0.95) 0%, rgba(20, 24, 36, 0.98) 100%);
  border: 1.5px solid rgba(245, 176, 65, 0.55);
  border-radius: 12px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5), inset 0 1px 2px rgba(255, 255, 255, 0.12);
  gap: 14px;
  position: relative;
  overflow: hidden;
}

.lb-my-rank-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 4px;
  height: 100%;
  background: linear-gradient(180deg, #f5b041 0%, #e67e22 100%);
}

.my-rank-left {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.my-rank-badge-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-width: 84px;
  background: rgba(0, 0, 0, 0.38);
  padding: 4px 8px;
  border-radius: 8px;
  border: 1px solid rgba(245, 176, 65, 0.3);
  transition: all 0.2s ease;
}

.my-rank-badge-col.rank-top3 {
  border-color: #ffd166;
  box-shadow: 0 0 10px rgba(245, 176, 65, 0.4);
  background: rgba(245, 176, 65, 0.16);
}

.my-rank-label {
  font-size: 0.65rem;
  color: #cfd8dc;
  font-weight: 600;
  white-space: nowrap;
}

.my-rank-value {
  font-family: var(--font-heading);
  font-size: 0.95rem;
  font-weight: 800;
  color: #ffd166;
  text-shadow: 0 1px 3px rgba(0,0,0,0.6);
  white-space: nowrap;
}

.my-rank-player-col {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.my-rank-avatar {
  font-size: 1.4rem;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.4));
  flex-shrink: 0;
}

.my-rank-name-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.my-rank-name {
  font-weight: 700;
  font-size: 0.96rem;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 240px;
}

.my-rank-you-badge {
  font-size: 0.65rem;
  font-weight: 700;
  background: rgba(245, 176, 65, 0.25);
  color: #ffd875;
  border: 1px solid rgba(245, 176, 65, 0.5);
  padding: 1px 6px;
  border-radius: 10px;
  white-space: nowrap;
}

.my-rank-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.my-rank-stat-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-width: 50px;
}

.my-rank-stat-title {
  font-size: 0.65rem;
  color: #90a4ae;
  font-weight: 600;
  white-space: nowrap;
}

.my-rank-stat-number {
  font-family: var(--font-heading);
  font-size: 0.88rem;
  font-weight: 700;
  color: #ffd166;
  white-space: nowrap;
}

.btn-refresh-lb {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 5px 9px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 8px;
  color: #e0e0e0;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.btn-refresh-lb:hover {
  background: rgba(245, 176, 65, 0.25);
  border-color: #f5b041;
  color: #ffd875;
  transform: translateY(-1px);
}

/* Victory Cloud Notice */
.vic-lb-status {
  background: rgba(46, 204, 113, 0.2);
  border: 1px solid #2ecc71;
  color: #a8e6cf;
  font-size: 0.8rem;
  font-weight: 600;
  padding: 4px 12px;
  border-radius: 12px;
  display: inline-block;
  margin-bottom: 10px;
}

.rank-badge-box {
  display: flex;
  align-items: center;
  gap: 14px;
  background: linear-gradient(135deg, rgba(245, 176, 65, 0.15) 0%, rgba(18, 22, 33, 0.8) 100%);
  border: 1.5px solid #f5b041;
  border-radius: 14px;
  padding: 12px 18px;
  margin-bottom: 14px;
}

.rank-icon {
  font-size: 2.2rem;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.5));
}

.rank-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.rank-title {
  font-size: 1.1rem;
  font-weight: 800;
  color: #ffd166;
  font-family: var(--font-heading);
}

.rank-sub {
  font-size: 0.82rem;
  color: #ccc;
}

.rank-sub b {
  color: #fff;
}

.daily-streak-card {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 16px;
}

.streak-item {
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  padding: 8px 10px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.streak-icon {
  font-size: 1.4rem;
}

.streak-label {
  display: block;
  font-size: 0.68rem;
  color: #aaa;
}

.streak-value {
  display: block;
  font-size: 0.88rem;
  font-weight: 700;
  color: #fff;
}

.records-subtitle {
  font-size: 0.88rem;
  color: #f5b041;
  margin-bottom: 8px;
  font-weight: 700;
}

.records-table-container {
  background: rgba(0, 0, 0, 0.35);
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  padding: 10px;
}

.records-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8rem;
  text-align: left;
}

.records-table th {
  color: #ffd166;
  font-weight: 700;
  padding: 6px 8px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.15);
}

.records-table td {
  padding: 6px 8px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  color: #ddd;
}

.records-table tr:last-child td {
  border-bottom: none;
}

/* Victory Streak Box */
.vic-streak-box {
  background: rgba(255, 107, 107, 0.2);
  border: 1.5px solid #ff6b6b;
  border-radius: 20px;
  padding: 6px 16px;
  color: #ff9f43;
  font-weight: 700;
  font-size: 0.95rem;
  display: inline-block;
  margin-bottom: 12px;
  box-shadow: 0 4px 12px rgba(255, 107, 107, 0.3);
}

/* ==========================================================
   RESPONSIVE SCALING (MOBILE PORTRAIT & LANDSCAPE SUPPORT)
   ========================================================== */

/* Universal mobile touch improvements */
button, .tile, .hanging-board, .booster-card, .btn-icon {
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

/* 1. TABLET & COMPACT DESKTOP (Width <= 900px) */
@media (max-width: 900px) {
  #game-viewport {
    aspect-ratio: unset;
    box-shadow: none;
  }
  
  #game-header {
    padding: 8px 14px 2px 14px;
    min-height: 48px;
  }
  
  #title-banner {
    top: 8px;
  }
  
  .banner-title {
    font-size: 0.95rem;
  }
  
  .hanging-board .board-body {
    min-width: 100px;
    padding: 5px 8px;
  }
  
  .board-tag {
    font-size: 0.82rem;
  }

  .board-reward {
    font-size: 0.65rem;
  }
  
  #game-footer {
    padding: 0 10px 8px 10px;
    gap: 8px;
  }
  
  #mascot-wrapper {
    width: 110px;
  }
  
  #mascot-avatar-box {
    width: 65px;
    height: 65px;
  }
  
  #speech-bubble {
    font-size: 0.65rem;
    max-width: 120px;
    padding: 4px 8px;
  }
  
  .booster-card {
    min-width: 52px;
    padding: 4px 6px 3px 6px;
  }
  
  .booster-icon-box {
    width: 32px;
    height: 32px;
  }
  
  .booster-symbol {
    font-size: 1.1rem;
  }
}

/* 2. MOBILE PORTRAIT (Phones held vertically) */
@media (max-width: 768px), (orientation: portrait) and (max-width: 900px) {
  :root {
    --tile-w: 35px;
    --tile-h: 35px;
  }

  html, body, #game-app {
    max-width: 100vw !important;
    width: 100vw !important;
    overflow-x: hidden !important;
  }

  #game-viewport {
    width: 100vw !important;
    max-width: 100vw !important;
    min-width: 0 !important;
    height: 100%;
    height: 100dvh;
    max-height: 100dvh;
    aspect-ratio: unset;
    border-radius: 0;
    overflow: hidden !important;
    overflow-x: hidden !important;
  }

  /* Compact single-row mobile header */
  #game-header {
    padding: max(4px, env(safe-area-inset-top)) max(8px, env(safe-area-inset-right)) 2px max(8px, env(safe-area-inset-left));
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    max-width: 100vw;
    box-sizing: border-box;
    gap: 4px;
    flex-shrink: 0;
  }

  .hanging-board {
    flex-shrink: 0;
  }

  .hanging-board .rope {
    display: none; /* Hide hanging ropes in compact mobile header */
  }

  .hanging-board .board-body {
    min-width: unset;
    padding: 3px 6px;
    border-radius: 6px;
    border-width: 1.5px;
  }

  .board-tag {
    font-size: 0.72rem;
  }

  .board-reward {
    display: none; /* Hide gold reward text in tiny header to save room */
  }

  #title-banner {
    padding: 4px 8px;
    flex: 1;
    min-width: 0;
    max-width: 115px;
    text-align: center;
    border-radius: 10px;
    display: flex;
    justify-content: center;
    align-items: center;
  }

  .banner-badge {
    display: none; /* Hide mini game badge in mobile header to save space */
  }

  .banner-title {
    display: none; /* Hide long title on mobile portrait to fit wallet and controls */
  }

  .banner-sub {
    font-size: 0.68rem;
    font-weight: 700;
    gap: 4px;
    margin: 0;
    white-space: nowrap;
    justify-content: center;
  }

  .sub-short {
    display: inline;
  }

  .sub-full {
    display: none;
  }

  #header-controls {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 3px;
  }

  .player-wallet {
    padding: 2px 6px;
    font-size: 0.74rem;
    gap: 3px;
    border-radius: 12px;
  }

  .wallet-icon {
    font-size: 0.82rem;
  }

  .btn-icon {
    width: 26px;
    height: 26px;
    font-size: 0.72rem;
    border-width: 1.5px;
  }

  /* Compact Combo Banner on mobile */
  .combo-banner {
    top: 8px;
    padding: 3px 12px;
  }

  .combo-title {
    font-size: 0.75rem;
  }

  .combo-badge {
    font-size: 0.95rem;
  }

  /* Mobile Modals: Shop & Stats */
  .shop-hero-banner {
    height: 90px;
    margin-bottom: 8px;
  }

  .shop-quote {
    font-size: 0.7rem;
  }

  .skins-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
  }

  .skin-card {
    padding: 6px;
    gap: 4px;
  }

  .skin-preview {
    width: 52px;
    height: 52px;
  }

  .skin-name {
    font-size: 0.76rem;
  }

  .skin-desc {
    font-size: 0.62rem;
  }

  .btn-skin-action {
    padding: 4px 6px;
    font-size: 0.72rem;
  }

  .booster-shop-item {
    padding: 6px 10px;
    gap: 8px;
  }

  .booster-shop-img-box {
    width: 44px;
    height: 44px;
    border-radius: 8px;
  }

  .booster-shop-title {
    font-size: 0.8rem;
  }

  .booster-shop-desc {
    font-size: 0.65rem;
  }

  .btn-buy-booster {
    padding: 5px 10px;
    font-size: 0.76rem;
  }

  .rank-badge-box {
    padding: 8px 12px;
    gap: 10px;
  }

  .rank-icon {
    font-size: 1.7rem;
  }

  .rank-title {
    font-size: 0.95rem;
  }

  .daily-streak-card {
    gap: 4px;
  }

  .streak-item {
    padding: 5px 6px;
    gap: 4px;
  }

  .streak-icon {
    font-size: 1.1rem;
  }

  .streak-value {
    font-size: 0.76rem;
  }

  /* Mobile Leaderboard Styles */
  .stats-tab {
    padding: 5px 6px;
    font-size: 0.75rem;
  }

  .dossier-grid-horizontal {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .lb-header-bar {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }

  .player-name-bar {
    flex-direction: column;
    align-items: stretch;
    padding: 6px 8px;
    gap: 4px;
  }

  .name-input-group {
    max-width: 100%;
  }

  .lb-filter-btn {
    padding: 4px 5px;
    font-size: 0.7rem;
  }

  .lb-table th:nth-child(6),
  .lb-table td:nth-child(6) {
    display: none; /* Hide skin column on narrow phone screens to avoid horizontal scrollbar */
  }

  .lb-table {
    table-layout: fixed;
    width: 100%;
  }

  .lb-table th:nth-child(1), .lb-table td:nth-child(1) { width: 14%; padding: 4px 2px; text-align: center; }
  .lb-table th:nth-child(2), .lb-table td:nth-child(2) { width: 12%; padding: 4px 2px; text-align: center; }
  .lb-table th:nth-child(3), .lb-table td:nth-child(3) { width: 36%; padding: 4px 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .lb-table th:nth-child(4), .lb-table td:nth-child(4) { width: 18%; padding: 4px 2px; text-align: center; }
  .lb-table th:nth-child(5), .lb-table td:nth-child(5) { width: 20%; padding: 4px 2px; text-align: right; }

  .lb-weekly-subtabs {
    flex-wrap: wrap;
    gap: 4px;
    padding: 4px 8px;
  }

  .lb-weekly-sub-btn {
    font-size: 0.68rem;
    padding: 2px 6px;
  }

  .lb-table-container {
    max-height: 200px;
    overflow-x: hidden;
  }

  .lb-my-rank-card {
    padding: 6px 8px;
    gap: 6px;
    flex-wrap: wrap;
  }

  .my-rank-left {
    gap: 6px;
    width: 100%;
    justify-content: space-between;
  }

  .my-rank-badge-col {
    min-width: 65px;
    padding: 2px 4px;
  }

  .my-rank-right {
    gap: 6px;
    width: 100%;
    justify-content: space-between;
  }

  .my-rank-skin-box {
    display: none;
  }

  .my-rank-stat-box {
    min-width: 44px;
  }

  /* Board area occupies all remaining vertical space */
  #board-container {
    flex: 1;
    min-height: 0;
    min-width: 0;
    padding: 2px 4px;
    overflow: hidden;
    width: 100%;
    max-width: 100vw;
    box-sizing: border-box;
  }

  #chalkboard-frame {
    width: 100%;
    height: 100%;
    max-width: calc(100vw - 8px);
    max-height: 100%;
    border-width: 3.5px;
    border-radius: 8px;
    box-sizing: border-box;
    overflow: hidden;
  }

  #board-grid {
    width: 100%;
    height: 100%;
    position: relative;
    overflow: hidden;
  }

  /* Footer: Centered Tray, Centered Boosters below, Mascot on bottom-left */
  #game-footer {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 0 max(8px, env(safe-area-inset-right)) max(8px, env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left));
    width: 100%;
    max-width: 100vw;
    position: relative;
    box-sizing: border-box;
    flex-shrink: 0;
  }

  #tray-outer {
    width: 100%;
    max-width: 100vw;
    display: flex;
    flex-direction: column;
    align-items: center;
    box-sizing: border-box;
  }

  .tray-wood-frame {
    height: calc(var(--tile-h) + 14px);
    padding: 3px 6px;
    border-width: 2.5px;
    border-radius: 12px;
    max-width: calc(100vw - 12px);
    box-sizing: border-box;
  }

  .tray-inner {
    gap: 4px;
    padding: 0 4px;
    border-radius: 8px;
    max-width: 100%;
    box-sizing: border-box;
  }

  .slot-marker {
    border-width: 1px;
    border-radius: 2px;
  }

  .tray-warning-bar {
    font-size: 0.68rem;
    margin-top: 2px;
  }

  #holding-shelf {
    padding: 3px 6px;
    border-radius: 10px;
    border-width: 1.5px;
    margin-bottom: 3px;
  }

  #holding-slots {
    gap: 4px;
  }

  /* Mascot companion on bottom left */
  #mascot-wrapper {
    position: absolute;
    bottom: 4px;
    left: 6px;
    display: flex;
    flex-direction: column;
    align-items: center;
    width: auto;
    z-index: 30;
    pointer-events: auto;
  }

  #mascot-avatar-box {
    width: 36px;
    height: 36px;
    flex-shrink: 0;
  }

  #speech-bubble {
    display: none; /* Hide speech bubble in portrait so it doesn't block buttons */
  }

  /* Boosters: Centered prominent touch bar */
  #boosters-container {
    display: flex;
    gap: 8px;
    justify-content: center;
    align-items: center;
    width: 100%;
    max-width: 100vw;
    box-sizing: border-box;
  }

  .booster-card {
    min-width: 54px;
    padding: 3px 6px 2px 6px;
    border-radius: 8px;
    border-width: 1.5px;
    gap: 2px;
  }

  .booster-icon-box {
    width: 28px;
    height: 28px;
    border-radius: 6px;
  }

  .booster-symbol {
    font-size: 1rem;
  }

  .booster-badge {
    width: 16px;
    height: 16px;
    font-size: 0.62rem;
    top: -5px;
    right: -5px;
  }

  .booster-name {
    font-size: 0.68rem;
  }

  .booster-badge {
    width: 16px;
    height: 16px;
    font-size: 0.62rem;
    top: -5px;
    right: -5px;
  }

  .booster-name {
    font-size: 0.65rem;
  }

  /* Modals on mobile */
  .game-modal {
    width: 92%;
    max-width: 360px;
    padding: 16px;
    border-radius: 16px;
    max-height: 85dvh;
    overflow-y: auto;
  }

  .modal-shop, .modal-stats, .modal-archive {
    width: 95% !important;
    max-width: 95vw !important;
    max-height: 88dvh !important;
    padding: 12px 14px !important;
  }

  .skins-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 8px !important;
  }

  .booster-shop-list {
    grid-template-columns: 1fr !important;
    gap: 8px !important;
  }

  .booster-shop-item {
    flex-direction: row !important;
    text-align: left !important;
    padding: 8px 10px !important;
  }

  .booster-shop-detail {
    align-items: flex-start !important;
  }

  .booster-shop-desc {
    min-height: unset !important;
  }

  .btn-buy-booster {
    width: auto !important;
  }

  .archive-grid {
    grid-template-columns: repeat(3, 1fr) !important;
    gap: 8px !important;
  }

  .modal-header h2 {
    font-size: 1.05rem;
  }

  .modal-body {
    font-size: 0.82rem;
    line-height: 1.45;
  }

  .rules-list {
    gap: 8px;
  }

  .btn-primary, .btn-secondary {
    padding: 9px 16px;
    font-size: 0.88rem;
  }
}

/* 3. MOBILE LANDSCAPE (Phones held horizontally: height <= 550px) */
@media (orientation: landscape) and (max-height: 550px) {
  #game-viewport {
    width: 100%;
    height: 100%;
    height: 100dvh;
    max-width: 100%;
    max-height: 100%;
    aspect-ratio: unset;
  }

  #game-header {
    padding: max(3px, env(safe-area-inset-top)) max(14px, env(safe-area-inset-right)) 2px max(14px, env(safe-area-inset-left));
    align-items: center;
  }

  .hanging-board .rope {
    display: none;
  }

  .hanging-board .board-body {
    padding: 3px 8px;
    min-width: unset;
    border-radius: 8px;
  }

  .board-tag {
    font-size: 0.78rem;
  }

  .board-reward {
    display: none;
  }

  #title-banner {
    top: 4px;
    padding: 2px 12px;
  }

  .banner-badge {
    display: none;
  }

  .banner-title {
    font-size: 0.88rem;
  }

  .banner-sub {
    font-size: 0.68rem;
  }

  .btn-icon {
    width: 32px;
    height: 32px;
    font-size: 0.9rem;
  }

  #board-container {
    flex: 1;
    min-height: 0;
    padding: 0 8px;
  }

  #chalkboard-frame {
    width: 100%;
    height: 100%;
    max-width: 100%;
    max-height: 100%;
    border-radius: 8px;
    border-width: 3px;
  }

  #game-footer {
    padding: 0 max(12px, env(safe-area-inset-right)) max(4px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
    gap: 10px;
    align-items: flex-end;
  }

  #mascot-wrapper {
    width: auto;
  }

  #mascot-avatar-box {
    width: 48px;
    height: 48px;
  }

  #speech-bubble {
    font-size: 0.6rem;
    padding: 3px 6px;
    max-width: 110px;
    line-height: 1.2;
  }

  .tray-wood-frame {
    height: calc(var(--tile-h) + 12px);
    padding: 2px 6px;
    border-radius: 12px;
  }

  .tray-inner {
    gap: 4px;
    padding: 0 4px;
  }

  #boosters-container {
    height: calc(var(--tile-h) + 12px);
    margin-bottom: 16px;
    align-items: center;
  }

  .booster-card {
    min-width: 48px;
    height: calc(var(--tile-h) + 8px);
    padding: 2px 4px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
  }

  .booster-icon-box {
    width: 26px;
    height: 26px;
  }

  .booster-symbol {
    font-size: 0.9rem;
  }

  .booster-name {
    font-size: 0.62rem;
  }

  .game-modal {
    max-height: 88dvh;
    overflow-y: auto;
    padding: 14px;
  }
}

/* ==========================================================
   WELCOME / NAME SETUP MODAL STYLES
   ========================================================== */
.modal-welcome {
  max-width: 440px !important;
  border: 2px solid rgba(245, 176, 65, 0.7);
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.8), 0 0 30px rgba(245, 176, 65, 0.25);
  animation: modalScaleIn 0.35s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.welcome-badge-icon {
  font-size: 3.2rem;
  margin-bottom: 8px;
  animation: pulseGlow 2s infinite ease-in-out;
}

.welcome-title {
  font-size: 1.25rem;
  color: #ffd166;
  font-weight: 700;
  margin-bottom: 6px;
}

.welcome-input-card {
  margin: 18px 0 12px;
  background: rgba(18, 22, 33, 0.8);
  border: 1.5px solid rgba(245, 176, 65, 0.35);
  border-radius: 14px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  text-align: left;
}

.welcome-input-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: #cfd8dc;
}

.welcome-input-wrapper {
  display: flex;
  align-items: center;
  background: rgba(10, 12, 18, 0.85);
  border: 1.5px solid rgba(255, 209, 102, 0.5);
  border-radius: 10px;
  padding: 4px 12px;
  gap: 8px;
  transition: border-color 0.2s;
}

.welcome-input-wrapper:focus-within {
  border-color: #ffd166;
  box-shadow: 0 0 12px rgba(255, 209, 102, 0.4);
}

.welcome-input-icon {
  font-size: 1.2rem;
}

.welcome-input-wrapper input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: #fff;
  font-size: 1rem;
  font-family: inherit;
  font-weight: 600;
  padding: 6px 0;
}

.welcome-input-wrapper input::placeholder {
  color: #78909c;
  font-weight: 400;
}

.welcome-hint {
  font-size: 0.72rem;
  color: #90a4ae;
}

.btn-welcome-start {
  width: 100%;
  padding: 12px;
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: 0.5px;
  box-shadow: 0 4px 18px rgba(245, 176, 65, 0.4);
}

/* ==========================================================
   CLUE ARCHIVE / GALLERY MODAL STYLES
   ========================================================== */
.modal-archive {
  width: 900px !important;
  max-width: min(920px, 94vw) !important;
  max-height: 92vh !important;
  padding: 16px 24px;
  display: flex;
  flex-direction: column;
}

.modal-archive .modal-header {
  margin-bottom: 8px;
  padding-bottom: 6px;
}

.modal-archive .modal-footer {
  margin-top: 10px;
}

.modal-archive .modal-body {
  overflow-y: auto;
  max-height: calc(90vh - 110px);
  padding-right: 4px;
}

.archive-summary-bar {
  display: flex;
  gap: 12px;
  margin-bottom: 12px;
  background: rgba(18, 22, 33, 0.75);
  border: 1px solid rgba(245, 176, 65, 0.3);
  border-radius: 12px;
  padding: 10px 16px;
  justify-content: space-around;
}

.archive-stat-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.archive-stat-label {
  font-size: 0.75rem;
  color: #90a4ae;
}

.archive-stat-val {
  font-size: 1.1rem;
  color: #ffd166;
  font-weight: 700;
}

.archive-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 10px;
  max-height: 52vh;
  overflow-y: auto;
  padding-right: 4px;
}

.clue-card {
  background: rgba(22, 27, 40, 0.85);
  border: 1.5px solid rgba(245, 176, 65, 0.25);
  border-radius: 12px;
  padding: 10px 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  transition: transform 0.2s, border-color 0.2s, box-shadow 0.2s;
  position: relative;
  overflow: hidden;
}

.clue-card:hover {
  transform: translateY(-2px);
  border-color: #ffd166;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.5);
}

.clue-card.locked {
  filter: grayscale(0.85);
  opacity: 0.65;
  background: rgba(14, 16, 22, 0.75);
  border-color: rgba(255, 255, 255, 0.1);
}

.clue-card.locked .clue-thumb {
  filter: brightness(0.2) contrast(1.2);
}

.clue-thumb-box {
  width: 58px;
  height: 58px;
  background: rgba(10, 12, 18, 0.7);
  border-radius: 10px;
  border: 1px solid rgba(245, 176, 65, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 8px;
  position: relative;
}

.clue-thumb {
  width: 48px;
  height: 48px;
  background-size: contain;
  background-position: center;
  background-repeat: no-repeat;
}

.clue-lock-icon {
  position: absolute;
  font-size: 1.4rem;
  color: #eceff1;
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.8);
}

.clue-name {
  font-size: 0.82rem;
  font-weight: 700;
  color: #fff;
  margin-bottom: 4px;
  line-height: 1.2;
}

.clue-card.locked .clue-name {
  color: #90a4ae;
}

.clue-progress-bar {
  width: 100%;
  height: 5px;
  background: rgba(0, 0, 0, 0.5);
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 6px;
}

.clue-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #ff9f43, #ffd166);
  border-radius: 4px;
  transition: width 0.3s ease;
}

.clue-count-badge {
  font-size: 0.68rem;
  color: #cfd8dc;
  font-weight: 600;
  margin-bottom: 4px;
}

.clue-lore {
  font-size: 0.68rem;
  color: #b0bec5;
  line-height: 1.25;
  margin-top: 4px;
  background: rgba(0, 0, 0, 0.3);
  padding: 4px 6px;
  border-radius: 6px;
  width: 100%;
}

.clue-lore-locked {
  font-style: italic;
  color: #78909c;
}

.clue-master-tag {
  position: absolute;
  top: 4px;
  right: 4px;
  font-size: 0.8rem;
}

/* Enhanced Combo Banner Effect */
.combo-banner.combo-super {
  background: linear-gradient(135deg, #ff1744 0%, #ff5252 50%, #ff9100 100%) !important;
  box-shadow: 0 0 30px rgba(255, 23, 68, 0.95), 0 0 10px #ffeb3b, 0 4px 14px rgba(0, 0, 0, 0.7) !important;
  border: 2px solid #ffd166 !important;
  animation: superComboPop 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275) !important;
}

@keyframes superComboPop {
  0% { transform: translateX(-50%) scale(0.4); opacity: 0; }
  60% { transform: translateX(-50%) scale(1.35) rotate(-3deg); }
  85% { transform: translateX(-50%) scale(1.1) rotate(2deg); }
  100% { transform: translateX(-50%) scale(1) rotate(0deg); opacity: 1; }
}

/* ==========================================================
   COMPACT SCREENS: one-row footer
   [mascot] [tray + holding shelf] [boosters on the right]
   Keeps the shelf and boosters from overlapping the board.
   ========================================================== */
@media (max-width: 900px), (max-height: 550px) {
  #game-footer {
    flex-direction: row;
    justify-content: center;
    align-items: flex-start;
    gap: 6px;
    padding-left: max(58px, env(safe-area-inset-left));
    padding-right: max(8px, env(safe-area-inset-right));
  }

  #tray-outer {
    width: auto;
    flex: 0 1 auto;
    min-width: 0;
  }

  .tray-row {
    gap: 4px;
  }

  .tray-wood-frame {
    max-width: none;
  }

  #holding-shelf {
    margin-bottom: 0;
    padding: 2px 4px;
  }

  #holding-slots {
    gap: 3px;
  }

  #boosters-container {
    width: auto;
    max-width: none;
    flex: 0 0 auto;
    gap: 4px;
    margin-bottom: 0;
    height: calc(var(--tile-h) + 14px);
  }

  .booster-card {
    min-width: 44px;
    height: calc(var(--tile-h) + 14px);
  }
}

/* ==========================================================
   VERTICAL BOOSTER STACK (right edge, vertically centered)
   Lives directly inside #game-viewport.
   ========================================================== */
#boosters-container {
  position: absolute;
  right: max(clamp(20px, 3.5vw, 48px), env(safe-area-inset-right));
  top: 50%;
  bottom: auto;
  transform: translateY(-50%);
  flex-direction: column;
  align-items: stretch;
  justify-content: center;
  gap: 6px;
  width: auto;
  height: auto;
  margin: 0;
  z-index: 30;
}

#boosters-container .booster-card {
  height: auto;
  min-width: 52px;
  padding: 3px 6px 2px 6px;
}

@media (max-width: 900px), (max-height: 550px) {
  #boosters-container {
    height: auto;
    gap: 4px;
    bottom: auto;
  }

  #boosters-container .booster-card {
    height: auto;
    min-width: 46px;
  }
}

/* Footer: tray always centered; mascot pinned left; shelf beside tray */
#game-footer {
  justify-content: center;
  padding-left: 12px;
  padding-right: 12px;
}

#mascot-wrapper {
  position: absolute;
  left: max(10px, env(safe-area-inset-left));
  bottom: 6px;
  width: auto;
  z-index: 30;
}

.tray-row {
  position: relative;
}

#holding-area-container {
  position: absolute;
  left: calc(100% + 8px);
  top: 50%;
  transform: translateY(-50%);
  z-index: 45;
}

/* Developer credit chip (bottom-right) */
#dev-credit {
  position: absolute;
  right: max(10px, env(safe-area-inset-right));
  bottom: max(6px, env(safe-area-inset-bottom));
  z-index: 35;
  font-family: 'Kanit', sans-serif;
  font-size: 0.68rem;
  font-weight: 600;
  color: #f5d48a;
  text-decoration: none;
  padding: 3px 9px;
  border-radius: 999px;
  background: rgba(38, 19, 7, 0.75);
  border: 1px solid rgba(212, 175, 55, 0.6);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.5);
  opacity: 0.8;
  transition: opacity 0.2s ease, transform 0.2s ease, color 0.2s ease;
}

#dev-credit .dev-credit-label {
  color: rgba(255, 255, 255, 0.6);
  font-weight: 400;
}

#dev-credit:hover {
  opacity: 1;
  color: #ffe9a8;
  transform: translateY(-1px);
}

@media (max-width: 900px), (max-height: 550px) {
  #dev-credit {
    font-size: 0.58rem;
    padding: 2px 7px;
  }
}


