/* ============================================
   Play Online (PvP Arena) — overrides on top of base.css
   Minimalist: one board, two clocks, nothing else shouting.
   ============================================ */

.pv-body {
    min-height: 100vh;
    min-height: 100dvh;
}

/* display:flex on sections would beat the UA [hidden] rule — reassert it */
.pv-body [hidden] { display: none !important; }

/* --- Floating chrome --- */
.pv-float-back {
    position: fixed;
    top: calc(18px + env(safe-area-inset-top));
    left: calc(18px + env(safe-area-inset-left));
    z-index: 120;
    width: 42px;
    height: 42px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, 0.14);
    background: rgba(10, 14, 22, 0.55);
    color: rgba(255, 255, 255, 0.75);
    text-decoration: none;
    font-size: 1.15rem;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    transition: all var(--ease-default);
}
.pv-float-back:hover { border-color: var(--accent); color: var(--accent-light); transform: translateX(-2px); }

.pv-float-sound {
    position: fixed;
    top: calc(18px + env(safe-area-inset-top));
    right: calc(18px + env(safe-area-inset-right));
    z-index: 120;
    width: 42px;
    height: 42px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, 0.14);
    background: rgba(10, 14, 22, 0.55);
    color: rgba(255, 255, 255, 0.75);
    font-size: 1rem;
    cursor: pointer;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    transition: all var(--ease-default);
}
.pv-float-sound:hover { border-color: var(--accent); }
.pv-float-sound.muted { opacity: 0.45; }

.pv-app {
    position: relative;
    z-index: 1;
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: calc(20px + env(safe-area-inset-top)) 16px calc(20px + env(safe-area-inset-bottom));
}

/* ============================================
   Sign-in gate
   ============================================ */
.pv-gate { display: flex; align-items: center; justify-content: center; width: 100%; }

.pv-gate-card {
    max-width: 440px;
    width: 100%;
    text-align: center;
    padding: 46px 38px;
    border-radius: var(--radius-xl);
    border: 1px solid rgba(255, 255, 255, 0.10);
    background: rgba(15, 20, 30, 0.55);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
    animation: pvRise 0.7s cubic-bezier(0.16, 1, 0.3, 1);
}
.pv-gate-glyph { font-size: 3rem; color: var(--accent-light); text-shadow: 0 8px 40px var(--accent-glow); margin-bottom: 10px; }
.pv-gate-card h1 { font-family: var(--font-brand); font-size: 1.9rem; font-weight: 700; margin-bottom: 12px; }
.pv-gate-card p { color: var(--text-muted); font-size: 0.95rem; line-height: 1.6; margin-bottom: 24px; }
.pv-gate-card p em { color: var(--accent-light); font-style: normal; }
.pv-gate-btn {
    display: inline-block;
    padding: 13px 34px;
    border-radius: 999px;
    background: var(--accent);
    color: #06080e;
    font-family: var(--font-brand);
    font-weight: 600;
    font-size: 0.95rem;
    text-decoration: none;
    transition: all var(--ease-snappy);
}
.pv-gate-btn:hover { background: var(--accent-light); transform: translateY(-2px); box-shadow: 0 12px 34px var(--accent-glow); }
.pv-gate-note { font-size: 0.8rem !important; margin: 18px 0 0 !important; color: var(--text-faint) !important; }

/* ============================================
   Lobby
   ============================================ */
.pv-lobby {
    width: 100%;
    max-width: 860px;
    animation: pvRise 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

.pv-lobby-head { text-align: center; position: relative; margin-bottom: 26px; }
.pv-lobby-head h1 {
    font-family: var(--font-brand);
    font-size: clamp(2.2rem, 6vw, 3.4rem);
    font-weight: 700;
    letter-spacing: -0.02em;
    background: linear-gradient(180deg, #ffffff 0%, #bcd4ee 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}
.pv-lobby-sub { color: var(--text-muted); font-size: 0.95rem; margin-top: 6px; }

.pv-rating-chip {
    position: absolute;
    top: 4px;
    right: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 8px 16px;
    border-radius: var(--radius-md);
    border: 1px solid rgba(255, 255, 255, 0.10);
    background: rgba(15, 20, 30, 0.5);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}
.pv-rating-num { font-family: var(--font-brand); font-weight: 700; font-size: 1.3rem; color: var(--accent-light); }
.pv-rating-label { font-size: 0.58rem; letter-spacing: 0.2em; color: var(--text-faint); }

/* Time controls */
.pv-tc-row { display: flex; gap: 10px; justify-content: center; margin-bottom: 22px; }
.pv-tc {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    min-width: 92px;
    padding: 12px 20px;
    border-radius: var(--radius-md);
    border: 1px solid rgba(255, 255, 255, 0.10);
    background: rgba(15, 20, 30, 0.45);
    color: var(--text);
    cursor: pointer;
    transition: all var(--ease-default);
}
.pv-tc:hover { border-color: rgba(126, 184, 232, 0.5); transform: translateY(-1px); }
.pv-tc.selected { border-color: var(--accent); background: rgba(91, 155, 213, 0.12); box-shadow: 0 0 22px rgba(91, 155, 213, 0.18); }
.pv-tc-time { font-family: var(--font-brand); font-weight: 700; font-size: 1.1rem; }
.pv-tc-kind { font-size: 0.68rem; letter-spacing: 0.12em; text-transform: uppercase; color: var(--text-faint); }

/* Opening grid */
.pv-openings {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 10px;
    margin-bottom: 26px;
}
.pv-open-card {
    text-align: left;
    padding: 13px 15px;
    border-radius: var(--radius-md);
    border: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(15, 20, 30, 0.4);
    color: var(--text);
    cursor: pointer;
    transition: all var(--ease-default);
}
.pv-open-card:hover { border-color: rgba(126, 184, 232, 0.45); transform: translateY(-1px); }
.pv-open-card.selected {
    border-color: var(--accent);
    background: rgba(91, 155, 213, 0.13);
    box-shadow: 0 0 24px rgba(91, 155, 213, 0.16);
}
.pv-open-name { display: block; font-family: var(--font-brand); font-weight: 600; font-size: 0.92rem; margin-bottom: 3px; }
.pv-open-line { display: block; font-size: 0.72rem; color: var(--text-faint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* CTA */
.pv-lobby-cta { text-align: center; }
.pv-play-btn {
    padding: 16px 58px;
    border: none;
    border-radius: 999px;
    background: var(--accent);
    color: #06080e;
    font-family: var(--font-brand);
    font-size: 1.05rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    cursor: pointer;
    transition: all var(--ease-snappy);
    box-shadow: 0 10px 34px rgba(91, 155, 213, 0.25);
}
.pv-play-btn:hover { background: var(--accent-light); transform: translateY(-2px); box-shadow: 0 16px 44px var(--accent-glow); }
.pv-play-btn:disabled { opacity: 0.55; cursor: default; transform: none; }
.pv-lobby-note { margin-top: 12px; font-size: 0.78rem; color: var(--text-faint); }

/* Searching overlay */
.pv-searching {
    position: fixed;
    inset: 0;
    z-index: 200;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 14px;
    background: rgba(5, 8, 13, 0.82);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
}
.pv-search-rings { position: relative; width: 74px; height: 74px; }
.pv-search-rings span {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    border: 2px solid transparent;
    border-top-color: var(--accent);
    animation: pvSpin 1.1s linear infinite;
}
.pv-search-rings span:nth-child(2) { inset: 10px; border-top-color: rgba(126, 184, 232, 0.6); animation-duration: 1.6s; animation-direction: reverse; }
.pv-search-rings span:nth-child(3) { inset: 20px; border-top-color: rgba(126, 184, 232, 0.3); animation-duration: 2.2s; }
.pv-search-text { font-family: var(--font-brand); font-size: 1.05rem; color: var(--text); }
.pv-search-detail { font-size: 0.8rem; color: var(--text-faint); }
.pv-cancel-btn {
    margin-top: 8px;
    padding: 10px 30px;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, 0.18);
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    transition: all var(--ease-default);
}
.pv-cancel-btn:hover { border-color: var(--error); color: var(--error); }

/* ============================================
   Game
   ============================================ */
.pv-game {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 26px;
    width: 100%;
    max-width: 1100px;
    animation: pvRise 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}

.pv-stage { display: flex; flex-direction: column; gap: 10px; }

.pv-player-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 4px;
}
.pv-player-info { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
.pv-player-name {
    font-family: var(--font-brand);
    font-weight: 600;
    font-size: 0.98rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 40vw;
}
.pv-player-rating { font-size: 0.8rem; color: var(--text-faint); }

.pv-clock {
    font-family: var(--font-brand);
    font-variant-numeric: tabular-nums;
    font-weight: 700;
    font-size: 1.5rem;
    padding: 4px 14px;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(15, 20, 30, 0.5);
    color: var(--text-muted);
    transition: color 0.25s ease, background 0.25s ease, border-color 0.25s ease;
}
.pv-clock.active { color: #ffffff; border-color: rgba(126, 184, 232, 0.55); background: rgba(91, 155, 213, 0.14); box-shadow: 0 0 18px rgba(91, 155, 213, 0.15); }
.pv-clock.low { color: #ff9d9d; border-color: rgba(229, 90, 90, 0.55); background: rgba(229, 90, 90, 0.12); animation: pvPulse 1s ease-in-out infinite; }

/* --- Board --- */
.pv-board-frame { position: relative; }
.pv-board {
    --sq: calc(min(min(88vw, 620px), calc(100vh - 250px), calc(100dvh - 250px)) / 8);
    position: relative;
    width: calc(var(--sq) * 8);
    height: calc(var(--sq) * 8);
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 24px 70px rgba(0, 0, 0, 0.55), 0 0 0 1px rgba(255, 255, 255, 0.07);
    user-select: none;
    -webkit-user-select: none;
    touch-action: none;
}

.pv-sq { position: absolute; width: var(--sq); height: var(--sq); }
.pv-sq.light { background: #ccd7e4; }
.pv-sq.dark  { background: #71889f; }
.pv-sq .pv-coord {
    position: absolute;
    bottom: 2px;
    right: 4px;
    font-size: calc(var(--sq) * 0.17);
    font-weight: 600;
    opacity: 0.55;
    pointer-events: none;
}
.pv-sq .pv-coord.file { bottom: 1px; right: 3px; }
.pv-sq .pv-coord.rank { top: 1px; left: 3px; right: auto; bottom: auto; }
.pv-sq.light .pv-coord { color: #71889f; }
.pv-sq.dark .pv-coord { color: #ccd7e4; }

.pv-sq.lastmove::after { content: ''; position: absolute; inset: 0; background: rgba(91, 155, 213, 0.34); }
.pv-sq.selected::after { content: ''; position: absolute; inset: 0; background: rgba(255, 255, 255, 0.28); }
.pv-sq.premove::after  { content: ''; position: absolute; inset: 0; background: rgba(216, 108, 108, 0.42); }
.pv-sq.check::after {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(circle at 50% 50%, rgba(230, 70, 70, 0.75) 0%, rgba(230, 70, 70, 0.25) 55%, transparent 75%);
}
.pv-sq.dot::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: calc(var(--sq) * 0.3);
    height: calc(var(--sq) * 0.3);
    transform: translate(-50%, -50%);
    border-radius: 50%;
    background: rgba(10, 16, 26, 0.28);
    z-index: 3;
}
.pv-sq.dot.capture::before {
    width: calc(var(--sq) * 0.92);
    height: calc(var(--sq) * 0.92);
    background: transparent;
    border: calc(var(--sq) * 0.07) solid rgba(10, 16, 26, 0.3);
}

.pv-piece {
    position: absolute;
    width: var(--sq);
    height: var(--sq);
    background-size: 100% 100%;
    background-repeat: no-repeat;
    cursor: grab;
    z-index: 2;
    transition: transform 0.13s cubic-bezier(0.2, 0.8, 0.3, 1);
    will-change: transform;
}
.pv-piece.dragging { transition: none; z-index: 10; cursor: grabbing; transform-origin: center; pointer-events: none; }
.pv-piece.ghost { opacity: 0.35; }

/* Promotion picker */
.pv-promo {
    position: absolute;
    inset: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    background: rgba(6, 9, 15, 0.78);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    border-radius: 10px;
}
.pv-promo button {
    width: calc(var(--sq) * 1.15);
    height: calc(var(--sq) * 1.15);
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.16);
    background-color: rgba(91, 155, 213, 0.12);
    background-size: 86% 86%;
    background-position: center;
    background-repeat: no-repeat;
    cursor: pointer;
    transition: all var(--ease-snappy);
}
.pv-promo button:hover { border-color: var(--accent); transform: translateY(-3px); background-color: rgba(91, 155, 213, 0.28); }

/* --- Side panel --- */
.pv-side {
    width: 268px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    align-self: stretch;
    justify-content: center;
}
.pv-opening-tag {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 10px 14px;
    border-radius: var(--radius-md);
    border: 1px solid rgba(255, 255, 255, 0.09);
    background: rgba(15, 20, 30, 0.5);
}
.pv-opening-name { font-family: var(--font-brand); font-weight: 600; font-size: 0.85rem; }
.pv-tc-tag { font-size: 0.75rem; color: var(--accent-light); white-space: nowrap; }

.pv-moves {
    flex: 0 1 300px;
    min-height: 120px;
    overflow-y: auto;
    padding: 10px 12px;
    border-radius: var(--radius-md);
    border: 1px solid rgba(255, 255, 255, 0.07);
    background: rgba(10, 14, 22, 0.45);
    font-size: 0.84rem;
    line-height: 1.9;
}
.pv-mvnum { color: var(--text-faint); margin-right: 2px; }
.pv-mv { color: var(--text); margin-right: 8px; }
.pv-mv.opening { color: var(--text-faint); }
.pv-mv.latest { color: var(--accent-light); font-weight: 600; }

.pv-drawbar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 9px 12px;
    border-radius: var(--radius-md);
    border: 1px solid rgba(126, 184, 232, 0.4);
    background: rgba(91, 155, 213, 0.12);
    font-size: 0.8rem;
}
.pv-drawbar span { flex: 1; }
.pv-drawbar button {
    padding: 5px 12px;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.16);
    background: rgba(255, 255, 255, 0.05);
    color: var(--text);
    font-size: 0.78rem;
    cursor: pointer;
}
.pv-drawbar button:hover { border-color: var(--accent); }

.pv-actions { display: flex; gap: 8px; }
.pv-act {
    flex: 1;
    padding: 10px 0;
    min-height: 40px;
    border-radius: var(--radius-md);
    border: 1px solid rgba(255, 255, 255, 0.10);
    background: rgba(15, 20, 30, 0.5);
    color: var(--text-muted);
    font-size: 1rem;
    cursor: pointer;
    transition: all var(--ease-default);
}
.pv-act:hover { border-color: rgba(126, 184, 232, 0.5); color: var(--text); }
.pv-act.pv-danger:hover { border-color: var(--error); color: var(--error); }
.pv-act.confirm { border-color: var(--error); color: #fff; background: rgba(229, 90, 90, 0.25); }

.pv-status { min-height: 1.2em; font-size: 0.78rem; color: var(--text-faint); text-align: center; }

/* --- Result modal --- */
.pv-modal {
    position: fixed;
    inset: 0;
    z-index: 300;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    background: rgba(5, 8, 13, 0.7);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}
.pv-modal-card {
    width: 100%;
    max-width: 360px;
    max-height: calc(100vh - 40px);
    max-height: calc(100dvh - 40px);
    overflow-y: auto;
    text-align: center;
    padding: 34px 28px 26px;
    border-radius: var(--radius-xl);
    border: 1px solid rgba(255, 255, 255, 0.12);
    background: rgba(17, 22, 31, 0.94);
    box-shadow: 0 24px 70px rgba(0, 0, 0, 0.6);
    animation: pvRise 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}
.pv-modal-card h2 { font-family: var(--font-brand); font-size: 1.6rem; font-weight: 700; margin-bottom: 4px; }
.pv-result-reason { color: var(--text-muted); font-size: 0.85rem; margin-bottom: 16px; }
.pv-result-delta { font-family: var(--font-brand); font-size: 2rem; font-weight: 700; margin-bottom: 20px; min-height: 1.2em; }
.pv-result-delta.up { color: #7fd49a; text-shadow: 0 0 30px rgba(127, 212, 154, 0.4); }
.pv-result-delta.down { color: #e58a8a; text-shadow: 0 0 30px rgba(229, 138, 138, 0.35); }
.pv-result-delta .pv-newrating { display: block; font-size: 0.78rem; font-weight: 400; color: var(--text-faint); margin-top: 2px; }
.pv-result-actions { display: flex; flex-direction: column; gap: 8px; }
.pv-result-btn {
    padding: 12px;
    min-height: 44px;
    border-radius: var(--radius-md);
    border: 1px solid rgba(255, 255, 255, 0.12);
    background: rgba(255, 255, 255, 0.04);
    color: var(--text);
    font-family: var(--font-brand);
    font-size: 0.92rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--ease-default);
}
.pv-result-btn:hover { border-color: var(--accent); transform: translateY(-1px); }
.pv-result-btn.primary { background: var(--accent); border-color: var(--accent); color: #06080e; }
.pv-result-btn.primary:hover { background: var(--accent-light); box-shadow: 0 10px 30px var(--accent-glow); }
.pv-result-btn.subtle { border-color: transparent; color: var(--text-faint); }
.pv-result-btn.subtle:hover { color: var(--text); transform: none; }
.pv-result-note { margin-top: 12px; font-size: 0.76rem; color: var(--text-faint); min-height: 1em; }

/* --- Animations --- */
@keyframes pvRise { from { opacity: 0; transform: translateY(18px); } to { opacity: 1; transform: translateY(0); } }
@keyframes pvSpin { to { transform: rotate(360deg); } }
@keyframes pvPulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.6; } }

/* ============================================
   Responsive
   ============================================ */
@media (max-width: 900px) {
    .pv-app { align-items: flex-start; padding-top: calc(64px + env(safe-area-inset-top)); }
    .pv-game { flex-direction: column; gap: 14px; }
    .pv-board { --sq: calc(min(calc(100vw - 28px), calc(100vh - 320px), calc(100dvh - 320px), 560px) / 8); }
    .pv-side { width: 100%; max-width: calc(var(--sq, 60px) * 8 + 200px); align-self: center; }
    .pv-moves { flex: none; max-height: 90px; min-height: 44px; }
    .pv-rating-chip { position: static; margin: 14px auto 0; width: max-content; }
}

@media (max-width: 520px) {
    .pv-openings { grid-template-columns: repeat(2, 1fr); }
    .pv-tc { min-width: 0; flex: 1; }
    .pv-tc-row { gap: 8px; }
    .pv-clock { font-size: 1.25rem; }
    .pv-player-name { max-width: 46vw; }
    .pv-gate-card { padding: 36px 24px; }
}

/* ---------- Coming soon ---------- */
.pv-soon-pill {
    display: inline-block;
    font-size: 0.62rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.22em;
    color: #e8c47a;
    border: 1px solid rgba(232, 196, 122, 0.45);
    border-radius: 999px;
    padding: 4px 13px 3px;
    margin-bottom: 16px;
    animation: pvSoonGlow 2.8s ease-in-out infinite;
}
@keyframes pvSoonGlow {
    0%, 100% { box-shadow: 0 0 0 0 rgba(232, 196, 122, 0); }
    50%      { box-shadow: 0 0 20px 0 rgba(232, 196, 122, 0.22); }
}
