.game-app button {
    font-family: "Ciname", sans-serif;
}

/* ---------------------------------------------------------------
   Accent identity — indigo (جنگ کاغذی)
--------------------------------------------------------------- */
:root {
    --pw-ink: #a5b4fc;
    --pw-ink-soft: rgba(129, 140, 248, 0.6);
    --pw-glow: rgba(99, 102, 241, 0.35);
    --pw-primary: linear-gradient(135deg, #818cf8, #4f46e5);
}

body.light-theme {
    --pw-ink: #4f46e5;
    --pw-ink-soft: rgba(79, 70, 229, 0.5);
    --pw-glow: rgba(79, 70, 229, 0.22);
}

/* ---------------------------------------------------------------
   Shell — clay page, safe-area aware
--------------------------------------------------------------- */
.pw-shell {
    width: min(96vw, 1160px);
    margin-inline: auto;
    padding: 8px 12px calc(16px + env(safe-area-inset-bottom));
    display: flex;
    flex-direction: column;
    align-items: center;
    min-height: calc(100vh - 100px);
    min-height: calc(100svh - 100px);
}

.pw-fill {
    height: calc(100vh - var(--pw-topbar-h, 90px));
    height: calc(100svh - var(--pw-topbar-h, 90px));
    min-height: 0;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
}

.pw-fill .pw-play-layout {
    flex: 1;
    min-height: 0;
    align-items: stretch;
}

.pw-fill .pw-board-stage {
    height: 100%;
}

.pw-fill .pw-panel {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    overscroll-behavior: contain;
}

.pw-fill .pw-board-wrap {
    flex: 1;
    min-height: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
}

.pw-fill .pw-over-actions {
    margin-top: auto;
    padding-top: 12px;
}

.pw-fill .pw-hero {
    margin-bottom: 12px;
}

.pw-fill .pw-hero-icon {
    font-size: 2.4rem;
    margin-bottom: 0;
}

.pw-fill .pw-over-actions .pw-btn {
    min-height: 46px;
    padding: 10px 18px;
    font-size: 0.95rem;
}

/* ---------------------------------------------------------------
   Hero
--------------------------------------------------------------- */
.pw-hero {
    text-align: center;
    margin-bottom: 16px;
}

.pw-hero-icon {
    font-size: 3rem;
    line-height: 1;
    margin-bottom: 6px;
    display: inline-block;
    animation: pwFloat 2.6s ease-in-out infinite;
    filter: drop-shadow(0 6px 16px rgba(99, 102, 241, 0.4));
}

@keyframes pwFloat {
    0%, 100% { transform: translateY(0) rotate(-3deg); }
    50% { transform: translateY(-9px) rotate(3deg); }
}

.pw-title {
    font-size: clamp(1.8rem, 7vw, 2.6rem);
    margin: 8px 0 4px;
    text-align: center;
    background: linear-gradient(135deg, #c7d2fe, #818cf8 45%, #6366f1);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    filter: drop-shadow(0 0 16px rgba(99, 102, 241, 0.35));
}

.pw-subtitle {
    font-size: 0.95rem;
    color: var(--muted);
    font-family: "Nazanin", sans-serif;
    margin: 0;
    text-align: center;
}

/* ---------------------------------------------------------------
   Setup panel — chunky clay card
--------------------------------------------------------------- */
.pw-panel {
    width: 100%;
    max-width: 480px;
    margin-inline: auto;
    background: var(--panel);
    border: 2px solid rgba(255, 255, 255, 0.08);
    border-radius: 30px;
    padding: 20px 16px;
    box-shadow:
        inset 2px 2px 8px rgba(255, 255, 255, 0.07),
        inset -3px -3px 12px rgba(0, 0, 0, 0.3),
        var(--shadow);
}

body.light-theme .pw-panel {
    border-color: rgba(109, 40, 217, 0.14);
    box-shadow:
        inset 2px 2px 8px rgba(255, 255, 255, 0.55),
        inset -3px -3px 12px rgba(70, 43, 124, 0.1),
        var(--shadow);
}

.pw-label {
    display: block;
    font-size: 0.95rem;
    color: var(--muted);
    font-family: "Nazanin", sans-serif;
    margin-bottom: 8px;
    text-align: center;
}

.pw-help {
    font-size: 0.85rem;
    color: var(--muted);
    font-family: "Nazanin", sans-serif;
    line-height: 1.9;
    margin: 0 0 16px;
    text-align: center;
}

/* ---------------------------------------------------------------
   Feedback — error / notice pills
--------------------------------------------------------------- */
.pw-err {
    color: var(--danger);
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.25);
    border-radius: 12px;
    padding: 10px 14px;
    font-size: 0.9rem;
    font-family: "Nazanin", sans-serif;
    margin-bottom: 12px;
    text-align: center;
}

body.light-theme .pw-err {
    background: rgba(239, 68, 68, 0.08);
}

.pw-notice {
    color: #4ade80;
    background: rgba(34, 197, 94, 0.12);
    border: 1px solid rgba(34, 197, 94, 0.3);
    border-radius: 12px;
    padding: 10px 14px;
    font-size: 0.9rem;
    font-family: "Nazanin", sans-serif;
    margin-bottom: 12px;
    text-align: center;
}

body.light-theme .pw-notice {
    color: #15803d;
    background: rgba(34, 197, 94, 0.1);
}

/* ---------------------------------------------------------------
   Lobby section
--------------------------------------------------------------- */
.pw-lobby-section {
    background: var(--bg-soft);
    border-radius: 18px;
    padding: 16px;
    border: 1px solid rgba(255, 255, 255, 0.06);
    box-shadow:
        inset 2px 2px 6px rgba(255, 255, 255, 0.06),
        inset -3px -3px 10px rgba(0, 0, 0, 0.28);
}

body.light-theme .pw-lobby-section {
    border-color: rgba(109, 40, 217, 0.12);
    box-shadow:
        inset 2px 2px 6px rgba(255, 255, 255, 0.6),
        inset -3px -3px 10px rgba(70, 43, 124, 0.08);
}

.pw-lobby-title {
    font-size: 1rem;
    margin: 0 0 12px;
    text-align: center;
    font-weight: 700;
}

/* ---------------------------------------------------------------
   Chips — chunky clay pills, ≥48px targets
--------------------------------------------------------------- */
.pw-chips {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin-bottom: 16px;
}

.pw-chip {
    flex: 1;
    max-width: 170px;
    min-height: 56px;
    padding: 10px 8px;
    border: 2px solid rgba(255, 255, 255, 0.16);
    border-radius: 16px;
    background: var(--panel);
    color: var(--text);
    font-size: 1rem;
    cursor: pointer;
    transition: transform 0.2s ease-out, border-color 0.2s, background 0.2s, box-shadow 0.2s;
    touch-action: manipulation;
    user-select: none;
    -webkit-user-select: none;
    box-shadow:
        inset 2px 2px 5px rgba(255, 255, 255, 0.06),
        inset -3px -3px 8px rgba(0, 0, 0, 0.3),
        0 5px 12px rgba(0, 0, 0, 0.2);
}

body.light-theme .pw-chip {
    border-color: rgba(109, 40, 217, 0.14);
    box-shadow:
        inset 2px 2px 5px rgba(255, 255, 255, 0.6),
        inset -3px -3px 8px rgba(70, 43, 124, 0.1),
        0 5px 12px rgba(70, 43, 124, 0.1);
}

.pw-chip-name {
    display: block;
}

.pw-chip small {
    display: block;
    font-family: "Nazanin", sans-serif;
    font-size: 0.75rem;
    color: var(--muted);
    margin-top: 3px;
    line-height: 1.6;
}

.pw-chip:hover {
    border-color: var(--pw-ink);
    transform: translateY(-2px);
}

.pw-chip:active {
    transform: translateY(1px) scale(0.97);
}

.pw-chip.active {
    border-color: var(--pw-ink);
    background: rgba(99, 102, 241, 0.18);
    color: var(--pw-ink);
    box-shadow:
        inset 2px 2px 6px rgba(0, 0, 0, 0.25),
        inset -2px -2px 6px rgba(255, 255, 255, 0.06),
        0 0 18px var(--pw-glow);
}

body.light-theme .pw-chip.active {
    background: rgba(109, 40, 217, 0.12);
    box-shadow:
        inset 2px 2px 6px rgba(255, 255, 255, 0.6),
        inset -2px -2px 6px rgba(70, 43, 124, 0.08),
        0 0 18px rgba(79, 70, 229, 0.18);
}

.pw-round-chips {
    margin-bottom: 12px;
    gap: 8px;
}

.pw-round-chips .pw-chip {
    min-height: 48px;
    padding: 8px 4px;
    font-size: 0.85rem;
    border-radius: 12px;
}

/* ---------------------------------------------------------------
   Inputs
--------------------------------------------------------------- */
.pw-input {
    width: 100%;
    min-height: 52px;
    background: var(--bg-soft);
    border: 2px solid rgba(255, 255, 255, 0.08);
    border-radius: 16px;
    padding: 12px 14px;
    color: var(--text);
    font-size: 1.15rem;
    outline: none;
    text-align: center;
    letter-spacing: 6px;
    text-transform: uppercase;
    margin-bottom: 10px;
    direction: ltr;
    font-family: "Consolas", "Courier New", monospace;
    box-shadow:
        inset 2px 2px 6px rgba(255, 255, 255, 0.05),
        inset -2px -2px 8px rgba(0, 0, 0, 0.22);
    transition: border-color 0.2s, box-shadow 0.2s;
}

body.light-theme .pw-input {
    border-color: rgba(109, 40, 217, 0.12);
    box-shadow:
        inset 2px 2px 6px rgba(255, 255, 255, 0.6),
        inset -2px -2px 8px rgba(70, 43, 124, 0.08);
}

.pw-input:focus {
    border-color: var(--accent);
    box-shadow:
        0 0 0 3px rgba(167, 139, 250, 0.18),
        inset 2px 2px 6px rgba(255, 255, 255, 0.05),
        inset -2px -2px 8px rgba(0, 0, 0, 0.22);
}

/* ---------------------------------------------------------------
   Buttons — chunky clay, soft press ~200ms, ≥56px targets
--------------------------------------------------------------- */
.pw-btn {
    min-height: 56px;
    padding: 12px 28px;
    border: 0;
    border-radius: 18px;
    background: var(--pw-primary);
    color: #fff;
    font-size: 1.02rem;
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.2s ease-out, opacity 0.2s, box-shadow 0.2s;
    touch-action: manipulation;
    user-select: none;
    -webkit-user-select: none;
    box-shadow:
        inset -3px -3px 8px rgba(0, 0, 0, 0.28),
        inset 2px 2px 6px rgba(255, 255, 255, 0.28),
        0 8px 18px var(--pw-glow);
}

.pw-btn:hover { opacity: 0.92; }

.pw-btn:active {
    transform: scale(0.96) translateY(1px);
    box-shadow:
        inset -2px -2px 6px rgba(0, 0, 0, 0.3),
        inset 3px 3px 8px rgba(0, 0, 0, 0.2),
        0 3px 8px rgba(79, 70, 229, 0.3);
}

.pw-btn.secondary {
    background: var(--panel-strong);
    color: var(--text);
    font-weight: 400;
    box-shadow:
        inset -3px -3px 8px rgba(0, 0, 0, 0.25),
        inset 2px 2px 6px rgba(255, 255, 255, 0.08),
        0 6px 14px rgba(0, 0, 0, 0.2);
}

body.light-theme .pw-btn.secondary {
    box-shadow:
        inset -3px -3px 8px rgba(70, 43, 124, 0.1),
        inset 2px 2px 6px rgba(255, 255, 255, 0.6),
        0 6px 14px rgba(70, 43, 124, 0.08);
}

.pw-btn.wide { width: 100%; }

.pw-btn:disabled,
.pw-btn.pending,
.pw-ghost.pending {
    opacity: 0.6;
    cursor: default;
    pointer-events: none;
}

.pw-btn-spin {
    display: inline-block;
    margin-left: 6px;
    animation: pwSpin 1s linear infinite;
}

.pw-ghost {
    background: none;
    border: 2px solid rgba(255, 255, 255, 0.12);
    color: var(--muted);
    min-height: 44px;
    padding: 8px 16px;
    border-radius: 12px;
    cursor: pointer;
    font-size: 0.85rem;
    font-family: "Nazanin", sans-serif;
    transition: background 0.2s, color 0.2s, border-color 0.2s;
    touch-action: manipulation;
}

body.light-theme .pw-ghost {
    border-color: rgba(109, 40, 217, 0.16);
}

.pw-ghost:hover {
    background: var(--panel);
    color: var(--text);
}

@keyframes pwSpin {
    to { transform: rotate(360deg); }
}

/* ---------------------------------------------------------------
   Top row — code, status chip, leave
--------------------------------------------------------------- */
.pw-top-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    width: 100%;
    max-width: 520px;
    margin-bottom: 10px;
}

.pw-code-inline {
    color: var(--pw-ink);
    direction: ltr;
    letter-spacing: 2px;
    font-family: "Consolas", "Courier New", monospace;
}

.pw-code-box {
    text-align: center;
    padding: 14px;
    border-radius: 18px;
    background: var(--bg-soft);
    border: 1.5px dashed var(--pw-ink-soft);
    margin-bottom: 14px;
    box-shadow:
        inset 2px 2px 6px rgba(255, 255, 255, 0.05),
        inset -3px -3px 10px rgba(0, 0, 0, 0.26);
}

body.light-theme .pw-code-box {
    box-shadow:
        inset 2px 2px 6px rgba(255, 255, 255, 0.6),
        inset -3px -3px 10px rgba(70, 43, 124, 0.08);
}

.pw-code {
    font-size: 2.2rem;
    letter-spacing: 10px;
    font-weight: 800;
    color: var(--pw-ink);
    direction: ltr;
    font-family: "Consolas", "Courier New", monospace;
    text-shadow: 0 0 18px var(--pw-glow);
}

.pw-qr {
    width: 180px;
    height: 180px;
    border-radius: 16px;
    background: #fff;
    padding: 8px;
    margin: 0 auto 12px;
    display: block;
    border: 2px solid rgba(255, 255, 255, 0.1);
}

body.light-theme .pw-qr {
    border-color: rgba(109, 40, 217, 0.14);
}

/* ---------------------------------------------------------------
   Player list
--------------------------------------------------------------- */
.pw-player-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin: 12px 0;
}

.pw-player-row {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--panel-strong);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 14px;
    padding: 10px 14px;
    box-shadow:
        inset 2px 2px 5px rgba(255, 255, 255, 0.05),
        inset -2px -2px 8px rgba(0, 0, 0, 0.26);
}

body.light-theme .pw-player-row {
    border-color: rgba(109, 40, 217, 0.12);
    box-shadow:
        inset 2px 2px 5px rgba(255, 255, 255, 0.55),
        inset -2px -2px 8px rgba(70, 43, 124, 0.08);
}

.pw-player-row .pw-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    flex-shrink: 0;
}

.pw-player-row .pw-name {
    flex: 1;
    font-family: "Nazanin", sans-serif;
    font-size: 0.95rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.pw-player-row .pw-tag {
    font-size: 0.68rem;
    color: var(--muted);
    background: var(--panel);
    border-radius: 999px;
    padding: 2px 8px;
    font-family: "Nazanin", sans-serif;
    flex-shrink: 0;
}

/* ---------------------------------------------------------------
   Waiting + status chip
--------------------------------------------------------------- */
.pw-waiting {
    text-align: center;
    color: var(--muted);
    font-family: "Nazanin", sans-serif;
    font-size: 0.95rem;
    margin: 8px 0;
    animation: pwBlink 1.2s ease-in-out infinite;
}

.pw-waiting-spin {
    display: inline-block;
    animation: pwSpin 1s linear infinite;
}

@keyframes pwBlink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.55; }
}

.pw-status-chip {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    font-size: 0.9rem;
    font-weight: 700;
    border-radius: 999px;
    padding: 6px 14px;
    text-align: center;
    border: 2px solid rgba(255, 255, 255, 0.12);
    background: var(--panel-strong);
    box-shadow:
        inset 2px 2px 5px rgba(255, 255, 255, 0.07),
        inset -2px -2px 8px rgba(0, 0, 0, 0.26),
        0 4px 12px rgba(0, 0, 0, 0.18);
    animation: pwStatusPop 0.3s cubic-bezier(0.22, 1.2, 0.36, 1);
}

body.light-theme .pw-status-chip {
    border-color: rgba(109, 40, 217, 0.14);
    box-shadow:
        inset 2px 2px 5px rgba(255, 255, 255, 0.6),
        inset -2px -2px 8px rgba(70, 43, 124, 0.08),
        0 4px 12px rgba(70, 43, 124, 0.08);
}

.pw-status-chip.mine {
    color: var(--pw-ink);
    border-color: var(--pw-ink-soft);
    box-shadow:
        inset 2px 2px 5px rgba(255, 255, 255, 0.06),
        inset -2px -2px 8px rgba(0, 0, 0, 0.24),
        0 0 16px var(--pw-glow);
}

body.light-theme .pw-status-chip.mine {
    box-shadow:
        inset 2px 2px 5px rgba(255, 255, 255, 0.6),
        inset -2px -2px 8px rgba(70, 43, 124, 0.08),
        0 0 16px rgba(79, 70, 229, 0.2);
}

.pw-status-chip.theirs { color: var(--muted); }

.pw-status-chip.won {
    color: #4ade80;
    border-color: rgba(34, 197, 94, 0.55);
    box-shadow:
        inset 2px 2px 5px rgba(255, 255, 255, 0.06),
        inset -2px -2px 8px rgba(0, 0, 0, 0.24),
        0 0 16px rgba(34, 197, 94, 0.25);
}

.pw-status-chip.lost {
    color: #f87171;
    border-color: rgba(239, 68, 68, 0.5);
    box-shadow:
        inset 2px 2px 5px rgba(255, 255, 255, 0.06),
        inset -2px -2px 8px rgba(0, 0, 0, 0.24),
        0 0 16px rgba(239, 68, 68, 0.25);
}

.pw-top-row .pw-status-chip {
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 44vw;
}

.pw-turn-time {
    direction: ltr;
    display: inline-block;
    min-width: 1.4em;
    font-family: "Consolas", "Courier New", monospace;
    font-weight: 800;
    color: var(--pw-ink);
}

.pw-turn-time.danger {
    color: #f87171;
    animation: pwBlink 0.8s ease-in-out infinite;
}

@keyframes pwStatusPop {
    0% { transform: scale(0.85); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}

/* ---------------------------------------------------------------
   Board — fits viewport width + height, never scrolls sideways
--------------------------------------------------------------- */
.pw-board-stage {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    width: 100%;
    max-width: min(96vw, 480px);
    min-width: 0;
}

.pw-play-layout {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    width: 100%;
}

.pw-play-layout .pw-board-stage {
    flex: 1 1 auto;
    max-width: none;
    width: auto;
    min-width: 0;
}

.pw-board-wrap {
    width: 100%;
    max-width: min(96vw, 460px);
    min-width: 0;
    display: flex;
    justify-content: center;
}

.pw-board {
    position: relative;
    width: var(--pw-side, 320px);
    height: calc(var(--pw-side, 320px) * 2);
    max-width: 96vw;
    background: var(--bg-soft);
    border-radius: 18px;
    border: 2px solid rgba(129, 140, 248, 0.35);
    box-shadow:
        inset 2px 2px 10px rgba(255, 255, 255, 0.08),
        inset -3px -3px 12px rgba(0, 0, 0, 0.35),
        0 14px 34px rgba(99, 102, 241, 0.18);
    perspective: 1100px;
    touch-action: manipulation;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
}

body.light-theme .pw-board {
    border-color: rgba(109, 40, 217, 0.3);
}

.pw-board.pw-board-solo {
    height: var(--pw-side, 320px);
}

.pw-board-solo::after {
    display: none;
}

.pw-board::after {
    content: "";
    position: absolute;
    left: 6%;
    right: 6%;
    top: 50%;
    border-top: 2px dashed rgba(255, 255, 255, 0.22);
    z-index: 3;
    pointer-events: none;
}

body.light-theme .pw-board::after {
    border-top-color: rgba(23, 18, 43, 0.18);
}

.pw-half {
    position: absolute;
    left: 0;
    width: 100%;
    height: 50%;
    overflow: hidden;
}

.pw-half.top { top: 0; border-radius: 17px 17px 0 0; }
.pw-half.bottom { bottom: 0; border-radius: 0 0 17px 17px; }

.pw-half.pw-half-solo {
    top: 0;
    bottom: auto;
    height: 100%;
    border-radius: 17px;
}

.pw-half-inner {
    position: absolute;
    inset: 0;
}

.pw-half-inner.interactive { cursor: crosshair; }

.pw-half-inner.interactive .pw-soldier,
.pw-half-inner.interactive .pw-soldier.dead {
    cursor: crosshair;
}

.pw-half-tag {
    position: absolute;
    top: 8px;
    inset-inline-start: 10px;
    font-size: 0.72rem;
    color: var(--muted);
    background: var(--panel-strong);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 999px;
    padding: 2px 12px;
    font-family: "Nazanin", sans-serif;
    z-index: 2;
}

.pw-half-tag.bottom {
    top: auto;
    bottom: 8px;
}

.pw-half.pw-turn-now {
    box-shadow: 0 0 0 2px var(--twc, var(--pw-ink)), 0 0 24px color-mix(in srgb, var(--twc, #818cf8) 45%, transparent);
    z-index: 2;
}

.pw-half.pw-locked-turn {
    box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.12);
}

.pw-half.pw-locked-turn .pw-half-inner {
    opacity: 0.45;
    filter: grayscale(0.5) brightness(0.85);
}

.pw-half.blurred .pw-half-inner {
    filter: blur(6px);
    opacity: 1;
}

body.light-theme .pw-half.pw-locked-turn {
    box-shadow: 0 0 0 2px rgba(70, 43, 124, 0.18);
}

.pw-half.pw-turn-now::after {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: inherit;
    background: linear-gradient(160deg, rgba(129, 140, 248, 0.05), transparent 55%);
    pointer-events: none;
}

/* ---------------------------------------------------------------
   Turn lock veil
--------------------------------------------------------------- */
.pw-turn-lock {
    position: absolute;
    inset: 0;
    z-index: 3;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    text-align: center;
    background: rgba(0, 0, 0, 0.32);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
    pointer-events: none;
    border-radius: inherit;
}

.pw-lock-badge {
    font-size: 1.8rem;
    animation: pwBlink 1.6s ease-in-out infinite;
}

.pw-turn-lock b {
    font-size: 0.95rem;
}

.pw-turn-lock small {
    font-size: 0.72rem;
    color: var(--muted);
    font-family: "Nazanin", sans-serif;
}

/* ---------------------------------------------------------------
   Soldiers, marks, aim, stamps
--------------------------------------------------------------- */
.pw-soldier {
    position: absolute;
    transform: translate(-50%, -50%);
    width: 11%;
    aspect-ratio: 1;
    z-index: 2;
    cursor: grab;
    touch-action: none;
    transition: filter 0.2s;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.45));
}

.pw-soldier svg {
    width: 100%;
    height: 100%;
    display: block;
}

.pw-soldier.pw-p1:not(.dead) {
    filter: drop-shadow(0 2px 4px rgba(59, 130, 246, 0.5));
}

.pw-soldier.pw-p2:not(.dead) {
    filter: drop-shadow(0 2px 4px rgba(249, 115, 22, 0.5));
}

.pw-soldier.dead {
    filter: saturate(0.3) brightness(0.85);
    opacity: 0.85;
    cursor: default;
}

.pw-soldier.dead svg { animation: pwDeadPulse 1.2s ease-in-out infinite; }

@keyframes pwDeadPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(0.94); }
}

.pw-soldier.shake { animation: pwShake 0.4s ease; }

@keyframes pwShake {
    0%, 100% { transform: translate(-50%, -50%); }
    25% { transform: translate(-50%, -50%) translateX(-7px); }
    75% { transform: translate(-50%, -50%) translateX(7px); }
}

.pw-mark {
    position: absolute;
    transform: translate(-50%, -50%);
    width: 4.5%;
    aspect-ratio: 1;
    z-index: 1;
    pointer-events: none;
}

.pw-mark svg {
    width: 100%;
    height: 100%;
    display: block;
    opacity: 0.85;
}

.pw-aim {
    position: absolute;
    transform: translate(-50%, -50%);
    width: 12%;
    aspect-ratio: 1;
    z-index: 4;
    pointer-events: none;
    animation: pwAimIn 0.18s ease-out;
}

@keyframes pwAimIn {
    0% { transform: translate(-50%, -50%) scale(1.5); opacity: 0; }
    100% { transform: translate(-50%, -50%) scale(1); opacity: 1; }
}

.pw-aim-ring {
    position: absolute;
    inset: 5%;
    border: 2px solid #fff;
    border-radius: 50%;
    animation: pwAimPulse 1s ease-in-out infinite;
}

.pw-aim-dot {
    position: absolute;
    left: 50%;
    top: 50%;
    width: 12%;
    aspect-ratio: 1;
    border-radius: 50%;
    transform: translate(-50%, -50%);
}

@keyframes pwAimPulse {
    0%, 100% { transform: scale(0.85); opacity: 0.7; }
    50% { transform: scale(1.15); opacity: 1; }
}

.pw-stamp {
    position: absolute;
    transform: translate(-50%, -50%);
    width: 8%;
    aspect-ratio: 1;
    z-index: 6;
    animation: pwStampIn 0.4s cubic-bezier(0.22, 1.2, 0.36, 1) both;
    filter: drop-shadow(0 0 6px rgba(239, 68, 68, 0.45));
}

.pw-stamp svg {
    width: 100%;
    height: 100%;
    display: block;
}

@keyframes pwStampIn {
    0% { transform: translate(-50%, -50%) scale(2.2); opacity: 0; }
    60% { transform: translate(-50%, -50%) scale(0.92); opacity: 1; }
    100% { transform: translate(-50%, -50%) scale(1); opacity: 1; }
}

/* ---------------------------------------------------------------
   Cover (opponent half) — semantic locked state
--------------------------------------------------------------- */
.pw-cover {
    position: absolute;
    inset: 0;
    z-index: 5;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    background: var(--bg);
    background-image: repeating-linear-gradient(45deg, var(--panel) 0 10px, transparent 10px 22px);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: inherit;
}

body.light-theme .pw-cover {
    border-color: rgba(109, 40, 217, 0.14);
}

.pw-cover-icon { font-size: 1.9rem; }
.pw-cover-title { font-size: 1.05rem; font-weight: 700; color: var(--text); }

.pw-cover-sub {
    font-size: 0.78rem;
    color: var(--muted);
    font-family: "Nazanin", sans-serif;
}

/* ---------------------------------------------------------------
   Round badge
--------------------------------------------------------------- */
.pw-round-badge {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 8;
    pointer-events: none;
    background: var(--panel-strong);
    border: 1.5px solid var(--pw-ink-soft);
    color: var(--pw-ink);
    font-family: "Nazanin", sans-serif;
    font-size: 0.72rem;
    font-weight: 700;
    padding: 3px 12px;
    border-radius: 999px;
    white-space: nowrap;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.35);
}

body.light-theme .pw-round-badge {
    box-shadow: 0 2px 10px rgba(70, 43, 124, 0.15);
}

/* ---------------------------------------------------------------
   Play actions + hint
--------------------------------------------------------------- */
.pw-actions {
    width: 100%;
    min-height: 56px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.pw-board-stage .pw-actions {
    max-width: var(--pw-side, 340px);
}

.pw-hint {
    color: var(--muted);
    font-family: "Nazanin", sans-serif;
    font-size: 0.9rem;
    margin: 0;
    text-align: center;
}

/* ---------------------------------------------------------------
   Whiff result toast — misses stay muted
--------------------------------------------------------------- */
.pw-result-field {
    position: absolute;
    inset-inline: 14px;
    bottom: 68px;
    z-index: 7;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 6px;
    padding: 10px 14px;
    border-radius: 16px;
    background: var(--panel-strong);
    border: 1.5px solid rgba(148, 163, 184, 0.55);
    color: var(--muted);
    font-family: "Nazanin", sans-serif;
    font-size: 0.88rem;
    font-weight: 700;
    text-align: center;
    box-shadow: 0 6px 24px rgba(0, 0, 0, 0.4);
    animation: pwWhiffToast 2.4s ease forwards;
}

.pw-result-field.whiff {
    border-color: rgba(148, 163, 184, 0.4);
    background: rgba(10, 12, 30, 0.55);
}

.pw-result-field b {
    font-family: "Ciname", sans-serif;
    color: var(--pw-ink);
}

body.light-theme .pw-result-field {
    background: var(--panel-strong);
    box-shadow: 0 6px 24px rgba(70, 43, 124, 0.2);
}

body.light-theme .pw-result-field.whiff {
    background: rgba(255, 255, 255, 0.9);
}

@keyframes pwWhiffToast {
    0% { transform: translateY(8px); opacity: 0; }
    10% { transform: translateY(0); opacity: 1; }
    70% { opacity: 1; }
    100% { opacity: 0; }
}

/* ---------------------------------------------------------------
   Over screen — winner banner + stats + actions
--------------------------------------------------------------- */
.pw-winner-banner {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    background: linear-gradient(135deg, rgba(129, 140, 248, 0.16), rgba(99, 102, 241, 0.06));
    border: 2px solid var(--pc, var(--pw-ink));
    border-radius: 20px;
    padding: 16px;
    margin-bottom: 16px;
    text-align: center;
    box-shadow:
        inset 2px 2px 6px rgba(255, 255, 255, 0.07),
        inset -3px -3px 10px rgba(0, 0, 0, 0.22),
        0 8px 20px rgba(70, 43, 124, 0.16);
}

.pw-winner-emoji { font-size: 2.2rem; line-height: 1; }
.pw-winner-banner b { font-size: 1.25rem; }

.pw-stats {
    display: flex;
    flex-direction: column;
    gap: 8px;
    background: var(--bg-soft);
    border: 1px solid rgba(255, 255, 255, 0.07);
    border-radius: 16px;
    padding: 14px;
    margin-bottom: 14px;
    box-shadow:
        inset 2px 2px 6px rgba(255, 255, 255, 0.06),
        inset -3px -3px 10px rgba(0, 0, 0, 0.26);
}

body.light-theme .pw-stats {
    border-color: rgba(109, 40, 217, 0.12);
    box-shadow:
        inset 2px 2px 6px rgba(255, 255, 255, 0.6),
        inset -3px -3px 10px rgba(70, 43, 124, 0.08);
}

.pw-stats-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding-bottom: 10px;
    border-bottom: 1px dashed rgba(255, 255, 255, 0.14);
    font-family: "Ciname", sans-serif;
    font-size: 0.9rem;
}

.pw-stats-head .mine { color: #93c5fd; }
.pw-stats-head .opp { color: #fdba74; }
.pw-stats-head .mid {
    font-size: 0.8rem;
    color: var(--muted);
    font-family: "Nazanin", sans-serif;
}

.pw-stats-row {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: 8px;
}

.pw-stats-row b {
    text-align: center;
    font-size: 1.05rem;
    font-family: "Consolas", "Courier New", monospace;
    font-weight: 800;
}

.pw-stats-row b.mine { color: #93c5fd; }
.pw-stats-row b.opp { color: #fdba74; }

.pw-stats-row span {
    text-align: center;
    font-family: "Nazanin", sans-serif;
    font-size: 0.82rem;
    color: var(--muted);
    background: var(--panel-strong);
    border: 1px solid rgba(255, 255, 255, 0.07);
    border-radius: 999px;
    padding: 3px 16px;
    white-space: nowrap;
}

.pw-stats-foot {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    margin-top: 4px;
    padding-top: 10px;
    border-top: 1px dashed rgba(255, 255, 255, 0.14);
    font-family: "Nazanin", sans-serif;
    font-size: 0.82rem;
    color: var(--muted);
}

.pw-over-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
    margin-top: 18px;
    flex-wrap: wrap;
}

.pw-over-actions a {
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* ---------------------------------------------------------------
   Accessibility: visible keyboard focus
--------------------------------------------------------------- */
.pw-btn:focus-visible,
.pw-chip:focus-visible,
.pw-ghost:focus-visible,
.pw-input:focus-visible {
    outline: 3px solid var(--accent);
    outline-offset: 3px;
}

/* ---------------------------------------------------------------
   Motion preferences: reduce all non-essential animation
--------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
    .pw-hero-icon,
    .pw-waiting,
    .pw-waiting-spin,
    .pw-btn-spin,
    .pw-status-chip,
    .pw-turn-time.danger,
    .pw-lock-badge,
    .pw-soldier.dead svg,
    .pw-soldier.shake,
    .pw-aim,
    .pw-aim-ring,
    .pw-stamp,
    .pw-result-field {
        animation: none;
    }
    .pw-btn,
    .pw-chip,
    .pw-ghost,
    .pw-input {
        transition: none;
    }
}

/* ---------------------------------------------------------------
   Tablet (≥641px)
--------------------------------------------------------------- */
@media (min-width: 641px) {
    .pw-shell {
        padding: 14px 20px calc(20px + env(safe-area-inset-bottom));
    }
    .pw-panel {
        padding: 26px 24px;
    }
    .pw-lobby-section {
        padding: 18px;
    }
    .pw-hero {
        margin-bottom: 20px;
    }
    .pw-hero-icon {
        font-size: 3.2rem;
    }
    .pw-top-row {
        max-width: 520px;
    }
}

/* ---------------------------------------------------------------
   Desktop (≥1024px)
--------------------------------------------------------------- */
@media (min-width: 1024px) {
    .pw-shell {
        width: min(96vw, 1160px);
        min-height: calc(100vh - 132px);
        min-height: calc(100svh - 132px);
        padding: 20px 28px calc(28px + env(safe-area-inset-bottom));
    }
    .pw-panel {
        max-width: 520px;
        padding: 30px 28px;
    }
    .pw-play-layout {
        gap: 28px;
    }
    .pw-board-stage .pw-actions {
        max-width: var(--pw-side, 340px);
    }
}

/* ---------------------------------------------------------------
   Phones in landscape: compact
--------------------------------------------------------------- */
@media (orientation: landscape) and (max-width: 1023px) {
    .pw-shell {
        padding: 6px 14px calc(12px + env(safe-area-inset-bottom));
        min-height: calc(100svh - 72px);
    }
    .pw-top-row {
        margin-bottom: 6px;
    }
    .pw-hero {
        margin-bottom: 10px;
    }
    .pw-hero-icon {
        font-size: 2.2rem;
        margin-bottom: 0;
    }
    .pw-title {
        margin-top: 0;
        font-size: 1.5rem;
    }
    .pw-subtitle {
        margin-bottom: 8px;
    }
    .pw-board-stage {
        gap: 8px;
    }
    .pw-actions {
        min-height: 48px;
    }
}

/* ---------------------------------------------------------------
   Short portrait phones (e.g. 375×667): tighten vertical rhythm
--------------------------------------------------------------- */
@media (max-width: 1023px) and (orientation: portrait) and (max-height: 700px) {
    .pw-shell {
        padding: 4px 12px calc(12px + env(safe-area-inset-bottom));
    }
    .pw-top-row {
        margin-bottom: 4px;
    }
    .pw-title {
        margin-top: 0;
        font-size: 1.5rem;
    }
    .pw-subtitle {
        margin-bottom: 10px;
    }
    .pw-panel {
        padding: 14px 14px;
    }
    .pw-hero {
        margin-bottom: 12px;
    }
    .pw-hero-icon {
        font-size: 2.2rem;
        margin-bottom: 0;
    }
    .pw-actions {
        min-height: 46px;
    }
    .pw-chips {
        gap: 6px;
        margin-bottom: 10px;
    }
    .pw-chip {
        min-height: 48px;
        padding: 8px 4px;
        font-size: 0.9rem;
    }
    .pw-lobby-section {
        padding: 12px;
    }
    .pw-winner-banner {
        padding: 10px;
        margin-bottom: 10px;
    }
    .pw-stats {
        padding: 10px;
        gap: 6px;
        margin-bottom: 10px;
    }
    .pw-stats-head {
        padding-bottom: 6px;
    }
    .pw-stats-row b {
        font-size: 0.95rem;
    }
    .pw-stats-foot {
        padding-top: 6px;
        margin-top: 2px;
    }
    .pw-over-actions .pw-btn {
        min-height: 44px;
        padding: 8px 14px;
        font-size: 0.9rem;
    }
}

/* ---------------------------------------------------------------
   Icon sizing for inline SVG chips and heroes
--------------------------------------------------------------- */
.pw-lock-icon {
    font-size: 2.6rem;
    line-height: 1;
    margin-bottom: 10px;
}

.pw-lock-icon svg {
    width: 2.6rem;
    height: 2.6rem;
}

.pw-waiting-spin svg,
.pw-btn-spin svg,
.pw-lock-badge svg {
    width: 1.15em;
    height: 1.15em;
    vertical-align: -0.2em;
}

.pw-hero-icon svg,
.pw-winner-emoji svg {
    width: 3rem;
    height: 3rem;
}

.pw-cover-icon svg {
    width: 1.9rem;
    height: 1.9rem;
}

.pw-status-chip svg {
    width: 1.15em;
    height: 1.15em;
    vertical-align: -0.2em;
}

.pw-hint svg {
    width: 1em;
    height: 1em;
    vertical-align: -0.15em;
}