/* ========================================================================== */
/* Architect TD — Game Styles                                                 */
/* ========================================================================== */

/* Layout ------------------------------------------------------------------- */

.td-body {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  overflow: hidden;
  background-image: none;
  background: var(--bg);
}

.td-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-right: 1.25rem;
  flex-shrink: 0;
}

.td-header-meta {
  margin-left: auto;
  flex-shrink: 0;
}

.td-user-badge {
  color: var(--hint);
  font-size: 0.8rem;
  font-family: 'JetBrains Mono', 'Courier New', monospace;
  white-space: nowrap;
}

.td-shell {
  display: grid;
  grid-template-columns: 1fr 300px;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.td-shell.menu-active {
  grid-template-columns: 1fr !important;
  grid-template-rows: 1fr !important;
}

.td-shell.menu-active .td-sidepanel {
  display: none !important;
}

/* Left column: stacks the canvas viewport above the stats/button bar */
.td-game-col {
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

/* Viewport (canvas area) --------------------------------------------------- */

.td-viewport {
  position: relative;
  overflow: hidden;
  background: #06090f;
  display: flex;
  align-items: stretch;
  flex: 1;
  min-height: 0;
}

#tdCanvas {
  display: block;
  touch-action: none;
  align-self: center;
  margin: 0 auto;
  transform: translateX(0);
  transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.td-build-drawer-open #tdCanvas {
  transform: translateX(var(--map-shift-x, 0px));
}

/* Bottom game bar (stats + action buttons) --------------------------------- */

.td-gamebar {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  padding: 0.45rem 0.7rem;
  background: var(--panel2);
  border-top: 1px solid var(--line);
  flex-shrink: 0;
}

.td-hud-row {
  display: flex;
  gap: 0.5rem;
  align-items: flex-start;
}

.td-hud-top {
  flex-wrap: wrap;
}

.td-stat {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  min-width: 70px;
  padding: 0.42rem 0.65rem;
  background: rgba(7, 10, 20, 0.82);
  border: 1px solid var(--line);
  border-radius: 9px;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.td-stat-label {
  color: var(--hint);
  font-family: 'JetBrains Mono', 'Courier New', monospace;
  font-size: 0.6rem;
  font-weight: 600;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  line-height: 1.2;
}

.td-stat-value {
  color: var(--text-strong);
  font-family: 'JetBrains Mono', 'Courier New', monospace;
  font-size: 1.05rem;
  font-weight: 600;
  line-height: 1.3;
}

.td-stat-coins .td-stat-value { color: #f0c040; }
.td-stat-core .td-stat-value  { color: #ff6b6b; }
.td-stat-wave .td-stat-value  { color: var(--accent-strong); }
.td-stat-tier .td-stat-value  { color: var(--teal); font-size: 0.82rem; }

/* Action bar --------------------------------------------------------------- */

.td-actionbar {
  display: flex;
  gap: 0.45rem;
  flex-wrap: wrap;
  pointer-events: auto;
}

.td-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.38rem;
  min-height: 36px;
  padding: 0.42rem 0.75rem;
  color: var(--text);
  background: rgba(7, 10, 20, 0.88);
  border: 1px solid var(--line);
  border-radius: 9px;
  font-size: 0.82rem;
  font-weight: 600;
  white-space: nowrap;
  transition: background 0.15s, border-color 0.15s, color 0.15s, transform 0.15s;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.td-btn:hover {
  color: var(--text-strong);
  background: rgba(59, 142, 255, 0.14);
  border-color: rgba(59, 142, 255, 0.45);
  transform: translateY(-1px);
}

.td-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
}

.td-btn-cost {
  padding: 0.1rem 0.38rem;
  background: rgba(255, 255, 255, 0.07);
  border-radius: 5px;
  font-size: 0.75rem;
  font-family: 'JetBrains Mono', monospace;
  color: #f0c040;
}

.td-btn-build  { border-color: rgba(59, 142, 255, 0.32); }
.td-btn-sell   { border-color: rgba(224, 80, 80, 0.32); }
.td-btn-sell:hover { border-color: rgba(224, 80, 80, 0.6); color: #ff8484; background: rgba(224, 80, 80, 0.12); }
.td-btn-move   { border-color: rgba(240, 192, 64, 0.34); }
.td-btn-move:hover,
.td-btn-move.active { border-color: rgba(240, 192, 64, 0.68); color: #ffe08a; background: rgba(240, 192, 64, 0.12); }
.td-btn-evolve { border-color: rgba(167, 139, 250, 0.38); }
.td-btn-evolve:hover:not(:disabled) { border-color: rgba(167, 139, 250, 0.72); color: #c4b5fd; background: rgba(139, 92, 246, 0.12); }
.td-btn-wave   { border-color: rgba(56, 212, 184, 0.32); color: var(--teal); }
.td-btn-wave:hover { background: rgba(56, 212, 184, 0.12); border-color: rgba(56, 212, 184, 0.6); }
.td-btn-speed  { min-width: 60px; justify-content: center; }

/* Main menu overlay -------------------------------------------------------- */

@keyframes td-menu-breathe {
  0%, 100% { opacity: 0.42; transform: scale(1); }
  50% { opacity: 0.72; transform: scale(1.05); }
}

@keyframes td-menu-enter {
  0% { opacity: 0; filter: saturate(0.7) blur(10px); }
  45% { opacity: 0.74; filter: saturate(0.92) blur(3px); }
  100% { opacity: 1; filter: saturate(1) blur(0); }
}

@keyframes td-menu-wake {
  0% { opacity: 0; transform: translateY(14px) scale(0.985); }
  100% { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes td-menu-sync-ring {
  0% { transform: translate(-50%, -50%) scale(0.74); opacity: 0.2; }
  55% { opacity: 0.86; }
  100% { transform: translate(-50%, -50%) scale(1.35); opacity: 0; }
}

@keyframes td-menu-sync-scan {
  0%, 100% { transform: translateX(-10px); opacity: 0.42; }
  50% { transform: translateX(10px); opacity: 1; }
}

@keyframes td-menu-grid-pan {
  0% { transform: translateY(0); }
  100% { transform: translateY(40px); }
}

@keyframes td-menu-sweep {
  0% { transform: translateX(-44%) skewX(-12deg); opacity: 0; }
  18% { opacity: 0.36; }
  44%, 100% { transform: translateX(140%) skewX(-12deg); opacity: 0; }
}

@keyframes td-start-stage-drift {
  0% { background-position: 0 0, 0 0; }
  100% { background-position: 38px 0, 0 38px; }
}

@keyframes td-route-pulse {
  0%, 100% { filter: brightness(0.92); opacity: 0.78; }
  50% { filter: brightness(1.55); opacity: 1; }
}

@keyframes td-core-pulse {
  0%, 100% { transform: translate(-50%, -50%) scale(0.96); box-shadow: 0 0 0 0 rgba(251, 191, 36, 0.32), 0 0 24px rgba(251, 191, 36, 0.38); }
  50% { transform: translate(-50%, -50%) scale(1.08); box-shadow: 0 0 0 12px rgba(251, 191, 36, 0), 0 0 36px rgba(251, 191, 36, 0.58); }
}

@keyframes td-tower-idle {
  0%, 100% { transform: translate(-50%, -50%) rotate(0deg) scale(1); }
  50% { transform: translate(-50%, -54%) rotate(8deg) scale(1.08); }
}

@keyframes td-shot-run {
  0% { left: var(--shot-x0); top: var(--shot-y0); opacity: 0; transform: scale(0.65); }
  14% { opacity: 1; }
  76% { opacity: 1; }
  100% { left: var(--shot-x1); top: var(--shot-y1); opacity: 0; transform: scale(0.28); }
}

@keyframes td-enemy-run {
  0% { opacity: 0; offset-distance: 0%; transform: scale(0.75); }
  7% { opacity: 1; }
  84% { opacity: 1; transform: scale(1); }
  100% { opacity: 0; offset-distance: 100%; transform: scale(0.7); }
}

@keyframes td-start-scan {
  0% { transform: translateX(-30%); opacity: 0; }
  15%, 55% { opacity: 0.62; }
  78%, 100% { transform: translateX(130%); opacity: 0; }
}

@keyframes td-chevron-run {
  0%, 100% { transform: translateX(0); opacity: 0.52; }
  50% { transform: translateX(5px); opacity: 1; }
}

@keyframes td-title-glint {
  0%, 42% { transform: translateX(-120%); opacity: 0; }
  52% { opacity: 0.95; }
  70%, 100% { transform: translateX(120%); opacity: 0; }
}

@keyframes td-title-bracket {
  0%, 100% { transform: translateY(0) scaleY(1); color: #67e8f9; }
  50% { transform: translateY(-1px) scaleY(1.16); color: #fbbf24; }
}

@keyframes td-continue-orbit {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

@keyframes td-continue-pulse {
  0%, 100% { transform: translateY(-50%) scale(0.88); opacity: 0.54; }
  50% { transform: translateY(-50%) scale(1.15); opacity: 1; }
}

@keyframes td-continue-scan {
  0% { transform: translateX(-80%); opacity: 0; }
  25%, 55% { opacity: 0.7; }
  100% { transform: translateX(140%); opacity: 0; }
}

.td-menu {
  position: absolute;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(4, 7, 12, 0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  overflow: hidden;
  opacity: 0;
  animation: td-menu-enter 2.7s cubic-bezier(.19, 1, .22, 1) forwards;
}

.td-menu.is-syncing {
  opacity: 1;
  animation: none;
  background: #030711;
}

.td-menu.is-waking {
  animation: td-menu-enter 2.7s cubic-bezier(.19, 1, .22, 1) forwards;
}

.td-menu.is-waking .td-menu-inner {
  animation: td-menu-wake 1.6s cubic-bezier(.19, 1, .22, 1) 0.45s both;
}

.td-menu-bg {
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
}

.td-menu-glow {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 800px;
  height: 800px;
  margin-top: -400px;
  margin-left: -400px;
  background:
    radial-gradient(circle, rgba(59,142,255,0.16) 0%, rgba(56,212,184,0.07) 38%, rgba(240,192,64,0.05) 52%, rgba(0,0,0,0) 72%);
  animation: td-menu-breathe 8s ease-in-out infinite;
}

.td-menu-grid {
  position: absolute;
  inset: -50px;
  background-image: 
    linear-gradient(rgba(255, 255, 255, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.03) 1px, transparent 1px);
  background-size: 40px 40px;
  animation: td-menu-grid-pan 7s linear infinite;
  mask-image: linear-gradient(to bottom, rgba(0,0,0,1) 10%, rgba(0,0,0,0) 90%);
  -webkit-mask-image: linear-gradient(to bottom, rgba(0,0,0,1) 10%, rgba(0,0,0,0) 90%);
}

.td-menu-sweep {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 34%;
  background: linear-gradient(90deg, transparent, rgba(103, 168, 255, 0.16), rgba(56, 212, 184, 0.09), transparent);
  animation: td-menu-sweep 5.8s ease-in-out infinite 1.4s;
}

.td-menu-sync {
  position: relative;
  z-index: 2;
  display: none;
  width: min(360px, 84%);
  min-height: 138px;
  padding: 1.25rem;
  overflow: hidden;
  color: #e2e8f0;
  background:
    radial-gradient(circle at 50% 38%, rgba(56, 212, 184, 0.14), transparent 46%),
    linear-gradient(135deg, rgba(8, 13, 24, 0.96), rgba(14, 25, 42, 0.98));
  border: 1px solid rgba(103, 168, 255, 0.38);
  border-radius: 8px;
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.34), 0 0 28px rgba(56, 212, 184, 0.12);
  font-family: 'JetBrains Mono', monospace;
  text-align: center;
  cursor: pointer;
}

.td-menu.is-syncing .td-menu-sync {
  display: grid;
  place-items: center;
  gap: 0.42rem;
}

.td-menu.is-syncing .td-menu-bg,
.td-menu.is-syncing .td-menu-inner {
  animation: none;
  display: none !important;
  opacity: 0;
  pointer-events: none;
}

.td-menu-sync::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, rgba(103, 232, 249, 0.16), transparent);
  animation: td-menu-sync-scan 2.2s ease-in-out infinite;
}

.td-menu-sync-ring {
  position: absolute;
  left: 50%;
  top: 42%;
  width: 92px;
  height: 92px;
  border: 1px solid rgba(103, 232, 249, 0.42);
  border-radius: 50%;
  transform: translate(-50%, -50%);
  animation: td-menu-sync-ring 1.8s ease-out infinite;
}

.td-menu-sync-label,
.td-menu-sync-sub {
  position: relative;
  z-index: 1;
}

.td-menu-sync-label {
  color: #f8fafc;
  font-size: 0.95rem;
  font-weight: 800;
  text-transform: uppercase;
}

.td-menu-sync-sub {
  max-width: 26ch;
  color: var(--hint);
  font-size: 0.72rem;
  line-height: 1.45;
}

.td-menu-inner {
  width: min(680px, 92%);
  text-align: center;
  z-index: 1;
  position: relative;
  opacity: 0;
  animation: td-menu-wake 1.6s cubic-bezier(.19, 1, .22, 1) 0.45s forwards;
}

.td-menu-mark {
  position: relative;
  display: inline-grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 0.65rem;
  min-width: min(520px, 92%);
  padding: 0.62rem 1rem 0.72rem;
  overflow: hidden;
  background:
    linear-gradient(90deg, rgba(56, 212, 184, 0), rgba(56, 212, 184, 0.16), rgba(251, 191, 36, 0.12), rgba(56, 212, 184, 0)),
    rgba(7, 13, 24, 0.72);
  border: 1px solid rgba(103, 232, 249, 0.38);
  border-radius: 8px;
  color: #dbeafe;
  font-family: 'JetBrains Mono', monospace;
  font-size: 1.38rem;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
  margin-bottom: 1.45rem;
  box-shadow: 0 0 22px rgba(59, 142, 255, 0.2), inset 0 0 22px rgba(56, 212, 184, 0.06);
}

.td-menu-mark::before,
.td-menu-mark::after {
  content: "";
  position: absolute;
  left: 10%;
  right: 10%;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(103, 232, 249, 0.72), rgba(251, 191, 36, 0.52), transparent);
}

.td-menu-mark::before { top: 0; }
.td-menu-mark::after { bottom: 0; }

.td-menu-mark-title {
  position: relative;
  display: inline-block;
  color: #f8fafc;
  text-shadow: 0 0 12px rgba(103, 232, 249, 0.5);
}

.td-menu-mark-title::after {
  content: "";
  position: absolute;
  inset: -0.2rem -0.35rem;
  background: linear-gradient(100deg, transparent 20%, rgba(255,255,255,0.36), transparent 58%);
  mix-blend-mode: screen;
  animation: td-title-glint 4.8s ease-in-out infinite 1.2s;
}

.td-menu-mark-bracket {
  display: inline-block;
  color: #67e8f9;
  font-size: 1.9rem;
  line-height: 0.8;
  text-shadow: 0 0 18px rgba(103, 232, 249, 0.72);
  animation: td-title-bracket 2.6s ease-in-out infinite;
}

.td-menu-mark-bracket:last-child {
  animation-delay: 0.32s;
}

.td-menu-title {
  margin: 0 0 0.9rem;
  font-size: 3rem;
  font-weight: 800;
  line-height: 1.1;
  letter-spacing: 0;
  color: #fff;
}

.td-menu-title em.td-menu-ascend {
  font-style: normal;
  background: linear-gradient(135deg, var(--teal), #60efff);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 0 12px rgba(56, 212, 184, 0.5));
}

.td-menu-blurb {
  margin: 0 auto 1.75rem;
  max-width: 44ch;
  color: #94a3b8;
  font-size: 1.05rem;
  line-height: 1.6;
}

.td-menu-buttons {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.8rem;
}

.td-menu-btn {
  min-height: 44px;
  padding: 0.72rem 1.4rem;
  border-radius: 10px;
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: 0;
  transition: transform 0.15s, background 0.15s, border-color 0.15s, box-shadow 0.15s;
}

.td-menu-btn-primary {
  position: relative;
  width: min(560px, 100%);
  min-height: 174px;
  padding: 0;
  overflow: hidden;
  color: #fff;
  background:
    linear-gradient(135deg, rgba(12, 19, 34, 0.96), rgba(10, 42, 62, 0.94) 52%, rgba(45, 25, 64, 0.92)),
    linear-gradient(90deg, rgba(56, 212, 184, 0.28), rgba(240, 192, 64, 0.22), rgba(244, 114, 182, 0.18));
  border: 1px solid rgba(103, 168, 255, 0.58);
  box-shadow: 0 22px 58px rgba(3, 7, 18, 0.38), 0 0 38px rgba(59, 142, 255, 0.18);
  isolation: isolate;
}

.td-menu-btn-primary:hover {
  transform: translateY(-3px);
  border-color: rgba(103, 232, 249, 0.76);
  box-shadow: 0 28px 68px rgba(3, 7, 18, 0.44), 0 0 52px rgba(56, 212, 184, 0.28);
}

.td-menu-btn-primary:focus-visible {
  outline: 2px solid rgba(251, 191, 36, 0.9);
  outline-offset: 4px;
}

.td-start-banner {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 0.35rem;
  padding: 0.86rem;
  text-align: left;
}

.td-start-banner-top,
.td-start-banner-bottom {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  font-family: 'JetBrains Mono', monospace;
  text-transform: uppercase;
}

.td-start-eyebrow {
  color: #f8fafc;
  font-size: 0.86rem;
  font-weight: 800;
}

.td-start-status {
  color: #fde68a;
  font-size: 0.68rem;
  font-weight: 700;
}

.td-start-banner-bottom {
  color: rgba(226, 232, 240, 0.9);
  font-size: 0.68rem;
  font-weight: 700;
}

.td-start-chevrons {
  color: #67e8f9;
  animation: td-chevron-run 1.1s ease-in-out infinite;
}

.td-start-stage {
  position: relative;
  z-index: 1;
  min-height: 94px;
  overflow: hidden;
  border: 1px solid rgba(148, 163, 184, 0.22);
  border-radius: 8px;
  background:
    linear-gradient(rgba(255, 255, 255, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.035) 1px, transparent 1px),
    radial-gradient(circle at 50% 52%, rgba(251, 191, 36, 0.14), transparent 27%),
    rgba(4, 10, 19, 0.86);
  background-size: 38px 38px, 38px 38px, auto, auto;
  animation: td-start-stage-drift 3.8s linear infinite;
}

.td-start-stage::before,
.td-start-stage::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.td-start-stage::before {
  background:
    linear-gradient(90deg, transparent 0 11%, rgba(103, 232, 249, 0.12) 12%, transparent 13% 45%, rgba(251, 191, 36, 0.12) 46%, transparent 47% 72%, rgba(244, 114, 182, 0.12) 73%, transparent 74%),
    linear-gradient(180deg, rgba(255,255,255,0.04), transparent 34%, rgba(255,255,255,0.035));
  mix-blend-mode: screen;
}

.td-start-stage::after {
  background: repeating-linear-gradient(180deg, rgba(255,255,255,0.045) 0 1px, transparent 1px 6px);
  opacity: 0.36;
}

.td-start-grid {
  position: absolute;
  inset: 12px;
  border: 1px solid rgba(56, 212, 184, 0.14);
  clip-path: polygon(0 16%, 84% 16%, 84% 0, 100% 50%, 84% 100%, 84% 84%, 0 84%);
}

.td-start-path {
  position: absolute;
  height: 4px;
  border-radius: 999px;
  background: linear-gradient(90deg, transparent, #67e8f9, #fbbf24, transparent);
  box-shadow: 0 0 14px rgba(103, 232, 249, 0.42);
  transform-origin: left center;
  animation: td-route-pulse 2.2s ease-in-out infinite;
}

.td-start-path-a {
  left: 12%;
  top: 54%;
  width: 74%;
}

.td-start-path-b {
  left: 34%;
  top: 54%;
  width: 32%;
  transform: rotate(-34deg);
  animation-delay: 0.35s;
}

.td-start-core,
.td-start-tower,
.td-start-shot,
.td-start-enemy,
.td-start-scan {
  position: absolute;
  display: block;
}

.td-start-core {
  left: 82%;
  top: 54%;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid rgba(254, 243, 199, 0.92);
  background: radial-gradient(circle, #fef3c7 0 20%, #f59e0b 21% 48%, rgba(251, 191, 36, 0.22) 49% 100%);
  animation: td-core-pulse 1.9s ease-in-out infinite;
}

.td-start-tower {
  width: 24px;
  height: 24px;
  border: 2px solid rgba(226, 232, 240, 0.82);
  background: linear-gradient(135deg, rgba(15, 23, 42, 0.95), rgba(56, 212, 184, 0.42));
  box-shadow: 0 0 18px rgba(56, 212, 184, 0.32);
  clip-path: polygon(50% 0, 100% 32%, 82% 100%, 18% 100%, 0 32%);
  animation: td-tower-idle 2.4s ease-in-out infinite;
}

.td-start-tower-a { left: 29%; top: 31%; }
.td-start-tower-b { left: 47%; top: 74%; animation-delay: 0.35s; background: linear-gradient(135deg, rgba(15, 23, 42, 0.95), rgba(244, 114, 182, 0.42)); }
.td-start-tower-c { left: 63%; top: 33%; animation-delay: 0.7s; background: linear-gradient(135deg, rgba(15, 23, 42, 0.95), rgba(251, 191, 36, 0.42)); }

.td-start-shot {
  left: 0;
  top: 0;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #e0f2fe;
  box-shadow: 0 0 12px #67e8f9, 0 0 22px rgba(56, 212, 184, 0.7);
  animation: td-shot-run 1.75s linear infinite;
}

.td-start-shot-a { --shot-x0: 30%; --shot-y0: 31%; --shot-x1: 58%; --shot-y1: 54%; }
.td-start-shot-b { --shot-x0: 47%; --shot-y0: 73%; --shot-x1: 70%; --shot-y1: 54%; animation-delay: 0.55s; background: #fce7f3; box-shadow: 0 0 12px #f472b6, 0 0 22px rgba(244, 114, 182, 0.62); }
.td-start-shot-c { --shot-x0: 63%; --shot-y0: 33%; --shot-x1: 78%; --shot-y1: 52%; animation-delay: 1.05s; background: #fef3c7; box-shadow: 0 0 12px #fbbf24, 0 0 22px rgba(251, 191, 36, 0.62); }

.td-start-enemy {
  width: 13px;
  height: 13px;
  border-radius: 4px;
  background: linear-gradient(135deg, #fb7185, #f97316);
  box-shadow: 0 0 14px rgba(251, 113, 133, 0.6);
  offset-path: path("M 42 52 C 118 52, 170 42, 246 52 C 300 59, 354 56, 420 52");
  animation: td-enemy-run 4.2s linear infinite;
}

.td-start-enemy-b {
  width: 10px;
  height: 10px;
  animation-delay: 1.35s;
  background: linear-gradient(135deg, #a78bfa, #38bdf8);
  box-shadow: 0 0 14px rgba(167, 139, 250, 0.58);
}

.td-start-enemy-c {
  width: 16px;
  height: 16px;
  animation-delay: 2.55s;
  background: linear-gradient(135deg, #fecaca, #ef4444);
}

.td-start-scan {
  inset: 0 auto 0 0;
  width: 22%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.18), transparent);
  animation: td-start-scan 3.4s ease-in-out infinite;
  z-index: 3;
}

.td-start-accessible {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
}

.td-menu-btn-ghost {
  position: relative;
  width: min(420px, 92%);
  min-height: 68px;
  padding: 0;
  overflow: hidden;
  color: var(--text);
  background:
    linear-gradient(135deg, rgba(8, 13, 24, 0.9), rgba(12, 23, 38, 0.9)),
    rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(148, 163, 184, 0.28);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.22);
}

.td-menu-btn-ghost:hover {
  color: var(--text-strong);
  background:
    linear-gradient(135deg, rgba(8, 18, 30, 0.96), rgba(28, 20, 48, 0.94)),
    rgba(59, 142, 255, 0.10);
  border-color: rgba(103, 232, 249, 0.52);
  transform: translateY(-1px);
}

.td-menu-btn-ghost::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, rgba(103, 168, 255, 0.18), transparent);
  animation: td-continue-scan 3.3s ease-in-out infinite;
}

.td-continue-banner {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-columns: 52px 1fr 34px;
  align-items: center;
  gap: 0.7rem;
  padding: 0.7rem 0.9rem;
  text-align: left;
}

.td-continue-orbit {
  position: relative;
  width: 38px;
  height: 38px;
  border: 1px solid rgba(103, 232, 249, 0.5);
  border-radius: 50%;
  box-shadow: inset 0 0 14px rgba(56, 212, 184, 0.16), 0 0 16px rgba(56, 212, 184, 0.14);
  animation: td-continue-orbit 5.4s linear infinite;
}

.td-continue-orbit::before,
.td-continue-orbit::after {
  content: "";
  position: absolute;
  border-radius: 50%;
}

.td-continue-orbit::before {
  inset: 12px;
  background: #fbbf24;
  box-shadow: 0 0 16px rgba(251, 191, 36, 0.62);
}

.td-continue-orbit::after {
  top: -3px;
  left: 15px;
  width: 7px;
  height: 7px;
  background: #67e8f9;
  box-shadow: 0 0 12px rgba(103, 232, 249, 0.82);
}

.td-continue-copy,
.td-continue-label,
.td-continue-sub,
.td-continue-pulse {
  position: relative;
  z-index: 1;
}

.td-continue-copy {
  display: grid;
  gap: 0.14rem;
}

.td-continue-label {
  color: #f8fafc;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.86rem;
  font-weight: 800;
  text-transform: uppercase;
}

.td-continue-sub {
  color: var(--hint);
  font-size: 0.72rem;
}

.td-continue-pulse {
  justify-self: end;
  top: 50%;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #22c55e;
  box-shadow: 0 0 16px rgba(34, 197, 94, 0.72);
  animation: td-continue-pulse 1.6s ease-in-out infinite;
}

.td-continue-accessible {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
}

.td-menu-foot {
  margin-top: 1.5rem;
  color: var(--hint);
  font-size: 0.78rem;
}

.td-link {
  color: var(--accent-strong);
  background: none;
  border: 0;
  padding: 0;
  font-size: inherit;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.td-link:hover { color: var(--text-strong); }

/* Game over overlay -------------------------------------------------------- */

.td-gameover {
  position: absolute;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(6, 9, 15, 0.90);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.td-gameover-inner {
  width: min(420px, 92%);
  text-align: center;
}

.td-gameover-mark {
  color: var(--danger);
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  margin-bottom: 0.9rem;
}

.td-gameover-inner h2 {
  margin: 0 0 0.5rem;
  color: var(--text-strong);
  font-size: 1.9rem;
  line-height: 1.1;
  letter-spacing: -0.03em;
}

.td-gameover-inner p {
  color: var(--mute);
  margin: 0 0 1.5rem;
}

/* Side panel --------------------------------------------------------------- */

.td-sidepanel {
  display: flex;
  flex-direction: column;
  gap: 0;
  overflow-y: auto;
  overflow-x: hidden;
  background: var(--panel2);
  border-left: 1px solid var(--line);
  scrollbar-width: thin;
  scrollbar-color: var(--line) transparent;
}

.td-sidepanel::-webkit-scrollbar { width: 5px; }
.td-sidepanel::-webkit-scrollbar-track { background: transparent; }
.td-sidepanel::-webkit-scrollbar-thumb { background: var(--line); border-radius: 99px; }

.td-panel {
  padding: 1rem;
  border-bottom: 1px solid var(--line);
}

.td-panel-head {
  margin-bottom: 0.75rem;
}

.td-panel-eyebrow {
  display: block;
  color: var(--hint);
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.62rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin-bottom: 0.2rem;
}

.td-panel-title {
  margin: 0;
  color: var(--text-strong);
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

/* Tier progress ------------------------------------------------------------ */

.td-tier-progress {
  margin-bottom: 0.75rem;
}

.td-tier-bar {
  height: 5px;
  background: var(--line);
  border-radius: 99px;
  overflow: hidden;
  margin-bottom: 0.35rem;
}

.td-tier-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--teal));
  border-radius: 99px;
  transition: width 0.4s ease;
  width: 0%;
}

.td-tier-caption {
  color: var(--hint);
  font-size: 0.74rem;
  font-family: 'JetBrains Mono', monospace;
}

.td-tier-perks {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.td-tier-perk {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  color: var(--mute);
  font-size: 0.78rem;
}

.td-tier-perk::before {
  content: "▸";
  color: var(--teal);
  flex-shrink: 0;
}

.td-tier-perk.active { color: var(--text); }

/* Build log ---------------------------------------------------------------- */

.td-panel-log {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.td-log {
  flex: 1;
  max-height: 240px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.18rem;
  scrollbar-width: thin;
  scrollbar-color: var(--line) transparent;
}

.td-log::-webkit-scrollbar { width: 4px; }
.td-log::-webkit-scrollbar-thumb { background: var(--line); border-radius: 99px; }

.td-log-line {
  font-family: 'JetBrains Mono', 'Courier New', monospace;
  font-size: 0.74rem;
  line-height: 1.55;
  color: var(--mute);
  word-break: break-word;
}

.td-log-line-system  { color: var(--hint); }
.td-log-line-success { color: var(--teal); }
.td-log-line-error   { color: var(--danger); }
.td-log-line-warn    { color: #f0c040; }
.td-log-line-info    { color: var(--accent-strong); }

/* Help panel --------------------------------------------------------------- */

.td-help {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.td-help li {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--mute);
  font-size: 0.78rem;
}

kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 24px;
  padding: 0.1rem 0.35rem;
  color: var(--text);
  background: var(--panel3);
  border: 1px solid rgba(141, 170, 210, 0.22);
  border-bottom-width: 2px;
  border-radius: 5px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.7rem;
  font-weight: 600;
  white-space: nowrap;
  flex-shrink: 0;
}

/* Blueprint Compiler Modal ------------------------------------------------- */

.td-modal {
  position: fixed;
  inset: 0;
  z-index: 500;
}

.td-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.72);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
}

.td-modal-frame {
  position: relative;
  z-index: 1;
  width: min(640px, calc(100% - 2rem));
  max-height: calc(100dvh - 4rem);
  overflow-y: auto;
  margin: 2rem auto;
  background: linear-gradient(180deg, rgba(11, 16, 26, 0.99), rgba(7, 10, 18, 0.99));
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.70), inset 0 1px 0 rgba(255, 255, 255, 0.045);
  scrollbar-width: thin;
  scrollbar-color: var(--line) transparent;
}

.td-modal-frame::-webkit-scrollbar { width: 5px; }
.td-modal-frame::-webkit-scrollbar-thumb { background: var(--line); border-radius: 99px; }

.td-modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.25rem 1.25rem 1rem;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  background: inherit;
  z-index: 10;
}

.td-modal-eyebrow {
  display: block;
  color: var(--hint);
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin-bottom: 0.18rem;
}

.td-modal-title {
  margin: 0;
  color: var(--text-strong);
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.td-modal-badges {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}

.td-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.22rem 0.55rem;
  border-radius: 99px;
  font-size: 0.7rem;
  font-weight: 700;
  white-space: nowrap;
}

.td-badge-tier {
  color: var(--teal);
  background: rgba(56, 212, 184, 0.10);
  border: 1px solid rgba(56, 212, 184, 0.28);
  font-family: 'JetBrains Mono', monospace;
}

.td-modal-close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  color: var(--mute);
  background: none;
  border: 1px solid transparent;
  border-radius: 8px;
  flex-shrink: 0;
  transition: color 0.14s, background 0.14s, border-color 0.14s;
}

.td-modal-close:hover {
  color: var(--text-strong);
  background: rgba(255, 255, 255, 0.06);
  border-color: var(--line);
}

.td-modal-body {
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

/* Form rows ---------------------------------------------------------------- */

.td-form-row {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.td-form-label {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  color: var(--text);
  font-size: 0.83rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.td-form-hint {
  color: var(--hint);
  font-size: 0.73rem;
  font-weight: 400;
}

.td-cost-slider {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.td-cost-slider input[type="range"] {
  flex: 1;
  height: 5px;
  accent-color: var(--accent);
  cursor: pointer;
}

.td-cost-display {
  display: flex;
  align-items: baseline;
  gap: 0.28rem;
  min-width: 80px;
  justify-content: flex-end;
}

.td-cost-value {
  color: #f0c040;
  font-family: 'JetBrains Mono', monospace;
  font-size: 1.05rem;
  font-weight: 600;
}

.td-cost-unit {
  color: var(--hint);
  font-size: 0.75rem;
}

.td-budget-preview {
  color: var(--mute);
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.74rem;
  padding: 0.45rem 0.7rem;
  background: var(--panel2);
  border: 1px solid var(--line);
  border-radius: 7px;
}

.td-textarea {
  width: 100%;
  min-height: 88px;
  padding: 0.72rem 0.85rem;
  color: var(--text);
  background: var(--panel2);
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: 0.9rem;
  line-height: 1.55;
  resize: vertical;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.td-textarea::placeholder { color: var(--hint); }

.td-textarea:hover { border-color: rgba(59, 142, 255, 0.38); }

.td-textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(59, 142, 255, 0.16);
}

.td-prompt-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.td-prompt-meta > span {
  color: var(--hint);
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.72rem;
}

.td-suggestion-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.td-suggestion {
  padding: 0.28rem 0.6rem;
  color: var(--mute);
  background: var(--panel2);
  border: 1px solid var(--line);
  border-radius: 99px;
  font-size: 0.74rem;
  font-weight: 600;
  transition: color 0.14s, background 0.14s, border-color 0.14s;
}

.td-suggestion:hover {
  color: var(--accent-strong);
  background: rgba(59, 142, 255, 0.10);
  border-color: rgba(59, 142, 255, 0.42);
}

/* Compile action row ------------------------------------------------------- */

.td-form-row-actions {
  gap: 0.75rem;
}

.td-btn-primary {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.65rem;
  min-height: 46px;
  padding: 0.72rem 1.25rem;
  color: #fff;
  background: linear-gradient(135deg, var(--accent), #256fd1);
  border: 1px solid rgba(103, 168, 255, 0.5);
  border-radius: 10px;
  font-size: 0.93rem;
  font-weight: 700;
  box-shadow: 0 8px 24px rgba(59, 142, 255, 0.22);
  transition: transform 0.15s, box-shadow 0.15s, opacity 0.15s;
}

.td-btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 14px 34px rgba(59, 142, 255, 0.34);
}

.td-btn-primary:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}

.td-btn-primary-cost {
  padding: 0.15rem 0.5rem;
  background: rgba(0, 0, 0, 0.22);
  border-radius: 6px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.82rem;
  color: #f0c040;
}

.td-compile-status {
  min-height: 1.4em;
  color: var(--mute);
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.8rem;
}

.td-compile-status.compiling { color: var(--accent-strong); }
.td-compile-status.error     { color: var(--danger); }
.td-compile-status.done      { color: var(--teal); }

/* Compile result ----------------------------------------------------------- */

.td-result {
  border: 1px solid rgba(56, 212, 184, 0.25);
  border-radius: 13px;
  overflow: hidden;
  background: rgba(56, 212, 184, 0.04);
  animation: result-in 0.22s ease-out;
}

@keyframes result-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.td-result-card {
  display: flex;
  gap: 1rem;
  padding: 1rem;
}

.td-result-preview {
  width: 80px;
  height: 80px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(7, 10, 20, 0.60);
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
}

.td-result-preview svg {
  width: 64px;
  height: 64px;
}

.td-result-body {
  flex: 1;
  min-width: 0;
}

.td-result-name {
  margin: 0 0 0.2rem;
  color: var(--text-strong);
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.td-result-flavor {
  margin: 0 0 0.6rem;
  color: var(--mute);
  font-size: 0.8rem;
  font-style: italic;
  line-height: 1.45;
}

.td-result-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.75rem;
  margin: 0;
}

.td-result-stats dt {
  color: var(--hint);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

.td-result-stats dd {
  margin: 0;
  color: var(--teal);
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.78rem;
  font-weight: 600;
}

/* Responsive --------------------------------------------------------------- */

@media (max-width: 900px) {
  .td-shell {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr auto;
  }

  .td-sidepanel {
    border-left: none;
    border-top: 1px solid var(--line);
    max-height: 240px;
    flex-direction: row;
    overflow-x: auto;
    overflow-y: hidden;
  }

  .td-panel {
    flex-shrink: 0;
    min-width: 200px;
    border-bottom: none;
    border-right: 1px solid var(--line);
  }

  .td-log { max-height: 160px; }
}

@media (max-width: 600px) {
  .td-gamebar { padding: 0.35rem 0.45rem; gap: 0.25rem; }

  .td-stat { min-width: 54px; padding: 0.3rem 0.5rem; }
  .td-stat-value { font-size: 0.9rem; }

  .td-btn { min-height: 32px; padding: 0.34rem 0.55rem; font-size: 0.76rem; }

  .td-menu-inner { width: min(94%, 520px); }
  .td-menu-mark {
    min-width: min(94%, 360px);
    gap: 0.42rem;
    padding: 0.5rem 0.68rem 0.58rem;
    font-size: 1rem;
  }
  .td-menu-mark-bracket { font-size: 1.46rem; }
  .td-menu-title { font-size: 2rem; }
  .td-menu-blurb { font-size: 0.92rem; }
  .td-menu-btn-primary { min-height: 150px; }
  .td-menu-btn-ghost { min-height: 62px; width: min(366px, 94%); }
  .td-start-banner { padding: 0.65rem; }
  .td-start-stage { min-height: 78px; }
  .td-start-status { display: none; }
  .td-start-banner-bottom { font-size: 0.62rem; }
  .td-continue-banner { grid-template-columns: 44px 1fr 24px; padding: 0.6rem 0.7rem; }
  .td-continue-orbit { width: 32px; height: 32px; }
  .td-continue-label { font-size: 0.76rem; }
  .td-continue-sub { font-size: 0.65rem; }

  .td-modal-frame { margin: 0.5rem auto; border-radius: 14px; }

  .td-result-card { flex-direction: column; }
  .td-result-preview { width: 64px; height: 64px; }
}

@media (prefers-reduced-motion: reduce) {
  .td-menu,
  .td-menu.is-waking,
  .td-menu-inner,
  .td-menu-glow,
  .td-menu-grid,
  .td-menu-sweep,
  .td-menu-sync::after,
  .td-menu-sync-ring,
  .td-start-stage,
  .td-start-path,
  .td-start-core,
  .td-start-tower,
  .td-start-shot,
  .td-start-enemy,
  .td-start-scan,
  .td-start-chevrons,
  .td-menu-mark-title::after,
  .td-menu-mark-bracket,
  .td-menu-btn-ghost::after,
  .td-continue-orbit,
  .td-continue-pulse {
    animation: none !important;
  }

  .td-menu,
  .td-menu-inner {
    opacity: 1;
    filter: none;
    transform: none;
  }
}

/* Hard override for HTML hidden. Without this, .td-gameover { display:flex } wins and the page opens on game over. */
[hidden],
.td-menu[hidden],
.td-gamebar[hidden],
.td-gameover[hidden],
.td-modal[hidden],
.td-result[hidden],
#btnContinue[hidden],
#btnNewGameMenu[hidden],
#btnMenuSignIn[hidden],
#btnSell[hidden],
#btnNextWave[hidden] {
  display: none !important;
}

.td-perk {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  color: var(--text);
  font-size: 0.76rem;
  line-height: 1.35;
}

.td-perk::before {
  content: "▸";
  color: var(--teal);
  font-size: 0.72rem;
}

.td-perk.locked {
  color: var(--hint);
  opacity: 0.72;
}

.td-header-meta {
  display: flex;
  align-items: center;
  gap: 0.7rem;
}

.td-header-meta .account-area {
  margin-left: 0;
}

@media (max-width: 740px) {
  .td-header {
    gap: 0.65rem;
    padding-right: 0.7rem;
  }

  .td-header-meta {
    gap: 0.45rem;
  }

  .td-user-badge {
    display: none;
  }

  /* Hide the top header/banner to reclaim screen space */
  .td-header {
    display: none !important;
  }
}

/* Mobile Overrides for Better Playability */
@media (max-width: 740px) {
  /* Reset body padding so game takes full screen without the banner */
  .td-body {
    padding-top: 0 !important;
  }
  
  /* Make the build store a bottom sheet */
  .td-build-store {
    top: 40% !important;
    right: 0 !important;
    bottom: 0 !important;
    left: 0 !important;
    width: 100% !important;
    border-radius: 24px 24px 0 0 !important;
    border-right: none !important;
    border-bottom: none !important;
    border-left: none !important;
    padding-bottom: 30px !important; /* safe area allowance */
    animation: tdDrawerInMobile 0.22s ease-out !important;
    transform: translateY(0);
  }

  /* Make the blueprint compiler modal a bottom sheet too */
  .td-modal-frame {
    position: absolute !important;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    top: auto !important;
    margin: 0 !important;
    width: 100% !important;
    max-height: 70dvh !important;
    border-radius: 24px 24px 0 0 !important;
    border-bottom: none !important;
    border-left: none !important;
    border-right: none !important;
    animation: tdDrawerInMobile 0.22s ease-out !important;
  }

  @keyframes tdDrawerInMobile {
    from { opacity: 0; transform: translateY(100%); }
    to { opacity: 1; transform: translateY(0); }
  }
  
  /* Make the side panel more compact on mobile to give more space to the map */
  .td-sidepanel {
    max-height: 180px !important;
  }
  
  .td-log {
    max-height: 120px !important;
  }
}

/* Threat intelligence panel */
.td-panel-threat {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.td-threat-intel {
  flex: 1;
  max-height: 240px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  scrollbar-width: thin;
  scrollbar-color: var(--line) transparent;
}

.td-threat-intel::-webkit-scrollbar { width: 4px; }
.td-threat-intel::-webkit-scrollbar-thumb { background: var(--line); border-radius: 99px; }

.td-threat-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.45rem 0.65rem;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(148, 163, 184, 0.08);
  border-radius: 6px;
  transition: background 0.15s, border-color 0.15s;
}

.td-threat-row:hover {
  background: rgba(255, 255, 255, 0.04);
  border-color: rgba(148, 163, 184, 0.15);
}

.td-threat-enemy-canvas {
  width: 32px;
  height: 32px;
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid rgba(148, 163, 184, 0.15);
  border-radius: 6px;
  flex-shrink: 0;
  display: block;
}

.td-threat-info {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  flex: 1;
  min-width: 0;
}

.td-threat-name {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.78rem;
  font-weight: 600;
  color: #f8fafc;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.td-threat-type {
  font-size: 0.68rem;
  color: var(--mute);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.td-threat-count {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.86rem;
  font-weight: 700;
  color: #fbbf24;
  padding: 0.15rem 0.4rem;
  background: rgba(251, 191, 36, 0.08);
  border: 1px solid rgba(251, 191, 36, 0.2);
  border-radius: 4px;
}

/* ========================================================================== */
/* Tutorial Overlay — FTUE TutorialManager                                    */
/* ========================================================================== */

/* ── Tutorial button in MMO top bar ─────────────────────────── */

#tdTutorialBtn {
  /* Styled via the td-mmo-client btn() helper inline — these rules add a       */
  /* subtle pulse so new players notice it.                                       */
  position: relative;
}

#tdTutorialBtn::after {
  content: '';
  position: absolute;
  inset: -3px;
  border-radius: 12px;
  border: 1px solid rgba(251, 191, 36, 0.55);
  animation: tut-btn-pulse 2.6s ease-in-out infinite;
  pointer-events: none;
}

@keyframes tut-btn-pulse {
  0%, 100% { opacity: 0.45; }
  50%       { opacity: 1;    }
}

/* ── Root overlay (fixed, full-screen, above everything) ─────── */

#tdTutOverlay {
  position: fixed;
  inset: 0;
  z-index: 900000;
  pointer-events: none; /* children opt-in individually */
}

/* ── SVG dark mask (pointer-events: none — purely visual) ────── */

.tut-svg {
  position: fixed;
  inset: 0;
  pointer-events: none;
}

/* ── Glowing spotlight ring ──────────────────────────────────── */

.tut-ring {
  position: fixed;
  border-radius: 12px;
  border: 2px solid rgba(56, 212, 184, 0.85);
  box-shadow:
    0 0 0 1px rgba(56, 212, 184, 0.22),
    0 0 28px rgba(56, 212, 184, 0.50),
    inset 0 0 20px rgba(56, 212, 184, 0.10);
  pointer-events: none;
  transition: left 0.22s cubic-bezier(.19,1,.22,1),
              top  0.22s cubic-bezier(.19,1,.22,1),
              width  0.22s cubic-bezier(.19,1,.22,1),
              height 0.22s cubic-bezier(.19,1,.22,1);
  /* Breathe via opacity only — avoids paint triggers from box-shadow animation */
  animation: tut-ring-breathe 2.8s ease-in-out infinite;
}

@keyframes tut-ring-breathe {
  0%, 100% { opacity: 0.75; }
  50%       { opacity: 1;    }
}

/* ── Tooltip panel ───────────────────────────────────────────── */

.tut-tip {
  position: fixed;
  width: 330px;
  padding: 1.1rem 1.15rem 0.95rem;
  background:
    linear-gradient(165deg, rgba(9, 15, 30, 0.98), rgba(6, 10, 20, 0.99));
  border: 1px solid rgba(56, 212, 184, 0.42);
  border-radius: 14px;
  box-shadow:
    0 24px 64px rgba(0, 0, 0, 0.72),
    0 0 0 1px rgba(56, 212, 184, 0.10),
    inset 0 1px 0 rgba(255, 255, 255, 0.045);
  pointer-events: auto;    /* tooltip always receives events */
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  animation: tut-tip-in 0.22s cubic-bezier(.19,1,.22,1);
  overflow: hidden;
}

/* Subtle sweep line across the top of the tooltip */
.tut-tip::before {
  content: '';
  position: absolute;
  left: 10%;
  right: 10%;
  top: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(56, 212, 184, 0.7), rgba(251, 191, 36, 0.5), transparent);
}

@keyframes tut-tip-in {
  from { opacity: 0; transform: translateY(-6px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0)    scale(1);    }
}

.tut-tip-eyebrow {
  color: #67e8f9;
  font-family: 'JetBrains Mono', 'Courier New', monospace;
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.tut-tip-title {
  color: #f8fafc;
  font-family: 'JetBrains Mono', 'Courier New', monospace;
  font-size: 0.96rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-shadow: 0 0 18px rgba(56, 212, 184, 0.35);
  line-height: 1.2;
}

.tut-tip-body {
  margin: 0;
  color: #94a3b8;
  font-size: 0.84rem;
  line-height: 1.6;
}

/* ── Tooltip footer: exit · dots · next ─────────────────────── */

.tut-tip-foot {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  margin-top: 0.2rem;
  padding-top: 0.7rem;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.tut-btn-exit {
  padding: 0.34rem 0.72rem;
  color: #64748b;
  background: transparent;
  border: 1px solid rgba(100, 116, 139, 0.28);
  border-radius: 7px;
  font-size: 0.74rem;
  font-weight: 600;
  white-space: nowrap;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
  cursor: pointer;
  flex-shrink: 0;
}

.tut-btn-exit:hover {
  color: #ff6b6b;
  border-color: rgba(255, 107, 107, 0.45);
  background: rgba(255, 107, 107, 0.08);
}

.tut-dots {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex: 1;
  justify-content: center;
  flex-wrap: wrap;
}

.tut-dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: rgba(148, 163, 184, 0.25);
  transition: background 0.2s, transform 0.2s;
}

.tut-dot.done {
  background: rgba(56, 212, 184, 0.45);
}

.tut-dot.active {
  background: #38d4b8;
  transform: scale(1.4);
  box-shadow: 0 0 8px rgba(56, 212, 184, 0.6);
}

.tut-btn-next {
  padding: 0.34rem 0.85rem;
  color: #e2e8f0;
  background: linear-gradient(135deg, rgba(56, 212, 184, 0.22), rgba(59, 142, 255, 0.18));
  border: 1px solid rgba(56, 212, 184, 0.52);
  border-radius: 7px;
  font-size: 0.78rem;
  font-weight: 700;
  white-space: nowrap;
  transition: background 0.15s, border-color 0.15s, transform 0.15s, color 0.15s;
  cursor: pointer;
  flex-shrink: 0;
}

.tut-btn-next:hover {
  color: #fff;
  background: linear-gradient(135deg, rgba(56, 212, 184, 0.38), rgba(59, 142, 255, 0.32));
  border-color: rgba(56, 212, 184, 0.80);
  transform: translateY(-1px);
}

/* Finish button (last step) gets a gold accent */
.tut-btn-next[data-last] {
  background: linear-gradient(135deg, rgba(251, 191, 36, 0.22), rgba(245, 166, 35, 0.18));
  border-color: rgba(251, 191, 36, 0.55);
}

.tut-btn-next[data-last]:hover {
  background: linear-gradient(135deg, rgba(251, 191, 36, 0.38), rgba(245, 166, 35, 0.32));
  border-color: rgba(251, 191, 36, 0.85);
}

/* ── Reduced-motion overrides ────────────────────────────────── */

@media (prefers-reduced-motion: reduce) {
  #tdTutorialBtn::after,
  .tut-ring {
    animation: none !important;
  }
  .tut-ring {
    transition: none !important;
  }
  .tut-tip {
    animation: none !important;
  }
}
