/* --- Motos de luz --- */
.tron { --arena: #16120f; }
.tron .p0 { --c: var(--tomato); --c-soft: #ffd0c4; --on-c: #fff; }
.tron .p1 { --c: var(--cobalt); --c-soft: #cdd9ff; --on-c: #fff; }
.tron .p2 { --c: var(--mint); --c-soft: #c9f5df; --on-c: var(--ink); }
.tron .p3 { --c: var(--sun); --c-soft: #fff0b8; --on-c: var(--ink); }

/* muestra de color: cuadradito pixel con brillo */
.tron .sw {
  display: inline-block; width: 22px; height: 22px; flex: none; background: var(--c, var(--ink-soft));
  border: 3px solid var(--ink); box-shadow: inset -4px -4px 0 #1f1a1733, inset 4px 4px 0 #ffffff88;
}

/* HUD */
.tron-hud { display: flex; align-items: center; justify-content: space-between; gap: 12px 16px; flex-wrap: wrap; margin: 0 auto 18px; }
.tron .chip.round {
  display: inline-flex; flex-direction: column; justify-content: center; padding: 4px 14px; min-height: 48px;
  background: var(--sun); border: var(--stroke); border-radius: 10px; box-shadow: var(--shadow); transform: rotate(-2deg);
}
.tron .chip.round b { font-family: var(--pixel); font-weight: 700; font-size: 1.4rem; line-height: 1; }
.tron .chip.round small { font-family: var(--pixel); font-size: .8rem; color: var(--ink); opacity: .75; line-height: 1.1; }

.tron .riders { display: flex; gap: 12px; flex-wrap: wrap; justify-content: flex-end; }
.tron .rider {
  display: inline-flex; align-items: center; gap: 9px; padding: 4px 12px 4px 8px; min-height: 48px;
  background: var(--c-soft); border: var(--stroke); border-radius: 10px; box-shadow: var(--shadow);
  transition: opacity .25s, filter .25s, transform .3s var(--ease-pop);
}
.tron .rider:nth-child(odd) { transform: rotate(-1deg); }
.tron .rider:nth-child(even) { transform: rotate(1.2deg); }
.tron .rider b { max-width: 12ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tron .rider.me { outline: 3px dashed var(--ink); outline-offset: 3px; }
.tron .rider.out { opacity: .5; filter: grayscale(.8); }
.tron .rider.out .sw { background: var(--ink); }
.tron .rider.bump { animation: tron-bump .55s var(--ease-pop); }
@keyframes tron-bump { 40% { transform: scale(1.18) rotate(-4deg); } }

.tron .pips { display: inline-flex; gap: 4px; }
.tron .pips i { width: 12px; height: 12px; border: 2px solid var(--ink); background: var(--sheet); display: block; }
.tron .pips i.on { background: var(--c); box-shadow: inset 2px 2px 0 #ffffff99; }

/* arena: sticker oscuro con cintas */
.tron .stage { display: flex; justify-content: center; }
.tron .frame {
  position: relative; line-height: 0; background: var(--arena); padding: 8px;
  border: 4px solid var(--ink); border-radius: 14px; box-shadow: var(--shadow-lg);
  outline: 5px solid var(--sheet); outline-offset: -1px;
}
.tron .frame::before, .tron .frame::after {
  content: ''; position: absolute; top: -16px; width: 96px; height: 28px; z-index: 2; pointer-events: none;
  background: #ffe28acc; border-left: 2px dashed #0002; border-right: 2px dashed #0002;
}
.tron .frame::before { left: -26px; transform: rotate(-22deg); }
.tron .frame::after { right: -26px; transform: rotate(20deg); background: #c9f5dfcc; }
.tron canvas.view {
  display: block; border-radius: 6px; border: 2px solid #3a322c;
  image-rendering: crisp-edges; image-rendering: pixelated;
}

/* cuenta regresiva gigante */
.tron .cd {
  position: absolute; left: 50%; top: 50%; z-index: 3; pointer-events: none; line-height: 1;
  font-family: var(--display); font-size: clamp(5rem, 16vw, 11rem); color: var(--sun);
  -webkit-text-stroke: 6px var(--ink); paint-order: stroke fill; filter: drop-shadow(6px 7px 0 var(--sheet));
  transform: translate(-50%, -50%) rotate(-6deg); animation: tron-cd 1s var(--ease-pop) both;
}
.tron .cd.n2 { color: var(--tomato); }
.tron .cd.n1 { color: var(--mint); }
.tron .cd.go { color: var(--sheet); filter: drop-shadow(6px 7px 0 var(--tomato)); font-size: clamp(4rem, 12vw, 8rem); animation-duration: .65s; }
.tron .cd[hidden] { display: none; }
@keyframes tron-cd {
  0% { transform: translate(-50%, -50%) scale(.2) rotate(-25deg); opacity: 0; }
  35% { transform: translate(-50%, -50%) scale(1.08) rotate(-4deg); opacity: 1; }
  80% { transform: translate(-50%, -50%) scale(1) rotate(-6deg); opacity: 1; }
  100% { transform: translate(-50%, -50%) scale(.85) rotate(-6deg); opacity: 0; }
}

.tron .banner {
  position: absolute; left: 50%; top: 42%; z-index: 3; pointer-events: none; white-space: nowrap; max-width: 92%; overflow: hidden; text-overflow: ellipsis;
  font-family: var(--pixel); font-size: clamp(1.3rem, 3.4vw, 2.4rem); line-height: 1.15;
  padding: 10px 26px 12px; border: 4px solid var(--ink); border-radius: 10px; box-shadow: 6px 6px 0 var(--ink);
  background: var(--c, var(--sheet)); color: var(--on-c, var(--ink));
  transform: translate(-50%, -50%) rotate(-3deg); animation: tron-pop .5s var(--ease-pop) both;
}
.tron .banner.draw { background: var(--sheet); color: var(--ink); transform: translate(-50%, -50%) rotate(2deg); }
.tron .banner[hidden] { display: none; }
@keyframes tron-pop { from { transform: translate(-50%, -50%) scale(.4) rotate(-12deg); opacity: 0; } }

/* ayuda */
.tron .help { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 12px 22px; margin: 22px auto 0; max-width: 940px; text-align: center; }
.tron .role {
  display: inline-flex; align-items: center; gap: 9px; padding: 4px 14px 4px 8px; min-height: 40px; font-weight: 800;
  background: var(--c-soft, var(--sheet)); border: var(--stroke); border-radius: 10px; box-shadow: var(--shadow);
}
.tron .keys { display: inline-flex; align-items: center; flex-wrap: wrap; justify-content: center; gap: 5px; font-weight: 700; }
.tron .keys em { font-style: normal; color: var(--ink-soft); margin: 0 4px; }
.tron kbd {
  display: inline-grid; place-items: center; min-width: 30px; height: 30px; padding: 0 7px;
  font-family: var(--pixel); font-size: 1rem; line-height: 1;
  background: var(--sheet); border: 2px solid var(--ink); border-bottom-width: 5px; border-radius: 7px;
}
.tron .hint { flex-basis: 100%; color: var(--ink-soft); font-size: .95rem; }

/* fin */
.tron .tron-end { overflow: hidden; }
.tron .trophy { display: flex; justify-content: center; margin-bottom: 10px; }
.tron .trophy .sw { width: 64px; height: 64px; border-width: 4px; box-shadow: inset -10px -10px 0 #1f1a1733, inset 10px 10px 0 #ffffff88, 5px 5px 0 var(--ink); transform: rotate(-8deg); animation: tron-pop2 .7s var(--ease-pop) both; }
@keyframes tron-pop2 { from { transform: scale(.2) rotate(-40deg); } }
.tron .tron-score { list-style: none; padding: 0; margin: 0 auto 22px; display: flex; flex-direction: column; gap: 8px; max-width: 320px; }
.tron .tron-score li {
  display: flex; align-items: center; gap: 10px; padding: 6px 12px; text-align: left;
  background: var(--c-soft); border: var(--stroke); border-radius: 10px; box-shadow: 3px 3px 0 var(--ink);
}
.tron .tron-score li b { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tron .tron-score li:first-child { transform: rotate(-1.5deg) scale(1.04); }
.tron .tron-end h3 { margin-top: 14px; }

.tron-confetti { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.tron-confetti i {
  position: absolute; top: -20px; width: 10px; height: 14px; border: 2px solid var(--ink);
  animation: tron-fall 3s linear both;
}
@keyframes tron-fall { to { transform: translate(var(--dx), 110vh) rotate(var(--rot)); } }

@media (max-width: 860px) {
  .tron-hud, .tron .riders { justify-content: center; }
  .tron .frame::before, .tron .frame::after { display: none; }
}

/* --- controles táctiles (tablet) --- */
.tron .tc-toggle { padding: 6px 12px; font-size: .85rem; box-shadow: 2px 2px 0 var(--ink); }
.tron .tc-toggle[aria-pressed="true"] { background: var(--sun); }
.tron.spec .tc-toggle, .tron.spec .tpad { display: none !important; }
.tron.touch { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
.tron.touch .stage { max-width: none; } /* la regla global de .stage (pintar) achica de más en tablet */
.tron.touch .frame, .tron.touch canvas.view { touch-action: none; -webkit-tap-highlight-color: transparent; }
.tron.touch .help .keys { display: none; }
.tron .tpad { display: none; }
.tron.touch .tpad {
  display: flex; align-items: center; justify-content: space-between; gap: 16px; margin: 18px auto 0; max-width: 940px;
  touch-action: none; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; -webkit-tap-highlight-color: transparent;
}
/* horizontal: el pad abajo a la izquierda y la arena corrida a la derecha para que no se tapen */
.tron.touch.land .stage, .tron.touch.land .help { padding-left: 222px; }
.tron.touch.land .tpad {
  position: fixed; z-index: 30; left: max(16px, env(safe-area-inset-left)); bottom: max(16px, env(safe-area-inset-bottom)); margin: 0;
}
.tron.touch.land .tp-notes { display: none; }
.tron .tp-dpad {
  position: relative; display: grid; grid-template: repeat(3, 66px) / repeat(3, 66px); gap: 3px; flex: none; touch-action: none;
  padding: 6px; background: color-mix(in srgb, var(--sheet) 55%, transparent); border: var(--stroke); border-radius: 50%; box-shadow: var(--shadow);
}
.tron .tp-key {
  display: grid; place-items: center; color: var(--sheet); pointer-events: none;
  background: color-mix(in srgb, var(--sheet) 85%, transparent); border: var(--stroke); border-radius: var(--r-sm); box-shadow: 3px 3px 0 var(--ink);
  transition: transform .08s, box-shadow .08s, background-color .08s;
}
.tron .tp-key svg { width: 38px; height: 38px; }
.tron .tp-key.d0 { grid-area: 1 / 2; }
.tron .tp-key.d1 { grid-area: 2 / 3; }
.tron .tp-key.d2 { grid-area: 3 / 2; }
.tron .tp-key.d3 { grid-area: 2 / 1; }
.tron .tp-hub { grid-area: 2 / 2; margin: 14px; border-radius: 50%; background: var(--c, var(--ink-soft)); border: var(--stroke); pointer-events: none; }
.tron .tp-key.on { background: var(--sun); box-shadow: 0 0 0 var(--ink); transform: translate(3px, 3px); }
.tron .tp-notes { display: flex; flex-direction: column; align-items: flex-end; gap: 12px; }
.tron .tp-notes p {
  margin: 0; padding: 6px 12px; font-weight: 800; font-size: .92rem; text-align: center; max-width: 280px;
  background: var(--sheet); border: var(--stroke); border-radius: var(--r-sm); box-shadow: var(--shadow); transform: rotate(1.5deg);
}
.tron .tp-notes .tp-rot { background: var(--sun); transform: rotate(-2deg); animation: tron-rot .5s var(--ease-pop) both; }
@keyframes tron-rot { from { transform: scale(.5) rotate(-10deg); opacity: 0; } }
@media (prefers-reduced-motion: reduce) {
  .tron .tp-key { transition: none; }
  .tron .tp-notes .tp-rot { animation: none; }
}
