/* ELITSLOTS AGENT ROLL - FINAL LAYOUT
   Existing ELITSLOTS header is untouched. The game scene uses one clean Nuke background.
*/
:root {
    --ar-purple: #8b4dff;
    --ar-purple-2: #bb78ff;
    --ar-purple-3: #d9b2ff;
    --ar-panel: rgba(10, 12, 26, .94);
    --ar-panel-2: rgba(19, 20, 43, .88);
    --ar-border: rgba(150, 77, 255, .72);
    --ar-text: #f8f7ff;
    --ar-dim: #a7adc3;
    --ar-win: #38e795;
    --ar-lose: #ff4d68;
}

body.agent-roll-body {
    margin: 0;
    min-height: 100vh;
    overflow-x: hidden;
    background: #080b18;
}

.agent-roll-page {
    position: relative;
    width: 100%;
    padding: 0;
    margin: 0;
    isolation: isolate;
}

.agent-roll-stage {
    position: relative;
    width: 100%;
    min-height: calc(100vh - 120px);
    overflow: hidden;
    background-image: url('../images/agents/agent-roll-bg-clean.png');
    background-position: center top;
    background-repeat: no-repeat;
    background-size: cover;
    background-color: #10182b;
}

.agent-roll-stage::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, rgba(3, 6, 17, .08), rgba(5, 7, 15, .06) 55%, rgba(4, 6, 13, .16));
    pointer-events: none;
    z-index: 1;
}

/* ---------------------------------------------------------
   Result panels: the panel frames are already baked into the scene.
   We only paint their contents.
--------------------------------------------------------- */
.agent-result-stack {
    position: absolute;
    left: 2.35%;
    top: 38.85%;
    width: 14.25%;
    height: 60.55%;
    z-index: 4;
    display: grid;
    grid-template-rows: repeat(3, 1fr);
    gap: 1.65%;
    pointer-events: none;
}

.agent-result-panel {
    display: grid;
    grid-template-columns: 31% minmax(0, 1fr);
    align-items: center;
    gap: 5%;
    min-width: 0;
    min-height: 0;
    padding: 6px 9px 6px 11px;
    box-sizing: border-box;
    overflow: hidden;
}

.result-piece {
    position: relative;
    width: 100%;
    height: 78%;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    border-radius: 8px;
}

.result-piece img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    filter: drop-shadow(0 8px 14px rgba(0,0,0,.45));
}

.result-piece .initials {
    width: 100%;
    height: 100%;
    display: grid;
    place-items: center;
    border-radius: 8px;
    color: #9da5bf;
    background: rgba(255,255,255,.03);
    font-weight: 900;
    font-size: clamp(10px, 1vw, 16px);
}

.result-copy {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.result-copy small {
    display: none;
}

.result-copy strong {
    color: #eef0fb;
    font-size: clamp(8px, .64vw, 12px);
    font-weight: 900;
    line-height: 1.1;
    max-height: 2.3em;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ---------------------------------------------------------
   Capsule roll windows - transparent over the baked machine.
--------------------------------------------------------- */
    .agent-roll-machine {
        position: absolute;
        left: 18.7%;
        top: 30.1%;
        width: 20.0%;
        height: 65.0%;
        z-index: 5;
        pointer-events: none;
}

.capsule-levels {
    position: absolute;
    inset: 0;
}

.capsule-level {
    position: absolute;
    left: 13%;
    width: 74%;
    height: 25.7%;
    overflow: hidden;
    border-radius: 22px;
}

.capsule-level:nth-child(1) { top: 0; }
.capsule-level:nth-child(2) { top: 30.7%; }
.capsule-level:nth-child(3) { top: 65.4%; }

.capsule-level::after {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    top: 50%;
    height: 2px;
    transform: translateY(-50%);
    background: linear-gradient(90deg, transparent, rgba(209, 170, 255, .72), transparent);
    opacity: 0;
    z-index: 3;
    pointer-events: none;
}

.capsule-placeholder {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    color: rgba(228, 211, 255, .78);
    font-size: clamp(54px, 4.2vw, 82px);
    font-weight: 900;
    text-shadow: 0 0 18px rgba(178, 108, 255, .55);
    opacity: 1;
    transition: opacity .18s ease;
    z-index: 2;
}

.capsule-level.is-spinning .capsule-placeholder,
.capsule-level.is-stopped .capsule-placeholder {
    opacity: 0;
}

.agent-strip-window {
    position: absolute;
    inset: 0;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

.agent-strip {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    will-change: transform;
}

.agent-strip-item {
    width: 100%;
    height: 88px;
    flex: 0 0 88px;
    display: grid;
    grid-template-rows: 64px 24px;
    justify-items: center;
    align-items: center;
    color: #f1eaff;
    opacity: .93;
    filter: drop-shadow(0 6px 12px rgba(0,0,0,.35));
}

.agent-strip-item.is-result {
    opacity: 1;
}

.agent-piece {
    width: 78px;
    height: 58px;
    display: grid;
    place-items: center;
}

.agent-piece img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.agent-piece-fallback {
    width: 48px;
    height: 48px;
    display: grid;
    place-items: center;
    border-radius: 10px;
    background: rgba(12, 15, 29, .72);
    color: #bfa8ff;
    font-size: 12px;
    font-weight: 900;
}

.agent-strip-name {
    width: 92%;
    overflow: hidden;
    color: rgba(236, 226, 255, .80);
    font-size: 8px;
    font-weight: 800;
    line-height: 1;
    text-align: center;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ---------------------------------------------------------
   HUD on the right - HTML, not baked into the background.
--------------------------------------------------------- */
.agent-roll-badge {
    position: absolute;
    top: 14.3%;
    right: 4.2%;
    z-index: 6;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 13px;
    border: 1px solid rgba(159, 87, 255, .62);
    border-radius: 999px;
    background: rgba(15, 7, 33, .78);
    color: #e6dcff;
    font-size: clamp(9px, .65vw, 12px);
    font-weight: 900;
    letter-spacing: .07em;
    box-shadow: 0 8px 24px rgba(0,0,0,.24);
}

.agent-roll-hud {
    position: absolute;
    top: 19.8%;
    right: 3.1%;
    width: min(27.6%, 470px);
    z-index: 6;
    padding: 16px;
    border: 1px solid rgba(151, 79, 255, .70);
    border-radius: 18px;
    background: linear-gradient(180deg, rgba(6, 8, 19, .96), rgba(10, 12, 26, .95));
    box-shadow: 0 26px 60px rgba(0,0,0,.34), inset 0 0 0 1px rgba(255,255,255,.025);
    box-sizing: border-box;
}

.hud-top {
    display: grid;
    grid-template-columns: 44px 1fr;
    gap: 12px;
    align-items: center;
}

.hud-title-icon {
    width: 44px;
    height: 44px;
    display: grid;
    place-items: center;
    border-radius: 14px;
    background: rgba(108, 45, 223, .22);
    color: var(--ar-purple-2);
    border: 1px solid rgba(161, 91, 255, .35);
    font-size: 20px;
}

.hud-top h2 {
    margin: 0;
    color: var(--ar-text);
    font-size: clamp(18px, 1.65vw, 28px);
    line-height: 1;
    font-weight: 1000;
}

.hud-top p {
    margin: 5px 0 0;
    color: #b4b9ca;
    font-size: clamp(9px, .74vw, 13px);
    line-height: 1.35;
}

.stake-card {
    position: relative;
    margin-top: 14px;
    padding: 14px 14px 13px;
    border: 1px solid rgba(255,255,255,.07);
    border-radius: 13px;
    background: rgba(10, 13, 28, .72);
}

.stake-card small {
    display: block;
    color: #8f95ac;
    font-size: 8px;
    font-weight: 900;
    letter-spacing: .16em;
}

.stake-card strong {
    display: block;
    margin-top: 2px;
    color: #ffffff;
    font-size: clamp(22px, 2vw, 34px);
    line-height: 1;
    font-weight: 1000;
}

.stake-card span {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: #c29aff;
    font-size: 9px;
    font-weight: 900;
}

.agent-roll-options {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 9px;
    margin-top: 10px;
}

.agent-roll-option {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    min-width: 0;
    padding: 10px 12px;
    border: 1px solid rgba(255,255,255,.1);
    border-radius: 10px;
    background: rgba(10,13,28,.78);
    color: #fff;
    cursor: pointer;
    transition: border-color .16s ease, background .16s ease, box-shadow .16s ease;
}

.agent-roll-option strong { font-size: 18px; font-weight: 1000; }
.agent-roll-option small { color: #9da3bb; font-size: 8px; font-weight: 900; letter-spacing: .08em; }
.agent-roll-option.is-selected { border-color: #a45bff; background: rgba(126,57,255,.2); box-shadow: 0 0 16px rgba(126,57,255,.2); }
.agent-roll-option.is-selected small { color: #d2b0ff; }
.agent-roll-option:disabled { opacity: .55; cursor: not-allowed; }

.agent-roll-btn {
    width: 100%;
    margin-top: 12px;
    min-height: 48px;
    border: 1px solid rgba(191, 115, 255, .72);
    border-radius: 12px;
    background: linear-gradient(135deg, #7e39ff, #b36aff);
    color: #fff;
    font-size: clamp(12px, .86vw, 16px);
    font-weight: 1000;
    letter-spacing: .03em;
    cursor: pointer;
    box-shadow: 0 10px 28px rgba(108, 44, 214, .27);
    transition: transform .16s ease, filter .16s ease, opacity .16s ease;
}

.agent-roll-btn:hover:not(:disabled) { transform: translateY(-1px); filter: brightness(1.05); }
.agent-roll-btn:disabled { opacity: .46; cursor: not-allowed; }

.hud-panel {
    margin-top: 12px;
    padding: 13px;
    border: 1px solid rgba(255,255,255,.065);
    border-radius: 13px;
    background: rgba(8, 11, 24, .67);
}

.hud-panel-head {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    align-items: center;
    margin-bottom: 9px;
}

.hud-panel-head strong {
    color: #f2f0fb;
    font-size: clamp(10px, .72vw, 13px);
    font-weight: 1000;
    letter-spacing: .08em;
}

.hud-panel-head span {
    color: #656c82;
    font-size: 8px;
    font-weight: 900;
    letter-spacing: .10em;
}

.history {
    display: grid;
    gap: 7px;
}

.history-row,
.history-empty {
    min-height: 34px;
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: center;
    gap: 8px;
    padding: 0 9px;
    border-radius: 8px;
    background: rgba(16, 19, 36, .66);
}

.history-row.win { border-left: 2px solid var(--ar-win); }
.history-row.lose { border-left: 2px solid var(--ar-lose); }

.history-result {
    justify-self: end;
    font-size: 8px;
    font-weight: 1000;
    letter-spacing: .08em;
}

.history-row.win .history-result { color: var(--ar-win); }
.history-row.lose .history-result { color: var(--ar-lose); }

.history-content {
    min-width: 0;
    overflow: hidden;
    color: #d8dbea;
    font-size: 9px;
    font-weight: 800;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.history-time {
    color: #71788f;
    font-size: 8px;
    font-weight: 700;
}

.history-empty { color: #4b5269; }
.history-empty > span:first-child { width: 20px; height: 20px; border-radius: 50%; background: rgba(255,255,255,.04); }
.history-empty > span:last-child { color: #5d6479; justify-self: end; font-weight: 900; }

.agent-rule {
    margin: 11px 2px 0;
    color: #6e758d;
    font-size: 8px;
    line-height: 1.5;
}

.agent-rule strong { color: #b987ff; }

/* Transparent hit zone over the lever baked into the background. */
.agent-lever {
    position: absolute;
    left: 42.7%;
    bottom: 4.5%;
    width: 11.8%;
    height: 21%;
    z-index: 7;
    border: 0;
    background: transparent;
    cursor: pointer;
}

.agent-roll-status {
    position: absolute;
    left: 36.1%;
    bottom: 4.2%;
    z-index: 7;
    padding: 9px 14px;
    border: 1px solid rgba(144, 77, 255, .42);
    border-radius: 999px;
    background: rgba(7, 10, 22, .78);
    color: #d5c8f1;
    font-size: clamp(8px, .64vw, 11px);
    font-weight: 900;
    letter-spacing: .06em;
    text-transform: uppercase;
}

.agent-roll-status.win { color: #8effc1; border-color: rgba(56,231,149,.45); }
.agent-roll-status.lose { color: #ff9dac; border-color: rgba(255,77,104,.42); }

/* ---------------------------------------------------------
   Motion
--------------------------------------------------------- */
.agent-roll-stage.is-rolling::before {
    content: '';
    position: absolute;
    left: 20.2%;
    top: 22.8%;
    width: 21.2%;
    height: 50%;
    z-index: 3;
    border-radius: 24px;
    box-shadow: 0 0 0 1px rgba(172, 112, 255, .10), 0 0 42px rgba(167, 89, 255, .18);
    pointer-events: none;
}

.agent-roll-stage.is-win::before {
    box-shadow: 0 0 0 1px rgba(56,231,149,.35), 0 0 58px rgba(56,231,149,.30);
}

.agent-roll-stage.lever-pulled .agent-lever {
    transform: translateY(4px) rotate(2deg);
}

@media (max-width: 1180px) {
    .agent-roll-stage { min-height: 780px; background-size: auto 100%; }
    .agent-roll-hud { width: min(31%, 420px); }
    .agent-roll-badge { right: 3.2%; }
    .agent-result-stack { left: 2.1%; width: 17%; }
    .agent-roll-machine { left: 24%; width: 24%; }
}

@media (max-width: 900px) {
    .agent-roll-stage {
        min-height: 920px;
        background-size: cover;
        background-position: 35% top;
    }
    .agent-result-stack { left: 2%; top: 25%; width: 26%; height: 46%; }
    .agent-roll-machine { left: 31%; top: 23%; width: 31%; height: 49%; }
    .agent-roll-hud { top: 72%; left: 4%; right: 4%; width: auto; }
    .agent-roll-badge { top: 69%; right: 4%; }
    .agent-lever { left: 57%; bottom: 25%; width: 19%; height: 15%; }
    .agent-roll-status { left: 38%; bottom: 23%; }
}

@media (prefers-reduced-motion: reduce) {
    .agent-roll-btn,
    .capsule-placeholder,
    .agent-roll-stage * { transition: none !important; }
}
