:root {
  color-scheme: dark;
  --tgd-bg: #09031b;
  --tgd-panel: rgba(20, 18, 46, 0.78);
  --tgd-line: rgba(160, 245, 255, 0.28);
  --tgd-text: rgba(247, 252, 255, 0.92);
  --tgd-muted: rgba(224, 236, 255, 0.68);
  --tgd-pink: #ff4fd8;
  --tgd-cyan: #36f7ff;
  --tgd-gold: #fff05a;
  --tgd-green: #7cff6b;
  --tgd-blue: #6c8dff;
  --tgd-orange: #ff9a3d;
}

html,
body {
  min-height: 100%;
  margin: 0;
  background: var(--tgd-bg);
}

body.tgd-page {
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--tgd-text);
  overflow-x: hidden;
}

body.tgd-page * {
  box-sizing: border-box;
}

.tgd-shell {
  position: relative;
  min-height: 100vh;
  background:
    radial-gradient(circle at 12% 12%, rgba(255, 79, 216, 0.28), transparent 23rem),
    radial-gradient(circle at 82% 4%, rgba(54, 247, 255, 0.23), transparent 24rem),
    radial-gradient(circle at 72% 76%, rgba(255, 154, 61, 0.2), transparent 26rem),
    radial-gradient(circle at 20% 88%, rgba(124, 255, 107, 0.16), transparent 22rem),
    linear-gradient(145deg, #120424 0%, #081d3a 48%, #220839 100%);
}

.tgd-language-toggle {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 20;
  display: inline-grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.28rem;
  padding: 0.28rem;
  border: 1px solid rgba(120, 247, 255, 0.24);
  border-radius: 999px;
  background: rgba(8, 6, 24, 0.72);
  backdrop-filter: blur(16px);
  box-shadow: 0 12px 34px rgba(0, 0, 0, 0.24);
}

.tgd-language-toggle button {
  min-width: 42px;
  min-height: 34px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: rgba(224, 236, 255, 0.7);
  cursor: pointer;
  font: 800 0.72rem/1 Inter, ui-sans-serif, system-ui, sans-serif;
  letter-spacing: 0.08em;
}

.tgd-language-toggle button.is-active {
  background: linear-gradient(135deg, var(--tgd-gold), var(--tgd-cyan));
  color: #11152a;
  box-shadow: 0 0 18px rgba(255, 240, 90, 0.22);
}

.tgd-language-toggle button:focus-visible {
  outline: 3px solid rgba(255, 230, 109, 0.92);
  outline-offset: 2px;
}

.tgd-hero {
  min-height: 56vh;
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(320px, 0.95fr);
  gap: 2rem;
  align-items: end;
  padding: clamp(5rem, 9vw, 7rem) clamp(1rem, 4vw, 4rem) 2rem;
  box-sizing: border-box;
}

.tgd-kicker,
.tgd-label,
.tgd-chip,
.tgd-tab {
  text-transform: uppercase;
  letter-spacing: 0.12em;
}

.tgd-kicker {
  color: var(--tgd-cyan);
  font-size: 0.72rem;
  margin: 0 0 0.7rem;
}

.tgd-hero h1 {
  max-width: 760px;
  margin: 0;
  font-size: clamp(3rem, 8vw, 7rem);
  line-height: 0.9;
  letter-spacing: 0;
}

.tgd-lede {
  max-width: 660px;
  margin: 1.1rem 0 0;
  color: var(--tgd-muted);
  font-size: clamp(1rem, 2vw, 1.2rem);
  line-height: 1.65;
}

.tgd-model-card,
.tgd-panel,
.tgd-play-stage,
.tgd-code-stage {
  border: 1px solid var(--tgd-line);
  background: var(--tgd-panel);
  backdrop-filter: blur(18px);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.28);
}

.tgd-model-card {
  border-radius: 8px;
  padding: 1rem;
  align-self: stretch;
  display: grid;
  gap: 0.85rem;
  align-content: start;
  background:
    linear-gradient(145deg, rgba(255, 79, 216, 0.24), rgba(54, 247, 255, 0.18) 52%, rgba(124, 255, 107, 0.12)),
    var(--tgd-panel);
  position: relative;
  overflow: hidden;
}

.tgd-model-card::before,
.tgd-model-card::after,
.tgd-robot-body-panel::before,
.tgd-robot-body-panel::after {
  content: "";
  position: absolute;
  width: 0.66rem;
  height: 0.66rem;
  border-radius: 50%;
  background: rgba(255, 230, 109, 0.78);
  box-shadow: 0 0 16px rgba(255, 230, 109, 0.45);
  pointer-events: none;
}

.tgd-model-card::before { left: 0.7rem; top: 0.7rem; }
.tgd-model-card::after { right: 0.7rem; top: 0.7rem; background: rgba(120, 247, 255, 0.74); }

.tgd-console-top {
  display: flex;
  gap: 0.42rem;
  justify-content: center;
  min-height: 1rem;
}

.tgd-console-top span {
  width: 0.62rem;
  height: 0.62rem;
  border-radius: 50%;
  background: var(--tgd-pink);
  box-shadow: 0 0 14px rgba(255, 112, 217, 0.52);
}

.tgd-console-top span:nth-child(2) {
  background: var(--tgd-gold);
  box-shadow: 0 0 14px rgba(255, 230, 109, 0.5);
}

.tgd-console-top span:nth-child(3) {
  background: var(--tgd-cyan);
  box-shadow: 0 0 14px rgba(120, 247, 255, 0.5);
}

.tgd-status-row,
.tgd-actions,
.tgd-tabs,
.tgd-game-stats {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.tgd-robot-chat {
  align-self: start;
  min-height: 112px;
  padding: 1rem;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.18), rgba(9, 3, 27, 0.5)),
    rgba(255, 255, 255, 0.11);
  position: relative;
}

.tgd-robot-chat::before {
  content: none;
}

.tgd-robot-mood {
  display: inline-flex;
  min-height: 24px;
  align-items: center;
  margin-bottom: 0.42rem;
  padding: 0.16rem 0.5rem;
  border-radius: 999px;
  background: rgba(120, 247, 255, 0.13);
  color: rgba(220, 250, 255, 0.8);
  font-size: 0.62rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.tgd-robot-chat p {
  margin: 0;
  color: rgba(252, 254, 255, 0.92);
  font-size: 1rem;
  line-height: 1.45;
}

.tgd-robot-setup {
  position: relative;
}

.tgd-status-dot {
  width: 0.72rem;
  height: 0.72rem;
  border-radius: 50%;
  background: var(--tgd-gold);
  box-shadow: 0 0 18px currentColor;
}

.tgd-ready .tgd-status-dot { background: var(--tgd-green); }
.tgd-unsupported .tgd-status-dot { background: #ff5f85; }

.tgd-status-text {
  font-weight: 700;
}

.tgd-detail,
.tgd-small,
.tgd-model-meta,
.tgd-cache-detail {
  color: var(--tgd-muted);
}

.tgd-detail {
  min-height: 2.8rem;
  margin: 0.9rem 0;
  line-height: 1.45;
}

.tgd-progress {
  height: 0.52rem;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
}

.tgd-progress span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--tgd-pink), var(--tgd-cyan), var(--tgd-gold));
  transition: width 0.25s ease;
}

.tgd-model-meta {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.45rem;
  margin: 1rem 0 0.65rem;
  font-size: 0.82rem;
}

.tgd-cache-detail {
  min-height: 2.4rem;
  margin: 0 0 0.9rem;
  font-size: 0.8rem;
  line-height: 1.45;
}

.tgd-actions button,
.tgd-form button,
.tgd-tab {
  min-height: 44px;
  border: 1px solid rgba(120, 247, 255, 0.28);
  border-radius: 8px;
  background: rgba(120, 247, 255, 0.08);
  color: var(--tgd-text);
  font: inherit;
  cursor: pointer;
}

.tgd-actions button,
.tgd-form button {
  padding: 0.72rem 1rem;
}

.tgd-actions button:first-child,
.tgd-form button:first-of-type {
  border-color: rgba(255, 112, 217, 0.42);
  background: rgba(255, 112, 217, 0.14);
}

.tgd-actions #deleteModelCache {
  border-color: rgba(255, 95, 133, 0.34);
  background: rgba(255, 95, 133, 0.08);
  color: #ffd7df;
}

.tgd-remix-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.6rem;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.44;
}

.tgd-main {
  display: grid;
  grid-template-columns: minmax(330px, 460px) minmax(0, 1fr);
  gap: 1rem;
  padding: 0 clamp(1rem, 4vw, 4rem) 4rem;
  align-items: start;
}

.tgd-panel {
  border-radius: 8px;
  padding: 1rem;
}

.tgd-robot-body-panel {
  position: relative;
  overflow: hidden;
  background:
    linear-gradient(145deg, rgba(108, 141, 255, 0.24), rgba(255, 79, 216, 0.2) 46%, rgba(255, 154, 61, 0.14)),
    var(--tgd-panel);
}

.tgd-robot-body-panel::before { left: 0.72rem; bottom: 0.72rem; background: rgba(255, 112, 217, 0.72); }
.tgd-robot-body-panel::after { right: 0.72rem; bottom: 0.72rem; background: rgba(155, 255, 137, 0.72); }

.tgd-panel h2,
.tgd-play-header h2 {
  margin: 0 0 0.9rem;
  font-size: 1rem;
  letter-spacing: 0;
}

.tgd-form {
  display: grid;
  gap: 0.85rem;
}

.tgd-block-pickers {
  display: grid;
  gap: 0.85rem;
}

.tgd-block-picker {
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.09), rgba(255, 255, 255, 0.03)),
    rgba(6, 8, 25, 0.42);
  overflow: hidden;
  min-width: 0;
  transform-origin: top center;
  transition:
    border-color 0.22s ease,
    box-shadow 0.22s ease,
    transform 0.22s cubic-bezier(0.2, 1.2, 0.3, 1);
}

.tgd-block-picker.is-opening {
  animation: tgd-block-open-pop 0.42s cubic-bezier(0.18, 1.35, 0.28, 1) both;
}

.tgd-block-picker.is-collapsing {
  animation: tgd-block-close-squish 0.34s ease both;
}

.tgd-block-picker[open] {
  border-color: rgba(255, 230, 109, 0.3);
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.08),
    0 16px 32px rgba(54, 247, 255, 0.08);
}

.tgd-block-title {
  min-height: 68px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.35rem 0.8rem;
  align-items: center;
  padding: 0.72rem 0.85rem;
  color: rgba(247, 252, 255, 0.9);
  font-weight: 750;
  cursor: pointer;
  list-style: none;
}

.tgd-block-title::-webkit-details-marker {
  display: none;
}

.tgd-block-title::after {
  content: "+";
  grid-column: 2;
  grid-row: 1 / span 2;
  width: 2rem;
  height: 2rem;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.12);
  color: var(--tgd-gold);
  font-size: 1.25rem;
  transition:
    transform 0.22s cubic-bezier(0.2, 1.5, 0.3, 1),
    background 0.22s ease,
    color 0.22s ease;
}

.tgd-block-picker[open] .tgd-block-title::after {
  content: "-";
  transform: rotate(180deg) scale(1.08);
  background: rgba(255, 240, 90, 0.18);
  color: #fff8a8;
}

.tgd-block-title span {
  grid-column: 1;
  font-size: 0.9rem;
}

.tgd-block-title strong {
  grid-column: 1;
  width: fit-content;
  max-width: 100%;
  padding: 0.22rem 0.56rem;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--tgd-pink), var(--tgd-cyan));
  color: #120424;
  font-size: 0.82rem;
  overflow-wrap: anywhere;
}

.tgd-block-title small {
  grid-column: 1 / -1;
  color: rgba(224, 236, 255, 0.7);
  font-size: 0.68rem;
  line-height: 1.3;
  text-align: left;
}

.tgd-block-options {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.52rem;
  padding: 0 0.72rem 0;
  max-height: 0;
  opacity: 0;
  transform: translateY(-8px) scale(0.98);
  transform-origin: top center;
  transition:
    max-height 0.36s cubic-bezier(0.2, 0.9, 0.24, 1),
    opacity 0.2s ease,
    transform 0.28s cubic-bezier(0.2, 1.12, 0.3, 1),
    padding 0.28s ease;
}

.tgd-block-picker[open] .tgd-block-options {
  max-height: 520px;
  opacity: 1;
  padding-bottom: 0.72rem;
  transform: translateY(0) scale(1);
}

.tgd-choice-block {
  min-height: 58px;
  display: grid;
  align-items: center;
  border: 2px solid hsla(var(--block-hue), 95%, 75%, 0.44);
  border-radius: 8px;
  background:
    linear-gradient(145deg, hsla(var(--block-hue), 98%, 62%, 0.42), rgba(255, 255, 255, 0.09)),
    rgba(5, 8, 16, 0.66);
  color: rgba(255, 255, 255, 0.92);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.07);
  cursor: pointer;
  font: inherit;
  font-weight: 760;
  line-height: 1.15;
  padding: 0.62rem;
  text-align: left;
  transform-origin: center;
  transition:
    transform 0.18s cubic-bezier(0.2, 1.55, 0.3, 1),
    box-shadow 0.2s ease,
    background 0.2s ease,
    color 0.2s ease;
}

.tgd-choice-block span {
  overflow-wrap: anywhere;
}

.tgd-choice-block:hover {
  transform: translateY(-2px) rotate(-0.7deg);
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.09),
    0 12px 26px hsla(var(--block-hue), 95%, 60%, 0.18);
}

.tgd-choice-block:active {
  transform: translateY(1px) scale(0.98);
}

.tgd-choice-block.is-selected {
  color: #101423;
  background:
    linear-gradient(145deg, hsla(var(--block-hue), 100%, 72%, 1), rgba(255, 255, 255, 0.8));
  box-shadow:
    0 0 0 2px rgba(255, 255, 255, 0.72),
    0 12px 28px hsla(var(--block-hue), 95%, 60%, 0.28);
}

.tgd-choice-block.is-popping {
  animation: tgd-choice-pop 0.42s cubic-bezier(0.17, 1.5, 0.3, 1) both;
}

.tgd-choice-block:focus-visible {
  outline: 3px solid rgba(255, 230, 109, 0.92);
  outline-offset: 2px;
}

.tgd-field {
  display: grid;
  gap: 0.35rem;
}

.tgd-label {
  color: var(--tgd-muted);
  font-size: 0.66rem;
}

.tgd-field select {
  width: 100%;
  min-height: 42px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  background: rgba(5, 8, 16, 0.72);
  color: var(--tgd-text);
  padding: 0 0.7rem;
  font: inherit;
  appearance: auto;
}

.tgd-grown-controls {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.68rem;
  padding: 0 0.8rem 0.8rem;
}

.tgd-prompt-mode {
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  background:
    linear-gradient(145deg, rgba(255, 112, 217, 0.08), rgba(155, 255, 137, 0.04)),
    rgba(255, 255, 255, 0.035);
}

.tgd-prompt-mode summary {
  min-height: 42px;
  display: flex;
  align-items: center;
  padding: 0 0.75rem;
  color: rgba(220, 250, 255, 0.78);
  cursor: pointer;
  font-size: 0.72rem;
  letter-spacing: 0.11em;
  text-transform: uppercase;
}

.tgd-prompt-field {
  padding: 0 0.75rem 0.75rem;
}

.tgd-prompt-field textarea {
  width: 100%;
  min-height: 116px;
  resize: vertical;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  background: rgba(5, 8, 16, 0.72);
  color: var(--tgd-text);
  padding: 0.7rem;
  font: inherit;
  font-size: 0.9rem;
  line-height: 1.45;
}

.tgd-prompt-field textarea::placeholder {
  color: rgba(210, 230, 246, 0.38);
}

.tgd-prompt-mode .tgd-small {
  margin: 0;
  font-size: 0.76rem;
}

.tgd-prompt-footer {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  align-items: start;
  margin: -0.25rem 0.75rem 0.8rem;
}

.tgd-prompt-counter {
  flex: 0 0 auto;
  min-width: 4.6rem;
  text-align: right;
  color: rgba(255, 230, 109, 0.82);
  font-size: 0.72rem;
}

.tgd-prompt-mode.is-near-limit .tgd-prompt-counter {
  color: #ffd7df;
}

.tgd-thinking-card {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 0.75rem;
  align-items: center;
  min-height: 88px;
  padding: 0.72rem;
  border: 1px solid rgba(255, 230, 109, 0.34);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(255, 79, 216, 0.22), rgba(54, 247, 255, 0.14), rgba(255, 240, 90, 0.12)),
    rgba(5, 8, 16, 0.5);
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.08),
    0 14px 34px rgba(255, 79, 216, 0.12);
}

.tgd-thinking-card[hidden] {
  display: none;
}

.tgd-thinking-clock {
  display: grid;
  place-items: center;
  gap: 0.28rem;
  min-width: 82px;
}

.tgd-dream-bot {
  width: 60px;
  height: 54px;
  position: relative;
  display: grid;
  grid-template-columns: 1fr 1fr;
  place-items: center;
  border: 3px solid rgba(255, 240, 90, 0.72);
  border-radius: 18px 18px 20px 20px;
  background:
    radial-gradient(circle at 28% 74%, rgba(255, 112, 217, 0.72) 0 9%, transparent 10%),
    radial-gradient(circle at 72% 74%, rgba(255, 112, 217, 0.72) 0 9%, transparent 10%),
    linear-gradient(145deg, rgba(255, 255, 255, 0.9), rgba(133, 247, 255, 0.9) 48%, rgba(255, 112, 217, 0.75));
  box-shadow:
    0 0 24px rgba(255, 240, 90, 0.22),
    inset 0 -7px 14px rgba(25, 22, 64, 0.16);
  animation: tgd-dream-bob 2.8s ease-in-out infinite;
}

.tgd-dream-bot::before,
.tgd-dream-bot::after {
  content: "";
  position: absolute;
  top: 15px;
  width: 7px;
  height: 3px;
  border-radius: 999px;
  background: #15172d;
  box-shadow: 0 0 0 1px rgba(21, 23, 45, 0.08);
}

.tgd-dream-bot::before { left: 17px; transform: rotate(9deg); }
.tgd-dream-bot::after { right: 17px; transform: rotate(-9deg); }

.tgd-dream-antenna {
  position: absolute;
  top: -15px;
  left: 50%;
  width: 3px;
  height: 14px;
  transform: translateX(-50%);
  border-radius: 999px;
  background: rgba(255, 240, 90, 0.82);
}

.tgd-dream-antenna::after {
  content: "";
  position: absolute;
  top: -7px;
  left: 50%;
  width: 10px;
  height: 10px;
  transform: translateX(-50%);
  border-radius: 999px;
  background: var(--tgd-gold);
  box-shadow: 0 0 16px rgba(255, 240, 90, 0.52);
}

.tgd-dream-eye {
  display: none;
}

.tgd-dream-mouth {
  position: absolute;
  left: 50%;
  bottom: 14px;
  width: 12px;
  height: 6px;
  transform: translateX(-50%);
  border-bottom: 3px solid #15172d;
  border-radius: 0 0 999px 999px;
}

.tgd-dream-cheek {
  position: absolute;
  top: 28px;
  width: 8px;
  height: 5px;
  border-radius: 999px;
  background: rgba(255, 112, 217, 0.58);
  filter: blur(0.2px);
}

.tgd-dream-cheek-left { left: 10px; }
.tgd-dream-cheek-right { right: 10px; }

.tgd-dream-bubble {
  position: absolute;
  border-radius: 999px;
  border: 2px solid rgba(255, 255, 255, 0.72);
  background: rgba(255, 255, 255, 0.14);
  box-shadow: 0 0 10px rgba(120, 247, 255, 0.2);
  animation: tgd-dream-bubble 2.4s ease-in-out infinite;
}

.tgd-dream-bubble-one {
  width: 11px;
  height: 11px;
  right: -9px;
  top: 2px;
}

.tgd-dream-bubble-two {
  width: 7px;
  height: 7px;
  right: -19px;
  top: -9px;
  animation-delay: 0.42s;
}

.tgd-thinking-clock strong {
  min-width: 4ch;
  color: #fff8a8;
  font: 800 1.08rem/1 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  text-align: center;
}

.tgd-thinking-copy {
  min-width: 0;
}

.tgd-thinking-copy span {
  display: inline-flex;
  min-height: 23px;
  align-items: center;
  margin-bottom: 0.24rem;
  padding: 0.14rem 0.48rem;
  border-radius: 999px;
  background: rgba(54, 247, 255, 0.13);
  color: rgba(225, 252, 255, 0.82);
  font-size: 0.62rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.tgd-thinking-copy p {
  margin: 0;
  color: rgba(255, 255, 255, 0.94);
  font-weight: 760;
  line-height: 1.3;
}

.tgd-busy-line {
  min-height: 1.4rem;
  color: var(--tgd-gold);
  font-size: 0.86rem;
}

.tgd-particle {
  position: fixed;
  left: var(--x);
  top: var(--y);
  z-index: 9999;
  width: var(--size);
  height: var(--size);
  pointer-events: none;
  transform: translate(-50%, -50%);
}

.tgd-particle::before {
  content: "";
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 35% 65% 55% 45%;
  background:
    radial-gradient(circle at 35% 30%, rgba(255, 255, 255, 0.95), transparent 32%),
    hsl(var(--hue), 95%, 67%);
  box-shadow: 0 0 14px hsla(var(--hue), 95%, 67%, 0.52);
  animation: tgd-particle-pop 0.78s ease-out forwards;
}

.tgd-particle.is-select::before {
  border-radius: 50%;
  animation-duration: 0.92s;
}

.tgd-error {
  margin-top: 1rem;
  padding: 0.8rem;
  border: 1px solid rgba(255, 95, 133, 0.36);
  border-radius: 8px;
  color: #ffd7df;
  background: rgba(255, 95, 133, 0.08);
}

.tgd-debug {
  margin-top: 1rem;
  border: 1px solid rgba(120, 247, 255, 0.12);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.24);
}

.tgd-debug summary {
  min-height: 42px;
  display: flex;
  align-items: center;
  padding: 0 0.8rem;
  color: rgba(255, 230, 109, 0.78);
  cursor: pointer;
  font-size: 0.78rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.tgd-debug-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.45rem;
  padding: 0 0.8rem 0.65rem;
}

.tgd-debug-actions button {
  min-height: 34px;
  padding: 0.35rem 0.68rem;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.05);
  color: rgba(255, 255, 255, 0.72);
  font: inherit;
  font-size: 0.75rem;
  cursor: pointer;
}

.tgd-debug-copy-status {
  min-height: 1.2rem;
  color: rgba(255, 240, 90, 0.78);
  font-size: 0.72rem;
}

.tgd-debug-state,
.tgd-debug-log {
  margin: 0 0.8rem 0.8rem;
  padding: 0.68rem;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.34);
  color: rgba(220, 250, 255, 0.72);
  font: 0.72rem/1.45 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  white-space: pre-wrap;
  overflow: auto;
  user-select: text;
  -webkit-user-select: text;
  touch-action: pan-x pan-y;
}

.tgd-debug-state {
  max-height: 170px;
}

.tgd-debug-log {
  min-height: 150px;
  max-height: 280px;
}

.tgd-output {
  display: grid;
  gap: 1rem;
  min-width: 0;
}

.tgd-tabs {
  border-bottom: 1px solid var(--tgd-line);
}

.tgd-tab {
  padding: 0 1rem;
  flex: 0 0 auto;
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
}

.tgd-tab[aria-selected="true"] {
  background: rgba(255, 255, 255, 0.13);
  color: #fff;
}

.tgd-mode {
  display: none;
}

body[data-mode="recipe"] .tgd-mode-recipe,
body[data-mode="code"] .tgd-mode-code {
  display: grid;
  gap: 1rem;
}

.tgd-play-stage,
.tgd-code-stage {
  border-radius: 8px;
  overflow: hidden;
}

.tgd-play-header {
  padding: 1rem;
  border-bottom: 1px solid var(--tgd-line);
}

.tgd-template-badge {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  margin-bottom: 0.7rem;
  padding: 0.22rem 0.56rem;
  border: 1px solid rgba(120, 247, 255, 0.2);
  border-radius: 999px;
  background: rgba(120, 247, 255, 0.07);
  color: rgba(210, 250, 255, 0.72);
  font-size: 0.64rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.tgd-game-stats {
  color: var(--tgd-muted);
  font-size: 0.9rem;
}

#gameCanvas {
  display: block;
  width: 100%;
  height: min(58vh, 560px);
  min-height: 360px;
  background: #090812;
  touch-action: none;
}

.tgd-recipe-json,
.tgd-code-text {
  width: 100%;
  box-sizing: border-box;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.34);
  color: rgba(237, 249, 255, 0.86);
  font: 0.82rem/1.55 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.tgd-recipe-json {
  max-height: 260px;
  overflow: auto;
  padding: 1rem;
  white-space: pre-wrap;
}

.tgd-code-text {
  min-height: 180px;
  padding: 0.85rem;
  resize: vertical;
}

.tgd-sandbox-wrap {
  min-height: 460px;
  background: rgba(255, 255, 255, 0.06);
}

#sandboxFrame {
  display: block;
  width: 100%;
  height: 460px;
  border: 0;
  background: #fff;
}

.tgd-advanced-note {
  padding: 0.9rem 1rem;
  color: var(--tgd-muted);
  border-bottom: 1px solid var(--tgd-line);
}

.tgd-lab-disclosure summary {
  min-height: 46px;
  display: flex;
  align-items: center;
  padding: 0 1rem;
  color: rgba(220, 250, 255, 0.74);
  cursor: pointer;
  font-size: 0.78rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

@keyframes tgd-block-open-pop {
  0% { transform: translateY(-4px) scale(0.97); }
  62% { transform: translateY(1px) scale(1.015); }
  100% { transform: translateY(0) scale(1); }
}

@keyframes tgd-block-close-squish {
  0% { transform: scale(1); }
  45% { transform: scale(0.985, 1.025); }
  100% { transform: scale(1); }
}

@keyframes tgd-choice-pop {
  0% { transform: scale(1); }
  45% { transform: scale(1.08) rotate(-1.2deg); }
  100% { transform: scale(1); }
}

@keyframes tgd-particle-pop {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.35) rotate(0deg);
  }
  18% { opacity: 1; }
  100% {
    opacity: 0;
    transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy))) scale(0.08) rotate(220deg);
  }
}

@keyframes tgd-dream-bob {
  0%, 100% { transform: translateY(0) rotate(-1deg); }
  50% { transform: translateY(-4px) rotate(1.5deg); }
}

@keyframes tgd-dream-bubble {
  0%, 100% {
    opacity: 0.4;
    transform: translate(0, 0) scale(0.78);
  }
  50% {
    opacity: 1;
    transform: translate(5px, -8px) scale(1.05);
  }
}

@media (prefers-reduced-motion: reduce) {
  .tgd-block-picker,
  .tgd-block-options,
  .tgd-choice-block,
  .tgd-dream-bot,
  .tgd-dream-bubble {
    animation: none !important;
    transition: none !important;
  }

  .tgd-particle {
    display: none;
  }
}

@media (max-width: 900px) {
  .tgd-hero,
  .tgd-main {
    grid-template-columns: 1fr;
  }

  .tgd-hero {
    min-height: auto;
    padding-top: 5rem;
  }

  .tgd-main {
    padding-bottom: 2.5rem;
  }

  #gameCanvas {
    height: 54vh;
    min-height: 320px;
  }
}

@media (max-width: 640px) {
  .tgd-shell {
    background:
      radial-gradient(circle at 8% 4%, rgba(255, 112, 217, 0.14), transparent 18rem),
      radial-gradient(circle at 94% 1%, rgba(120, 247, 255, 0.12), transparent 18rem),
      linear-gradient(145deg, #070611 0%, #0b1625 52%, #12091f 100%);
  }

  .tgd-page .back-link.is-experiment-back {
    top: 0.75rem;
    left: 0.75rem;
  }

  .tgd-language-toggle {
    top: 0.75rem;
    right: 0.75rem;
  }

  .tgd-language-toggle button {
    min-width: 38px;
    min-height: 32px;
    font-size: 0.68rem;
  }

  .tgd-hero {
    gap: 1rem;
    padding: 4.35rem 0.75rem 0.75rem;
  }

  .tgd-kicker {
    font-size: 0.62rem;
    line-height: 1.45;
    margin-bottom: 0.45rem;
  }

  .tgd-hero h1 {
    max-width: 11ch;
    font-size: clamp(2.45rem, 15vw, 4rem);
    line-height: 0.92;
  }

  .tgd-lede {
    margin-top: 0.8rem;
    font-size: 0.94rem;
    line-height: 1.55;
  }

  .tgd-model-card,
  .tgd-panel,
  .tgd-play-stage,
  .tgd-code-stage {
    box-shadow: 0 16px 44px rgba(0, 0, 0, 0.24);
  }

  .tgd-model-card {
    padding: 0.82rem;
    gap: 0.75rem;
  }

  .tgd-robot-chat {
    min-height: 0;
    padding: 0.75rem;
  }

  .tgd-robot-chat p {
    font-size: 0.9rem;
    line-height: 1.42;
  }

  .tgd-status-row,
  .tgd-actions,
  .tgd-game-stats {
    gap: 0.5rem;
  }

  .tgd-status-text {
    font-size: 0.95rem;
  }

  .tgd-detail {
    min-height: 0;
    margin: 0.65rem 0;
    font-size: 0.88rem;
  }

  .tgd-model-meta {
    margin: 0.75rem 0;
    font-size: 0.76rem;
    line-height: 1.45;
    overflow-wrap: anywhere;
  }

  .tgd-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .tgd-actions button,
  .tgd-form button,
  .tgd-tab {
    min-height: 46px;
    padding: 0.62rem 0.72rem;
    font-size: 0.9rem;
  }

  .tgd-main {
    gap: 0.75rem;
    padding: 0 0.75rem 2rem;
  }

  .tgd-panel {
    padding: 0.82rem;
  }

  .tgd-panel h2,
  .tgd-play-header h2 {
    margin-bottom: 0.65rem;
  }

  .tgd-form {
    grid-template-columns: 1fr;
    gap: 0.68rem;
  }

  .tgd-field {
    min-width: 0;
  }

  .tgd-prompt-mode {
    grid-column: 1 / -1;
  }

  .tgd-choice-block {
    min-height: 52px;
    padding: 0.58rem;
    font-size: 0.84rem;
  }

  .tgd-label {
    font-size: 0.58rem;
  }

  .tgd-prompt-field textarea {
    min-height: 104px;
    font-size: 0.86rem;
  }

  .tgd-prompt-footer {
    display: grid;
    gap: 0.45rem;
  }

  .tgd-prompt-counter {
    text-align: left;
  }

  .tgd-field select {
    min-height: 44px;
    padding: 0 0.55rem;
    font-size: 0.9rem;
  }

  .tgd-form button,
  .tgd-remix-actions,
  .tgd-thinking-card,
  .tgd-busy-line {
    grid-column: 1 / -1;
  }

  .tgd-remix-actions {
    gap: 0.5rem;
  }

  .tgd-busy-line {
    min-height: 1.2rem;
    font-size: 0.82rem;
  }

  .tgd-thinking-card {
    grid-template-columns: auto minmax(0, 1fr);
    min-height: 82px;
    padding: 0.62rem;
  }

  .tgd-thinking-clock {
    min-width: 68px;
  }

  .tgd-dream-bot {
    width: 50px;
    height: 46px;
    border-radius: 15px 15px 17px 17px;
  }

  .tgd-thinking-clock strong {
    font-size: 0.96rem;
  }

  .tgd-thinking-copy p {
    font-size: 0.86rem;
  }

  .tgd-error {
    margin-top: 0.75rem;
    font-size: 0.84rem;
  }

  .tgd-debug {
    margin-top: 0.75rem;
  }

  .tgd-debug summary {
    min-height: 40px;
    font-size: 0.7rem;
  }

  .tgd-debug-state,
  .tgd-debug-log {
    margin-inline: 0.62rem;
    padding: 0.55rem;
    font-size: 0.64rem;
    line-height: 1.42;
  }

  .tgd-grown-controls {
    grid-template-columns: 1fr;
  }

  .tgd-debug-state {
    max-height: 120px;
  }

  .tgd-debug-log {
    min-height: 120px;
    max-height: 190px;
  }

  .tgd-tabs {
    position: sticky;
    top: 0;
    z-index: 5;
    overflow-x: auto;
    flex-wrap: nowrap;
    padding-top: 0.25rem;
    background: rgba(8, 6, 17, 0.82);
    backdrop-filter: blur(14px);
    scrollbar-width: none;
  }

  .tgd-tabs::-webkit-scrollbar {
    display: none;
  }

  .tgd-tab {
    min-width: max-content;
    border-radius: 8px 8px 0 0;
    letter-spacing: 0.08em;
  }

  .tgd-play-header {
    padding: 0.82rem;
  }

  .tgd-game-stats,
  .tgd-small,
  .tgd-advanced-note {
    font-size: 0.82rem;
    line-height: 1.48;
  }

  #gameCanvas {
    height: 48vh;
    min-height: 280px;
    max-height: 430px;
  }

  .tgd-recipe-json {
    max-height: 190px;
    padding: 0.72rem;
    font-size: 0.68rem;
  }

  .tgd-code-text {
    min-height: 150px;
    padding: 0.72rem;
    font-size: 0.68rem;
  }

  .tgd-sandbox-wrap {
    min-height: 330px;
  }

  #sandboxFrame {
    height: 330px;
  }

  .tgd-advanced-note {
    padding: 0.75rem 0.82rem;
  }

  .tgd-lab-disclosure summary {
    min-height: 44px;
    padding: 0 0.82rem;
    font-size: 0.7rem;
  }
}

@media (max-width: 390px) {
  .tgd-hero {
    padding-inline: 0.62rem;
  }

  .tgd-main {
    padding-inline: 0.62rem;
  }

  .tgd-form {
    grid-template-columns: 1fr;
  }

  .tgd-block-options {
    grid-template-columns: 1fr;
  }

  .tgd-field {
    grid-column: 1 / -1;
  }

  .tgd-actions {
    grid-template-columns: 1fr;
  }

  .tgd-remix-actions {
    grid-template-columns: 1fr;
  }

  .tgd-hero h1 {
    font-size: clamp(2.25rem, 14vw, 3.35rem);
  }

  .tgd-model-card {
    grid-template-columns: 1fr;
  }

}
