/* Reset & Base Setup */
.qa-panel{position:fixed;left:12px;top:12px;width:230px;padding:15px;background:#15241cf2;border:1px solid #688a62;border-radius:12px;z-index:1000;font-size:12px;box-shadow:0 4px 20px #0008}
.qa-panel p{margin:9px 0;color:#cedfc8;line-height:1.4}.qa-panel button{display:block;width:100%;margin:6px 0;padding:8px;border:1px solid #506b49;border-radius:6px;background:#29432c;color:white;text-align:left;cursor:pointer}.qa-panel a{color:#f2d48b}
@media(max-width:800px){.qa-panel{top:75px;left:4px;width:170px;max-height:42vh;overflow:auto;opacity:.94}}
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  width: 100%;
  height: 100%;
  background-color: #0b0704;
  overflow: hidden;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: #fff;
  display: flex;
  justify-content: center;
  align-items: center;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* 9:16 Responsive Container - Strict Mobile Portrait Format */
#gameContainer {
  position: relative;
  width: 100vw;
  height: 100vh;
  /* Standard vh/vw fallback first, then dvh */
  width: min(100vw, calc(100vh * 9 / 16));
  height: min(100vh, calc(100vw * 16 / 9));
  width: min(100vw, calc(100dvh * 9 / 16));
  height: min(100dvh, calc(100vw * 16 / 9));
  max-width: 100vw;
  max-height: 100vh;
  max-height: 100dvh;
  aspect-ratio: 9 / 16;
  container-type: size;
  background: #171109;
  overflow: hidden;
  box-shadow: 0 0 50px rgba(0, 0, 0, 0.85);
  margin: auto;
}

@media (min-aspect-ratio: 9/16) {
  #gameContainer {
    border-left: 2px solid #3d2712;
    border-right: 2px solid #3d2712;
  }
}

/* WebGL Canvas */
#arenaCanvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  z-index: 1;
}

/* Deploy Zone Overlay */
#deployOverlay {
  position: absolute;
  inset: 0;
  z-index: 5;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  transition: opacity 0.2s ease;
}

#deployOverlay.hidden {
  opacity: 0;
  pointer-events: none;
}

#deployOverlay svg{width:100%;height:100%;position:absolute;inset:0}
#deployOverlay .deploy-spell-area,#deployOverlay .deploy-anywhere-area{display:none}
#deployOverlay[data-mode="effect"] .deploy-spell-area{display:block}
#deployOverlay[data-mode="anywhere"] .deploy-anywhere-area{display:block}
#deployOverlay[data-mode="effect"] .deploy-troop-area,
#deployOverlay[data-mode="anywhere"] .deploy-troop-area{display:none}
.card-item{background:none;font:inherit;color:inherit;border:0;padding:0}

.deploy-zone {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

.player-zone {
  order: 2;
  background: radial-gradient(circle, rgba(58, 194, 255, 0.12) 0%, rgba(58, 194, 255, 0.02) 80%);
  border-top: 2px dashed rgba(58, 194, 255, 0.7);
  box-shadow: inset 0 0 30px rgba(58, 194, 255, 0.15);
}

.enemy-zone {
  order: 1;
  background: radial-gradient(circle, rgba(255, 50, 50, 0.14) 0%, rgba(255, 50, 50, 0.02) 80%);
  border-bottom: 2px dashed rgba(255, 50, 50, 0.5);
}

.zone-warning {
  font-size: 13px;
  font-weight: 900;
  letter-spacing: 0.1em;
  color: #ff5252;
  background: rgba(18, 6, 6, 0.85);
  padding: 6px 14px;
  border-radius: 999px;
  border: 1px solid rgba(255, 82, 82, 0.4);
  text-shadow: 0 1px 3px #000;
}

/* Top Status Bar */
#topBar {
  position: absolute;
  top: max(8px, env(safe-area-inset-top));
  left: 8px;
  right: 8px;
  height: clamp(62px, 17cqw, 88px);
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  pointer-events: auto;
}

.top-right-cluster {
  display: flex;
  align-items: center;
  gap: 5px;
  margin-left: auto;
  margin-top: 2px;
}

.player-badge {
  display: flex;
  align-items: center;
  gap: 5px;
  background: linear-gradient(135deg, rgba(28, 17, 9, 0.88), rgba(46, 26, 12, 0.85));
  border: 1px solid #5a3818;
  padding: 2px 7px 2px 2px;
  border-radius: 999px;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
}

.avatar-ring {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 1px solid #ffb000;
  overflow: hidden;
  background: #2b1706;
}

.avatar-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.rival-crop {
  transform: scale(1.6) translate(-10%, 10%);
}

.badge-info {
  display: flex;
  flex-direction: column;
}

.badge-name {
  font-size: 10px;
  font-weight: 850;
  color: #fff4d8;
  text-shadow: 0 1px 2px #000;
  line-height: 1.1;
}

.badge-sub {
  font-size: 7.5px;
  font-weight: 700;
  color: #ffc252;
  line-height: 1;
}

#timerContainer {
  background: rgba(18, 10, 5, 0.9);
  border: 1.5px solid #ffaa00;
  border-radius: 8px;
  padding: 2px 7px;
  text-align: center;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.45);
}

.timer-label {
  font-size: 7px;
  font-weight: 800;
  letter-spacing: 0.08em;
  color: #ffbe42;
  line-height: 1;
}

#timerValue {
  font-size: 13.5px;
  font-weight: 900;
  color: #ffffff;
  font-variant-numeric: tabular-nums;
  line-height: 1.05;
}

.timer-panic {
  color: #ff3b30 !important;
  animation: pulseTimer 0.6s infinite alternate;
}

@keyframes pulseTimer {
  from { transform: scale(1); }
  to { transform: scale(1.1); }
}

.hud-icon-btn {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 1px solid #5a3818;
  background: rgba(28, 17, 9, 0.85);
  color: #fff;
  font-size: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.4);
}

/* Compact tower portraits and vertical health meters. */
.post-hp-bar {
  position: absolute;
  z-index: 26;
  pointer-events: none;
}

.tower-mood {
  grid-area: mood;
  width: 100%;
  height: 100%;
  aspect-ratio: 1 / 1;
  justify-self: center;
  align-self: center;
  background-image: url("assets/image-quality/variants/opombo_tower_moods-0fb29c9a8bbe-512.webp");
  background-image: image-set(url("assets/image-quality/variants/opombo_tower_moods-0fb29c9a8bbe-512.webp") 1x, url("assets/image-quality/variants/opombo_tower_moods-0fb29c9a8bbe-1024.webp") 2x);
  background-size: 400% 400%;
  background-position: 0 0;
  background-repeat: no-repeat;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,.85));
  transform-origin: center bottom;
  border-radius: 8px;
}

.tower-mood.mood-pop { animation: towerMoodPop .26s ease-out; }

@keyframes towerMoodPop {
  45% { transform: translateY(-3px) scale(1.12); }
}

.enemy-post-hp {
  position: relative;
  top: 0;
  left: 0;
  width: clamp(140px, 36cqw, 178px);
  height: clamp(48px, 13cqw, 58px);
  display: grid;
  grid-template-areas: "mood copy meter";
  grid-template-columns: clamp(40px, 10cqw, 46px) 1fr clamp(10px, 2.6cqw, 13px);
  column-gap: 6px;
  align-items: center;
  padding: 4px 6px;
  border: 1px solid rgba(255, 90, 100, .75);
  border-radius: 12px;
  background: linear-gradient(135deg, rgba(55, 24, 20, 0.95), rgba(28, 12, 10, 0.96));
  box-shadow: 0 4px 12px rgba(0,0,0,.6), inset 0 1px 0 rgba(255,160,160,.2);
}

.enemy-post-hp::before {
  content: '';
  position: absolute;
  inset: 4px auto 4px 0;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: #ff4747;
}

.enemy-post-hp .tower-mood {
  grid-area: mood;
  width: clamp(40px, 10cqw, 46px);
  height: clamp(40px, 10cqw, 46px);
  aspect-ratio: 1 / 1;
  border-radius: 8px;
  background-color: rgba(20, 10, 8, 0.65);
  border: 1px solid rgba(255, 100, 100, 0.35);
  justify-self: center;
  align-self: center;
}

.enemy-post-hp .team-status-copy {
  position: static;
  grid-area: copy;
  width: 100%;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: 2px;
  padding: 0;
  background: none;
  box-shadow: none;
  text-align: left;
}

.enemy-post-hp .team-status-heading {
  width: 100%;
}

.enemy-post-hp .team-status-heading strong {
  display: block;
  font-size: clamp(9.5px, 2.5cqw, 12px);
  color: #fff0d4;
  font-weight: 900;
  text-shadow: 0 1px 3px rgba(0,0,0,0.9);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.enemy-post-hp .hp-text {
  font-size: clamp(8.5px, 2.2cqw, 11px);
  color: #ff8585;
  font-weight: 800;
  letter-spacing: 0.02em;
}

.enemy-post-hp .hp-track {
  grid-area: meter;
  width: 100%;
  height: 100%;
  border-radius: 6px;
}

.player-post-hp {
  bottom: 0.8cqw;
  right: 0.8cqw;
  width: clamp(68px, 17.5cqw, 82px);
  height: clamp(94px, 25cqw, 120px);
  display: grid;
  grid-template-areas: "mood meter" "copy meter";
  grid-template-columns: 1fr clamp(10px, 2.6cqw, 13px);
  grid-template-rows: 1fr auto;
  column-gap: 4px;
  row-gap: 3px;
  padding: 4px;
  border: 1px solid rgba(68, 207, 255, 0.85);
  border-radius: 12px;
  background: linear-gradient(145deg, rgba(20, 42, 54, 0.96), rgba(10, 22, 28, 0.96));
  box-shadow: 0 4px 14px rgba(0,0,0,.7), inset 0 1px 0 rgba(100, 220, 255, .25);
}

.player-post-hp::before {
  content: '';
  position: absolute;
  inset: 4px 0 4px auto;
  width: 3px;
  border-radius: 3px 0 0 3px;
  background: #38bdf8;
}

.player-post-hp .tower-mood {
  grid-area: mood;
  width: clamp(44px, 12cqw, 56px);
  height: clamp(44px, 12cqw, 56px);
  aspect-ratio: 1 / 1;
  justify-self: center;
  align-self: center;
  margin: auto;
  border-radius: 8px;
  background-color: rgba(6, 18, 24, 0.6);
  border: 1px solid rgba(56, 189, 248, 0.35);
}

.inline-trophy-img {
  width: 17px;
  height: 17px;
  vertical-align: -2px;
  object-fit: contain;
  display: inline-block;
}

.inline-biscuit-img {
  width: 17px;
  height: 17px;
  vertical-align: -2px;
  object-fit: contain;
  display: inline-block;
}

.trophy-bread-icon {
  width: 24px;
  height: 24px;
  vertical-align: middle;
  object-fit: contain;
  margin-right: 5px;
}

.coin-biscuit-icon {
  width: 18px;
  height: 18px;
  vertical-align: -3px;
  object-fit: contain;
  margin-right: 3px;
}

.player-post-hp .team-status-copy {
  position: static;
  grid-area: copy;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  padding: 2px;
  border-radius: 5px;
  background: rgba(10, 20, 28, 0.85);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.08);
  text-align: center;
}

.player-post-hp .team-status-heading {
  width: 100%;
}

.player-post-hp .team-status-heading strong {
  display: block;
  font-size: clamp(8.5px, 2.2cqw, 11px);
  color: #e0f2fe;
  font-weight: 900;
  text-shadow: 0 1px 2px #000;
}

.player-post-hp .hp-text {
  font-size: clamp(7.5px, 1.9cqw, 9.5px);
  color: #38bdf8;
  font-weight: 800;
}

.player-post-hp .hp-track {
  grid-area: meter;
  width: 100%;
  height: 100%;
  border-radius: 6px;
}

.hp-track {
  grid-area: meter;
  position: relative;
  width: 15px;
  height: 74px;
  align-self: start;
  background: rgba(15, 8, 4, 0.9);
  border: 2px solid #38200f;
  border-radius: 7px;
  overflow: hidden;
  box-shadow: inset 0 1px 5px rgba(0, 0, 0, .75), 0 2px 6px rgba(0, 0, 0, .5);
}

.hp-track::after {
  content: '';
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(to bottom, transparent 0, transparent calc(25% - 1px), rgba(0,0,0,.42) calc(25% - 1px), rgba(0,0,0,.42) 25%);
  pointer-events: none;
}

.hp-fill {
  position: absolute;
  left: 0;
  bottom: 0;
  width: 100%;
  height: 100%;
  transition: height 0.25s ease-out;
}

.enemy-post-hp .hp-fill {
  background: linear-gradient(0deg, #ae2737, #ff6b7b);
}

.player-post-hp .hp-fill {
  background: linear-gradient(0deg, #066bc5, #5cd2ff);
}

.hp-text {
  font-size: 9px;
  font-weight: 900;
  color: #fff8e8;
  text-shadow: 0 1px 2px #000, 0 0 4px #000;
  white-space: nowrap;
}

@media (max-width: 350px) {
  #topBar { left: 5px; right: 5px; }
  .player-post-hp { right: 3px; bottom: 6px; }
  .top-right-cluster { gap: 3px; }
  .hud-icon-btn { width: 23px; height: 23px; }
}

/* Action Toast Message */
#actionToast {
  position: absolute;
  top: 130px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(18, 10, 4, 0.88);
  color: #ffd659;
  border: 1px solid rgba(255, 214, 89, 0.4);
  padding: 6px 16px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 850;
  z-index: 15;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.5);
  pointer-events: none;
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.toast-hidden {
  opacity: 0;
  transform: translateX(-50%) translateY(-10px) !important;
}

/* Overtime Banner */
#overtimeBanner {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(1);
  background: linear-gradient(135deg, rgba(230, 80, 0, 0.92), rgba(255, 170, 0, 0.92));
  border: 3px solid #fff;
  color: #fff;
  padding: 14px 24px;
  border-radius: 18px;
  font-size: 16px;
  font-weight: 1000;
  text-shadow: 0 2px 4px #000;
  box-shadow: 0 0 35px rgba(255, 140, 0, 0.8);
  z-index: 25;
  pointer-events: none;
  transition: transform 0.4s cubic-bezier(0.18, 0.89, 0.32, 1.28), opacity 0.3s ease;
}

.overtime-hidden {
  opacity: 0;
  transform: translate(-50%, -50%) scale(0.6) !important;
}

/* Bottom Control Dock - Authentic Rio Deck with Parchment Cards & Elixir Bar */
#bottomDock {
  position: absolute;
  bottom: 0;
  left: 0;
  --hud-side-lane: 19cqw;
  width: calc(100% - var(--hud-side-lane));
  aspect-ratio: 1994 / 789;
  z-index: 20;
  pointer-events: auto;
  user-select: none;
  background: transparent;
}

/* A faixa direita acomoda a vida do jogador sem liberar deploy atrás do HUD. */
#bottomDock::after {
  content: '';
  position: absolute;
  top: 0;
  left: 100%;
  width: var(--hud-side-lane);
  height: 100%;
  pointer-events: auto;
}

.hud-base-texture {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: fill;
  pointer-events: none;
  z-index: 1;
}

/* 4 Cards Container */
.hud-hand-container {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
}

/* Cards placed inside each parchment frame */
.hud-hand-container .card-item {
  position: absolute;
  top: 11.5%;
  height: 57.5%;
  width: 16.2%;
  background: transparent;
  border: none;
  border-radius: 4px;
  overflow: hidden;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.5);
  cursor: grab;
  touch-action: none;
  pointer-events: auto;
  padding: 0;
  transition: transform 0.15s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.hud-hand-container .card-item:nth-child(1) { left: 3.7%; }
.hud-hand-container .card-item:nth-child(2) { left: 22.4%; }
.hud-hand-container .card-item:nth-child(3) { left: 41.2%; }
.hud-hand-container .card-item:nth-child(4) { left: 60.0%; }

.hud-hand-container .card-item:hover:not(.disabled) {
  transform: translateY(-8px) scale(1.05);
}

.hud-hand-container .card-item.selected {
  transform: translateY(-14px) scale(1.1);
  filter: drop-shadow(0 0 10px #ffcc00);
}

.hud-hand-container .card-item.disabled {
  filter: grayscale(0.7) brightness(0.65);
  cursor: not-allowed;
  opacity: 0.85;
}

.hud-hand-container .card-thumb {
  width: 100%;
  height: 100%;
  object-fit: fill;
  pointer-events: none;
  border-radius: 4px;
}

.hud-hand-container .card-name {
  display: none;
}

.hud-hand-container .card-cost {
  display: none;
}

/* Next Card Slot under PRÓXIMA 👑 Header */
.hud-next-slot {
  position: absolute;
  left: 83.0%;
  top: 30.5%;
  width: 12.0%;
  height: 39.0%;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.hud-next-slot img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 4px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.5);
}

/* Elixir / Farelo Bar (10 Compartments Track) */
#fareloTubeContainer {
  position: absolute;
  left: 13%;
  top: 82%;
  width: 72%;
  height: 10%;
  z-index: 2;
  overflow: hidden;
  border-radius: 4px;
  background: rgba(10, 5, 2, 0.4);
  display: flex;
  align-items: center;
  pointer-events: none;
}

/* Glass & segment divider overlay */
#fareloTubeContainer::after {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: repeating-linear-gradient(
    90deg,
    transparent 0,
    transparent calc(10% - 1.5px),
    rgba(20, 10, 5, 0.7) calc(10% - 1.5px),
    rgba(20, 10, 5, 0.7) 10%
  );
  box-shadow: inset 0 2px 3px rgba(0, 0, 0, 0.6), inset 0 -1px 2px rgba(255, 200, 50, 0.2);
}

.farelo-liquid {
  height: 100%;
  width: 50%;
  background: linear-gradient(180deg, #fff3a8 0%, #ffb700 45%, #e67300 100%);
  box-shadow: 0 0 12px rgba(255, 170, 0, 0.85);
  border-radius: 3px;
  transition: width 0.12s linear;
}

/* Farelo Number Display in the center of the bar */
.hud-farelo-counter {
  white-space: nowrap;
  position: absolute;
  left: 13%;
  top: 82%;
  width: 72%;
  height: 10%;
  z-index: 4;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 1000;
  color: #ffffff;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 0 5px #000, 0 1px 3px #000, 0 0 10px rgba(255, 170, 0, 0.9);
  letter-spacing: 0.05em;
  pointer-events: none;
}

/* Modals */
.modal-overlay {
  position: absolute;
  inset: 0;
  background: rgba(10, 5, 2, 0.85);
  backdrop-filter: blur(6px);
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  transition: opacity 0.3s ease;
}

.modal-hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.btn-secondary{display:block;width:100%;margin:12px 0;padding:10px;border:1px solid #916631;border-radius:10px;background:#f4dfa8;color:#3b1900;font:inherit;font-size:12px;font-weight:800;cursor:pointer}
button:focus-visible,a:focus-visible{outline:3px solid #2dc7ff;outline-offset:3px}
#arenaCanvas{touch-action:none}
#progressionModal{z-index:60}
.progression-card{max-height:94%;overflow-y:auto;padding:14px 18px}
.progression-card h2{font-size:21px}.progression-card progress{display:block;width:100%;height:10px;margin:8px 0;accent-color:#927027}
#crownTotal{display:block;font-size:25px;margin-top:8px}#crownNext{font-size:12px}
#arenaLadder{display:flex;flex-direction:column;gap:8px;list-style:none;margin:16px 0;text-align:left;max-height:36dvh;overflow-y:auto;scrollbar-color:#a88345 #efdaa4;scrollbar-width:thin}
#arenaLadder li{padding:10px 12px;background:#ffffff70;border:1px solid #ad834d;border-left:4px solid #a19076;border-radius:9px}
#arenaLadder span{display:block;margin-top:3px;font-size:11px}#arenaLadder strong{font-size:13px}
#arenaLadder .current{border-color:#147c64;background:#e2f7d3}#arenaLadder .unlocked{border-left-color:#147c64}.prototype-note{font-size:10px;line-height:1.4;color:#634224;margin-top:7px}

.modal-card {
  width: 100%;
  max-width: 360px;
  background: linear-gradient(135deg, #fff7e4, #fed37e);
  border: 4px solid #4a2505;
  border-radius: 26px;
  padding: 24px 20px;
  color: #3b1900;
  text-align: center;
  box-shadow: 0 16px 0 #2b1402, 0 24px 40px rgba(0, 0, 0, 0.7);
  transform: translateY(0);
}

.game-tag {
  display: inline-block;
  background: #4a2505;
  color: #ffd659;
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 0.1em;
  padding: 4px 10px;
  border-radius: 999px;
  margin-bottom: 6px;
}

.modal-header h2 {
  font-size: 24px;
  font-weight: 1000;
  line-height: 1.1;
  color: #3b1900;
}

.modal-desc {
  font-size: 12.5px;
  font-weight: 750;
  line-height: 1.4;
  margin: 10px 0 14px;
  color: #5a2e0a;
}

.rules-summary {
  background: rgba(255, 255, 255, 0.55);
  border: 2px solid rgba(74, 37, 5, 0.2);
  border-radius: 14px;
  padding: 10px 12px;
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 7px;
  font-size: 11px;
  font-weight: 700;
  color: #3b1900;
  margin-bottom: 18px;
}

.btn-primary {
  width: 100%;
  padding: 14px;
  background: linear-gradient(180deg, #ffc83b, #f37d07);
  border: 3px solid #5a2700;
  border-radius: 16px;
  font-size: 16px;
  font-weight: 1000;
  color: #3b1700;
  cursor: pointer;
  box-shadow: 0 6px 0 #3d1a00, 0 10px 15px rgba(0, 0, 0, 0.3);
  transition: transform 0.1s ease, box-shadow 0.1s ease;
}

.btn-primary:active {
  transform: translateY(4px);
  box-shadow: 0 2px 0 #3d1a00, 0 4px 8px rgba(0, 0, 0, 0.3);
}

/* Victory / Game Over */
.crown-banner {
  font-size: 54px;
  filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.3));
  margin-bottom: 6px;
}

.match-stats {
  display: flex;
  justify-content: space-around;
  margin: 16px 0 20px;
}

.stat-box {
  background: rgba(255, 255, 255, 0.6);
  border: 2px solid rgba(74, 37, 5, 0.25);
  border-radius: 12px;
  padding: 8px 16px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.stat-label {
  font-size: 9px;
  font-weight: 850;
  color: #6a360d;
}

.stat-val {
  font-size: 18px;
  font-weight: 1000;
  color: #3b1900;
}

/* Matchmaking Modal & Radar Animation */
.matchmake-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}
.matchmake-radar {
  position: relative;
  width: 90px;
  height: 90px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 6px auto 10px;
}
.radar-circle {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 3px solid #d49138;
  background: radial-gradient(circle, rgba(255,176,0,0.25), transparent 70%);
}
.radar-pulse {
  position: absolute;
  inset: -6px;
  border-radius: 50%;
  border: 2.5px solid #ffcf54;
  animation: radarPulse 1.3s cubic-bezier(0.2, 0.8, 0.4, 1) infinite;
  opacity: 0;
}
@keyframes radarPulse {
  0% { transform: scale(0.6); opacity: 0.95; }
  100% { transform: scale(1.45); opacity: 0; }
}
.matchmake-avatar {
  font-size: 40px;
  z-index: 2;
  filter: drop-shadow(0 4px 10px rgba(0,0,0,0.4));
  animation: pigeonBob 1s ease-in-out infinite alternate;
}
@keyframes pigeonBob {
  0% { transform: translateY(0); }
  100% { transform: translateY(-6px) rotate(4deg); }
}
.matchmake-countdown-box {
  background: #3b1900;
  color: #ffd659;
  border-radius: 999px;
  padding: 6px 24px;
  font-size: 22px;
  font-weight: 1000;
  border: 2.5px solid #f37d07;
  box-shadow: 0 4px 12px rgba(0,0,0,0.35);
  margin: 6px 0;
  letter-spacing: 0.05em;
}
.matchmake-tip {
  font-size: 11.5px;
  font-weight: 750;
  color: #6a360d;
  line-height: 1.35;
}

/* =========================================
   Player Profile Chip & Login Modal Styles
   ========================================= */
.player-profile-header {
  margin-bottom: 12px;
}
.player-profile-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: rgba(74, 37, 5, 0.12);
  border: 1.5px solid rgba(74, 37, 5, 0.35);
  border-radius: 999px;
  padding: 4px 12px 4px 6px;
  cursor: pointer;
  transition: all 0.2s ease;
  user-select: none;
}
.player-profile-chip:hover {
  background: rgba(74, 37, 5, 0.22);
  border-color: #f37d07;
  transform: translateY(-1px);
}
.player-avatar-icon {
  font-size: 20px;
  width: 28px;
  height: 28px;
  background: #fff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}
.player-info-meta {
  display: flex;
  flex-direction: column;
  text-align: left;
  line-height: 1.1;
}
.player-info-meta strong {
  font-size: 12px;
  font-weight: 900;
  color: #3b1900;
}
.player-info-meta small {
  font-size: 8.5px;
  font-weight: 750;
  color: #7a4613;
}
.edit-badge {
  font-size: 11px;
  margin-left: 2px;
  opacity: 0.7;
}

/* Login Modal */
.login-card {
  max-width: 360px;
  padding: 20px 18px;
}
.avatar-section-title {
  font-size: 10px;
  font-weight: 900;
  color: #5a2e0a;
  letter-spacing: 0.08em;
  text-align: left;
  margin-bottom: 6px;
}
.avatar-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  margin-bottom: 12px;
}
.avatar-option {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 6px 2px;
  background: rgba(255, 255, 255, 0.65);
  border: 2px solid rgba(74, 37, 5, 0.2);
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
}
.avatar-option:hover {
  background: rgba(255, 255, 255, 0.9);
  transform: translateY(-2px);
}
.avatar-option.selected {
  background: #fff5c7;
  border-color: #f37d07;
  box-shadow: 0 0 10px rgba(243, 125, 7, 0.5), inset 0 0 0 1px #f37d07;
  transform: scale(1.04);
}
.avatar-emoji {
  font-size: 24px;
  line-height: 1.2;
}
.avatar-label {
  font-size: 9px;
  font-weight: 800;
  color: #4a2505;
  margin-top: 2px;
  white-space: nowrap;
}
.login-input-group {
  text-align: left;
  margin: 10px 0 6px;
}
.login-input-group label {
  display: block;
  font-size: 10px;
  font-weight: 900;
  color: #5a2e0a;
  letter-spacing: 0.08em;
  margin-bottom: 4px;
}
.input-with-action {
  display: flex;
  gap: 6px;
}
.input-with-action input {
  flex: 1;
  padding: 10px 12px;
  border: 2px solid #7a4613;
  border-radius: 12px;
  background: #fff;
  font-size: 14px;
  font-weight: 900;
  color: #3b1900;
  outline: none;
  font-family: inherit;
  transition: border-color 0.2s ease;
}
.input-with-action input:focus {
  border-color: #f37d07;
  box-shadow: 0 0 8px rgba(243, 125, 7, 0.35);
}
.btn-dice {
  width: 44px;
  height: 44px;
  border: 2px solid #7a4613;
  border-radius: 12px;
  background: linear-gradient(180deg, #ffdc69, #f7941d);
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s ease;
}
.btn-dice:active {
  transform: rotate(20deg) scale(0.9);
}

/* ==========================================================================
   Rasch Studio Splash & Title Screen (Strict Mobile Portrait Layout)
   ========================================================================== */

/* 1. Rasch Studio Splash Screen */
#raschSplash, .rasch-splash, .studio-splash {
  position: absolute;
  inset: 0;
  z-index: 100;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: radial-gradient(ellipse at 50% 48%, #543714 0%, #21170d 35%, #090907 80%);
  transition: opacity 0.45s ease, transform 0.45s ease;
  overflow: hidden;
  cursor: pointer;
  pointer-events: auto;
}
#raschSplash.is-leaving, .rasch-splash.is-leaving, .studio-splash.is-leaving {
  opacity: 0;
  transform: scale(1.03);
  pointer-events: none;
}
#raschSplash img, .rasch-splash img, .studio-splash-mark img {
  display: block;
  width: 75%;
  max-width: 320px;
  max-height: 40%;
  object-fit: contain;
  filter: drop-shadow(0 0 25px rgba(233, 164, 55, 0.45));
}
#raschSplash[hidden], .rasch-splash[hidden], .studio-splash[hidden] {
  display: none !important;
}

/* 2. Full-Screen Title / Start Screen (Confined within #gameContainer) */
#startModal.title-screen, #startModal.modal-overlay, .home-screen {
  position: absolute;
  inset: 0;
  padding: 0 !important;
  margin: 0 !important;
  display: block !important;
  background: #0b0704;
  overflow: hidden;
  z-index: 50;
  backdrop-filter: none;
  transition: opacity 0.3s ease;
}
#startModal.modal-hidden, .home-screen[hidden] {
  display: none !important;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.title-screen-art, .home-screen-art {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: 50% 45%;
  z-index: 1;
  pointer-events: none;
}

.title-screen-shade, .home-screen-shade {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 2;
  background: linear-gradient(180deg, rgba(7, 16, 26, 0.4) 0%, rgba(7, 16, 26, 0.05) 30%, rgba(22, 15, 8, 0.6) 65%, rgba(18, 11, 8, 0.95) 100%),
              radial-gradient(ellipse at 50% 30%, transparent 30%, rgba(22, 14, 8, 0.5) 100%);
  pointer-events: none;
}

.title-screen-content, .home-screen-content {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  padding: clamp(12px, 3vh, 20px) 16px clamp(16px, 4vh, 28px);
  box-sizing: border-box;
  text-align: center;
  overflow: hidden;
}

.title-profile-row {
  width: 100%;
  display: flex;
  justify-content: flex-start;
  align-items: center;
  flex-shrink: 0;
}

.player-profile-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: rgba(28, 17, 9, 0.88);
  border: 1.5px solid #d49a3d;
  border-radius: 999px;
  padding: 4px 12px 4px 6px;
  color: #fff;
  cursor: pointer;
  backdrop-filter: blur(8px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
  font: inherit;
}

.player-avatar-icon { font-size: 20px; line-height: 1; }
.player-info-meta { text-align: left; }
.player-info-meta strong { display: block; font-size: 13px; color: #ffd659; font-weight: 800; line-height: 1.1; }
.player-info-meta small { display: block; font-size: 10px; color: #cbd5e1; }
.edit-badge { font-size: 11px; opacity: 0.8; margin-left: 2px; }

.title-screen-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  max-width: 320px;
  margin: 6px auto auto auto;
  flex-shrink: 0;
}

.title-screen-logo, .home-game-logo {
  display: block;
  width: 100%;
  max-width: 260px;
  max-height: 22vh;
  height: auto;
  object-fit: contain;
  filter: drop-shadow(0 6px 14px rgba(0, 0, 0, 0.9)) drop-shadow(0 2px 4px rgba(0, 0, 0, 0.7));
}

.title-screen-actions, .home-screen-actions {
  width: 100%;
  max-width: 310px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
  margin-bottom: clamp(4px, 1.5vh, 12px);
}

.title-play-button, .home-play-button {
  width: 100%;
  height: clamp(50px, 7.5vh, 62px);
  border: 3px solid #261406;
  border-radius: 18px;
  background: linear-gradient(180deg, #fff078 0%, #ffbf13 49%, #f5820c 100%);
  box-shadow: inset 0 2px #fff9bd, 0 5px 0 #3b1c08, 0 8px 18px rgba(0, 0, 0, 0.6);
  color: #241407;
  font-size: clamp(19px, 3vh, 25px);
  font-weight: 1000;
  letter-spacing: 0.08em;
  text-shadow: 0 1px #fff5a8;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.12s ease, filter 0.12s ease;
  font-family: inherit;
}
.title-play-button:hover, .home-play-button:hover {
  filter: brightness(1.08);
}
.title-play-button:active, .home-play-button:active {
  transform: translateY(3px);
  box-shadow: inset 0 2px #fff9bd, 0 2px 0 #3b1c08, 0 4px 10px rgba(0, 0, 0, 0.6);
}

.title-secondary-button, .home-journey-button {
  width: 100%;
  min-height: 40px;
  border: 1.5px solid #d49a3d;
  border-radius: 14px;
  background: linear-gradient(180deg, rgba(62, 38, 19, 0.95), rgba(36, 24, 15, 0.95));
  box-shadow: inset 0 1px rgba(255, 230, 162, 0.35), 0 4px 12px rgba(0, 0, 0, 0.5);
  color: #ffedbf;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.06em;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: filter 0.15s ease;
  font-family: inherit;
}
.title-secondary-button:hover, .home-journey-button:hover {
  filter: brightness(1.15);
}

.title-return-button {
  width: 100%;
  background: none;
  border: none;
  color: #a3927e;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.05em;
  cursor: pointer;
  padding: 6px;
  transition: color 0.15s ease;
  font-family: inherit;
}
.title-return-button:hover { color: #f4dfa8; }

.title-workbench-link {
  font-size: 10px;
  color: #7d7265;
  text-decoration: none;
  letter-spacing: 0.04em;
  transition: color 0.15s ease;
}
.title-workbench-link:hover { color: #ffd659; }

@media (orientation: landscape) {
  .title-screen-logo, .home-game-logo {
    max-height: 22vh;
  }
  .title-screen-actions, .home-screen-actions {
    max-width: 280px;
  }
}
@media (prefers-reduced-motion: reduce) {
  #raschSplash, .rasch-splash, .studio-splash, #startModal, .title-play-button {
    transition: none !important;
  }
}
