:root {
  --td-bg: #0B0F17;
  --td-surface: #1A1A2E;
  --td-accent: #59F3FF;
  --td-danger: #EF5350;
  --td-text: #E8F1FF;
  --td-muted: #93A4BD;
  --td-border: rgba(89, 243, 255, 0.22);
  --td-path: #8ED1FF;
  --td-core: #FFD84D;
  --td-good: #8BFF9A;
  --td-hud-h: 56px;
  --td-rail-w: 416px;
  --td-rail-w-mid: 360px;
}

html,
body {
  background: var(--td-bg);
}

body {
  min-height: 100svh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  color: var(--td-text);
}

.td-shell {
  min-height: 100svh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background:
    radial-gradient(circle at top, rgba(89, 243, 255, 0.08), transparent 35%),
    linear-gradient(180deg, rgba(9, 18, 31, 0.96), rgba(11, 15, 23, 1));
}

.overlay {
  background: rgba(0, 0, 0, 0.88);
}

.overlay-card.td-panel {
  background: linear-gradient(180deg, rgba(26, 26, 46, 0.98), rgba(16, 20, 31, 0.96));
  border: 2px solid var(--td-border);
  box-shadow: 0 0 40px rgba(89, 243, 255, 0.16);
}

.overlay-card.td-panel h1,
.td-card h2,
.td-tower-header h3 {
  color: var(--td-text);
}

.spinner {
  border-top-color: var(--td-accent);
}

.td-logo {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 86px;
  height: 86px;
  margin: 0 auto 12px;
  filter: drop-shadow(0 0 20px rgba(89, 243, 255, 0.24));
}

.td-logo-path {
  position: absolute;
  inset: 18px 10px 12px;
  border: 4px solid var(--td-path);
  border-radius: 24px;
}

.td-logo-path::after {
  content: "";
  position: absolute;
  inset: 10px 14px;
  border: 2px solid var(--td-accent);
  border-radius: 16px;
}

.td-logo-tower {
  position: relative;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  z-index: 1;
}

.td-logo-top {
  width: 40px;
  height: 16px;
  background: linear-gradient(180deg, #e8f9ff 0%, var(--td-accent) 100%);
  clip-path: polygon(50% 0%, 100% 42%, 82% 100%, 18% 100%, 0% 42%);
}

.td-logo-core {
  width: 20px;
  height: 30px;
  margin-top: -2px;
  border: 3px solid var(--td-accent);
  border-top: none;
  background: rgba(89, 243, 255, 0.14);
}

.td-logo-base {
  width: 40px;
  height: 14px;
  margin-top: 4px;
  border-radius: 999px;
  border: 2px solid rgba(142, 209, 255, 0.5);
  background: linear-gradient(180deg, #28384a 0%, #15202b 100%);
}

.td-lobby-panel {
  width: min(92vw, 560px);
  max-height: 90dvh;
  overflow-y: auto;
}

.name-input,
.settings-select {
  width: 100%;
  padding: 12px 16px;
  border-radius: 10px;
  border: 2px solid var(--td-border);
  background: rgba(0, 0, 0, 0.4);
  color: var(--td-text);
  font: inherit;
}

.settings-select {
  width: auto;
  min-width: 132px;
}

.name-input:focus,
.settings-select:focus {
  outline: none;
  border-color: var(--td-accent);
}

.btn-primary {
  background: var(--td-accent);
  color: #061018;
  min-height: 56px;
}

.btn-secondary {
  border-color: var(--td-border);
  color: var(--td-text);
  min-height: 48px;
}

.btn-secondary:hover {
  border-color: var(--td-accent);
  color: var(--td-accent);
}

.player-list {
  width: 100%;
  min-height: 72px;
  margin-bottom: 16px;
  border: 1px solid var(--td-border);
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.28);
}

.lobby-settings {
  margin-bottom: 16px;
}

.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
}

.settings-label,
.td-hud-label,
.td-stat-label,
.td-rail-eyebrow {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--td-muted);
  font-weight: 700;
}

.td-readonly-chip,
.td-inline-chip,
.td-cost-chip,
.td-hotkey-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 32px;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid rgba(142, 209, 255, 0.25);
  background: rgba(142, 209, 255, 0.08);
  color: var(--td-text);
}

.td-inline-chip-accent {
  border-color: rgba(89, 243, 255, 0.45);
  background: rgba(89, 243, 255, 0.16);
}

.td-lobby-rules {
  margin-bottom: 16px;
  padding: 14px 16px;
  border-radius: 12px;
  background: rgba(89, 243, 255, 0.08);
  border: 1px solid rgba(89, 243, 255, 0.18);
  text-align: left;
}

.td-lobby-rules p + p {
  margin-top: 8px;
}

.waiting-text,
.td-card-copy,
.td-run-summary,
.rankings-empty p {
  color: var(--td-muted);
}

.td-phase-banner {
  position: fixed;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 12;
  padding: 10px 18px;
  border-radius: 999px;
  background: rgba(89, 243, 255, 0.16);
  border: 1px solid rgba(89, 243, 255, 0.35);
  color: var(--td-accent);
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  backdrop-filter: blur(10px);
}

.td-spectator-banner {
  position: fixed;
  top: calc(var(--td-hud-h) + 16px);
  left: 24px;
  z-index: 11;
  padding: 10px 14px;
  border-radius: 999px;
  border: 1px solid rgba(142, 209, 255, 0.24);
  background: rgba(17, 24, 37, 0.92);
  color: var(--td-text);
}

.td-hud {
  height: var(--td-hud-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 20px;
  border-bottom: 1px solid rgba(142, 209, 255, 0.16);
  background: rgba(8, 12, 19, 0.92);
  backdrop-filter: blur(12px);
  position: relative;
  z-index: 5;
}

.td-hud-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.td-hud-center {
  flex-direction: column;
  gap: 0;
  text-align: center;
}

.td-hud-right {
  justify-content: flex-end;
  flex: 1;
}

.td-core-critical {
  color: var(--td-danger);
  animation: td-core-pulse 0.9s ease-in-out infinite alternate;
}

@keyframes td-core-pulse {
  from { text-shadow: 0 0 0 rgba(239, 83, 80, 0.15); }
  to { text-shadow: 0 0 14px rgba(239, 83, 80, 0.65); }
}

.td-desktop-hint {
  color: var(--td-muted);
  font-size: 0.82rem;
}

.td-main-layout {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) var(--td-rail-w);
}

.td-canvas-wrap {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  min-height: 0;
  padding: 24px;
  overflow: hidden;
  touch-action: none;
  background:
    linear-gradient(rgba(142, 209, 255, 0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(142, 209, 255, 0.05) 1px, transparent 1px),
    radial-gradient(circle at 75% 62%, rgba(255, 216, 77, 0.16), transparent 12%),
    linear-gradient(180deg, rgba(6, 12, 22, 0.94), rgba(11, 15, 23, 0.98));
  background-size: 48px 48px, 48px 48px, auto, auto;
}

.td-canvas-wrap::before {
  content: "";
  position: absolute;
  inset: 12% 12% 14% 10%;
  border: 10px solid var(--td-path);
  border-radius: 64px;
  opacity: 0.18;
  pointer-events: none;
}

.td-canvas-wrap::after {
  content: "";
  position: absolute;
  inset: 16% 16% 18% 14%;
  border: 4px solid var(--td-accent);
  border-radius: 48px;
  opacity: 0.16;
  pointer-events: none;
}

#gameCanvas {
  position: relative;
  z-index: 1;
  width: min(100%, 1080px);
  aspect-ratio: 16 / 10;
  max-height: 100%;
  touch-action: none;
  border-radius: 24px;
  border: 1px solid rgba(142, 209, 255, 0.16);
  background:
    radial-gradient(circle at 88% 64%, rgba(255, 216, 77, 0.2), transparent 8%),
    linear-gradient(rgba(142, 209, 255, 0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(142, 209, 255, 0.05) 1px, transparent 1px),
    linear-gradient(180deg, #111a28 0%, #0b0f17 100%);
  background-size: auto, 48px 48px, 48px 48px, auto;
  box-shadow: inset 0 0 0 12px rgba(5, 9, 16, 0.88);
}

.td-pixi-view {
  position: absolute;
  z-index: 2;
  pointer-events: none;
}

.td-canvas-callout {
  position: absolute;
  left: 32px;
  padding: 10px 14px;
  border-radius: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  z-index: 3;
  pointer-events: none;
}

.td-boss-callout {
  top: 32px;
  background: rgba(255, 216, 77, 0.14);
  border: 1px solid rgba(255, 216, 77, 0.36);
  color: var(--td-core);
}

.td-core-callout {
  top: 88px;
  background: rgba(239, 83, 80, 0.14);
  border: 1px solid rgba(239, 83, 80, 0.34);
  color: var(--td-danger);
}

.td-command-rail {
  width: var(--td-rail-w);
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 16px;
  border-left: 1px solid rgba(142, 209, 255, 0.14);
  background: rgba(10, 15, 25, 0.94);
  overflow-y: auto;
}

.td-rail-header {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.td-sheet-summary {
  display: none;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.td-sheet-summary span {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(142, 209, 255, 0.12);
  color: var(--td-text);
  font-size: 0.85rem;
  font-weight: 700;
}

.td-sheet-handle {
  display: none;
  width: 72px;
  height: 6px;
  margin: 0 auto;
  border-radius: 999px;
  background: rgba(142, 209, 255, 0.28);
}

.td-audio-controls {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
}

.td-audio-controls button,
.td-ping-btn,
.td-action-btn {
  min-height: 48px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--td-border);
  background: rgba(255, 255, 255, 0.04);
  color: var(--td-text);
  font: inherit;
  cursor: pointer;
}

.td-volume-slider {
  width: 100%;
  min-height: 48px;
  margin: 0;
  accent-color: var(--td-accent);
}

.td-mobile-details-toggle {
  display: none;
  min-height: 48px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--td-border);
  background: rgba(255, 255, 255, 0.04);
  color: var(--td-text);
  font: inherit;
  cursor: pointer;
}

.td-audio-controls button:hover,
.td-ping-btn:hover,
.td-action-btn:hover,
.td-mobile-details-toggle:hover {
  border-color: var(--td-accent);
  color: var(--td-accent);
}

.td-ping-btn.is-selected,
.td-action-btn.is-selected {
  border-color: rgba(89, 243, 255, 0.55);
  color: var(--td-accent);
  background: rgba(89, 243, 255, 0.12);
}

.td-audio-controls button:disabled,
.td-ping-btn:disabled,
.td-action-btn:disabled,
.td-mobile-details-toggle:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.td-card {
  padding: 16px;
  border-radius: 16px;
  background: var(--td-surface);
  border: 1px solid rgba(142, 209, 255, 0.14);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.03);
}

.td-rail-details {
  display: grid;
  gap: 16px;
}

.td-card-heading,
.td-tower-header,
.td-roster-row,
.td-selection-meta,
.td-action-row,
.td-summary-chips {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.td-card-heading {
  margin-bottom: 14px;
}

.td-status-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}

.td-status-grid strong,
.td-selection-block strong {
  display: block;
  margin-top: 4px;
}

.td-action-row {
  margin-top: 14px;
}

.td-action-row > * {
  flex: 1;
}

.td-roster-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.td-roster-row {
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(142, 209, 255, 0.1);
}

.td-player-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  box-shadow: 0 0 10px currentColor;
  flex-shrink: 0;
}

.td-player-dot-a { color: #59F3FF; background: #59F3FF; }
.td-player-dot-b { color: #FFD84D; background: #FFD84D; }
.td-player-dot-c { color: #8BFF9A; background: #8BFF9A; }
.td-player-dot-d { color: #EF5350; background: #EF5350; }

.td-player-name {
  flex: 1;
}

.td-player-gold {
  color: var(--td-core);
  font-weight: 700;
}

.td-status-chip {
  min-width: 112px;
  min-height: 32px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 700;
  text-align: center;
  letter-spacing: 0.08em;
}

.td-status-chip[data-status="ready"] {
  background: rgba(89, 243, 255, 0.12);
  color: var(--td-accent);
}

.td-status-chip[data-status="building"] {
  background: rgba(255, 216, 77, 0.12);
  color: var(--td-core);
}

.td-status-chip[data-status="spectating"] {
  background: rgba(139, 255, 154, 0.12);
  color: var(--td-good);
}

.td-status-chip[data-status="disconnected"] {
  background: rgba(239, 83, 80, 0.12);
  color: var(--td-danger);
}

.td-selection-block {
  border-radius: 14px;
  padding: 14px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(89, 243, 255, 0.18);
}

.td-selection-block.td-pad-reserved-self {
  border-color: rgba(89, 243, 255, 0.55);
  box-shadow: 0 0 0 1px rgba(89, 243, 255, 0.18);
}

.td-selection-block.td-pad-reserved-other {
  border-color: rgba(255, 216, 77, 0.45);
  box-shadow: 0 0 0 1px rgba(255, 216, 77, 0.12);
}

.td-selection-block.td-selection-readonly {
  border-color: rgba(239, 83, 80, 0.3);
}

.td-selection-meta {
  flex-wrap: wrap;
  margin-top: 12px;
  color: var(--td-muted);
  font-size: 0.9rem;
}

.td-upgrade-history {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.td-upgrade-grid {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.td-upgrade-card {
  padding: 12px;
  border-radius: 12px;
  border: 1px solid rgba(142, 209, 255, 0.16);
  background: rgba(255, 255, 255, 0.03);
}

.td-upgrade-card.is-unavailable {
  border-color: rgba(239, 83, 80, 0.34);
}

.td-upgrade-card.is-disabled {
  opacity: 0.7;
}

.td-upgrade-card p {
  margin-top: 6px;
  color: var(--td-muted);
  font-size: 0.88rem;
}

.td-upgrade-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.td-selection-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.td-selection-actions > * {
  min-width: 0;
}

.td-selection-actions > *:last-child {
  grid-column: 1 / -1;
}

.td-action-danger:hover {
  border-color: var(--td-danger);
  color: var(--td-danger);
}

.td-shop-grid {
  display: grid;
  gap: 12px;
}

.td-tower-card {
  display: flex;
  gap: 12px;
  padding: 12px;
  border-radius: 14px;
  border: 1px solid rgba(142, 209, 255, 0.12);
  background: rgba(255, 255, 255, 0.03);
  cursor: pointer;
  transition: border-color 120ms ease, transform 120ms ease, background 120ms ease;
}

.td-tower-card:hover {
  border-color: rgba(89, 243, 255, 0.36);
  transform: translateY(-1px);
}

.td-tower-card.is-selected {
  border-color: rgba(89, 243, 255, 0.55);
  background: rgba(89, 243, 255, 0.1);
}

.td-tower-card.is-disabled {
  opacity: 0.55;
}

.td-tower-card.is-unavailable {
  border-color: rgba(239, 83, 80, 0.38);
}

.td-tower-card.is-pending {
  border-color: rgba(255, 216, 77, 0.42);
}

.td-tower-icon {
  width: 62px;
  min-width: 62px;
  height: 62px;
  border-radius: 18px;
  position: relative;
  overflow: hidden;
  color: inherit;
}

@keyframes td-shop-pulse {
  from { transform: scale(0.9); opacity: 0.32; }
  50% { transform: scale(1.08); opacity: 0.65; }
  to { transform: scale(0.92); opacity: 0.28; }
}

@keyframes td-shop-spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

@keyframes td-shop-float {
  from { transform: translateY(0px); }
  50% { transform: translateY(-3px); }
  to { transform: translateY(0px); }
}

@keyframes td-shop-blink {
  0%, 100% { opacity: 0.18; transform: scaleX(0.9); }
  50% { opacity: 0.82; transform: scaleX(1.04); }
}

.td-shop-preview {
  border: 1px solid rgba(142, 209, 255, 0.12);
  background:
    radial-gradient(circle at 50% 30%, rgba(255, 255, 255, 0.12), transparent 36%),
    radial-gradient(circle at 50% 115%, rgba(89, 243, 255, 0.14), transparent 48%),
    linear-gradient(180deg, rgba(13, 21, 34, 0.94), rgba(7, 11, 19, 0.98));
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.03);
}

.td-shop-preview span {
  position: absolute;
  display: block;
}

.td-shop-glow {
  inset: 9px;
  border-radius: 50%;
  background: radial-gradient(circle, color-mix(in srgb, currentColor 60%, white 10%), transparent 72%);
  opacity: 0.42;
  animation: td-shop-pulse 1600ms ease-in-out infinite;
}

.td-shop-base {
  left: 14px;
  right: 14px;
  bottom: 10px;
  height: 10px;
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.18), rgba(8, 15, 25, 0.96));
  box-shadow: 0 0 10px rgba(0, 0, 0, 0.34);
}

.td-shop-ring {
  inset: 14px;
  border-radius: 50%;
  border: 1px solid color-mix(in srgb, currentColor 60%, white 10%);
  opacity: 0.36;
  animation: td-shop-spin 5s linear infinite;
}

.td-shop-body,
.td-shop-core,
.td-shop-hex,
.td-shop-crystal,
.td-shop-scope {
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  animation: td-shop-float 1800ms ease-in-out infinite;
}

.td-shop-body {
  width: 18px;
  height: 22px;
  margin-top: 6px;
  border-radius: 6px;
  background: linear-gradient(180deg, color-mix(in srgb, currentColor 60%, white 20%), color-mix(in srgb, currentColor 78%, black 18%));
}

.td-shop-core {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: radial-gradient(circle, #ffffff 0%, color-mix(in srgb, currentColor 55%, white 30%) 38%, currentColor 100%);
}

.td-shop-hex {
  width: 24px;
  height: 24px;
  margin-top: 2px;
  background: linear-gradient(180deg, color-mix(in srgb, currentColor 70%, white 12%), color-mix(in srgb, currentColor 86%, black 20%));
  clip-path: polygon(25% 6%, 75% 6%, 100% 50%, 75% 94%, 25% 94%, 0% 50%);
}

.td-shop-crystal {
  width: 24px;
  height: 28px;
  margin-top: -2px;
  background: linear-gradient(180deg, #f4fcff 0%, currentColor 100%);
  clip-path: polygon(50% 0%, 100% 38%, 72% 100%, 28% 100%, 0% 38%);
}

.td-shop-scope {
  width: 10px;
  height: 10px;
  margin-left: -2px;
  margin-top: -12px;
  border-radius: 50%;
  background: radial-gradient(circle, #fff 0%, color-mix(in srgb, currentColor 70%, white 18%) 42%, currentColor 100%);
}

.td-shop-barrel,
.td-shop-barrel-a,
.td-shop-barrel-b,
.td-shop-tracer,
.td-shop-wave,
.td-shop-flash,
.td-shop-beam {
  background: currentColor;
}

.td-shop-preview-cannon .td-shop-barrel {
  left: 30px;
  top: 23px;
  width: 20px;
  height: 8px;
  border-radius: 999px;
  animation: td-shop-float 1800ms ease-in-out infinite;
}

.td-shop-preview-cannon .td-shop-flash {
  right: 9px;
  top: 23px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  opacity: 0.45;
  filter: blur(0.5px);
  animation: td-shop-blink 900ms ease-in-out infinite;
}

.td-shop-preview-rapid .td-shop-barrel-a,
.td-shop-preview-rapid .td-shop-barrel-b {
  left: 18px;
  width: 24px;
  height: 6px;
  border-radius: 999px;
  animation: td-shop-float 1200ms ease-in-out infinite;
}

.td-shop-preview-rapid .td-shop-barrel-a { top: 20px; }
.td-shop-preview-rapid .td-shop-barrel-b { top: 32px; animation-delay: 120ms; }

.td-shop-preview-rapid .td-shop-tracer {
  right: 10px;
  top: 28px;
  width: 16px;
  height: 2px;
  border-radius: 999px;
  box-shadow: 0 0 10px currentColor;
  animation: td-shop-blink 620ms linear infinite;
}

.td-shop-preview-splash .td-shop-barrel {
  left: 30px;
  top: 26px;
  width: 18px;
  height: 7px;
  border-radius: 999px;
  animation: td-shop-float 1800ms ease-in-out infinite;
}

.td-shop-preview-splash .td-shop-wave {
  inset: 12px;
  border-radius: 50%;
  border: 2px solid color-mix(in srgb, currentColor 70%, white 8%);
  opacity: 0.18;
  background: transparent;
  animation: td-shop-pulse 1200ms ease-out infinite;
}

.td-shop-preview-frost .td-shop-shard {
  left: 50%;
  top: 50%;
  width: 6px;
  height: 18px;
  margin-left: -3px;
  margin-top: -20px;
  border-radius: 999px;
  background: linear-gradient(180deg, #ffffff 0%, currentColor 100%);
  transform-origin: center 22px;
  animation: td-shop-spin 2.8s linear infinite;
}

.td-shop-preview-frost .td-shop-shard-a { transform: rotate(0deg); }
.td-shop-preview-frost .td-shop-shard-b { transform: rotate(120deg); }
.td-shop-preview-frost .td-shop-shard-c { transform: rotate(240deg); }

.td-shop-preview-sniper .td-shop-body {
  width: 22px;
  height: 16px;
  margin-top: 8px;
  border-radius: 6px;
}

.td-shop-preview-sniper .td-shop-barrel {
  left: 30px;
  top: 27px;
  width: 24px;
  height: 4px;
  border-radius: 999px;
  animation: td-shop-float 1800ms ease-in-out infinite;
}

.td-shop-preview-sniper .td-shop-scope {
  left: 27px;
  top: 22px;
}

.td-shop-preview-sniper .td-shop-beam {
  right: 8px;
  top: 28px;
  width: 16px;
  height: 2px;
  border-radius: 999px;
  box-shadow: 0 0 12px currentColor;
  animation: td-shop-blink 1s ease-in-out infinite;
}

.td-shop-orbit {
  left: 50%;
  top: 50%;
  width: 10px;
  height: 10px;
  margin-left: -5px;
  margin-top: -5px;
  border-radius: 50%;
  background: color-mix(in srgb, currentColor 55%, white 28%);
  box-shadow: 0 0 10px currentColor;
}

.td-shop-preview-support .td-shop-orbit-a { animation: td-shop-spin 2.4s linear infinite; transform-origin: 0 20px; }
.td-shop-preview-support .td-shop-orbit-b { animation: td-shop-spin 2.4s linear infinite reverse; transform-origin: 18px -4px; }
.td-shop-preview-support .td-shop-orbit-c { animation: td-shop-spin 2.4s linear infinite; transform-origin: -18px -4px; }
.td-shop-preview-gold .td-shop-orbit-a { animation: td-shop-spin 2s linear infinite; transform-origin: 0 20px; }
.td-shop-preview-gold .td-shop-orbit-b { animation: td-shop-spin 2s linear infinite reverse; transform-origin: 18px -4px; }
.td-shop-preview-gold .td-shop-orbit-c { animation: td-shop-spin 2s linear infinite; transform-origin: -18px -4px; }
.td-shop-preview-gold .td-shop-coin {
  left: 50%;
  top: 50%;
  width: 18px;
  height: 18px;
  margin-left: -9px;
  margin-top: -9px;
  border-radius: 50%;
  border: 2px solid color-mix(in srgb, currentColor 68%, white 20%);
  box-shadow: 0 0 14px currentColor;
  animation: td-shop-blink 1.5s ease-in-out infinite;
}

.td-shop-preview-laser .td-shop-emitter {
  left: 50%;
  top: 50%;
  width: 24px;
  height: 14px;
  margin-left: -4px;
  margin-top: -7px;
  border-radius: 999px;
  background: linear-gradient(90deg, color-mix(in srgb, currentColor 70%, white 18%) 0%, white 100%);
}

.td-shop-preview-laser .td-shop-laser {
  left: 50%;
  top: 50%;
  width: 28px;
  height: 3px;
  margin-left: 16px;
  margin-top: -1.5px;
  border-radius: 999px;
  background: linear-gradient(90deg, currentColor 0%, color-mix(in srgb, currentColor 55%, white 45%) 100%);
  box-shadow: 0 0 16px currentColor;
  animation: td-shop-blink 900ms ease-in-out infinite;
}

.td-tower-cannon { color: #F4B942; }
.td-tower-rapid { color: #59F3FF; }
.td-tower-splash { color: #FF8A3D; }
.td-tower-frost { color: #8ED1FF; }
.td-tower-sniper { color: #F06292; }
.td-tower-laser { color: #FF5CF4; }
.td-tower-support { color: #8BFF9A; }
.td-tower-gold { color: #FFD84D; }

.td-tower-copy {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 6px;
}

.td-tower-copy p {
  color: var(--td-muted);
  font-size: 0.88rem;
}

.td-hotkey-chip {
  align-self: flex-start;
  min-width: 32px;
}

.td-score-panel {
  width: min(92vw, 860px);
}

.td-table-wrap {
  margin: 18px 0;
  border-radius: 14px;
  border: 1px solid rgba(142, 209, 255, 0.12);
  overflow: auto;
}

.rankings-table {
  width: 100%;
  border-collapse: collapse;
}

.rankings-table th,
.rankings-table td {
  padding: 12px 14px;
  border-bottom: 1px solid rgba(142, 209, 255, 0.08);
  text-align: left;
}

.rankings-table th {
  color: var(--td-muted);
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.td-results-table td:first-child,
.rankings-table tbody tr:first-child td:first-child {
  color: var(--td-accent);
  font-weight: 700;
}

.td-summary-chips {
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 12px;
}

.td-summary-chips .td-inline-chip {
  gap: 4px;
  background: rgba(89, 243, 255, 0.1);
}

.td-results-table tbody tr:hover,
.rankings-table tbody tr:hover {
  background: rgba(89, 243, 255, 0.05);
}

.td-bottom-sheet {
  scrollbar-color: rgba(89, 243, 255, 0.3) transparent;
}

@media (min-width: 960px) and (max-width: 1199px) {
  .td-main-layout {
    grid-template-columns: minmax(0, 1fr) var(--td-rail-w-mid);
  }

  .td-command-rail {
    width: var(--td-rail-w-mid);
  }

  .td-desktop-hint {
    max-width: 180px;
    text-align: right;
  }
}

@media (max-width: 959px), (pointer: coarse) {
  body {
    overflow: hidden;
  }

  .td-phase-banner {
    top: 10px;
    padding: 8px 14px;
  }

  .td-main-layout {
    display: block;
    position: relative;
    padding-bottom: 320px;
  }

  .td-canvas-wrap {
    padding: 12px 12px 24px;
  }

  #gameCanvas {
    width: 100%;
    border-radius: 18px;
  }

  .td-command-rail {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    max-height: min(55dvh, 420px);
    padding: 12px 12px calc(20px + env(safe-area-inset-bottom));
    border-left: none;
    border-top: 1px solid rgba(142, 209, 255, 0.16);
    border-radius: 20px 20px 0 0;
    background: rgba(11, 15, 23, 0.98);
    backdrop-filter: blur(16px);
    box-shadow: 0 -18px 34px rgba(0, 0, 0, 0.34);
  }

  .td-sheet-handle {
    display: block;
  }

  .td-rail-header {
    position: sticky;
    top: 0;
    z-index: 2;
    padding-bottom: 8px;
    background: rgba(11, 15, 23, 0.98);
  }

  .td-hud {
    align-items: flex-start;
    height: auto;
    min-height: 56px;
    padding: 10px 14px;
    flex-wrap: wrap;
  }

  .td-hud-right {
    width: 100%;
    justify-content: space-between;
  }

  .td-mobile-details-toggle {
    display: block;
  }

  .td-sheet-summary {
    display: grid;
  }

  .td-rail-details {
    display: none;
  }

  .td-rail-details.is-open {
    display: grid;
    gap: 16px;
  }

  .td-desktop-hint {
    display: none;
  }

  .td-spectator-banner {
    top: auto;
    left: 0;
    right: 0;
    width: 100%;
    border-radius: 0;
    text-align: center;
    border-left: none;
    border-right: none;
  }

  #runStatusCard {
    order: 1;
  }

  #towerShopCard {
    order: 2;
  }

  #selectionCard {
    order: 3;
  }

  #teamRosterCard {
    order: 4;
  }

  .td-shop-grid {
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: minmax(220px, 74%);
    overflow-x: auto;
    padding-bottom: 4px;
  }

  .td-status-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .td-audio-controls button,
  .td-volume-slider,
  .td-ping-btn,
  .td-action-btn,
  .btn-secondary,
  .td-mobile-details-toggle {
    min-height: 48px;
  }
}

@media (max-height: 860px) and (min-width: 960px) {
  :root {
    --td-hud-h: 48px;
    --td-rail-w: 360px;
  }

  .td-main-layout {
    grid-template-columns: minmax(0, 1fr) var(--td-rail-w);
  }

  .td-canvas-wrap {
    padding: 14px;
  }

  .td-hud {
    padding: 0 12px;
  }

  .td-desktop-hint {
    max-width: 220px;
    text-overflow: ellipsis;
    overflow: hidden;
    white-space: nowrap;
  }
}
