/* PokéDash — vue intégrée #pokedash */
#pokedashRoot {
    width: var(--ppbro-page-w, 980px);
    max-width: 100%;
    margin: 0 auto;
    font-family: "Segoe UI", system-ui, sans-serif;
    --pd-text: #eef6ea;
    --pd-border: rgba(120, 180, 100, 0.4);
    --pd-view-bg: #142218;
    --pd-shadow: rgba(70, 140, 60, 0.18);
    --pd-btn-border: rgba(180, 220, 150, 0.35);
    --pd-btn-bg: rgba(10, 24, 12, 0.72);
    --pd-btn-fg: #e8f6df;
    --pd-active-a: #9ee05f;
    --pd-active-b: #4a9a2c;
    --pd-active-fg: #0e1a08;
    --pd-hud-bg: rgba(8, 20, 10, 0.45);
    --pd-hud-border: rgba(160, 210, 140, 0.28);
    --pd-cd: #f4ffe8;
    --pd-cd-go: #d8ff8a;
    --pd-overlay: linear-gradient(to top, rgba(8, 18, 8, 0.62), transparent 48%);
    --pd-ctrl-border: #5a7a52;
    --pd-board-bg: rgba(8, 20, 10, 0.55);
    color: var(--pd-text);
    padding: 8px 0 20px;
}
#pokedashRoot.theme-halloween {
    --pd-text: #f3eef8;
    --pd-border: rgba(167, 139, 250, 0.35);
    --pd-view-bg: #120e1a;
    --pd-shadow: rgba(124, 58, 237, 0.18);
    --pd-btn-border: rgba(200, 170, 255, 0.35);
    --pd-btn-bg: rgba(20, 12, 32, 0.75);
    --pd-btn-fg: #f3eef8;
    --pd-active-a: #f0a54a;
    --pd-active-b: #c45e18;
    --pd-active-fg: #1a0e06;
    --pd-hud-bg: rgba(12, 8, 20, 0.5);
    --pd-hud-border: rgba(180, 150, 255, 0.28);
    --pd-cd: #fff7e8;
    --pd-cd-go: #ffe08a;
    --pd-overlay: linear-gradient(to top, rgba(8, 4, 14, 0.55), transparent 45%);
    --pd-ctrl-border: #6b5a8a;
    --pd-board-bg: rgba(12, 8, 20, 0.6);
}
#pokedashRoot .pd-titleBar {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    flex-wrap: wrap;
    margin: 4px 0 10px;
}
#pokedashRoot h1 {
    margin: 0;
    font-size: 22px;
    font-weight: 900;
    letter-spacing: 0.04em;
    color: var(--pd-text);
    background: var(--pd-btn-bg);
    border: 1px solid var(--pd-btn-border);
    border-radius: 999px;
    padding: 7px 18px;
    box-shadow: 0 4px 14px var(--pd-shadow);
}
#themePick {
    display: flex;
    gap: 6px;
}
#themePick[hidden] { display: none !important; }
#themePick button {
    border: 1px solid var(--pd-btn-border);
    border-radius: 999px;
    padding: 5px 12px;
    font-weight: 800;
    font-size: 12px;
    cursor: pointer;
    background: var(--pd-btn-bg);
    color: var(--pd-btn-fg);
}
#themePick button.active {
    background: linear-gradient(180deg, var(--pd-active-a), var(--pd-active-b));
    color: var(--pd-active-fg);
    border-color: transparent;
}
#pokedashRoot .pd-hud {
    display: inline-flex;
    align-items: center;
    font-weight: 800;
    font-size: 14px;
    margin: 0 0 10px;
    color: var(--pd-text);
    background: var(--pd-btn-bg);
    border: 1px solid var(--pd-btn-border);
    border-radius: 999px;
    padding: 6px 14px;
    box-shadow: 0 4px 14px var(--pd-shadow);
}
#pdView {
    position: relative;
    width: 100%;
    height: 480px;
    min-height: 360px;
    border: 2px solid var(--pd-border);
    border-radius: 14px;
    overflow: hidden;
    background: var(--pd-view-bg);
    box-shadow: 0 0 28px var(--pd-shadow);
    touch-action: none;
}
#pdView canvas { display: block; width: 100% !important; height: 100% !important; }
#lootHud {
    position: absolute;
    top: 10px;
    right: 12px;
    z-index: 6;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 6px;
    pointer-events: none;
    font-weight: 800;
    font-size: 14px;
    text-shadow: 0 1px 3px rgba(0,0,0,0.65);
}
#lootHud .row {
    display: flex;
    align-items: center;
    gap: 7px;
    background: var(--pd-hud-bg);
    border: 1px solid var(--pd-hud-border);
    border-radius: 999px;
    padding: 4px 10px 4px 6px;
}
#lootHud .row[hidden] { display: none !important; }
#lootHud img { width: 22px; height: 22px; object-fit: contain; display: block; }
#pdCountdown {
    position: absolute;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    pointer-events: none;
    z-index: 5;
    font-size: clamp(48px, 12vw, 96px);
    font-weight: 900;
    color: var(--pd-cd);
    text-shadow: 0 0 24px var(--pd-shadow), 0 4px 0 rgba(0,0,0,0.35);
}
#pdCountdown.show { display: flex; }
#pdCountdown.go { color: var(--pd-cd-go); }
#pdOverlay {
    position: absolute;
    inset: 0;
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
    gap: 12px;
    padding-bottom: 22px;
    background: var(--pd-overlay);
    z-index: 4;
}
#pdOverlay.show { display: flex; }
#charPick {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
}
#charPick button {
    border: 1px solid var(--pd-btn-border);
    border-radius: 999px;
    padding: 8px 14px;
    font-weight: 800;
    font-size: 13px;
    cursor: pointer;
    background: var(--pd-btn-bg);
    color: var(--pd-btn-fg);
}
#charPick button.active {
    background: linear-gradient(180deg, var(--pd-active-a), var(--pd-active-b));
    color: var(--pd-active-fg);
    border-color: transparent;
}
#pdBegin {
    border: none;
    border-radius: 999px;
    padding: 14px 34px;
    font-weight: 900;
    font-size: 16px;
    cursor: pointer;
    background: linear-gradient(180deg, var(--pd-active-a), var(--pd-active-b));
    color: var(--pd-active-fg);
    box-shadow: 0 8px 22px var(--pd-shadow);
}
.pd-lane-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 7;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    border: 2px solid var(--pd-btn-border);
    background: var(--pd-btn-bg);
    color: var(--pd-text);
    font-size: 22px;
    font-weight: 900;
    line-height: 1;
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.45);
}
/* Flèches overlay visibles pendant la run (mobile / tactile) */
.pd-lane-btn.show { display: flex; }
.pd-lane-btn:active { background: rgba(0, 0, 0, 0.7); transform: translateY(-50%) scale(0.96); }
.pd-lane-left { left: 10px; }
.pd-lane-right { right: 10px; }
/* PC souris : masquer les flèches à l'écran (sauf si racine forcée pd-touch) */
@media (hover: hover) and (pointer: fine) {
    #pokedashRoot:not(.pd-touch) .pd-lane-btn.show { display: none !important; }
}
#lootHud .row-moti { gap: 5px; }
#lootHud .row-moti img { width: 20px; height: 20px; object-fit: contain; display: block; }
.pd-controls {
    margin-top: 12px;
    display: flex;
    gap: 48px;
    justify-content: center;
    align-items: center;
    padding: 10px 14px;
    border-radius: 16px;
    background: var(--pd-board-bg);
    border: 1px solid var(--pd-hud-border);
    box-shadow: 0 4px 14px var(--pd-shadow);
    max-width: 320px;
    margin-left: auto;
    margin-right: auto;
    box-sizing: border-box;
}
.pd-controls button {
    border-radius: 999px;
    min-width: 64px;
    min-height: 48px;
    padding: 12px 22px;
    font-weight: 800;
    font-size: 18px;
    cursor: pointer;
    background: var(--pd-btn-bg);
    border: 1px solid var(--pd-btn-border);
    color: var(--pd-text);
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
}
.pd-controls button:active {
    transform: scale(0.96);
}
.pd-board {
    margin-top: 16px;
    padding: 14px 16px 16px;
    border-radius: 14px;
    border: 1px solid var(--pd-hud-border);
    background: var(--pd-board-bg);
    text-align: center;
}
.pd-board h2 {
    margin: 0 0 10px;
    font-size: 15px;
    font-weight: 900;
    letter-spacing: 0.04em;
}
.pd-board .top3-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
    max-width: 420px;
    margin-inline: auto;
}
.pd-board .top3-list li,
#pokedashTop3 .top3-list li {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--pd-hud-bg);
    border: 1px solid var(--pd-hud-border);
    border-radius: 999px;
    padding: 8px 14px;
    font-weight: 800;
    font-size: 13px;
}
.pd-board .top3-rank { flex: 0 0 auto; }
.pd-board .top3-name {
    flex: 1 1 auto;
    text-align: left;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.pd-board .top3-dist { flex: 0 0 auto; }
.pd-board .top3-empty { justify-content: center; opacity: 0.65; font-weight: 700; }
.pd-myrecord {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--pd-hud-border);
}
.pd-myrecord-label {
    font-size: 13px;
    font-weight: 900;
    letter-spacing: 0.03em;
    margin-bottom: 6px;
    opacity: 0.9;
}
.pd-myrecord-value {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 120px;
    background: var(--pd-hud-bg);
    border: 1px solid var(--pd-hud-border);
    border-radius: 999px;
    padding: 8px 16px;
    font-weight: 900;
    font-size: 14px;
}
.pd-runhist {
    margin-top: 14px;
    padding-top: 12px;
    border-top: 1px solid var(--pd-hud-border);
    text-align: left;
}
.pd-runhist .pd-myrecord-label {
    text-align: center;
    margin-bottom: 8px;
}
.pd-runhist-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
    max-width: 480px;
    margin-inline: auto;
}
.pd-runhist-item {
    background: var(--pd-hud-bg);
    border: 1px solid var(--pd-hud-border);
    border-radius: 12px;
    padding: 8px 12px;
    font-weight: 700;
    font-size: 12px;
    line-height: 1.35;
}
.pd-runhist-main {
    font-weight: 800;
    font-size: 13px;
}
.pd-runhist-when {
    margin-top: 3px;
    opacity: 0.7;
    font-size: 11px;
    font-weight: 600;
}
.pd-runhist-empty {
    text-align: center;
    opacity: 0.65;
    font-weight: 700;
    font-size: 12px;
    padding: 8px;
}
.pd-status {
    margin-top: 8px;
    font-size: 12px;
    text-align: center;
    opacity: 0.75;
    min-height: 1em;
}

@media (max-width: 720px) {
    #pokedashRoot {
        width: 100%;
        padding: 4px 0 16px;
        box-sizing: border-box;
    }
    #pokedashRoot h1 { font-size: 18px; }
    #pokedashRoot .pd-hud { font-size: 13px; }
    #pdView {
        height: min(58vh, 420px);
        min-height: 280px;
        border-radius: 12px;
    }
    #charPick {
        gap: 10px;
        padding: 0 8px;
        max-width: 100%;
    }
    #charPick button {
        padding: 12px 16px;
        font-size: 14px;
        min-height: 44px;
        touch-action: manipulation;
        -webkit-tap-highlight-color: transparent;
    }
    #pdBegin {
        padding: 16px 40px;
        font-size: 17px;
        min-height: 48px;
        touch-action: manipulation;
    }
    #pdOverlay {
        padding-bottom: 18px;
        gap: 14px;
    }
    .pd-lane-btn {
        width: 92px;
        height: 92px;
        min-width: 92px;
        min-height: 92px;
        font-size: 36px;
        background: var(--pd-btn-bg);
        border-width: 3px;
    }
    .pd-lane-btn.show { display: flex !important; }
    .pd-lane-left { left: 6px; }
    .pd-lane-right { right: 6px; }
    /* Tactile forcé (classe JS) */
    #pokedashRoot.pd-touch .pd-lane-btn {
        width: 92px;
        height: 92px;
        min-width: 92px;
        min-height: 92px;
        font-size: 36px;
    }
    /* Sur mobile : flèches à l'écran ; barre bas en secours plus espacée */
    .pd-controls {
        gap: min(36vw, 140px);
        margin-top: 14px;
    }
    .pd-controls button {
        min-width: 72px;
        min-height: 52px;
        font-size: 20px;
    }
    .pd-board {
        margin-top: 14px;
        padding: 12px;
    }
    .pd-board h2 {
        font-size: 14px;
        letter-spacing: 0.02em;
    }
    .pd-board .top3-list {
        max-width: 100%;
        gap: 8px;
    }
    .pd-board .top3-list li,
    #pokedashTop3 .top3-list li {
        padding: 10px 12px;
        font-size: 13px;
        gap: 8px;
        border-radius: 12px;
    }
    .pd-board .top3-name {
        min-width: 0;
    }
    .pd-board .top3-dist {
        white-space: nowrap;
        font-variant-numeric: tabular-nums;
    }
    .pd-myrecord-value {
        min-width: 100px;
        width: 100%;
        box-sizing: border-box;
    }
}

@media (max-width: 420px) {
    #charPick button {
        flex: 1 1 calc(50% - 10px);
        text-align: center;
    }
    .pd-controls { gap: 28vw; }
    .pd-lane-btn,
    #pokedashRoot.pd-touch .pd-lane-btn {
        width: 84px;
        height: 84px;
        min-width: 84px;
        min-height: 84px;
        font-size: 32px;
    }
}
