.rg-cell::before,
.rg-cell::after {
  content: '';
  position: absolute;
  inset: 0;
  opacity: 0;
  transition: opacity 100ms linear;
  pointer-events: none;
}

.rg-cell::before {
  background:
    linear-gradient(135deg, transparent 47%, rgba(255,255,255,0.45) 48%, rgba(255,255,255,0.45) 52%, transparent 53%),
    linear-gradient(45deg, transparent 44%, rgba(255,255,255,0.32) 45%, rgba(255,255,255,0.32) 49%, transparent 50%),
    linear-gradient(90deg, transparent 68%, rgba(255,255,255,0.22) 69%, rgba(255,255,255,0.22) 71%, transparent 72%);
}

.rg-cell::after {
  background:
    radial-gradient(circle at 50% 50%, rgba(9,20,35,0.85), rgba(7,14,24,0.96) 58%, rgba(0,0,0,0.98) 100%),
    radial-gradient(circle at 50% 40%, rgba(255,255,255,0.12), rgba(255,255,255,0) 55%);
  transform: scale(0.2);
  transform-origin: 50% 50%;
  transition: transform 120ms ease-out, opacity 120ms ease-out;
}

.rg-cell.crack-1::before { opacity: 0.28; }
.rg-cell.crack-2::before { opacity: 0.52; }
.rg-cell.crack-3::before { opacity: 0.78; }
.rg-cell.crack-4::before { opacity: 1; }
.rg-cell.broken::before { opacity: 0; }
.rg-cell.broken::after { opacity: 1; transform: scale(1); }

#ringgrab-mp-rings,
#ringgrab-mp-chao-container { z-index: 2; }


/* ============================================================
   Race arena shell / track layering ownership
   Migrated from 15-face-editor.css and 14-trail-c.css
   Keep race root-shell, layering, and vertical track fixes under
   minigame arena ownership instead of unrelated owner files.
   ============================================================ */
.race-arena-root {
  display: flex !important;
  flex-direction: column !important;
  overflow: hidden !important;
}

.race-arena-root > .panel-header {
  flex: 0 0 auto !important;
}

.race-arena-root > .panel-body,
.race-arena-root .race-panel-body {
  position: relative !important;
  display: block !important;
  flex: 1 1 auto !important;
  width: 100% !important;
  height: auto !important;
  min-width: 0 !important;
  min-height: 0 !important;
  margin: 0 !important;
  padding: 0 !important;
  overflow: hidden !important;
  background: transparent !important;
}

.race-arena-root canvas {
  display: block !important;
  position: absolute !important;
  inset: 0 !important;
  width: 100% !important;
  height: 100% !important;
  max-width: none !important;
  max-height: none !important;
  margin: 0 !important;
  background-position: center center !important;
  background-repeat: no-repeat !important;
  background-size: 100% 100% !important;
  z-index: 1 !important;
}

.race-arena-root [id$="-chao-container"] {
  position: absolute !important;
  inset: 0 !important;
  width: 100% !important;
  height: 100% !important;
  max-width: none !important;
  max-height: none !important;
  margin: 0 !important;
  overflow: hidden !important;
  pointer-events: none !important;
  z-index: 2 !important;
}

.race-arena-root :is(#race3-result, #race4-result, #race-multiplayer-result) {
  position: absolute !important;
  left: 12px !important;
  bottom: 10px !important;
  right: auto !important;
  margin: 0 !important;
  z-index: 5 !important;
  text-align: left !important;
  pointer-events: none !important;
}

.race-arena-root .arena-footer {
  position: absolute !important;
  inset-inline: 0 !important;
  bottom: 0 !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  gap: 8px !important;
  min-height: 0 !important;
  margin: 0 !important;
  padding: 8px 12px !important;
  box-sizing: border-box !important;
  z-index: 6 !important;
  pointer-events: none !important;
}

.race-arena-root .arena-footer > * {
  pointer-events: auto !important;
}

#race4-arena-panel.race-arena-root > .panel-body {
  display: block !important;
  position: relative !important;
  overflow: hidden !important;
  background: #000 !important;
}

#race4-canvas,
#race4-chao-container {
  inset: auto !important;
  width: 460px !important;
  height: 1980px !important;
  max-width: none !important;
  max-height: none !important;
}

/* ============================================================
   Active minigame background ownership
   Keep core arena / track art out of dormant legacy shards.
   ============================================================ */
#race-canvas {
  background: url("../assets/bgs/bg_chaorace1.png") no-repeat center/cover !important;
}

#race3-canvas,
#race-multiplayer-canvas {
  background: url("../assets/bgs/bg_chaorace3.png") no-repeat center/cover !important;
}

#race4-canvas {
  background: url("../assets/bgs/bg_chaorace4.png") no-repeat center/cover !important;
}

#karate-canvas,
#karate2-canvas,
.karate-arena-canvas {
  background: url("../assets/bgs/bg_karate.png") no-repeat center/cover !important;
}


/* ============================================================
   Pass 9 — migrated arena fit ownership from 19-panel-fit-helpers.css
   Keep arena-specific shells, body fit, z-order, and special-case
   gameplay panel dimensions under minigame arena ownership.
   ============================================================ */

#karate-mp-panel {
  width: 1000px;
  height: 680px;
  left: auto;
  top: auto;
  transform: none;
  padding: 0;
  overflow: hidden;
  z-index: 9400;
}

#karate-mp-panel > .panel-body {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
}

#class-arena-panel,
#karate-arena-panel,
#karate2-arena-panel {
  width: 760px;
  height: 560px;
  overflow: hidden;
}

#class-arena-panel > .panel-body,
#karate-arena-panel > .panel-body,
#karate2-arena-panel > .panel-body {
  position: relative;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  padding: 0;
  overflow: hidden;
}

/* Race live HUD / timer strip */
.race-arena-root > .panel-body,
.race-arena-root .race-panel-body {
  position: relative;
}

.race-live-hud {
  position: absolute !important;
  inset: 0 !important;
  pointer-events: none !important;
  z-index: 900 !important;
  font-family: system-ui, sans-serif;
  visibility: visible !important;
  opacity: 1 !important;
}

.race-live-timer {
  position: absolute;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  min-width: 128px;
  padding: 6px 14px;
  border-radius: 14px;
  background: linear-gradient(180deg, rgba(12, 23, 37, 0.92), rgba(6, 12, 22, 0.96));
  border: 1px solid rgba(255, 255, 255, 0.18);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.26);
  color: #fff7cd;
  font-size: 28px;
  font-weight: 900;
  line-height: 1;
  letter-spacing: 0.03em;
  text-align: center;
  text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.72);
}

.race-live-standings {
  position: absolute !important;
  top: 10px !important;
  left: 10px !important;
  z-index: 902 !important;
  display: flex !important;
  flex-direction: column !important;
  gap: 6px !important;
  width: 224px !important;
  max-width: min(224px, calc(50% - 18px)) !important;
  max-height: calc(100% - 20px) !important;
  overflow: hidden !important;
  visibility: visible !important;
  opacity: 1 !important;
}

.race-live-hud-slot {
  min-height: 52px;
  display: grid !important;
  grid-template-columns: 42px 46px minmax(0, 1fr);
  align-items: center;
  gap: 6px;
  padding: 5px 7px;
  border-radius: 14px;
  background: linear-gradient(180deg, rgba(14, 24, 38, 0.94), rgba(6, 11, 19, 0.98));
  border: 1px solid rgba(255, 255, 255, 0.16);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.24);
  color: #edf6ff;
  overflow: hidden;
}

.race-live-hud-slot.is-finished {
  border-color: rgba(255, 238, 156, 0.78);
  box-shadow: 0 0 0 1px rgba(255, 238, 156, 0.25), 0 6px 16px rgba(0, 0, 0, 0.26);
}

.race-live-hud-rank {
  color: #fff0ab;
  font-size: 18px;
  font-weight: 900;
  line-height: 1;
  text-align: center;
  text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.72);
}

.race-live-hud-portrait {
  width: 42px;
  height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.race-live-hud-chao {
  image-rendering: pixelated;
  max-width: none;
  max-height: none;
}

.race-live-hud-portrait-fallback {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  color: #fff7cd;
  font-size: 18px;
  font-weight: 900;
}

.race-live-hud-info {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.race-live-hud-primary,
.race-live-hud-secondary,
.race-live-hud-runner-time {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.race-live-hud-primary {
  color: #ffffff;
  font-size: 12px;
  font-weight: 900;
  line-height: 1.05;
}

.race-live-hud-secondary {
  color: #bfe6ff;
  font-size: 11px;
  font-weight: 800;
  line-height: 1.05;
}

.race-live-hud-runner-time {
  color: #fff7cd;
  font-size: 15px;
  font-weight: 900;
  line-height: 1.1;
  letter-spacing: 0.02em;
}

#race4-arena-panel .race-live-standings {
  width: 220px !important;
}

#race4-arena-panel .race-live-timer {
  top: 12px;
}
