html, body, #root { margin: 0; min-height: 100%; }
body { background: #eef4ff; }
* { -webkit-tap-highlight-color: transparent; }

/* ---------- stage ---------- */
.ra-stage {
    position: relative;
    width: 100%;
    height: 500px;
    min-height: 360px;
    border-radius: 18px;
    overflow: hidden;
    background: linear-gradient(#bfe0ff, #eaf4ff 62%, #dfe9f5);
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
}
.ra-canvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    display: block;
}

/* ---------- HUD ---------- */
.ra-hud { position: absolute; inset: 0; pointer-events: none; }
.ra-hud-top {
    position: absolute;
    top: 10px; left: 10px; right: 10px;
    display: flex; align-items: center; gap: 8px;
    font: 600 13px/1.2 system-ui, -apple-system, "Segoe UI", sans-serif;
    direction: rtl;
}
.ra-hp {
    position: relative;
    flex: 1;
    height: 20px;
    border-radius: 999px;
    background: rgba(255,255,255,.72);
    box-shadow: inset 0 0 0 2px rgba(20,40,70,.18);
    overflow: hidden;
}
.ra-hp i {
    display: block; height: 100%;
    background: linear-gradient(90deg, #38d47a, #7fe36a);
    transition: width .12s linear;
}
.ra-hp span {
    position: absolute; inset: 0;
    display: flex; align-items: center; justify-content: center;
    color: #123; font-size: 11px; font-weight: 700;
}
.ra-wave, .ra-score {
    padding: 4px 9px; border-radius: 999px;
    background: rgba(255,255,255,.85);
    color: #12304a; font-size: 12px; font-weight: 700;
    box-shadow: 0 1px 3px rgba(20,40,70,.18);
    white-space: nowrap;
}
.ra-weapon {
    position: absolute;
    top: 40px; right: 10px;
    padding: 4px 10px; border-radius: 999px;
    background: rgba(255,255,255,.9);
    border: 2px solid #999;
    color: #12304a; font: 700 11px/1 system-ui, sans-serif;
    direction: rtl;
}
.ra-banner {
    position: absolute;
    top: 26%; left: 50%;
    transform: translateX(-50%);
    padding: 8px 20px; border-radius: 14px;
    background: rgba(255,255,255,.92);
    color: #0f2d46; font: 800 22px/1.2 system-ui, sans-serif;
    box-shadow: 0 6px 18px rgba(20,40,70,.18);
    direction: rtl; white-space: nowrap;
}

/* ---------- controls ---------- */
.ra-stick {
    position: absolute;
    left: 16px; bottom: 16px;
    width: 116px; height: 116px;
    border-radius: 50%;
    background: rgba(255,255,255,.42);
    box-shadow: inset 0 0 0 2px rgba(20,40,70,.22);
    pointer-events: auto;
    touch-action: none;
}
.ra-stick span {
    position: absolute;
    left: 50%; top: 50%;
    width: 52px; height: 52px; margin: -26px 0 0 -26px;
    border-radius: 50%;
    background: rgba(255,255,255,.92);
    box-shadow: 0 3px 8px rgba(20,40,70,.28);
}
.ra-buttons {
    position: absolute;
    right: 14px; bottom: 16px;
    display: flex; align-items: flex-end; gap: 10px;
    direction: rtl;
}
.ra-btn {
    pointer-events: auto;
    width: 84px; height: 84px;
    border: 0; border-radius: 50%;
    font: 800 14px/1.1 system-ui, sans-serif;
    color: #fff;
    box-shadow: 0 4px 12px rgba(20,40,70,.3);
    touch-action: none;
    cursor: pointer;
}
.ra-btn.is-shoot { background: radial-gradient(circle at 35% 30%, #ff9a5a, #e8562a); }
.ra-btn.is-punch { background: radial-gradient(circle at 35% 30%, #7fb8ff, #2f6fd0); width: 72px; height: 72px; }
.ra-btn:active { transform: scale(.94); filter: brightness(.94); }

/* ---------- title / game over ---------- */
.ra-overlay {
    position: absolute;
    inset: 0;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 8px; padding: 18px;
    background: linear-gradient(180deg, rgba(233,244,255,.72), rgba(255,255,255,.9));
    direction: rtl; text-align: center;
    overflow-y: auto;
    touch-action: pan-y;
}
.ra-overlay h2 {
    margin: 0;
    font: 900 30px/1 system-ui, sans-serif;
    letter-spacing: 1px; color: #12304a;
}
.ra-overlay h2 span { color: #e8562a; margin-inline-start: 4px; }
.ra-overlay h3 { margin: 0; font: 900 26px/1 system-ui, sans-serif; color: #12304a; }
.ra-overlay p {
    margin: 0; max-width: 30ch;
    font: 500 12px/1.5 system-ui, sans-serif; color: #3a5470;
}
.ra-picker-label { font: 700 11px/1 system-ui, sans-serif; color: #5a7391; margin-top: 2px; }
.ra-picker { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; }
.ra-avatar {
    padding: 5px 10px; border-radius: 999px;
    border: 2px solid rgba(20,40,70,.16);
    background: #fff; color: #22405c;
    font: 700 11px/1 system-ui, sans-serif;
    cursor: pointer;
}
.ra-avatar.is-on { border-color: #e8562a; color: #c23f18; background: #fff2ec; }
.ra-cta {
    margin-top: 4px;
    padding: 12px 34px; border: 0; border-radius: 999px;
    background: linear-gradient(180deg, #ff8a4c, #e8562a);
    color: #fff; font: 800 16px/1 system-ui, sans-serif;
    box-shadow: 0 6px 16px rgba(232,86,42,.35);
    cursor: pointer;
}
.ra-cta:disabled { background: #b9c7d6; box-shadow: none; cursor: default; }
.ra-legend {
    display: flex; flex-wrap: wrap; gap: 6px 12px; justify-content: center;
    margin-top: 6px;
    font: 600 10px/1.3 system-ui, sans-serif; color: #456080;
}
.ra-legend span { display: inline-flex; align-items: center; gap: 4px; }
.ra-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.ra-dot.is-stick { background: #2f6fd0; }
.ra-dot.is-punch { background: #2f6fd0; }
.ra-dot.is-shoot { background: #e8562a; }
.ra-dot.is-crate { background: #d9a12a; }
.ra-over-score { font: 900 40px/1 system-ui, sans-serif; color: #e8562a; }
.ra-over-sub { font: 600 12px/1.3 system-ui, sans-serif; color: #3a5470; }
.ra-error {
    position: absolute; inset: auto 12px 12px 12px;
    padding: 10px; border-radius: 12px;
    background: #ffe9e2; color: #a02c0c;
    font: 600 12px/1.4 system-ui, sans-serif;
    direction: rtl;
}

/* ---------- fullscreen play mode ---------- */
.ra-stage.is-playing {
    border-radius: 0;
}
.ra-stage.is-playing .ra-hud-top { left: 70px; }
.ra-exit {
    position: absolute;
    top: 10px; left: 10px;
    padding: 7px 12px;
    border: 0; border-radius: 999px;
    background: rgba(255,255,255,.86);
    color: #22405c;
    font: 700 11px/1 system-ui, sans-serif;
    box-shadow: 0 1px 4px rgba(20,40,70,.2);
    pointer-events: auto;
    direction: rtl;
    cursor: pointer;
}
.ra-stage.is-playing .ra-stick {
    left: 18px;
    bottom: calc(20px + env(safe-area-inset-bottom, 0px));
}
.ra-stage.is-playing .ra-buttons {
    right: 16px;
    bottom: calc(22px + env(safe-area-inset-bottom, 0px));
}
.ra-stage.is-playing .ra-btn { width: 92px; height: 92px; }
.ra-stage.is-playing .ra-btn.is-punch { width: 78px; height: 78px; }

/* ---------- vehicle button ---------- */
.ra-car {
    position: absolute;
    right: 16px;
    bottom: calc(128px + env(safe-area-inset-bottom, 0px));
    padding: 10px 16px;
    border: 0; border-radius: 999px;
    background: rgba(255,255,255,.92);
    color: #12304a;
    font: 800 12px/1 system-ui, sans-serif;
    box-shadow: 0 4px 12px rgba(20,40,70,.25);
    pointer-events: auto;
    direction: rtl;
    cursor: pointer;
}
.ra-car.is-in { background: linear-gradient(180deg, #ffd166, #e8a52a); color: #3a2600; }

/* ---------- touch-anywhere control ---------- */
.ra-touch {
    position: absolute;
    inset: 0;
    pointer-events: auto;
    touch-action: none;
}
.ra-ghost {
    position: absolute;
    width: 124px;
    height: 124px;
    margin: -62px 0 0 -62px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.28);
    box-shadow: inset 0 0 0 2px rgba(20, 40, 70, 0.22);
    pointer-events: none;
}
.ra-ghost i {
    position: absolute;
    left: 50%;
    top: 50%;
    width: 58px;
    height: 58px;
    margin: -29px 0 0 -29px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.92);
    box-shadow: 0 3px 8px rgba(20, 40, 70, 0.28);
}
.ra-btn.is-swap {
    width: 66px;
    height: 66px;
    font-size: 12px;
    background: radial-gradient(circle at 35% 30%, #a8e6a1, #3f9e58);
}

.ra-stage { scroll-margin-top: 72px; }
