.tst-shell {
  --tst-canvas: #fbfbf7;
  --tst-ink: #101116;
  --tst-muted: #62666f;
  --tst-line: rgba(17, 17, 22, 0.1);
  --tst-glass: rgba(255, 255, 255, 0.68);
  --tst-glass-strong: rgba(255, 255, 255, 0.84);
  --tst-shadow: rgba(18, 22, 33, 0.18);
  --tst-accent: #00a878;
  --tst-hot: #ff3d71;
  --tst-blue: #2d7ff9;
  --tst-sheen: rgba(255, 255, 255, 0.38);

  border: 1px solid var(--tst-line);
  border-radius: 8px;
  color: var(--tst-ink);
  overflow: hidden;
  width: 100%;
}

.theme-dark .tst-shell {
  --tst-canvas: #090b0d;
  --tst-ink: #f7f9fb;
  --tst-muted: #a8b0bd;
  --tst-line: rgba(255, 255, 255, 0.14);
  --tst-glass: rgba(16, 20, 26, 0.66);
  --tst-glass-strong: rgba(20, 26, 34, 0.84);
  --tst-shadow: rgba(0, 0, 0, 0.4);
  --tst-accent: #37e69f;
  --tst-hot: #ff5c8a;
  --tst-blue: #70a7ff;
  --tst-sheen: rgba(255, 255, 255, 0.05);
}

.tst-board {
  background:
    linear-gradient(180deg, var(--tst-sheen), transparent 13rem),
    var(--tst-canvas);
  min-height: clamp(32rem, 72vh, 50rem);
  overflow: hidden;
  position: relative;
  touch-action: none;
  user-select: none;
  width: 100%;
}

.tst-board:fullscreen {
  min-height: 100vh;
}

.tst-board:fullscreen .tst-actions {
  bottom: max(1rem, env(safe-area-inset-bottom));
}

#tst-canvas {
  display: block;
  height: 100%;
  inset: 0;
  position: absolute;
  touch-action: none;
  width: 100%;
  z-index: 2;
}

.tst-hud,
.tst-status,
.tst-actions {
  backdrop-filter: blur(18px) saturate(150%);
  -webkit-backdrop-filter: blur(18px) saturate(150%);
  background: var(--tst-glass);
  border: 1px solid var(--tst-line);
  box-shadow: 0 18px 50px var(--tst-shadow);
  position: absolute;
  z-index: 4;
}

.tst-hud {
  border-radius: 8px;
  display: grid;
  gap: 0;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  left: clamp(0.8rem, 3vw, 1.35rem);
  right: clamp(0.8rem, 3vw, 1.35rem);
  top: clamp(0.8rem, 3vw, 1.35rem);
}

.tst-hud div {
  display: grid;
  gap: 0.25rem;
  min-width: 0;
  padding: 0.85rem clamp(0.65rem, 2vw, 1rem);
}

.tst-hud div + div {
  border-left: 1px solid var(--tst-line);
}

.tst-hud span,
.tst-status,
.tst-action {
  color: var(--tst-muted);
  font-size: 0.72rem;
  font-weight: 850;
  letter-spacing: 0;
  text-transform: uppercase;
}

.tst-hud strong {
  color: var(--tst-ink);
  font-size: clamp(1.9rem, 6vw, 3.1rem);
  font-weight: 940;
  line-height: 0.9;
}

.tst-hud div:first-child strong {
  color: var(--tst-hot);
}

.tst-hud div:nth-child(2) strong {
  color: var(--tst-blue);
}

.tst-hud div:nth-child(3) strong {
  color: var(--tst-accent);
}

.tst-status {
  border-radius: 999px;
  left: 50%;
  margin: 0;
  max-width: calc(100% - 2rem);
  padding: 0.55rem 0.85rem;
  text-align: center;
  top: clamp(7rem, 18vw, 7.8rem);
  transform: translateX(-50%);
  white-space: nowrap;
}

.tst-actions {
  background: var(--tst-glass-strong);
  border-radius: 999px;
  bottom: clamp(0.9rem, 3vw, 1.35rem);
  display: flex;
  gap: 0.45rem;
  left: 50%;
  padding: 0.42rem;
  transform: translateX(-50%);
}

.tst-action {
  background: transparent;
  border: 0;
  border-radius: 999px;
  color: var(--tst-ink);
  cursor: pointer;
  min-height: 2.45rem;
  padding: 0.55rem 0.85rem;
  transition: background 160ms ease, color 160ms ease;
  white-space: nowrap;
}

.tst-action:hover {
  background: var(--tst-ink);
  color: var(--tst-canvas);
}

.tst-shell[data-state='drawing'] .tst-status {
  color: var(--tst-hot);
}

.tst-shell[data-state='cleared'] .tst-status {
  color: var(--tst-accent);
}

@media (min-width: 720px) {
  .tst-hud {
    left: 1.35rem;
    right: auto;
    width: min(31rem, calc(100% - 2.7rem));
  }
}

@media (max-width: 520px) {
  .tst-board {
    min-height: 34rem;
  }

  .tst-hud span,
  .tst-status,
  .tst-action {
    font-size: 0.64rem;
  }

  .tst-status {
    top: 6.5rem;
  }

  .tst-actions {
    width: calc(100% - 1.4rem);
  }

  .tst-action {
    flex: 1;
    padding-inline: 0.45rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .tst-action {
    transition: none;
  }
}
