/* ML Hangman: GPU rig. Uses theme tokens from styles.css */
.rig { margin-bottom: 2rem; }

/* ----- Telemetry ----- */
.telemetry { margin-bottom: 1.25rem; }
.load-head {
  display: flex; justify-content: space-between; align-items: baseline;
  font-size: 0.95rem; color: var(--text-secondary); margin-bottom: 0.5rem;
}
.load-head strong { font-size: 1.6rem; color: var(--text-primary); font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }
.load-bar { display: grid; grid-template-columns: repeat(6, 1fr); gap: 4px; }
.load-bar i {
  height: 10px; border-radius: 3px; background: var(--code-bg); border: 1px solid var(--border-color);
  transition: background 0.3s ease, border-color 0.3s ease;
}
.load-bar i.on { background: #76b900; border-color: #76b900; }
.load-bar i:nth-child(3).on, .load-bar i:nth-child(4).on { background: #e0b000; border-color: #e0b000; }
.load-bar i:nth-child(5).on { background: #f08a00; border-color: #f08a00; }
.load-bar i:nth-child(6).on { background: #ff2a1a; border-color: #ff2a1a; }
.stats { display: flex; gap: 2rem; margin-top: 0.9rem; flex-wrap: wrap; }
.stats dt { font-size: 0.8rem; color: var(--text-secondary); }
.stats dd { font-size: 1rem; font-variant-numeric: tabular-nums; font-weight: 500; }

/* ----- GPU ----- */
.gpu {
  --heat: #76b900; --fan-speed: 4s; --fan: clamp(78px, 22vw, 132px);
  position: relative; padding-top: 70px; /* room for flames */
}
.gpu[data-stage="1"] { --heat: #8fc400; --fan-speed: 2.6s; }
.gpu[data-stage="2"] { --heat: #b5c400; --fan-speed: 1.7s; }
.gpu[data-stage="3"] { --heat: #e0b000; --fan-speed: 1.1s; }
.gpu[data-stage="4"] { --heat: #f08a00; --fan-speed: 0.7s; }
.gpu[data-stage="5"] { --heat: #ff5a1f; --fan-speed: 0.4s; }
.gpu[data-stage="6"] { --heat: #ff2a1a; }
.gpu[data-state="won"] { --heat: #76b900; --fan-speed: 5s; }

.card {
  position: relative;
  background: linear-gradient(180deg, #2b2b2f, #121214);
  border: 1px solid #3a3a3e; border-bottom: 3px solid var(--heat);
  border-radius: 14px; padding: 18px 18px 0;
  box-shadow: 0 0 calc(var(--glow, 0) * 1px) var(--heat), 0 10px 30px rgba(0,0,0,0.25);
  transition: box-shadow 0.4s ease, border-color 0.4s ease;
}
.gpu[data-stage="2"] .card { --glow: 14; }
.gpu[data-stage="3"] .card { --glow: 22; }
.gpu[data-stage="4"] .card { --glow: 32; }
.gpu[data-stage="5"] .card { --glow: 44; animation: tremble 0.12s linear infinite; }
.gpu[data-stage="6"] .card { --glow: 60; filter: saturate(0.6) brightness(0.75); animation: shake 0.5s ease 1; }

.shroud { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.plate { flex: 1; text-align: center; color: #d8d8dc; min-width: 0; }
.plate b { display: block; color: #76b900; font-size: clamp(0.95rem, 3.4vw, 1.35rem); letter-spacing: 0.12em; }
.plate small { font-size: 0.72rem; color: #8e8e93; letter-spacing: 0.08em; }

.fan {
  position: relative; width: var(--fan); height: var(--fan); flex: none; border-radius: 50%;
  background:
    radial-gradient(circle, transparent 0 24%, #0b0b0c 25% 100%);
  border: 3px solid #333338;
  box-shadow: inset 0 0 0 2px #0b0b0c, 0 0 10px -2px var(--heat);
}
.fan::before { /* blades */
  content: ""; position: absolute; inset: 4px; border-radius: 50%;
  background: repeating-conic-gradient(from 0deg, #4a4a50 0 14deg, #1c1c1f 14deg 40deg);
  -webkit-mask: radial-gradient(circle, transparent 0 22%, #000 23% 100%);
          mask: radial-gradient(circle, transparent 0 22%, #000 23% 100%);
  animation: spin var(--fan-speed) linear infinite;
}
.hub {
  position: absolute; inset: 34%; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #5a5a60, #1a1a1c);
  border: 2px solid var(--heat);
}
.gpu[data-state="lost"] .fan::before { animation-play-state: paused; }

.vram { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; margin: 16px 0 12px; }
.vram span {
  height: clamp(16px, 4vw, 24px); border-radius: 3px; background: #0b0b0c; border: 1px solid #3a3a3e;
  position: relative; transition: background 0.3s ease, box-shadow 0.3s ease;
}
.vram span.used { background: var(--heat); box-shadow: 0 0 10px var(--heat); border-color: var(--heat); }
.gpu[data-state="lost"] .vram span { animation: blink 0.5s steps(2) infinite; }

.pcie {
  height: 14px; margin: 0 14px;
  background: repeating-linear-gradient(90deg, #c9a24a 0 5px, transparent 5px 8px);
  border-radius: 0 0 3px 3px;
  -webkit-mask: linear-gradient(#000, #000); mask: linear-gradient(#000, #000);
}

/* ----- Out of memory ----- */
.oom {
  display: none; position: absolute; left: 50%; top: 58%; transform: translate(-50%, -50%);
  width: min(92%, 460px); padding: 14px 16px; border-radius: 10px;
  background: rgba(14, 0, 0, 0.92); border: 1px solid #ff2a1a; color: #ffb3ab;
  font-family: "SF Mono", Monaco, Consolas, monospace; font-size: 0.8rem; line-height: 1.5;
  z-index: 5; box-shadow: 0 0 30px rgba(255, 42, 26, 0.5);
}
.oom-title { color: #ff5a4d; font-weight: 700; }
.oom-word { margin-top: 6px; color: #fff; }
.gpu[data-state="lost"] .oom { display: block; animation: pop 0.3s ease; }

/* ----- Fire ----- */
.fire { display: none; position: absolute; left: 0; right: 0; bottom: 28px; height: 190px; pointer-events: none; z-index: 4; }
.gpu[data-state="lost"] .fire { display: block; }
.flame {
  position: absolute; bottom: 0; width: var(--w, 36px); height: var(--h, 90px); transform-origin: 50% 100%;
  border-radius: 50% 50% 35% 35% / 75% 75% 25% 25%;
  background: radial-gradient(ellipse at 50% 100%, #fff4a8 0%, #ffc21a 30%, #ff5a00 62%, rgba(255, 40, 0, 0) 76%);
  filter: blur(1.5px); opacity: 0.92;
  animation: flicker 0.8s ease-in-out infinite alternate;
}
.flame:nth-child(3n) { background: radial-gradient(ellipse at 50% 100%, #ffe27a 0%, #ff8a00 40%, rgba(255, 40, 0, 0) 74%); }

/* ----- Game ----- */
.game { text-align: center; }
.hint { color: var(--text-secondary); margin-bottom: 1.25rem; }
.word { display: flex; justify-content: center; flex-wrap: wrap; gap: 0.4rem; margin-bottom: 0.75rem; }
.slot {
  width: clamp(22px, 6vw, 38px); height: clamp(34px, 8vw, 48px);
  display: inline-flex; align-items: center; justify-content: center;
  border-bottom: 3px solid var(--text-primary);
  font-family: "SF Mono", Monaco, Consolas, monospace; font-size: clamp(1.2rem, 4.5vw, 1.8rem); font-weight: 600;
}
.slot.missed { color: #ff3b30; border-color: #ff3b30; }
.misses { color: var(--text-secondary); font-size: 0.9rem; margin-bottom: 1.25rem; font-variant-numeric: tabular-nums; }

.keys { display: grid; grid-template-columns: repeat(auto-fit, minmax(40px, 1fr)); gap: 6px; max-width: 560px; margin: 0 auto 1.25rem; }
.key {
  padding: 0.65rem 0; border-radius: 8px; border: 1px solid var(--border-color);
  background: var(--card-bg); color: var(--text-primary); font: inherit; font-weight: 500; cursor: pointer;
  transition: background 0.12s ease, border-color 0.12s ease, transform 0.08s ease;
}
.key:hover:not(:disabled) { border-color: var(--text-secondary); }
.key:active:not(:disabled) { transform: scale(0.95); }
.key:focus-visible, .btn:focus-visible { outline: 2px solid var(--link-color); outline-offset: 2px; }
.key:disabled { cursor: default; opacity: 0.45; }
.key.hit { background: #76b900; border-color: #76b900; color: #0b0b0c; opacity: 1; }
.key.miss { background: transparent; text-decoration: line-through; }

.result { min-height: 1.6rem; font-weight: 600; margin-bottom: 1rem; }
.log {
  list-style: none; text-align: left; max-width: 560px; margin: 0 auto 1.5rem; min-height: 7.5rem;
  background: var(--code-bg); border: 1px solid var(--border-color); border-radius: 8px; padding: 0.75rem 1rem;
  font-family: "SF Mono", Monaco, Consolas, monospace; font-size: 0.8rem; color: var(--text-secondary);
}
.log li::before { content: "> "; opacity: 0.6; }
.log li.ok { color: #4c8f00; }
.log li.warn { color: #b87500; }
.log li.err { color: #ff3b30; }
@media (prefers-color-scheme: dark) { .log li.ok { color: #76b900; } .log li.warn { color: #f0b429; } }

.btn {
  padding: 0.7rem 1.6rem; border-radius: 980px; border: none; background: var(--link-color); color: #fff;
  font: inherit; font-weight: 500; cursor: pointer;
}
.btn:hover { filter: brightness(1.1); }

/* ----- Keyframes ----- */
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes tremble { 0%,100% { transform: translate(0,0); } 50% { transform: translate(1px,-1px); } }
@keyframes shake { 0%,100% { transform: translate(0); } 20% { transform: translate(-6px,3px); } 40% { transform: translate(6px,-3px); } 60% { transform: translate(-4px,-2px); } 80% { transform: translate(4px,2px); } }
@keyframes blink { 50% { opacity: 0.3; } }
@keyframes pop { from { opacity: 0; transform: translate(-50%, -46%) scale(0.95); } }
@keyframes flicker {
  0%   { transform: scale(1, 0.8) skewX(-4deg); }
  100% { transform: scale(0.85, 1.15) skewX(5deg); }
}

@media (prefers-reduced-motion: reduce) {
  .fan::before, .card, .flame, .vram span, .oom { animation: none !important; }
}