/* Game 01 · Perfect Timing Gets You Banned. Every rule is scoped under .g-timing. */

.g-timing .tm-root {
  /* z-index 0 makes the whole scene one stacking context, so nothing in it can rise above the shell's overlays */
  position: absolute; inset: 0; z-index: 0; overflow: hidden; cursor: pointer; touch-action: none;
  -webkit-user-select: none; user-select: none; -webkit-tap-highlight-color: transparent;
}
.g-timing .tm-root::before {
  content: ''; position: absolute; inset: 0; pointer-events: none; opacity: 0; transition: opacity .6s;
  box-shadow: inset 0 0 0 3px rgba(255, 77, 77, .55), inset 0 0 110px rgba(255, 40, 90, .30);
}
.g-timing .tm-root.insane::before { opacity: 1; }

/* ── HUD ── */
.g-timing .tm-col { flex-direction: column; align-items: flex-start; gap: 6px; }
.g-timing .g-hud-r.tm-col { align-items: flex-end; }
.g-timing .tm-timec.red { border-color: rgba(255, 107, 107, .6); }
.g-timing .tm-timec.red b { color: #FF6B6B; }
.g-timing .doubles .tm-beatc { border-color: rgba(255, 176, 32, .55); }
.g-timing .doubles .tm-beatc b { color: #FFB020; }
.g-timing .insane .tm-beatc { border-color: rgba(255, 107, 107, .7); background: rgba(60, 10, 20, .9); }
.g-timing .insane .tm-beatc b { color: #FF6B6B; }

/* ── the robot detector ── */
.g-timing .tm-gauge {
  position: absolute; z-index: 2; left: 50%; top: 8px; width: clamp(150px, min(29cqw, 40cqh), 280px); transform: translateX(-50%);
  display: grid; justify-items: center; pointer-events: none;
}
.g-timing .tm-gsvg { display: block; width: 100%; height: auto; overflow: visible; }
.g-timing .tm-g-out { fill: none; stroke: #000; stroke-width: 23; }
.g-timing .tm-g-trk { fill: none; stroke: var(--panel2); stroke-width: 17; }
.g-timing .tm-g-z { fill: none; stroke-width: 17; opacity: .22; }
.g-timing .tm-g-z.z1 { stroke: var(--lime); }
.g-timing .tm-g-z.z2 { stroke: #FFB020; }
.g-timing .tm-g-z.z3 { stroke: #FF4D4D; opacity: .38; }
.g-timing .tm-g-fill { fill: none; stroke: var(--lime); stroke-width: 17; stroke-dasharray: 0 100; transition: stroke-dasharray .14s linear, stroke .2s; }
.g-timing .tm-gauge.warn .tm-g-fill { stroke: #FFB020; }
.g-timing .tm-gauge.hot .tm-g-fill { stroke: #FF4D4D; }
.g-timing .tm-g-tick { stroke: var(--panel-muted); stroke-width: 2.5; stroke-linecap: round; }
.g-timing .tm-needle { transform-box: view-box; transform-origin: 100px 98px; transform: rotate(-90deg); transition: transform .16s var(--ease); }
.g-timing .tm-needle .o { stroke: #000; stroke-width: 8; stroke-linecap: round; }
.g-timing .tm-needle .i { stroke: var(--panel-text); stroke-width: 3.6; stroke-linecap: round; }
.g-timing .tm-hub { fill: var(--lime); stroke: #000; stroke-width: 3; transition: fill .2s; }
.g-timing .tm-gauge.warn .tm-hub { fill: #FFB020; }
.g-timing .tm-gauge.hot .tm-hub { fill: #FF4D4D; }
.g-timing .tm-gread { position: relative; margin-top: 3px; line-height: 1; }
.g-timing .tm-dval {
  display: block; font: 800 clamp(26px, min(4.4cqw, 6.4cqh), 40px)/1 var(--mono); letter-spacing: -.04em; color: var(--panel-text);
  font-variant-numeric: tabular-nums; text-shadow: 3px 3px 0 #000; transition: color .2s;
}
.g-timing .tm-gauge.warn .tm-dval { color: #FFB020; }
.g-timing .tm-gauge.hot .tm-dval { color: #FF6B6B; }
.g-timing .tm-gauge.kick .tm-dval { animation: tmKick .32s var(--spring); }
.g-timing .tm-delta {
  position: absolute; left: 100%; top: 50%; margin-left: 8px; font: 800 15px/1 var(--mono); font-style: normal;
  white-space: nowrap; opacity: 0; text-shadow: 2px 2px 0 #000;
}
.g-timing .tm-delta.up { color: #FF6B6B; }
.g-timing .tm-delta.down { color: var(--lime); }
.g-timing .tm-delta.go { animation: tmDelta .8s var(--ease) both; }
.g-timing .tm-glbl {
  margin-top: 4px; font: 700 10px/1 var(--mono); letter-spacing: .16em; text-transform: uppercase; color: var(--panel-muted); white-space: nowrap;
}
.g-timing .tm-gauge.hot .tm-glbl { color: #FF6B6B; }

/* ── the send lane ── */
.g-timing .tm-lane {
  position: absolute; left: 0; right: 0; top: 38cqh; height: 28cqh;
  background: rgba(240, 240, 255, .028); border-top: 2px dashed var(--panel-line); border-bottom: 2px dashed var(--panel-line);
  transition: background-color .4s, border-color .4s;
}
.g-timing .tm-lane::before {
  content: ''; position: absolute; inset: 0; pointer-events: none; opacity: 0; transition: opacity .5s;
  background: repeating-linear-gradient(-45deg, rgba(255, 77, 77, .1) 0 12px, transparent 12px 24px);
}
.g-timing .insane .tm-lane { background-color: rgba(255, 50, 90, .05); border-color: rgba(255, 77, 77, .5); }
.g-timing .insane .tm-lane::before { opacity: 1; animation: tmFlow .5s linear infinite; }

/* the beat grid: one line per beat, riding the lane into the SEND line */
.g-timing .tm-grid { position: absolute; inset: 0; pointer-events: none; }
.g-timing .tm-bl {
  position: absolute; left: 0; top: 0; bottom: 0; width: 2px; margin-left: -1px; will-change: transform;
  background: repeating-linear-gradient(180deg, rgba(57, 255, 20, .34) 0 6px, transparent 6px 12px);
}
.g-timing .tm-bl::before, .g-timing .tm-bl::after {
  content: ''; position: absolute; left: 50%; width: 8px; height: 8px; margin-left: -4px; border-radius: 50%;
  background: var(--lime); border: 1.5px solid #000; opacity: .75;
}
.g-timing .tm-bl::before { top: -5px; }
.g-timing .tm-bl::after { bottom: -5px; }
.g-timing .tm-bl.past { background: repeating-linear-gradient(180deg, rgba(136, 136, 170, .2) 0 6px, transparent 6px 12px); }
.g-timing .tm-bl.past::before, .g-timing .tm-bl.past::after { background: var(--panel-muted); opacity: .4; }
.g-timing .insane .tm-bl { background: repeating-linear-gradient(180deg, rgba(255, 107, 107, .45) 0 6px, transparent 6px 12px); }
.g-timing .insane .tm-bl::before, .g-timing .insane .tm-bl::after { background: #FF6B6B; }
.g-timing .tm-dim { position: absolute; top: 0; bottom: 0; pointer-events: none; }
.g-timing .tm-dim-l { left: 0; width: 6%; background: rgba(9, 9, 14, .6); border-right: 2px dashed rgba(255, 107, 107, .35); }
.g-timing .tm-dim-r { left: 65%; right: 0; background: linear-gradient(90deg, rgba(9, 9, 14, .15), rgba(9, 9, 14, .55)); border-left: 2px dashed rgba(57, 255, 20, .3); }
.g-timing .tm-dim-r span {
  position: absolute; left: 8px; bottom: 6px; font: 700 9.5px/1 var(--mono); letter-spacing: .14em; text-transform: uppercase;
  color: rgba(57, 255, 20, .6); white-space: nowrap;
}
.g-timing .tm-dim-r span::before { content: '← '; }

/* danger zones around the line: red is "too perfect", amber is "suspicious" (both fixed in ms, so they widen with speed) */
.g-timing .tm-band { position: absolute; top: -12px; bottom: -12px; pointer-events: none; transition: left .3s, width .3s; }
.g-timing .tm-band-sus { background: rgba(255, 176, 32, .09); border-left: 1.5px dashed rgba(255, 176, 32, .45); border-right: 1.5px dashed rgba(255, 176, 32, .45); }
.g-timing .tm-band-hot { background: rgba(255, 77, 77, .2); }
.g-timing .insane .tm-band-hot { background: rgba(255, 77, 77, .3); }

/* the SEND line: the temptation. It throbs on every beat. */
.g-timing .tm-line { position: absolute; left: 22%; top: -22px; bottom: -22px; width: 0; pointer-events: none; z-index: 2; }
.g-timing .tm-core {
  position: absolute; top: 0; bottom: 0; left: -2.5px; width: 5px; border-radius: 5px; background: var(--lime);
  box-shadow: 0 0 0 2px #000, 0 0 16px 3px rgba(57, 255, 20, .5);
}
.g-timing .insane .tm-core { left: -3.5px; width: 7px; box-shadow: 0 0 0 2px #000, 0 0 26px 6px rgba(57, 255, 20, .6); }
.g-timing .tm-line.beat .tm-core { animation: tmThrob .3s ease-out; }
.g-timing .insane .tm-line.beat .tm-core { animation-name: tmThrobBig; }
.g-timing .tm-send {
  position: absolute; left: 0; bottom: 100%; transform: translate(-50%, -6px); padding: 4px 9px 3px;
  font: 800 11px/1 var(--mono); letter-spacing: .16em; text-transform: uppercase; color: var(--ink); white-space: nowrap;
  background: var(--lime); border: 2px solid #000; border-radius: 7px; box-shadow: 2px 2px 0 #000;
}
.g-timing .tm-line.beat .tm-send { animation: tmBump .3s var(--spring); }
.g-timing .tm-ring {
  position: absolute; left: 0; top: 50%; width: 44px; height: 44px; margin: -22px 0 0 -22px; border-radius: 50%;
  border: 3px solid var(--lime); opacity: 0;
}
.g-timing .tm-line.beat .tm-ring { animation: tmRing .5s ease-out; }
.g-timing .insane .tm-line.beat .tm-ring { animation: tmRingBig .5s ease-out; border-color: #FF6B6B; }

/* ── chat bubbles ── */
.g-timing .tm-track { position: absolute; inset: 0; }
.g-timing .tm-b {
  position: absolute; left: 0; z-index: 1; height: 38px; display: inline-flex; align-items: center; gap: 7px; padding: 0 9px 0 12px;
  white-space: nowrap; font: 600 15px/1 var(--font); letter-spacing: -.01em; color: #111B21; background: #D9FDD3;
  border: 2px solid #000; border-radius: 3px 14px 14px 14px; box-shadow: 3px 3px 0 #000; transform-origin: 0 0; will-change: transform;
  transition: background-color .12s, opacity .25s, filter .25s, outline-color .12s;
}
.g-timing .tm-b.r0 { top: 7%; }
.g-timing .tm-b.r1 { top: 50%; margin-top: -19px; }
.g-timing .tm-b.r2 { bottom: 7%; }
.g-timing .tm-clk { width: 13px; height: 13px; flex: none; fill: none; stroke: #667781; stroke-width: 1.5; stroke-linecap: round; }
.g-timing .tm-b.out { opacity: .5; filter: saturate(.35); }
.g-timing .tm-b.warn { background: #FFEBC2; }
.g-timing .tm-b.hot { background: #FFC9C9; box-shadow: 3px 3px 0 #000, 0 0 18px rgba(255, 77, 77, .7); }
.g-timing .tm-b.hot::after {
  content: '🤖'; position: absolute; top: -15px; right: -11px; font-size: 19px; line-height: 1; filter: drop-shadow(1px 1px 0 #000);
}
.g-timing .tm-b.next { outline: 3px solid var(--lime); outline-offset: 3px; }
.g-timing .tm-b.next.warn { outline-color: #FFB020; }
.g-timing .tm-b.next.hot { outline-color: #FF4D4D; }
.g-timing .tm-b.gone { opacity: .22; filter: grayscale(1); }
.g-timing .tm-b.sent { z-index: 6; outline: 3px solid var(--lime); outline-offset: 2px; }

/* ── the delivered pile ── */
.g-timing .tm-pile {
  position: absolute; z-index: 2; left: 12px; bottom: 16px; width: min(46cqw, 300px); height: clamp(92px, 22cqh, 150px);
  display: flex; flex-direction: column; background: #0B141A; border: 2px solid var(--panel-line); border-radius: 14px;
  box-shadow: 4px 4px 0 #000; overflow: hidden;
}
.g-timing .tm-pile-h {
  display: flex; align-items: center; gap: 6px; padding: 7px 10px 6px; border-bottom: 1.5px solid var(--panel-line);
  font: 700 10px/1 var(--mono); letter-spacing: .14em; text-transform: uppercase; color: var(--panel-muted);
}
.g-timing .tm-tk { width: 16px; height: 11px; flex: none; fill: none; stroke: #53BDEB; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.g-timing .tm-pile-list {
  flex: 1; min-height: 0; display: flex; flex-direction: column; justify-content: flex-end; align-items: flex-end; gap: 5px; padding: 6px 9px 8px;
  overflow: hidden; -webkit-mask-image: linear-gradient(transparent, #000 45%); mask-image: linear-gradient(transparent, #000 45%);
}
.g-timing .tm-pb {
  flex: none; display: inline-flex; align-items: center; gap: 6px; max-width: 100%; padding: 4px 7px 4px 9px;
  font: 600 12.5px/1.2 var(--font); color: #111B21; background: #D9FDD3; border: 1.5px solid #000; border-radius: 10px 10px 3px 10px;
  box-shadow: 2px 2px 0 #000; animation: tmIn .28s var(--spring) both;
}
.g-timing .tm-pb span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ── your gaps ── */
.g-timing .tm-gaps {
  position: absolute; z-index: 2; right: 12px; bottom: 16px; width: min(40cqw, 240px); height: clamp(92px, 22cqh, 150px);
  display: grid; grid-template-rows: auto 1fr auto; gap: 6px; padding: 8px 10px 8px;
  background: var(--panel2); border: 2px solid var(--panel-line); border-radius: 14px; box-shadow: 4px 4px 0 #000;
  transition: border-color .2s, background-color .2s;
}
.g-timing .tm-gaps-h { font: 700 10px/1 var(--mono); letter-spacing: .14em; text-transform: uppercase; color: var(--panel-muted); white-space: nowrap; }
.g-timing .tm-bars { display: flex; align-items: flex-end; gap: 6px; min-height: 0; border-bottom: 1.5px solid var(--panel-line); }
.g-timing .tm-bars i {
  flex: 1; height: 8%; background: var(--lime); border: 1.5px solid #000; border-bottom: 0; border-radius: 4px 4px 0 0;
  transition: height .2s var(--ease), background-color .2s;
}
.g-timing .tm-bars i.empty { background: var(--panel-line); }
.g-timing .tm-bars i.fast { background: #FFB020; }
.g-timing .tm-gaps-f { display: flex; align-items: baseline; justify-content: space-between; gap: 6px; font: 700 10.5px/1 var(--mono); letter-spacing: .08em; text-transform: uppercase; white-space: nowrap; }
.g-timing .tm-spread { color: var(--panel-muted); }
.g-timing .tm-verdict { color: var(--panel-text); font-size: 12px; letter-spacing: .1em; }
.g-timing .tm-gaps.human .tm-verdict { color: var(--lime); }
.g-timing .tm-gaps.robot { border-color: rgba(255, 107, 107, .8); background: #1E0E14; }
.g-timing .tm-gaps.robot .tm-bars i { background: #FF4D4D; }
.g-timing .tm-gaps.robot .tm-verdict { color: #FF6B6B; }
.g-timing .tm-gaps.robot .tm-verdict::before { content: '🤖 '; }

/* rules card, wide screens only */
.g-timing .tm-legend {
  position: absolute; z-index: 2; left: 50%; bottom: 16px; width: 290px; transform: translateX(-50%);
  display: none; gap: 5px; padding: 9px 12px; background: rgba(15, 15, 24, .7); border: 1.5px dashed var(--panel-line); border-radius: 12px;
}
.g-timing .tm-legend span { display: flex; justify-content: space-between; gap: 10px; font: 600 11px/1.25 var(--mono); white-space: nowrap; }
.g-timing .tm-legend b { color: var(--panel-muted); font-weight: 600; }
.g-timing .tm-legend em { font-style: normal; font-weight: 800; }
.g-timing .tm-legend .hot em { color: #FF6B6B; }
.g-timing .tm-legend .sus em { color: #FFB020; }
.g-timing .tm-legend .ok em { color: var(--lime); }

.g-timing .tm-hint {
  position: absolute; z-index: 2; left: 50%; top: calc(66cqh + 26px); transform: translateX(-50%); pointer-events: none;
  font: 700 10.5px/1 var(--mono); letter-spacing: .12em; text-transform: uppercase; color: var(--panel-muted); white-space: nowrap;
  transition: opacity .4s;
}
.g-timing .tm-hint.off { opacity: 0; }

/* ── phase banners ── */
.g-timing .tm-banner {
  position: absolute; z-index: 3; left: 50%; top: 52cqh; display: grid; justify-items: center; gap: 8px; width: max-content; max-width: 94cqw;
  text-align: center; pointer-events: none; opacity: 0; transform: translate(-50%, -50%);
}
.g-timing .tm-banner b {
  font: 900 clamp(38px, 9cqw, 92px)/.92 var(--font); letter-spacing: -.055em; text-transform: uppercase; white-space: nowrap; color: var(--lime);
  -webkit-text-stroke: 2px #000; paint-order: stroke fill; text-shadow: 5px 5px 0 #000;
}
.g-timing .tm-banner small {
  padding: 4px 10px; font: 800 clamp(10px, 1.5cqw, 13px)/1.2 var(--mono); letter-spacing: .12em; text-transform: uppercase; color: var(--ink);
  background: var(--lime); border: 2px solid #000; border-radius: 7px; box-shadow: 3px 3px 0 #000; white-space: nowrap;
}
.g-timing .tm-banner.red b { color: #FF4D4D; }
.g-timing .tm-banner.red small { background: #FF6B6B; }
.g-timing .tm-banner.small b { font-size: clamp(30px, 6.4cqw, 64px); }
.g-timing .tm-banner.show { animation: tmBanner 1.9s var(--ease) both; }

/* ── danger and bust ── */
.g-timing .tm-root::after {
  content: ''; position: absolute; inset: 0; pointer-events: none; opacity: 0; transition: opacity .3s;
  background: radial-gradient(120% 90% at 50% 50%, transparent 55%, rgba(255, 40, 60, .32));
}
.g-timing .tm-root.danger::after { opacity: 1; animation: tmBreathe 1.3s ease-in-out infinite alternate; }
.g-timing .tm-root.busted .tm-b { animation: none; }
.g-timing .g-pop.tm-meh { font: 700 12px var(--mono); letter-spacing: .1em; text-transform: uppercase; color: var(--panel-muted); }


/* ── sizes ── */
@container (max-width: 560px) {
  .g-timing .g-hud { inset: 10px 10px auto; }
  .g-timing .g-chip { gap: 5px; padding: 5px 7px; font-size: 9.5px; letter-spacing: .08em; }
  .g-timing .g-chip b { font-size: 13px; }
  .g-timing .tm-b { height: 32px; gap: 5px; padding: 0 7px 0 9px; font-size: 12.5px; border-radius: 3px 12px 12px 12px; }
  .g-timing .tm-b.r1 { margin-top: -16px; }
  .g-timing .tm-clk { width: 11px; height: 11px; }
  .g-timing .tm-b.hot::after { top: -13px; right: -9px; font-size: 16px; }
  .g-timing .tm-pile, .g-timing .tm-gaps { bottom: 14px; }
  .g-timing .tm-pile { left: 10px; }
  .g-timing .tm-gaps { right: 10px; padding: 7px 8px; }
  .g-timing .tm-pb { font-size: 11px; padding: 3px 6px 3px 8px; }
  .g-timing .tm-gaps-h, .g-timing .tm-pile-h { font-size: 9px; letter-spacing: .1em; }
  .g-timing .tm-gaps-f { font-size: 9.5px; letter-spacing: .04em; }
  .g-timing .tm-verdict { font-size: 10.5px; }
  .g-timing .tm-hint { font-size: 9.5px; letter-spacing: .08em; }
  .g-timing .tm-send { font-size: 10px; padding: 3px 7px 2px; }
  .g-timing .tm-delta { font-size: 13px; margin-left: 5px; }
}
@container (min-width: 900px) {
  .g-timing .tm-legend { display: grid; }
}
/* phones: a taller lane, pulled up under the detector */
@container (orientation: portrait) {
  .g-timing .tm-lane { top: 31cqh; height: 33cqh; }
  .g-timing .tm-hint { top: calc(64cqh + 26px); }
  .g-timing .tm-banner { top: 47.5cqh; }
}

/* ── motion ── */
@keyframes tmFlow { to { background-position: -33.94px 0; } }
@keyframes tmThrob {
  0% { transform: scaleX(2.4); box-shadow: 0 0 0 2px #000, 0 0 34px 10px rgba(57, 255, 20, .85); }
  100% { transform: none; box-shadow: 0 0 0 2px #000, 0 0 16px 3px rgba(57, 255, 20, .5); }
}
@keyframes tmThrobBig {
  0% { transform: scaleX(3.2); box-shadow: 0 0 0 2px #000, 0 0 56px 18px rgba(57, 255, 20, .9); }
  100% { transform: none; box-shadow: 0 0 0 2px #000, 0 0 26px 6px rgba(57, 255, 20, .6); }
}
@keyframes tmBump { 0% { transform: translate(-50%, -6px) scale(1.22); } 100% { transform: translate(-50%, -6px) scale(1); } }
@keyframes tmRing { 0% { opacity: .9; transform: scale(.3); } 100% { opacity: 0; transform: scale(1.5); } }
@keyframes tmRingBig { 0% { opacity: 1; transform: scale(.3); border-width: 4px; } 100% { opacity: 0; transform: scale(2.6); border-width: 1px; } }
@keyframes tmKick { 0% { transform: scale(1.35); } 100% { transform: none; } }
@keyframes tmDelta { 0% { opacity: 0; transform: translate(0, -20%); } 15% { opacity: 1; } 100% { opacity: 0; transform: translate(0, -140%); } }
@keyframes tmIn { from { opacity: 0; transform: translateY(10px) scale(.7); } to { opacity: 1; transform: none; } }
@keyframes tmBanner {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(2.2) rotate(-9deg); }
  13% { opacity: 1; transform: translate(-50%, -50%) scale(.95) rotate(-3deg); }
  20% { transform: translate(-50%, -50%) scale(1) rotate(-3deg); }
  80% { opacity: 1; transform: translate(-50%, -50%) scale(1.04) rotate(-3deg); }
  100% { opacity: 0; transform: translate(-50%, -50%) scale(1.1) rotate(-3deg); }
}
@keyframes tmBannerFade { 0%, 100% { opacity: 0; } 12%, 82% { opacity: 1; } }
@keyframes tmBreathe { from { opacity: .55; } to { opacity: 1; } }
@keyframes tmSoft { 0% { opacity: .55; } 100% { opacity: 1; } }

@media (prefers-reduced-motion: reduce) {
  .g-timing .tm-lane::before, .g-timing .tm-root.danger::after, .g-timing .tm-pb, .g-timing .tm-gauge.kick .tm-dval,
  .g-timing .tm-line.beat .tm-send, .g-timing .tm-line.beat .tm-ring { animation: none; }
  .g-timing .tm-line.beat .tm-core, .g-timing .insane .tm-line.beat .tm-core { animation: tmSoft .3s ease-out; }
  .g-timing .tm-banner.show { animation: tmBannerFade 1.9s linear both; transform: translate(-50%, -50%); }
  .g-timing .tm-needle, .g-timing .tm-band { transition: none; }
}
