/* Polterchess board + game UI. Layered on top of style.css. */

.play-page { max-width: 1040px; }

.play-header {
    display: flex;
    align-items: baseline;
    gap: 1rem;
    padding: 2rem 0 0.5rem;
    border-bottom: 1px solid var(--line);
    margin-bottom: 1rem;
}
.play-header h1 {
    font-size: 2rem;
    font-weight: normal;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    margin: 0;
}
.play-header .back {
    font-family: system-ui, sans-serif;
    font-size: 0.85rem;
    text-decoration: none;
}
.play-header .subtle {
    margin-left: auto;
    color: var(--muted);
    font-style: italic;
    font-size: 0.9rem;
}

.game-layout {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    gap: 1rem;
    align-items: start;
    justify-content: center;
}
.board-col { min-width: 0; }

/* ---- queues ---- */
.queue-col { width: 84px; }
.queue-label {
    font-family: system-ui, sans-serif;
    font-size: 0.62rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--muted);
    text-align: center;
    margin-bottom: 0.5rem;
}
.queue {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-height: 40px;
    background: #0c0d18;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 4px;
}
.queue .cap {
    font-size: 1.5rem;
    line-height: 1.1;
    text-align: center;
    filter: drop-shadow(0 1px 1px rgba(0,0,0,0.6));
}
.queue .cap.next {
    /* the piece that will resurrect next (top of the stack) */
    background: rgba(184,161,255,0.16);
    border-radius: 5px;
    outline: 1px solid var(--accent-dim);
}

/* ---- board ---- */
.board {
    display: grid;
    grid-template-columns: 20px repeat(8, 1fr);
    grid-template-rows: repeat(8, 1fr) 20px;
    aspect-ratio: 8 / 8;
    width: min(72vmin, 520px);
    max-width: 100%;
    margin: 0 auto;
    border: 3px solid #2c2f4a;
    border-radius: 6px;
    overflow: hidden;
    box-shadow: 0 12px 40px rgba(0,0,0,0.5);
    user-select: none;
}
.sq {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: clamp(1.4rem, 5.5vmin, 2.5rem);
    cursor: pointer;
}
.sq.light { background: #d7d3e8; }
.sq.dark  { background: #6b6690; }
/* inner 6x6 grid (files B-G, ranks 2-7) — the only resurrection-reachable zone */
.sq.inner::before {
    content: "";
    position: absolute;
    inset: 0;
    box-shadow: inset 0 0 0 1px rgba(184,161,255,0.22);
    pointer-events: none;
}
.sq .piece {
    line-height: 1;
    filter: drop-shadow(0 2px 2px rgba(0,0,0,0.45));
    pointer-events: none;
}
.sq .piece.w { color: #fffef8; text-shadow: 0 0 2px #000, 0 0 1px #000; }
.sq .piece.b { color: #1c1830; text-shadow: 0 0 2px #cfc9ee; }
/* the square a lifted piece came from — a quiet dashed marker of "home" */
.sq.origin { outline: 2px dashed var(--accent-dim); outline-offset: -4px; }
/* the piece currently "in transit": raised, enlarged, haloed. Above its square,
   and it must not fight the FLIP glide (which drives `transform`), so the lift
   look is carried by filter/scale via a wrapper-free glow rather than transform. */
.sq .piece.lifted {
    /* held in hand: tilted to the right, brightened, haloed, raised above the
       board. The tilt pivots low so it reads like a picked-up piece. The FLIP
       glide (inline transform) composes this same rotate while travelling. */
    transform: rotate(15deg);
    transform-origin: 50% 68%;
    position: relative;
    z-index: 3;
    filter: brightness(1.4) drop-shadow(0 8px 8px rgba(0,0,0,0.55)) drop-shadow(0 0 12px rgba(184,161,255,0.95));
    animation: liftPulse 1.6s ease-in-out infinite;
}
/* animate the glow/brightness only — the tilt is a static pose, left untouched */
@keyframes liftPulse {
    0%, 100% { filter: brightness(1.35) drop-shadow(0 7px 8px rgba(0,0,0,0.55)) drop-shadow(0 0 9px rgba(184,161,255,0.8)); }
    50%      { filter: brightness(1.55) drop-shadow(0 9px 11px rgba(0,0,0,0.6)) drop-shadow(0 0 17px rgba(184,161,255,1)); }
}
.sq.move::after {
    content: "";
    position: absolute;
    width: 26%;
    height: 26%;
    border-radius: 50%;
    background: rgba(184,161,255,0.75);
}
.sq.move.capture::after {
    width: 82%;
    height: 82%;
    background: transparent;
    border: 4px solid rgba(184,161,255,0.75);
    box-sizing: border-box;
}
.sq.check { box-shadow: inset 0 0 0 4px var(--danger); }

/* --- resurrection roll: refined & quiet --- */
/* The destination "peers open" during the held breath before the reveal. */
.sq.peer { animation: peer 0.62s ease both; }
@keyframes peer {
    0%   { box-shadow: inset 0 0 0 0 rgba(184,161,255,0); }
    45%  { box-shadow: inset 0 0 0 3px rgba(184,161,255,0.5); }
    100% { box-shadow: inset 0 0 0 1px rgba(184,161,255,0.18); }
}
/* A piece rises: a slow, soft flare of the square... */
.sq.resurrect { animation: flare 1.5s ease; }
@keyframes flare {
    0%   { box-shadow: inset 0 0 0 0 rgba(184,161,255,0); }
    25%  { box-shadow: inset 0 0 0 5px rgba(184,161,255,0.7); }
    100% { box-shadow: inset 0 0 0 0 rgba(184,161,255,0); }
}
/* ...and the newly-placed glyph fades up from below, drifting into focus. */
.piece.risen { animation: rise 0.95s cubic-bezier(0.2, 0.7, 0.25, 1); }
@keyframes rise {
    0%   { opacity: 0; transform: translateY(7px) scale(0.55); }
    55%  { opacity: 1; transform: translateY(0) scale(1.14); }
    100% { transform: scale(1); }
}
/* Empty roll: a faint, cold pulse — nothing rose. */
.sq.whiff { animation: whiff 0.85s ease; }
@keyframes whiff {
    0%   { box-shadow: inset 0 0 0 0 rgba(154,154,184,0); }
    40%  { box-shadow: inset 0 0 0 3px rgba(154,154,184,0.32); }
    100% { box-shadow: inset 0 0 0 0 rgba(154,154,184,0); }
}
/* Dice: motion-blurred while tumbling, a gentle pop when they settle. */
.dice .die.tumbling { opacity: 0.8; transform: scale(0.95); filter: blur(0.4px); }
.dice .die.settled { animation: dieSettle 0.42s ease; }
@keyframes dieSettle {
    0%   { transform: scale(1.2); box-shadow: 0 0 12px rgba(184,161,255,0.55); }
    60%  { transform: scale(0.95); }
    100% { transform: scale(1); box-shadow: none; }
}
@media (prefers-reduced-motion: reduce) {
    .sq.peer, .sq.resurrect, .piece.risen, .sq.whiff, .dice .die.settled,
    .sq .piece.lifted { animation: none; }
    .dice .die.tumbling { filter: none; opacity: 1; transform: none; }
}
/* rank/file labels */
.rank-lab, .file-lab {
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: system-ui, sans-serif;
    font-size: 0.6rem;
    color: var(--muted);
    background: #0c0d18;
}
.corner-lab { background: #0c0d18; }

/* ---- status / controls / dice / log ---- */
.status {
    text-align: center;
    margin: 0.9rem 0 0.6rem;
    font-size: 1.05rem;
    min-height: 1.5rem;
}
.status.win { color: var(--accent); font-weight: 600; }
.controls {
    display: flex;
    gap: 0.5rem;
    justify-content: center;
    flex-wrap: wrap;
}
.controls button {
    font-family: system-ui, sans-serif;
    font-size: 0.85rem;
    font-weight: 600;
    padding: 0.5rem 1rem;
    border-radius: 999px;
    border: 0;
    background: var(--accent);
    color: #17142b;
    cursor: pointer;
}
.controls button:disabled { opacity: 0.35; cursor: default; }
.controls button.ghost {
    background: transparent;
    color: var(--accent);
    border: 1px solid var(--accent-dim);
}
.controls .opponent {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    font-family: system-ui, sans-serif;
    font-size: 0.8rem;
    color: var(--muted);
    cursor: pointer;
    user-select: none;
}
.controls .opponent input { accent-color: var(--accent); cursor: pointer; }
.dice {
    display: flex;
    gap: 0.5rem;
    justify-content: center;
    min-height: 2.4rem;
    margin: 0.8rem 0 0.2rem;
    align-items: center;
}
.dice .die.rolled {
    width: 2.4rem;
    height: 2.4rem;
    font-size: 1.1rem;
}
.dice .arrow { color: var(--muted); }
.log {
    margin: 0.5rem auto 0;
    max-width: 32rem;
    max-height: 8.5rem;
    overflow-y: auto;
    font-family: ui-monospace, 'SF Mono', Menlo, monospace;
    font-size: 0.75rem;
    color: var(--muted);
    background: #0c0d18;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 0.5rem 0.75rem;
    line-height: 1.6;
}
.log .ghostly { color: var(--accent); }

/* ---- GDPR consent bar ---- */
.consent {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.75rem 1.25rem;
    justify-content: space-between;
    background: linear-gradient(180deg, var(--panel), var(--bg-soft));
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 0.85rem 1.15rem;
    margin: 1rem 0 0.5rem;
}
.consent p { margin: 0; font-size: 0.92rem; color: #cfceea; flex: 1 1 20rem; }
.consent-realm { color: var(--muted); font-style: italic; }
.consent-buttons { display: flex; gap: 0.5rem; flex: 0 0 auto; }
.consent-buttons button {
    font-family: system-ui, sans-serif;
    font-size: 0.85rem; font-weight: 600;
    padding: 0.5rem 1.1rem; border-radius: 999px; border: 0; cursor: pointer;
    background: var(--accent); color: #17142b;
}
.consent-buttons button.ghost { background: transparent; color: var(--accent); border: 1px solid var(--accent-dim); }

/* ---- identity + tally ledger ---- */
.ledger {
    margin: 1rem auto 0;
    max-width: 32rem;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: #0c0d18;
    padding: 0.7rem 0.9rem;
    font-family: system-ui, sans-serif;
    font-size: 0.8rem;
    color: var(--muted);
    text-align: center;
}
.ledger-id { color: #cfceea; }
.ledger-id .addr { font-family: ui-monospace, Menlo, monospace; color: var(--accent); }
.ledger-id .tier { font-style: italic; }
.ledger-tally { margin: 0.4rem 0; display: flex; flex-wrap: wrap; gap: 0.25rem 1rem; justify-content: center; }
.ledger-tally b { color: #e7e6f0; font-weight: 600; }
.linky {
    background: none; border: 0; color: var(--muted); cursor: pointer;
    font: inherit; text-decoration: underline; padding: 0; font-size: 0.72rem;
}
.linky:hover { color: var(--danger); }

.play-aside-ad {
    display: flex;
    justify-content: center;
    margin: 2rem 0;
}
.play-aside-ad .ad-block { position: static; width: 300px; max-width: 100%; }

.rules-recap {
    max-width: 40rem;
    margin: 1.5rem auto;
    background: var(--bg-soft);
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 0.75rem 1.1rem;
}
.rules-recap summary {
    cursor: pointer;
    font-family: system-ui, sans-serif;
    font-size: 0.9rem;
    color: var(--accent);
}
.rules-recap p { font-size: 0.95rem; margin: 0.75rem 0 0.25rem; }

@media (max-width: 720px) {
    .game-layout { grid-template-columns: 1fr; }
    .queue-col { width: auto; }
    .queue { flex-direction: row; flex-wrap: wrap; justify-content: center; }
    .queue .cap { font-size: 1.3rem; }
}
