/* Prism Hopper — Simple Board Games
   Direction: a floating pyramid of crystal prisms in deep space —
   indigo night sky, prismatic gradients, glass HUD chips and glowing
   target colours. The site chrome around it stays whatever
   styles.css decides. */
:root {
    --ph-bg: #0d0a1f;
    --ph-panel: #151130;
    --ph-surface: #1b1638;
    --ph-line: #2e2757;
    --ph-text: #eef0ff;
    --ph-muted: #a29ccb;
    --ph-cyan: #5ff0c0;
    --ph-violet: #b06cff;
    --ph-pink: #ff7ad9;
    --ph-amber: #ffd166;
    --ph-danger: #ff6b7a;
    --ph-display: 'Arial Black', 'Helvetica Neue', Impact, system-ui, sans-serif;
    --ph-mono: ui-monospace, 'SFMono-Regular', Menlo, Consolas, 'Liberation Mono', monospace;
    --ph-prism: linear-gradient(120deg, #5ff0c0, #7fc4ff 35%, #b06cff 68%, #ff7ad9);
}

/* Scoped reset — no `*` rule, it would reach the whole document. */
body,
button,
input {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: var(--ph-bg);
    color: var(--ph-text);
    font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
    -webkit-tap-highlight-color: transparent;
}

.ph-container {
    width: 100%;
    max-width: 720px;
    margin: 0 auto;
    padding: 12px;
    text-align: center;
}

.ph-container .hidden {
    display: none !important;
}

.ph-sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
    border: 0;
}

/* --- Header --------------------------------------------------------- */

.ph-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 12px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--ph-line);
}

.ph-back {
    color: var(--ph-cyan);
    text-decoration: none;
    font-weight: 700;
    font-size: 0.85rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    padding: 8px 4px;
}

.ph-back:hover {
    color: var(--ph-pink);
}

.ph-title {
    margin: 0;
    font-family: var(--ph-display);
    font-size: clamp(1.3rem, 5vw, 1.9rem);
    font-weight: 900;
    letter-spacing: 0.07em;
    text-transform: uppercase;
    background: var(--ph-prism);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    filter: drop-shadow(0 2px 0 rgba(80, 44, 160, 0.75));
}

.ph-header-actions {
    display: flex;
    gap: 6px;
}

.ph-icon-btn {
    background: linear-gradient(180deg, #221b48, #120e28);
    border: 1px solid var(--ph-line);
    color: var(--ph-text);
    width: 42px;
    height: 42px;
    min-width: 42px;
    min-height: 42px;
    border-radius: 10px;
    font-size: 1.05rem;
    cursor: pointer;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.07);
}

.ph-icon-btn:active {
    transform: scale(0.94);
}

/* --- HUD ------------------------------------------------------------- */

.ph-hud {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
    margin-bottom: 12px;
}

.ph-chip {
    background: linear-gradient(180deg, #201945, #130f2c);
    border: 1px solid var(--ph-line);
    border-radius: 10px;
    padding: 5px 12px;
    min-width: 70px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1px;
}

.ph-chip-label {
    font-size: 0.6rem;
    letter-spacing: 0.14em;
    color: var(--ph-muted);
    font-weight: 700;
}

.ph-chip-value {
    font-family: var(--ph-mono);
    font-size: 1.02rem;
    font-weight: 700;
    color: var(--ph-text);
}

.ph-chip-target {
    min-width: 62px;
}

.ph-chip-swatch {
    width: 34px;
    height: 16px;
    border-radius: 6px;
    margin: 3px 0 2px;
    background: linear-gradient(135deg, #5ff0c0, #2fae86);
    box-shadow: 0 0 10px rgba(95, 240, 192, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.35);
}

.ph-chip-reverse .ph-chip-value {
    color: var(--ph-violet);
}

.ph-chip-star {
    border-color: rgba(255, 224, 102, 0.6);
    box-shadow: 0 0 14px rgba(255, 224, 102, 0.35);
}

.ph-chip-star .ph-chip-value {
    color: #ffe066;
    animation: ph-blink 0.8s steps(2, start) infinite;
}

.ph-chip-slow .ph-chip-value {
    color: #7fe9ff;
}

#hudTiles.is-warn {
    color: var(--ph-cyan);
    animation: ph-blink 1s steps(2, start) infinite;
}

@keyframes ph-blink {
    50% { opacity: 0.4; }
}

/* --- Stage ----------------------------------------------------------- */

.ph-stage {
    position: relative;
    width: 100%;
    max-width: 416px;
    margin: 0 auto 14px;
    border-radius: 16px;
    overflow: hidden;
    border: 1px solid var(--ph-line);
    box-shadow: 0 14px 40px rgba(0, 0, 0, 0.55), inset 0 0 0 1px rgba(255, 255, 255, 0.04);
    background: #08061a;
}

#prismHopperCanvas {
    display: block;
    width: 100%;
    height: auto;
    touch-action: none;
    cursor: pointer;
}

/* --- Touch controls -------------------------------------------------- */

.ph-touch {
    display: none;
    align-items: center;
    justify-content: center;
    gap: 20px;
    max-width: 416px;
    margin: 0 auto 14px;
    user-select: none;
}

.ph-dpad {
    display: grid;
    grid-template-columns: repeat(2, 66px);
    grid-template-rows: repeat(2, 58px);
    gap: 6px;
}

.ph-dir {
    background: linear-gradient(180deg, #241d52, #141031);
    border: 1px solid var(--ph-line);
    color: var(--ph-text);
    border-radius: 14px;
    font-size: 1.5rem;
    line-height: 1;
    cursor: pointer;
    touch-action: none;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.ph-dir:active {
    background: linear-gradient(180deg, var(--ph-violet), #4a2b8f);
    transform: scale(0.94);
}

.ph-dir-nw { grid-area: 1 / 1; }
.ph-dir-ne { grid-area: 1 / 2; }
.ph-dir-sw { grid-area: 2 / 1; }
.ph-dir-se { grid-area: 2 / 2; }

.ph-touch-hint {
    margin: 0;
    max-width: 150px;
    font-size: 0.8rem;
    line-height: 1.5;
    color: var(--ph-muted);
    text-align: left;
}

@media (max-width: 820px), (pointer: coarse) {
    .ph-touch {
        display: flex;
    }
}

@media (max-width: 400px) {
    .ph-dpad {
        grid-template-columns: repeat(2, 58px);
        grid-template-rows: repeat(2, 52px);
    }

    .ph-touch-hint {
        font-size: 0.75rem;
    }
}

/* --- Overlays and panels ---------------------------------------------- */

.ph-overlay {
    position: fixed;
    inset: var(--app-header-h, 72px) 0 0;
    background: rgba(8, 6, 22, 0.84);
    backdrop-filter: blur(3px);
    display: flex;
    align-items: flex-start;
    justify-content: center;
    overflow-y: auto;
    padding: 12px;
    z-index: 40;
}

.ph-panel {
    background: linear-gradient(180deg, var(--ph-panel), #0c0920);
    border: 1px solid var(--ph-line);
    border-radius: 18px;
    padding: 24px 22px;
    width: 100%;
    max-width: 440px;
    max-height: calc(100vh - var(--app-header-h, 72px) - 24px);
    max-height: calc(100dvh - var(--app-header-h, 72px) - 24px);
    margin: auto;
    overflow-y: auto;
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.6);
}

.ph-kicker {
    margin: 0 0 6px;
    font-size: 0.66rem;
    letter-spacing: 0.22em;
    font-weight: 700;
    color: var(--ph-cyan);
    text-transform: uppercase;
}

.ph-panel-title {
    margin: 0 0 8px;
    font-family: var(--ph-display);
    font-size: 1.7rem;
    font-weight: 900;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    background: var(--ph-prism);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

.ph-tagline {
    margin: 0 0 16px;
    color: var(--ph-muted);
    line-height: 1.55;
    font-size: 0.95rem;
}

.ph-label {
    font-size: 0.72rem;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--ph-muted);
    font-weight: 700;
}

.ph-name-row {
    display: flex;
    flex-direction: column;
    gap: 6px;
    align-items: stretch;
    margin-bottom: 14px;
    text-align: left;
}

.ph-input {
    background: #0b0820;
    border: 1px solid var(--ph-line);
    border-radius: 10px;
    color: var(--ph-text);
    font-size: 1rem;
    padding: 10px 12px;
    outline: none;
}

.ph-input:focus {
    border-color: var(--ph-cyan);
}

.ph-diff-row {
    display: flex;
    flex-direction: column;
    gap: 7px;
    align-items: center;
    margin-bottom: 16px;
}

.ph-diff-btns {
    display: flex;
    gap: 7px;
    flex-wrap: wrap;
    justify-content: center;
}

.ph-diff-btn {
    background: #171238;
    border: 1px solid var(--ph-line);
    color: var(--ph-muted);
    border-radius: 10px;
    padding: 9px 15px;
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    cursor: pointer;
}

.ph-diff-btn.is-active {
    background: linear-gradient(180deg, var(--ph-cyan), #2fae86);
    border-color: var(--ph-cyan);
    color: #06231b;
}

.ph-btn {
    display: block;
    width: 100%;
    border: none;
    border-radius: 12px;
    padding: 13px 16px;
    font-size: 0.95rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    cursor: pointer;
    margin-bottom: 9px;
}

.ph-btn-primary {
    background: var(--ph-prism);
    color: #140b28;
    box-shadow: 0 8px 22px rgba(150, 90, 255, 0.35);
}

.ph-btn-primary:active {
    transform: scale(0.98);
}

.ph-btn-ghost {
    background: transparent;
    border: 1px solid var(--ph-line);
    color: var(--ph-text);
}

.ph-controls-hint {
    margin-top: 10px;
    border-top: 1px solid var(--ph-line);
    padding-top: 12px;
}

.ph-controls-hint p {
    margin: 0 0 7px;
    font-size: 0.84rem;
    color: var(--ph-muted);
    line-height: 1.5;
}

.ph-over-reason {
    margin: 0 0 14px;
    color: var(--ph-danger);
    font-weight: 600;
}

.ph-results {
    display: flex;
    gap: 8px;
    justify-content: center;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.ph-result {
    background: #130f2e;
    border: 1px solid var(--ph-line);
    border-radius: 10px;
    padding: 8px 14px;
    min-width: 86px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.ph-result-label {
    font-size: 0.6rem;
    letter-spacing: 0.14em;
    color: var(--ph-muted);
    font-weight: 700;
}

.ph-result-value {
    font-family: var(--ph-mono);
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--ph-cyan);
}

/* --- Own guide / tips section ----------------------------------------- */

.game-extras {
    max-width: 720px;
    margin: 26px auto 8px;
    padding: 0 12px;
    text-align: left;
}

.game-extras h2 {
    font-family: var(--ph-display);
    background: var(--ph-prism);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    font-size: 1.35rem;
    letter-spacing: 0.03em;
    margin: 0 0 14px;
}

.game-extras h3 {
    color: var(--ph-cyan);
    font-size: 1.02rem;
    margin: 0 0 6px;
}

.ph-tips-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 12px;
    margin-bottom: 16px;
}

.ph-tips-card {
    background: linear-gradient(180deg, var(--ph-surface), #100c26);
    border: 1px solid var(--ph-line);
    border-radius: 14px;
    padding: 14px 16px;
}

.ph-tips-card p {
    margin: 0;
    color: var(--ph-muted);
    line-height: 1.6;
    font-size: 0.9rem;
}

.game-extras > p {
    color: var(--ph-muted);
    line-height: 1.65;
    font-size: 0.92rem;
}

/* --- Short-phone layout ------------------------------------------------ */
@media (max-width: 420px) {
    .ph-container { padding: 8px 10px 24px; }
    .ph-header { gap: 6px; margin-bottom: 6px; padding-bottom: 5px; }
    .ph-back {
        width: 32px;
        height: 32px;
        padding: 0;
        font-size: 0;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        flex-shrink: 0;
    }
    .ph-back::before { content: "←"; font-size: 15px; }
    .ph-title { font-size: 1.08rem; letter-spacing: 0.04em; white-space: nowrap; }
    .ph-icon-btn {
        width: 34px; height: 34px;
        min-width: 34px; min-height: 34px;
        font-size: 0.95rem;
        border-radius: 8px;
    }
    .ph-hud { gap: 4px; margin-bottom: 6px; }
    .ph-chip { flex: 1 1 60px; min-width: 0; padding: 3px 4px; border-radius: 8px; }
    .ph-chip-label { font-size: 0.48rem; letter-spacing: 0.03em; }
    .ph-chip-value { font-size: 0.82rem; }
    .ph-chip-target { min-width: 0; }
    .ph-chip-swatch { width: 26px; height: 12px; margin: 2px 0 1px; }
    .ph-stage { margin-bottom: 8px; }
    .ph-touch { gap: 12px; margin-bottom: 8px; }
    .ph-dpad {
        grid-template-columns: repeat(2, 48px);
        grid-template-rows: repeat(2, 44px);
        gap: 5px;
    }
    .ph-dir { font-size: 1.2rem; border-radius: 10px; }
    .ph-touch-hint { font-size: 0.68rem; line-height: 1.35; max-width: 140px; }
    .ph-panel { padding: 18px 15px; }
    .ph-panel-title { font-size: 1.4rem; }
    .ph-tagline { font-size: 0.88rem; }
    .ph-diff-btns { flex-wrap: nowrap; gap: 4px; }
    .ph-diff-btn { flex: 1 1 0; min-width: 0; padding: 9px 4px; font-size: 0.7rem; letter-spacing: 0.04em; }
    .ph-results { flex-wrap: nowrap; gap: 4px; }
    .ph-result { flex: 1 1 0; min-width: 0; padding: 8px 4px; }
    .ph-result-label { font-size: 0.52rem; letter-spacing: 0.06em; }
    .ph-result-value { font-size: 1rem; }

    /* Keep the primary action reachable while the setup card scrolls. */
    #btnStart {
        position: sticky;
        bottom: 0;
        z-index: 2;
        box-shadow: 0 -10px 22px rgba(8, 6, 22, 0.95), 0 8px 24px rgba(95, 240, 192, 0.2);
    }
}
