:root {
  --bg-deep: #0b0e18;
  --bar-bg: #121728;
  --bar-border: #273252;
  --accent-yellow: #ffcb05;
  --accent-blue: #3b5ba7;
  --text-light: #e9eefc;
  --text-muted: #9aa7cc;
}

* {
  box-sizing: border-box;
  user-select: none;
  -webkit-user-select: none;
  -webkit-user-drag: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  height: 100dvh;
  background: radial-gradient(circle at 50% 30%, #19223d 0%, #090c14 75%);
  color: var(--text-light);
  font-family: 'Trebuchet MS', 'Segoe UI', system-ui, sans-serif;
  overflow: hidden;
  overscroll-behavior: none;
  touch-action: manipulation;
}

#app-shell {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
  height: 100dvh;
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  padding-left: env(safe-area-inset-left, 0px);
  padding-right: env(safe-area-inset-right, 0px);
}

#top-bar {
  height: 44px;
  flex: 0 0 44px;
  background: linear-gradient(180deg, #1a223b 0%, #101526 100%);
  border-bottom: 1px solid var(--bar-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 14px;
  gap: 12px;
  z-index: 20;
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}

.brand-badge {
  background: var(--accent-yellow);
  color: #182342;
  font-weight: 900;
  font-size: 11px;
  padding: 2px 6px;
  border-radius: 4px;
  letter-spacing: 0.5px;
}

.brand-title {
  font-weight: 800;
  font-size: 15px;
  color: var(--accent-yellow);
  text-shadow: 0 1px 2px #000;
}

.brand-sub {
  font-size: 12px;
  color: var(--text-muted);
}

.quick-nav {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: nowrap;
  overflow-x: auto;
}

.nav-btn {
  background: #1f2a4a;
  color: #e6ecff;
  border: 1px solid #354778;
  border-radius: 6px;
  padding: 5px 10px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s, transform 0.08s;
  white-space: nowrap;
}

.nav-btn:hover {
  background: #2c3c6b;
  border-color: var(--accent-yellow);
}

.nav-btn.active {
  background: var(--accent-blue);
  border-color: var(--accent-yellow);
  color: #fff;
}

.nav-btn.mute-btn {
  background: #23283d;
}

.lang-switch,
.version-switch {
  display: inline-flex;
  align-items: center;
  background: #141b30;
  border: 1px solid #354778;
  border-radius: 6px;
  padding: 2px;
  gap: 2px;
}

.lang-btn,
.ver-btn {
  background: transparent;
  color: #a8b7e0;
  border: none;
  border-radius: 4px;
  padding: 3px 7px;
  font-size: 11px;
  font-weight: 900;
  cursor: pointer;
  letter-spacing: 0.4px;
}

.lang-btn.active {
  background: var(--accent-yellow);
  color: #131b33;
}

.ver-btn.active {
  background: linear-gradient(180deg, #9d5cff 0%, #6426d9 100%);
  color: #fff;
  box-shadow: 0 0 8px rgba(157, 92, 255, 0.45);
}

.lang-btn:hover:not(.active),
.ver-btn:hover:not(.active) {
  color: #fff;
}

/* Quick Play V2 Gymnasium Nodes */
.qp-node {
  position: absolute;
  width: 116px;
  height: 116px;
  border-radius: 50%;
  border: none;
  background: transparent;
  padding: 0;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 12;
  transition: transform 0.14s ease, filter 0.14s ease;
}

.qp-node:hover {
  transform: scale(1.07);
  filter: brightness(1.16) drop-shadow(0 0 10px rgba(255, 224, 80, 0.85));
}

.qp-node.qp-final {
  width: 136px;
  height: 136px;
}

.qp-node .qp-ribbon {
  position: absolute;
  right: -2px;
  bottom: -2px;
  background: linear-gradient(180deg, #ffe047 0%, #f09c00 100%);
  color: #1c1200;
  border: 2px solid #fff7c2;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 900;
  padding: 2px 6px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.7);
  z-index: 4;
}

.qp-node .qp-label {
  position: absolute;
  bottom: 4px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(11, 14, 30, 0.86);
  color: #ffe875;
  border: 1px solid rgba(255, 215, 70, 0.55);
  border-radius: 999px;
  font-size: 9.5px;
  font-weight: 800;
  padding: 1px 6px;
  white-space: nowrap;
  max-width: 118px;
  overflow: hidden;
  text-overflow: ellipsis;
  z-index: 3;
}

.qp-freeplay-btn {
  position: absolute;
  left: 14px;
  top: 190px;
  width: 162px;
  z-index: 15;
  padding: 9px 10px !important;
  font-size: 12px !important;
  line-height: 1.25;
  text-align: center;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.65);
}

.qp-info-card {
  position: absolute;
  left: 14px;
  top: 256px;
  width: 162px;
  background: rgba(18, 12, 38, 0.88);
  border: 1px solid rgba(173, 128, 255, 0.55);
  border-radius: 10px;
  padding: 8px 9px;
  color: #e6dcff;
  font-size: 11px;
  line-height: 1.35;
  z-index: 14;
  pointer-events: none;
}

.qp-info-card b {
  color: #ffdd44;
  display: block;
  margin-bottom: 3px;
  font-size: 11.5px;
}

.owned-badge {
  position: absolute;
  top: 3px;
  left: 3px;
  background: rgba(20, 150, 62, 0.92);
  color: #fff;
  font-size: 10px;
  font-weight: 900;
  padding: 1px 5px;
  border-radius: 4px;
  border: 1px solid #9effb8;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.7);
}

#stage-wrapper {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10px;
  overflow: hidden;
  touch-action: none;
}

/* ==================== EXTERNAL NARRATOR BAR ==================== */
#narrator-bar {
  height: 44px;
  flex: 0 0 44px;
  background: linear-gradient(180deg, #101526 0%, #171f36 100%);
  border-top: 1px solid var(--bar-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 14px;
  gap: 12px;
  z-index: 20;
  touch-action: none;
}

.narrator-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.narrator-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 30px;
}

.narrator-btn:disabled {
  opacity: 0.42;
  cursor: default;
  pointer-events: none;
}

.narrator-btn.is-off {
  background: #1a2033;
  color: #9aa7cc;
  border-color: #2d385a;
}

.narrator-stop-btn.is-speaking {
  background: #b71c1c;
  border-color: #ff8a80;
  color: #fff;
  box-shadow: 0 0 10px rgba(239, 83, 80, 0.55);
}

.narrator-status {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(9, 13, 25, 0.72);
  border: 1px solid #263357;
  border-radius: 6px;
  padding: 4px 10px;
  height: 30px;
}

.narrator-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #5c6f9c;
  flex-shrink: 0;
  transition: background 0.15s, box-shadow 0.15s;
}

.narrator-status.is-enabled .narrator-dot {
  background: #4caf50;
}

.narrator-status.is-speaking .narrator-dot {
  background: #ffcb05;
  box-shadow: 0 0 8px #ffcb05;
  animation: narratorPulse 0.9s ease-in-out infinite;
}

@keyframes narratorPulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.35); opacity: 0.65; }
}

.narrator-preview {
  font-size: 12px;
  color: #cfd8f3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#stage-frame {
  position: relative;
  width: 800px;
  height: 600px;
  transform-origin: center center;
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.78), 0 0 0 2px #2b3860, 0 0 24px rgba(59, 91, 167, 0.35);
  border-radius: 4px;
  overflow: hidden;
  background: #000;
}

#stage {
  position: relative;
  width: 800px;
  height: 600px;
  overflow: hidden;
  background: #000;
  touch-action: none;
}

#loading-screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  background: radial-gradient(circle, #18274a, #080c17);
}

.loader-ball {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: 4px solid #fff;
  background: linear-gradient(180deg, #e53935 0 47%, #111 47% 53%, #fff 53% 100%);
  animation: spin 0.9s linear infinite;
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.loader-text {
  font-size: 16px;
  font-weight: 700;
  color: var(--accent-yellow);
}

/* ==================== GENERIC STAGE LAYER ==================== */
.screen {
  position: absolute;
  inset: 0;
  width: 800px;
  height: 600px;
  overflow: hidden;
}

.screen-bg {
  position: absolute;
  inset: 0;
  width: 800px;
  height: 600px;
  pointer-events: none;
  image-rendering: auto;
}

.sprite-el {
  position: absolute;
  background-repeat: no-repeat;
  pointer-events: none;
}

.sprite-btn {
  position: absolute;
  background: transparent;
  border: none;
  padding: 0;
  margin: 0;
  cursor: pointer;
  outline: none;
}

.sprite-btn:disabled,
.sprite-btn.disabled {
  cursor: default;
  pointer-events: none;
}

/* ==================== INTRO SCREEN ==================== */
.intro-screen {
  background: #000;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.intro-video {
  width: 800px;
  height: 600px;
  object-fit: contain;
  background: #000;
}

.intro-skip-hint {
  position: absolute;
  bottom: 14px;
  right: 18px;
  background: rgba(0, 0, 0, 0.72);
  border: 1px solid rgba(255, 203, 5, 0.5);
  color: #ffcb05;
  font-size: 12px;
  font-weight: 700;
  padding: 5px 12px;
  border-radius: 16px;
  pointer-events: none;
}

/* ==================== ARENA SCREEN ==================== */
.arena-top-bar {
  position: absolute;
  left: 0;
  top: 2px;
  width: 800px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 800;
  color: #ffef5a;
  text-shadow: 0 1px 3px #000, 1px 1px 0 #000;
  letter-spacing: 0.2px;
  pointer-events: none;
  z-index: 12;
  padding: 0 24px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.julie-monitor {
  position: absolute;
  left: 20px;
  top: 214px;
  width: 138px;
  height: 134px;
  overflow: hidden;
  background: #070b14;
  border-radius: 3px;
  z-index: 5;
}

.julie-monitor video,
.julie-monitor img {
  width: 138px;
  height: 134px;
  object-fit: cover;
  display: block;
}

.julie-badge {
  position: absolute;
  bottom: 2px;
  left: 3px;
  right: 3px;
  background: rgba(0, 0, 0, 0.72);
  color: #ffd84d;
  font-size: 10px;
  font-weight: 800;
  text-align: center;
  padding: 1px 4px;
  border-radius: 3px;
  pointer-events: none;
}

/* Right-side Card Inspector (exact pgamewindow.ui coords: 638,26 156x214 & 638,250 154x165) */
.card-zoom-box {
  position: absolute;
  left: 638px;
  top: 26px;
  width: 156px;
  height: 214px;
  z-index: 6;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.card-zoom-box img {
  width: 156px;
  height: 214px;
  object-fit: contain;
  border-radius: 6px;
}

.card-detail-box {
  position: absolute;
  left: 638px;
  top: 250px;
  width: 154px;
  height: 165px;
  z-index: 6;
  overflow: hidden;
  background: #05070e;
  border-radius: 4px;
  color: #e9f2ff;
  font-size: 11px;
  padding: 6px 7px;
  line-height: 1.3;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.card-detail-box.has-img {
  padding: 0;
}

.card-detail-box img.side-img {
  width: 154px;
  height: 165px;
  object-fit: contain;
}

.detail-title {
  font-weight: 900;
  font-size: 12px;
  color: #ffdf52;
  border-bottom: 1px solid #2b3860;
  padding-bottom: 2px;
}

.detail-atk {
  background: rgba(255, 255, 255, 0.06);
  border-radius: 3px;
  padding: 2px 4px;
  margin-top: 2px;
}

/* Active & Bench Pokemon Slots (exact pplayerarea1.ui & pplayerarea2.ui coords) */
.poke-slot {
  position: absolute;
  z-index: 6;
  border-radius: 6px;
  transition: box-shadow 0.12s, transform 0.12s;
}

.poke-slot.active-slot {
  width: 90px;
  height: 108px;
}

.poke-slot.bench-slot {
  width: 80px;
  height: 102px;
}

.poke-slot.drop-valid {
  box-shadow: 0 0 0 3px #42ff7b, 0 0 18px rgba(66, 255, 123, 0.85);
  cursor: pointer;
}

.poke-slot.target-highlight {
  box-shadow: 0 0 0 3px #ffcb05, 0 0 18px rgba(255, 203, 5, 0.9);
  cursor: pointer;
}

.poke-slot .slot-card-img {
  width: 78px;
  height: 102px;
  display: block;
  border-radius: 4px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.7);
  cursor: pointer;
}

.poke-slot.active-slot .slot-card-img {
  width: 82px;
  height: 106px;
}

.hp-pill {
  position: absolute;
  top: -11px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(8, 12, 24, 0.92);
  border: 1px solid #4be37b;
  color: #fff;
  font-size: 10px;
  font-weight: 900;
  padding: 1px 5px;
  border-radius: 8px;
  white-space: nowrap;
  pointer-events: none;
  z-index: 9;
}

.hp-pill.opp {
  border-color: #ff6257;
}

.hp-pill.low {
  background: #6c1111;
  border-color: #ff4747;
  color: #ffdede;
}

.energy-strip {
  position: absolute;
  bottom: -6px;
  left: -4px;
  right: -4px;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 1px;
  pointer-events: none;
  z-index: 9;
}

.energy-pip {
  width: 17px;
  height: 17px;
  border-radius: 50%;
  border: 1px solid #000;
  box-shadow: 0 1px 3px rgba(0,0,0,0.8);
  background-size: 51px 17px;
  background-repeat: no-repeat;
}

.damage-badge {
  position: absolute;
  top: 24px;
  right: -12px;
  min-width: 30px;
  height: 24px;
  background: radial-gradient(circle at 35% 30%, #ff5a52, #b80d0d);
  border: 2px solid #fff;
  border-radius: 12px;
  color: #fff;
  font-weight: 900;
  font-size: 11px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.8);
  pointer-events: none;
  z-index: 10;
}

.status-pills {
  position: absolute;
  top: 6px;
  left: -10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  pointer-events: none;
  z-index: 10;
}

.status-tag {
  font-size: 9px;
  font-weight: 900;
  padding: 1px 4px;
  border-radius: 4px;
  color: #fff;
  text-transform: uppercase;
  box-shadow: 0 1px 3px #000;
}

.status-tag.poisoned { background: #8e24aa; }
.status-tag.paralyzed { background: #f9a825; color: #111; }
.status-tag.confused { background: #e65100; }
.status-tag.asleep { background: #1e88e5; }
.status-tag.stiffen { background: #37474f; border: 1px solid #90a4ae; }
.status-tag.burn { background: #d50000; border: 1px solid #ffea00; }

/* Deck & Discard Piles */
.pile-slot {
  position: absolute;
  width: 68px;
  height: 82px;
  z-index: 6;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 5px;
}

.pile-slot.clickable {
  cursor: pointer;
}

.pile-slot.glow-deck {
  box-shadow: 0 0 0 3px #ffeb3b, 0 0 20px #ffeb3b;
  animation: pulse-glow 0.9s ease-in-out infinite alternate;
}

@keyframes pulse-glow {
  from { box-shadow: 0 0 0 2px #ffeb3b, 0 0 10px #ffeb3b; }
  to { box-shadow: 0 0 0 4px #fff59d, 0 0 22px #ffeb3b; }
}

.pile-slot img {
  width: 60px;
  height: 76px;
  object-fit: contain;
  border-radius: 3px;
}

.pile-count {
  position: absolute;
  bottom: -10px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(5, 8, 16, 0.9);
  border: 1px solid #6b80b8;
  color: #fff;
  font-size: 11px;
  font-weight: 900;
  padding: 0px 6px;
  border-radius: 8px;
  pointer-events: none;
}

/* Prize Piles */
.prize-pile {
  position: absolute;
  z-index: 7;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.prize-pile.clickable {
  cursor: pointer;
  filter: drop-shadow(0 0 10px #42ff7b);
  animation: prize-bounce 0.7s ease-in-out infinite alternate;
}

@keyframes prize-bounce {
  from { transform: scale(1); }
  to { transform: scale(1.07); }
}

.prize-cards-row {
  display: flex;
  gap: 3px;
}

.prize-mini-card {
  width: 24px;
  height: 32px;
  border-radius: 3px;
  border: 1px solid #ffd54f;
  background-image: url('/assets/cards/back_s.png');
  background-size: cover;
  box-shadow: 0 1px 4px #000;
}

.prize-pile.six-prizes .prize-cards-row {
  gap: 2px;
}

.prize-pile.six-prizes .prize-mini-card {
  width: 20px;
  height: 28px;
}

.prize-label {
  font-size: 10px;
  font-weight: 900;
  color: #fff;
  background: rgba(0, 0, 0, 0.72);
  padding: 1px 5px;
  border-radius: 4px;
}

/* Player Hand Bar (exact coords: x=153, y=474, w=480, h=100) */
.hand-bar {
  position: absolute;
  left: 192px;
  top: 472px;
  width: 416px;
  height: 98px;
  z-index: 8;
  display: flex;
  align-items: center;
  gap: 4px;
}

.hand-scroll-btn {
  flex: 0 0 28px;
  height: 32px;
  background: transparent;
  border: none;
  padding: 0;
  cursor: pointer;
}

.hand-cards-strip {
  flex: 1 1 auto;
  height: 98px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  overflow: hidden;
  padding: 0 2px;
}

.hand-card {
  position: relative;
  flex: 0 0 auto;
  width: 68px;
  height: 90px;
  border-radius: 4px;
  cursor: grab;
  transition: transform 0.12s, box-shadow 0.12s;
}

.hand-card:hover {
  transform: translateY(-6px) scale(1.05);
  z-index: 15;
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.8), 0 0 0 2px #ffcb05;
}

.hand-card.selected {
  transform: translateY(-10px) scale(1.07);
  z-index: 16;
  box-shadow: 0 0 0 3px #42ff7b, 0 0 18px rgba(66, 255, 123, 0.85);
}

.hand-card.playable {
  box-shadow: 0 0 0 1.5px rgba(255, 224, 92, 0.65);
}

.hand-card img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  border-radius: 4px;
}

/* Julie Hand Count Pill */
.julie-hand-pill {
  position: absolute;
  left: 16px;
  top: 138px;
  background: rgba(12, 16, 30, 0.85);
  border: 1px solid #ef5350;
  color: #ffcdd2;
  font-size: 11px;
  font-weight: 800;
  padding: 2px 8px;
  border-radius: 10px;
  z-index: 7;
}

/* Bottom Battle Log (exact coords: x=18, y=575, w=726, h=22) */
.battle-log-bar {
  position: absolute;
  left: 18px;
  top: 575px;
  width: 726px;
  height: 22px;
  z-index: 10;
  display: flex;
  align-items: center;
  color: #9effa9;
  font-size: 12px;
  font-weight: 700;
  text-shadow: 0 1px 2px #000;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ==================== MODAL OVERLAYS ==================== */
.stage-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(4, 6, 14, 0.72);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 65;
  pointer-events: auto;
}

/* Attack Picker using authentic attackframe.png (296x215) */
.attack-picker-box {
  position: relative;
  width: 296px;
  height: 215px;
  background-image: url('/assets/ui/attackframe.png');
  background-size: 296px 215px;
}

.attack-picker-title {
  position: absolute;
  left: 24px;
  top: 8px;
  width: 248px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 900;
  color: #ffea59;
  text-shadow: 0 1px 2px #000;
}

.attack-option {
  position: absolute;
  left: 19px;
  width: 258px;
  height: 62px;
  border-radius: 6px;
  padding: 6px 10px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 3px;
  cursor: pointer;
  background: rgba(15, 22, 42, 0.86);
  border: 1px solid #3f5285;
  color: #fff;
  transition: background 0.1s, border-color 0.1s;
}

.attack-option:hover:not(.cant-pay) {
  background: url('/assets/ui/attackhi.png') center/cover no-repeat, rgba(55, 92, 180, 0.9);
  border-color: #ffcb05;
}

.attack-option.cant-pay {
  opacity: 0.45;
  cursor: not-allowed;
}

.attack-opt-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.attack-opt-name {
  font-weight: 900;
  font-size: 14px;
  color: #fff;
}

.attack-opt-dmg {
  font-weight: 900;
  font-size: 15px;
  color: #ffcb05;
}

.attack-opt-costs {
  display: flex;
  align-items: center;
  gap: 3px;
}

.attack-opt-note {
  font-size: 10px;
  color: #b7c8f7;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Deck Picker using authentic popup01.png (523x404) */
.deck-picker-popup {
  position: relative;
  width: 523px;
  height: 404px;
  background-image: url('/assets/ui/popup01.png');
  background-size: 523px 404px;
}

.deck-picker-title {
  position: absolute;
  left: 106px;
  top: 14px;
  width: 205px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  font-weight: 900;
  color: #ffea59;
  text-shadow: 0 1px 2px #000;
}

.deck-picker-list {
  position: absolute;
  left: 208px;
  top: 56px;
  width: 292px;
  height: 170px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 8px;
  overflow-x: hidden;
  overflow-y: auto;
  align-content: start;
  padding: 4px;
}

.deck-tile {
  background: rgba(14, 24, 58, 0.88);
  border: 2px solid #415ca8;
  border-radius: 8px;
  padding: 7px 8px;
  min-width: 0;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  color: #fff;
  transition: transform 0.1s, border-color 0.1s, background 0.1s;
}

.deck-tile:hover {
  border-color: #ffcb05;
  background: rgba(30, 52, 118, 0.92);
}

.deck-tile.selected {
  border-color: #42ff7b;
  background: rgba(24, 78, 52, 0.92);
  box-shadow: 0 0 12px rgba(66, 255, 123, 0.5);
}

.deck-tile-name {
  font-weight: 900;
  font-size: 13px;
  color: #ffea59;
}

.deck-tile-meta {
  font-size: 10px;
  color: #c5d4ff;
  margin-top: 2px;
}

.deck-picker-julie-row {
  position: absolute;
  left: 34px;
  top: 238px;
  width: 375px;
  height: 120px;
  display: flex;
  align-items: center;
  gap: 12px;
  background: rgba(7, 12, 32, 0.78);
  border: 1px solid #354c96;
  border-radius: 8px;
  padding: 8px 10px;
}

.deck-picker-julie-row img.julie-tiny {
  width: 68px;
  height: 84px;
  object-fit: contain;
}

.julie-deck-info {
  flex: 1;
  font-size: 11px;
  color: #dfe8ff;
}

.julie-deck-select {
  margin-top: 5px;
  width: 100%;
  background: #141f42;
  color: #ffea59;
  border: 1px solid #4d67b8;
  border-radius: 5px;
  padding: 4px 6px;
  font-weight: 700;
  font-size: 12px;
}

/* Generic Retro Dialog Box */
.retro-dialog {
  width: 440px;
  max-width: 740px;
  background: linear-gradient(180deg, #162248 0%, #0c132a 100%);
  border: 3px solid #ffcb05;
  border-radius: 12px;
  padding: 18px 20px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.85);
  color: #fff;
  text-align: center;
}

.retro-dialog h2 {
  margin: 0 0 10px;
  color: #ffcb05;
  font-size: 20px;
  text-shadow: 0 2px 4px #000;
}

.retro-dialog p {
  margin: 0 0 14px;
  font-size: 13px;
  color: #dce5ff;
  line-height: 1.45;
}

.retro-btn-row {
  display: flex;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
}

.retro-btn {
  background: linear-gradient(180deg, #3f66c8 0%, #243f8f 100%);
  color: #fff;
  border: 2px solid #ffcb05;
  border-radius: 8px;
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
}

.retro-btn:hover {
  background: linear-gradient(180deg, #517be0 0%, #2e52b5 100%);
}

.retro-btn.secondary {
  background: #232c47;
  border-color: #6b7db3;
}

/* Card picker grid inside modals (Poké Ball, Revive, Pokédex, Discard Viewer) */
.modal-card-grid {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  max-height: 290px;
  overflow-y: auto;
  margin-bottom: 14px;
  padding: 4px;
}

.modal-card-item {
  width: 82px;
  cursor: pointer;
  border-radius: 5px;
  border: 2px solid transparent;
  padding: 2px;
  transition: transform 0.1s, border-color 0.1s;
}

.modal-card-item:hover {
  transform: scale(1.06);
  border-color: #ffcb05;
}

.modal-card-item img {
  width: 100%;
  display: block;
  border-radius: 4px;
}

/* ==================== FULL OVERLAY ANIMATION LAYER ==================== */
.fx-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 40;
}

.damage-float {
  position: absolute;
  font-size: 28px;
  font-weight: 900;
  color: #ff3b30;
  text-shadow: 0 0 6px #000, 2px 2px 0 #fff, -2px -2px 0 #000;
  animation: float-up 1.1s ease-out forwards;
}

.damage-float.heal {
  color: #42ff7b;
}

@keyframes float-up {
  0% { opacity: 1; transform: translate(-50%, 0) scale(0.8); }
  25% { opacity: 1; transform: translate(-50%, -18px) scale(1.25); }
  100% { opacity: 0; transform: translate(-50%, -56px) scale(1); }
}

/* ==================== LESSONS, DECK BUILDER, POKEDEX, EXTRAS ==================== */
.subscreen-panel {
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 50% 20%, #1d2d5c 0%, #0b1022 85%);
  display: flex;
  flex-direction: column;
  padding: 12px 16px;
  gap: 10px;
}

.subscreen-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 2px solid #354c96;
  padding-bottom: 8px;
}

.subscreen-header h1 {
  margin: 0;
  font-size: 20px;
  color: #ffcb05;
  text-shadow: 0 2px 3px #000;
}

.filter-row {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.filter-chip {
  background: #1a2548;
  color: #d7e2ff;
  border: 1px solid #3d5499;
  border-radius: 14px;
  padding: 4px 10px;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
}

.filter-chip.active {
  background: #ffcb05;
  color: #121c38;
  border-color: #fff;
}

.builder-body {
  flex: 1 1 auto;
  display: grid;
  grid-template-columns: 1fr 250px;
  gap: 12px;
  min-height: 0;
}

.card-catalog {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
  overflow-y: auto;
  padding-right: 4px;
  align-content: start;
}

.catalog-card {
  position: relative;
  background: #111936;
  border: 1px solid #2d3e72;
  border-radius: 6px;
  padding: 4px;
  cursor: pointer;
  text-align: center;
  transition: border-color 0.1s, transform 0.1s;
}

.catalog-card:hover {
  border-color: #ffcb05;
  transform: translateY(-2px);
}

.catalog-card img {
  width: 100%;
  border-radius: 3px;
  display: block;
}

.catalog-card .count-badge {
  position: absolute;
  top: 2px;
  right: 2px;
  background: #ffcb05;
  color: #111;
  font-weight: 900;
  font-size: 11px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 1px 4px #000;
}

.deck-sidebar {
  background: rgba(9, 13, 28, 0.88);
  border: 1px solid #354c96;
  border-radius: 8px;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 0;
}

.deck-sidebar input,
.deck-sidebar select {
  background: #151f40;
  color: #fff;
  border: 1px solid #445ca6;
  border-radius: 5px;
  padding: 5px 8px;
  font-size: 12px;
  font-weight: 700;
}

.deck-entries {
  flex: 1 1 auto;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.deck-entry-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #162144;
  border-radius: 4px;
  padding: 4px 7px;
  font-size: 11px;
}

.deck-entry-row button {
  background: #304278;
  color: #fff;
  border: none;
  border-radius: 4px;
  width: 20px;
  height: 20px;
  font-weight: 900;
  cursor: pointer;
}

.deck-entry-row button:hover {
  background: #e53935;
}

/* Lesson Overlay */
.lesson-text-banner {
  position: absolute;
  left: 170px;
  top: 507px;
  width: 575px;
  height: 52px;
  display: flex;
  align-items: center;
  padding: 4px 12px;
  color: #ffef6b;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.3;
  z-index: 12;
}

.lesson-title-banner {
  position: absolute;
  left: 230px;
  top: 10px;
  width: 495px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ffef6b;
  font-size: 14px;
  font-weight: 900;
  z-index: 12;
}

.lesson-content-area {
  position: absolute;
  left: 162px;
  top: 48px;
  width: 618px;
  height: 444px;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 8;
}

.lesson-hotspot {
  position: absolute;
  border: 2px solid rgba(255, 235, 59, 0.75);
  background: rgba(255, 235, 59, 0.14);
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.12s, box-shadow 0.12s;
}

.lesson-hotspot:hover,
.lesson-hotspot.active {
  background: rgba(255, 235, 59, 0.35);
  box-shadow: 0 0 12px #ffeb3b;
}

/* Pokedex full view */
.pokedex-body {
  flex: 1 1 auto;
  display: grid;
  grid-template-columns: 1fr 290px;
  gap: 14px;
  min-height: 0;
}

.pokedex-detail {
  background: rgba(9, 13, 28, 0.9);
  border: 2px solid #3c56a8;
  border-radius: 10px;
  padding: 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  overflow-y: auto;
}

.pokedex-detail img {
  width: 178px;
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.7);
}

/* ==================== TOUCH & TABLET ENHANCEMENTS ==================== */
.card-catalog,
.deck-entries,
.deck-picker-list,
.modal-card-grid,
.pokedex-detail {
  touch-action: pan-y;
  -webkit-overflow-scrolling: touch;
}

.quick-nav {
  touch-action: pan-x;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.quick-nav::-webkit-scrollbar {
  display: none;
}

.hand-card {
  touch-action: none;
}

.hand-card.dragging-source {
  opacity: 0.35;
  transform: scale(0.95);
}

.touch-drag-ghost {
  position: absolute;
  width: 78px;
  height: 104px;
  pointer-events: none;
  z-index: 80;
  transform: translate(-50%, -60%) rotate(-3deg) scale(1.1);
  filter: drop-shadow(0 12px 20px rgba(0, 0, 0, 0.85)) drop-shadow(0 0 10px rgba(255, 203, 5, 0.85));
  border-radius: 6px;
}

.touch-drag-ghost img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  border-radius: 6px;
}

/* Expanded invisible touch hit area for compact 1999 buttons */
.sprite-btn.touch-pad::after {
  content: '';
  position: absolute;
  inset: -10px;
}

.poke-slot.drag-hover {
  box-shadow: 0 0 0 4px #ffeb3b, 0 0 24px rgba(255, 235, 59, 0.95) !important;
  transform: scale(1.06);
}

.card-lightbox {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 14px;
  background: rgba(10, 15, 32, 0.96);
  border: 3px solid #ffcb05;
  border-radius: 14px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.9);
  max-width: 340px;
}

.card-lightbox img {
  width: 260px;
  height: auto;
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.8);
}

@media (max-width: 900px), (pointer: coarse) {
  #top-bar {
    height: 48px;
    flex: 0 0 48px;
    padding: 0 8px;
    gap: 8px;
  }
  #narrator-bar {
    height: 48px;
    flex: 0 0 48px;
    padding: 0 8px;
    gap: 8px;
  }
  .brand-sub {
    display: none;
  }
  .nav-btn {
    padding: 7px 12px;
    font-size: 13px;
    min-height: 34px;
  }
  .narrator-status {
    height: 34px;
  }
  #stage-wrapper {
    padding: 4px;
  }
}

@media (max-width: 860px) {
  .brand-title {
    display: none;
  }
}

@media (max-width: 820px) {
  .narrator-status {
    display: none;
  }
  #narrator-bar {
    justify-content: center;
  }
  .narrator-controls {
    gap: 6px;
    overflow-x: auto;
    scrollbar-width: none;
  }
  .narrator-controls::-webkit-scrollbar {
    display: none;
  }
}
