.td-shell {
  max-width: 980px;
  margin: 0 auto;
  padding: 0 14px 22px;
  color: var(--cg-ink);
  font-family: Inter, Arial, sans-serif;
}

.td-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.td-stats,
.td-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.td-stat {
  min-width: 74px;
  padding: 7px 10px;
  border: 1px solid var(--cg-line);
  border-radius: 10px;
  background: var(--cg-panel);
  box-shadow: 0 8px 20px rgba(33, 43, 40, 0.08);
  text-align: center;
}

.td-stat span {
  display: block;
  color: var(--cg-muted);
  font-size: 10px;
  font-weight: 850;
  letter-spacing: 0.05em;
  line-height: 1.1;
  text-transform: uppercase;
}

.td-stat strong {
  display: block;
  margin-top: 2px;
  font-size: 18px;
  font-variant-numeric: tabular-nums;
  line-height: 1.05;
}

.td-btn,
.td-close {
  min-width: 44px;
  min-height: 44px;
  padding: 0 14px;
  border: 1px solid var(--cg-line);
  border-radius: 10px;
  background: var(--cg-panel);
  color: var(--cg-ink);
  font: inherit;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 8px 20px rgba(33, 43, 40, 0.08);
  transition: transform 120ms ease, border-color 120ms ease;
}

.td-btn:hover:not(:disabled),
.td-close:hover {
  transform: translateY(-1px);
  border-color: var(--cg-teal);
}

.td-btn:disabled {
  cursor: default;
  opacity: 0.55;
}

.td-btn:focus-visible,
.td-close:focus-visible,
.td-buy:focus-visible,
.td-canvas:focus-visible {
  outline: 3px solid rgba(23, 162, 179, 0.5);
  outline-offset: 3px;
}

.td-icon {
  display: inline-grid;
  padding: 0;
  place-items: center;
  font-size: 17px;
}

.td-icon svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.td-primary {
  border-color: transparent;
  background: var(--cg-teal);
  color: #fff;
}

.td-main {
  display: grid;
  gap: 12px;
  grid-template-columns: minmax(0, 1fr) 272px;
  align-items: stretch;
}

.td-stage {
  position: relative;
  min-height: 470px;
  overflow: hidden;
  border: 1px solid #16332b;
  border-radius: 14px;
  background: #152b26;
  box-shadow: var(--cg-shadow);
  touch-action: manipulation;
  user-select: none;
}

.td-canvas {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  cursor: pointer;
}

.td-flash {
  position: absolute;
  inset: 0;
  background: radial-gradient(115% 85% at 50% 50%, rgba(224, 101, 90, 0) 42%, rgba(224, 101, 90, 0.6) 100%);
  opacity: 0;
  pointer-events: none;
  transition: opacity 200ms ease;
}

.td-flash-on {
  opacity: 1;
  transition: opacity 40ms ease;
}

.td-over {
  position: absolute;
  top: 50%;
  left: 50%;
  z-index: 3;
  display: grid;
  gap: 8px;
  width: min(86%, 330px);
  padding: 20px;
  border: 1px solid var(--cg-line);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.96);
  text-align: center;
  box-shadow: 0 26px 70px rgba(6, 22, 18, 0.5);
  transform: translate(-50%, -50%);
  backdrop-filter: blur(8px);
}

.td-over span,
.td-over p {
  margin: 0;
  color: var(--cg-muted);
  font-size: 13.5px;
  line-height: 1.35;
}

.td-over strong {
  font-size: 30px;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

.td-over-row {
  display: flex;
  gap: 8px;
  margin-top: 4px;
}

.td-over-row .td-btn {
  flex: 1 1 0;
}

.td-panel {
  display: grid;
  gap: 10px;
  min-width: 0;
}

.td-card {
  padding: 12px;
  border: 1px solid var(--cg-line);
  border-radius: 12px;
  background: var(--cg-panel);
  box-shadow: 0 8px 20px rgba(33, 43, 40, 0.07);
}

.td-card-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.td-card-head span {
  color: var(--cg-muted);
  font-size: 10.5px;
  font-weight: 850;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.td-card-head b {
  color: var(--cg-ink);
  font-size: 14px;
  font-variant-numeric: tabular-nums;
}

.td-preview {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 10px;
  min-height: 26px;
}

.td-pv {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  border: 1px solid var(--cg-line);
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 700;
}

.td-pv i {
  width: 11px;
  height: 11px;
  border: 1.5px solid;
  border-radius: 3px;
}

.td-pv i.td-pv-fly {
  border-radius: 50%;
  transform: rotate(45deg);
}

.td-start {
  width: 100%;
}

.td-timer {
  height: 6px;
  margin-top: 8px;
  border-radius: 999px;
  background: rgba(33, 43, 40, 0.12);
  overflow: hidden;
}

.td-timer-fill {
  height: 100%;
  width: 100%;
  border-radius: 999px;
  background: var(--cg-amber);
  transition: width 200ms linear;
}

.td-buys {
  display: grid;
  gap: 6px;
}

.td-buy {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 46px;
  padding: 5px 10px;
  border: 1px solid var(--cg-line);
  border-radius: 10px;
  background: var(--cg-panel);
  color: var(--cg-ink);
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: border-color 120ms ease, background 120ms ease;
}

.td-buy:hover {
  border-color: var(--cg-teal);
}

.td-buy span {
  display: grid;
  flex: 1 1 auto;
  min-width: 0;
}

.td-buy b {
  font-size: 13.5px;
  font-weight: 850;
  line-height: 1.15;
}

.td-buy em {
  color: var(--cg-muted);
  font-size: 10.5px;
  font-style: normal;
  line-height: 1.2;
}

.td-buy strong {
  color: var(--cg-amber);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

.td-buy.td-armed {
  border-color: var(--cg-ink);
  background: #f2f6f1;
  box-shadow: inset 0 0 0 1px var(--cg-ink);
}

.td-buy.td-poor {
  opacity: 0.5;
}

.td-chip {
  width: 22px;
  height: 22px;
  flex: 0 0 auto;
  border-radius: 6px;
}

.td-chip-arrow { background: #4fb477; }
.td-chip-cannon { background: #d0803a; }
.td-chip-frost { background: #3f9bd6; }
.td-chip-tesla { background: #a877e0; }

.td-sel-stats {
  display: grid;
  gap: 3px;
  margin-bottom: 9px;
}

.td-sel-stats div {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  font-size: 12.5px;
}

.td-sel-stats span {
  color: var(--cg-muted);
}

.td-sel-stats b {
  font-variant-numeric: tabular-nums;
}

.td-sel-row {
  display: flex;
  gap: 6px;
}

.td-sel-row .td-btn {
  flex: 1 1 0;
  padding: 0 8px;
  font-size: 13px;
}

.td-sell {
  border-color: var(--cg-red);
  color: var(--cg-red);
}

.td-tip {
  margin: 0;
  color: var(--cg-muted);
  font-size: 12px;
  line-height: 1.4;
}

.td-modal {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(11, 30, 26, 0.45);
}

.td-modal-card {
  position: relative;
  width: min(100%, 470px);
  padding: 22px;
  border: 1px solid var(--cg-line);
  border-radius: 14px;
  background: var(--cg-panel);
  box-shadow: 0 26px 76px rgba(30, 37, 40, 0.28);
}

.td-modal-card h2 {
  margin: 0 48px 10px 0;
  font-size: 23px;
  line-height: 1.1;
}

.td-modal-card p {
  margin: 9px 0 0;
  color: var(--cg-muted);
  font-size: 14px;
  line-height: 1.5;
}

.td-close {
  position: absolute;
  top: 12px;
  right: 12px;
  padding: 0;
  font-size: 24px;
  line-height: 1;
}

.td-hidden {
  display: none !important;
}

@media (max-width: 860px) {
  .td-main {
    grid-template-columns: minmax(0, 1fr);
  }

  .td-stage {
    min-height: 0;
    aspect-ratio: 12 / 9;
  }

  .td-panel {
    grid-template-columns: 1fr 1fr;
    align-items: start;
  }

  .td-wavecard {
    grid-column: span 2;
  }

  .td-tip {
    grid-column: span 2;
  }
}

@media (max-width: 620px) {
  .td-shell {
    padding: 0 8px 18px;
  }

  .td-top {
    align-items: stretch;
    flex-direction: column;
    gap: 8px;
  }

  .td-stats {
    justify-content: space-between;
    gap: 6px;
  }

  .td-stat {
    min-width: 0;
    flex: 1 1 0;
    padding: 6px 4px;
  }

  .td-stat strong {
    font-size: 16px;
  }

  .td-actions {
    justify-content: center;
  }

  .td-panel {
    grid-template-columns: 1fr;
  }

  .td-wavecard,
  .td-tip {
    grid-column: span 1;
  }
}
