:root {
    --play-glow: #5dff9d;
    --play-gold: #ffd966;
    --play-panel: rgba(12, 10, 8, 0.72);
    --play-border: #2d2418;
    --play-text: #fff8ea;
    --play-muted: #c9b896;
}

@font-face {
    font-family: "silkscreen";
    src: url("/fonts/silkscreen.ttf") format("truetype");
    font-display: swap;
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

html,
body.play-body {
    margin: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    font-family: silkscreen, "Courier New", monospace;
    color: var(--play-text);
    image-rendering: pixelated;
    -webkit-font-smoothing: none;
}

.play-body {
    background: #0a0c10;
}

/* Slow Ken Burns zoom on hero background */
.play-bg {
    position: fixed;
    inset: -4%;
    z-index: 0;
    overflow: hidden;
    pointer-events: none;
}

.play-bg__image {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center 42%;
    transform: scale(1);
    animation: play-bg-zoom 48s linear infinite;
    will-change: transform, opacity;
}

@keyframes play-bg-intro {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes play-bg-zoom {
    from { transform: scale(1); }
    to { transform: scale(1.12); }
}

.play-bg__shade {
    position: absolute;
    inset: 0;
    background:
        radial-gradient(ellipse 80% 60% at 50% 18%, rgba(93, 255, 157, 0.14), transparent 58%),
        linear-gradient(180deg, rgba(8, 10, 14, 0.35) 0%, rgba(8, 10, 14, 0.72) 55%, rgba(6, 8, 12, 0.92) 100%);
}

.play-bg__scan {
    position: absolute;
    inset: 0;
    opacity: 0.08;
    background-image:
        linear-gradient(rgba(255, 255, 255, 0.04) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.04) 1px, transparent 1px);
    background-size: 4px 4px;
    mix-blend-mode: overlay;
    animation: play-scan-drift 12s linear infinite;
}

@keyframes play-scan-drift {
    from { background-position: 0 0, 0 0; }
    to { background-position: 0 16px, 16px 0; }
}

.play-bg__grain {
    position: absolute;
    inset: 0;
    opacity: 0.18;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 160 160' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='1.35' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.55'/%3E%3C/svg%3E");
    background-size: 120px 120px;
    mix-blend-mode: soft-light;
}

#play-landing {
    position: fixed;
    inset: 0;
    z-index: 10050;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px 16px 32px;
    transition: opacity 420ms steps(6, end), visibility 420ms steps(6, end);
}

#play-landing.is-hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    display: none !important;
}

.play-landing-inner {
    position: relative;
    z-index: 1;
    width: min(560px, 100%);
    text-align: center;
    padding: 28px 22px 24px;
    border: 4px solid var(--play-border);
    background: var(--play-panel);
    box-shadow:
        0 0 0 2px #8b7355,
        8px 8px 0 rgba(0, 0, 0, 0.45);
}

.play-landing-inner::before {
    content: "";
    position: absolute;
    inset: 6px;
    border: 2px dashed rgba(255, 248, 234, 0.12);
    pointer-events: none;
}

.play-logo {
    width: min(280px, 82vw);
    height: auto;
    margin: 0 auto 18px;
    display: block;
    filter: drop-shadow(4px 4px 0 rgba(0, 0, 0, 0.45));
    animation: play-logo-bob 2.4s steps(2, end) infinite;
}

@keyframes play-logo-bob {
    0%, 100% { transform: translateY(-2px); }
    50% { transform: translateY(3px); }
}

.play-kicker {
    margin: 0 0 14px;
    font-size: clamp(11px, 2.8vw, 13px);
    line-height: 1.65;
    letter-spacing: 0.06em;
    color: var(--play-glow);
    text-shadow: 2px 2px 0 #123a24;
}

.play-tagline {
    margin: 0 0 22px;
    font-size: clamp(10px, 2.5vw, 12px);
    line-height: 1.75;
    color: var(--play-muted);
    max-width: 46ch;
    margin-inline: auto;
}

.play-actions {
    display: flex;
    flex-direction: column;
    gap: 12px;
    align-items: stretch;
}

.play-btn {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 52px;
    padding: 12px 18px;
    border: 3px solid var(--play-border);
    font-family: inherit;
    font-size: 13px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    cursor: pointer;
    transition: transform 80ms steps(2, end), filter 80ms steps(2, end);
    image-rendering: pixelated;
}

.play-btn:active:not(:disabled) {
    transform: translate(2px, 2px);
}

.play-btn:disabled {
    opacity: 0.55;
    cursor: wait;
}

.play-btn--primary {
    color: #123a24;
    background: linear-gradient(180deg, #7dffb8 0%, var(--play-glow) 55%, #35c974 100%);
    box-shadow: 0 4px 0 #1a8a4a, 0 0 24px rgba(93, 255, 157, 0.35);
}

.play-btn--primary:hover:not(:disabled) {
    filter: brightness(1.06);
}

.play-btn--ghost {
    color: #2a2218;
    background: #ffffff;
    box-shadow: 0 4px 0 #b8b0a0;
}

.play-btn--ghost:hover:not(:disabled) {
    background: #fffefb;
}

.play-profile-flow {
    margin-top: 18px;
    width: 100%;
    max-width: 360px;
    margin-inline: auto;
}

.play-profile-flow.hidden {
    display: none;
}

.play-profile-panel {
    display: flex;
    flex-direction: column;
    gap: 12px;
    align-items: stretch;
}

.play-profile-panel.hidden {
    display: none;
}

.play-profile-title {
    margin: 0;
    font-size: 13px;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--play-glow);
    text-shadow: 2px 2px 0 #123a24;
}

.play-profile-copy {
    margin: 0;
    font-size: 10px;
    line-height: 1.65;
    color: var(--play-muted);
}

.play-profile-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-height: min(42vh, 280px);
    overflow-y: auto;
    padding-right: 2px;
}

.play-profile-row {
    display: flex;
    align-items: stretch;
    gap: 8px;
}

.play-profile-row .play-profile-slot {
    flex: 1;
    min-width: 0;
}

.play-profile-delete {
    flex-shrink: 0;
    width: 44px;
    min-height: 48px;
    padding: 0;
    border: 3px solid var(--play-border);
    background: rgba(255, 255, 255, 0.92);
    color: #b34040;
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
    box-shadow: 2px 2px 0 rgba(0, 0, 0, 0.25);
    font-family: inherit;
}

.play-profile-delete:hover:not(:disabled) {
    background: #fff5f5;
}

.play-profile-delete:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.play-profile-slot {
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
    min-height: 48px;
    text-transform: none;
    letter-spacing: 0.04em;
}

.play-profile-slot-name {
    font-size: 12px;
    letter-spacing: 0.06em;
    text-transform: none;
}

.play-profile-slot-meta {
    font-size: 10px;
    color: var(--play-muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.play-profile-empty {
    margin: 0;
    padding: 12px 10px;
    border: 2px dashed rgba(201, 184, 150, 0.45);
    font-size: 10px;
    line-height: 1.6;
    color: var(--play-muted);
    text-align: center;
}

.play-profile-status {
    margin: 0;
    min-height: 1.2em;
    font-size: 10px;
    color: var(--play-muted);
}

.play-profile-status.is-error {
    color: #ff9f9f;
}

.play-profile-back {
    margin-top: 4px;
}

.play-profile-confirm {
    position: fixed;
    inset: 0;
    z-index: 10200;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: rgba(4, 6, 10, 0.78);
}

.play-profile-confirm.hidden {
    display: none !important;
}

.play-profile-confirm-panel {
    width: min(340px, 100%);
    padding: 20px 18px 16px;
    border: 4px solid var(--play-border);
    background: #f4ecd8;
    color: #2a2218;
    box-shadow: 8px 8px 0 rgba(0, 0, 0, 0.45);
    text-align: center;
}

.play-profile-confirm-title {
    margin: 0 0 10px;
    font-size: 13px;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: #8b2e2e;
    text-shadow: 2px 2px 0 rgba(0, 0, 0, 0.15);
}

.play-profile-confirm-body {
    margin: 0 0 8px;
    font-size: 11px;
    line-height: 1.65;
    letter-spacing: 0.04em;
    color: #2a2218;
}

.play-profile-confirm-body strong {
    color: #123a24;
    font-weight: inherit;
    letter-spacing: 0.06em;
}

.play-profile-confirm-warn {
    margin: 0 0 16px;
    font-size: 10px;
    line-height: 1.55;
    color: #6b5d48;
}

.play-profile-confirm-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.play-btn--danger {
    color: #fff8ea;
    background: linear-gradient(180deg, #e06060 0%, #b34040 55%, #8b2e2e 100%);
    box-shadow: 0 4px 0 #5a1515, 0 0 16px rgba(179, 64, 64, 0.25);
}

.play-btn--danger:hover:not(:disabled) {
    filter: brightness(1.05);
}

.play-passcode-display {
    display: flex;
    justify-content: center;
    gap: 12px;
    margin: 4px 0 2px;
}

.play-passcode-slot {
    width: 18px;
    height: 18px;
    border: 3px solid var(--play-border);
    background: rgba(255, 255, 255, 0.92);
    box-shadow: 2px 2px 0 rgba(0, 0, 0, 0.25);
}

.play-passcode-slot.is-filled {
    background: var(--play-glow);
    box-shadow: 2px 2px 0 #1a8a4a, inset 0 0 0 2px #35c974;
}

.play-passcode-keypad {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}

.play-passcode-key {
    min-height: 46px;
    border: 3px solid var(--play-border);
    background: rgba(255, 255, 255, 0.95);
    color: #2a2218;
    font-family: inherit;
    font-size: 14px;
    cursor: pointer;
}

.play-passcode-key:active {
    transform: translate(2px, 2px);
}

.play-passcode-key-muted {
    opacity: 0;
    pointer-events: none;
}

.play-passcode-key-back {
    font-size: 16px;
}

.play-wallet-bar {
    position: fixed;
    top: 14px;
    right: 14px;
    z-index: 10160;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 8px;
    pointer-events: auto;
}

.play-wallet-bar.hidden {
    display: none;
}

body.play-in-app:has(#game-screen:not(.hidden)) .play-wallet-bar {
    display: none !important;
}

.play-wallet-bar-address {
    padding: 6px 10px;
    border: 2px solid rgba(93, 255, 157, 0.55);
    border-radius: 6px;
    background: rgba(93, 255, 157, 0.14);
    box-shadow:
        0 0 12px rgba(93, 255, 157, 0.22),
        inset 0 0 10px rgba(93, 255, 157, 0.08);
    font-size: 9px;
    letter-spacing: 0.06em;
    color: var(--play-glow);
    text-transform: uppercase;
}

.play-wallet-bar-address.hidden {
    display: none;
}

.play-wallet-bar-disconnect {
    padding: 7px 12px;
    border: 2px solid var(--play-border);
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.94);
    box-shadow: 2px 2px 0 rgba(0, 0, 0, 0.28);
    font-family: inherit;
    font-size: 9px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #6b2a2a;
    cursor: pointer;
}

.play-wallet-bar-disconnect:hover:not(:disabled) {
    background: #fff;
}

.play-wallet-bar-disconnect:active:not(:disabled) {
    transform: translate(1px, 1px);
    box-shadow: 1px 1px 0 rgba(0, 0, 0, 0.28);
}

.play-wallet-bar-disconnect:disabled {
    opacity: 0.55;
    cursor: wait;
}

.play-status {
    min-height: 2.4em;
    margin: 14px 0 0;
    font-size: 10px;
    line-height: 1.5;
    color: var(--play-muted);
}

.play-status.is-error {
    color: #ff8f8f;
}

.play-status.is-success {
    color: var(--play-glow);
}

.play-wallet-hint {
    margin: 16px 0 0;
    font-size: 9px;
    line-height: 1.5;
    color: rgba(201, 184, 150, 0.75);
}

/* Wallet picker modal */
.play-wallet-modal {
    position: fixed;
    inset: 0;
    z-index: 10100;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: rgba(4, 6, 10, 0.78);
}

.play-wallet-modal.hidden {
    display: none !important;
}

.play-wallet-panel {
    width: min(380px, 100%);
    padding: 22px 18px 18px;
    border: 4px solid var(--play-border);
    background: #f4ecd8;
    color: #2a2218;
    box-shadow: 8px 8px 0 rgba(0, 0, 0, 0.45);
}

.play-wallet-title {
    margin: 0 0 8px;
    font-size: 14px;
    letter-spacing: 0.06em;
}

.play-wallet-copy {
    margin: 0 0 16px;
    font-size: 10px;
    line-height: 1.55;
    color: #6b5d48;
}

.play-wallet-status {
    margin: -6px 0 14px;
    padding: 10px 12px;
    font-size: 10px;
    line-height: 1.55;
    border: 2px solid #2d2418;
    background: #fff8ea;
    color: #2a2218;
}

.play-wallet-status.hidden {
    display: none !important;
}

.play-wallet-status.is-error {
    border-color: #8b2e2e;
    background: #ffe8e8;
    color: #5a1515;
}

.play-wallet-status.is-success {
    border-color: #2d6a3e;
    background: #e8f8ec;
    color: #1a4a28;
}

.play-wallet-status.is-info {
    border-color: #2d2418;
    background: #fff2d6;
    color: #2a2218;
}

.play-wallet-options {
    display: grid;
    gap: 10px;
}

.play-wallet-option {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 12px 14px;
    border: 3px solid #2d2418;
    background: #fff8ea;
    font-family: inherit;
    font-size: 11px;
    cursor: pointer;
    text-align: left;
}

.play-wallet-option:hover {
    background: #fff2d6;
}

.play-wallet-option-text {
    display: flex;
    flex-direction: column;
    gap: 3px;
    min-width: 0;
}

.play-wallet-option-name {
    font-size: 11px;
    line-height: 1.2;
}

.play-wallet-detected {
    font-size: 9px;
    line-height: 1.3;
    letter-spacing: 0.04em;
    color: #1a6b3a;
}

.play-wallet-detected.hidden {
    display: none;
}

.play-wallet-icon {
    width: 28px;
    height: 28px;
    border-radius: 6px;
    display: grid;
    place-items: center;
    overflow: hidden;
    flex-shrink: 0;
}

.play-wallet-icon img {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: cover;
    border-radius: 6px;
}

.play-wallet-close {
    margin-top: 12px;
    width: 100%;
    padding: 10px;
    border: 3px solid #2d2418;
    background: transparent;
    font-family: inherit;
    font-size: 10px;
    cursor: pointer;
}

/* Landing hero on /play; menus use retro sky; live game hides both */
body.play-mode #retro-pixel-bg,
body.play-mode .play-bg {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 420ms ease, visibility 420ms ease;
}

body.play-mode:not(.play-in-app) #retro-pixel-bg {
    opacity: 0;
    visibility: hidden;
}

body.play-mode:not(.play-in-app) .play-bg {
    opacity: 1;
    visibility: visible;
}

body.play-mode:not(.play-in-app) .play-bg__image {
    animation:
        play-bg-intro 2.8s ease-out forwards,
        play-bg-zoom 48s linear 2.8s infinite;
}

body.play-mode.play-in-app:not(.game-active) #retro-pixel-bg {
    opacity: 1;
    visibility: visible;
}

body.play-mode.play-in-app:not(.game-active) .play-bg {
    opacity: 0;
    visibility: hidden;
}

body.play-mode.game-active #retro-pixel-bg,
body.play-mode.game-active .play-bg,
body.play-mode.play-in-app.game-active #retro-pixel-bg,
body.play-mode.play-in-app.game-active .play-bg {
    opacity: 0 !important;
    visibility: hidden !important;
    pointer-events: none !important;
    display: none !important;
}

body.play-mode .play-bg {
    z-index: 0;
}

body.play-mode .screen {
    z-index: 2;
}

#play-game {
    position: fixed;
    inset: 0;
    z-index: 10;
}

#play-game #game-screen {
    padding: 0;
    justify-content: stretch;
    align-items: stretch;
}

#play-game #app-container {
    flex: 1;
    width: 100%;
    height: 100%;
}

#play-game.hidden {
    display: none !important;
}

body.spectator-mode #game-hud,
body.spectator-mode #game-hud-stack,
body.spectator-mode .game-hud-deposit,
body.spectator-mode .game-top-actions,
body.spectator-mode .game-poketab-btn,
body.spectator-mode .game-bag-btn,
body.spectator-mode .game-pad,
body.spectator-mode .join-toast-stack,
body.spectator-mode .sign-modal,
body.spectator-mode .game-drawer,
body.spectator-mode .game-loading {
    display: none !important;
}

body.spectator-mode #game-screen::before,
body.spectator-mode #game-screen::after {
    display: none !important;
}

.play-spectate-badge {
    position: fixed;
    top: 12px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 30;
    padding: 6px 12px;
    border: 2px solid #2d2418;
    background: rgba(12, 10, 8, 0.78);
    color: var(--play-gold);
    font-size: 9px;
    letter-spacing: 0.12em;
    pointer-events: none;
    display: none;
}

body.spectator-mode .play-spectate-badge {
    display: block;
    max-width: min(92vw, 420px);
    text-align: center;
    line-height: 1.45;
}

body.spectator-mode #app-container,
body.spectator-mode #app-container canvas {
    touch-action: none;
}

body.spectator-mode #game-screen {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    justify-content: stretch;
    width: 100%;
    height: 100%;
}

body.spectator-mode #app-container {
    flex: 1 1 auto;
    width: 100%;
    min-height: 0;
    position: relative;
    z-index: 1;
}

body.spectator-mode #app-container canvas {
    cursor: grab;
}

body.spectator-mode.spectator-dragging #app-container canvas {
    cursor: grabbing !important;
}

body.spectator-mode #app-container canvas:active {
    cursor: grabbing;
}

.play-exit-spectate {
    position: fixed;
    top: 12px;
    right: 12px;
    z-index: 30;
    display: none;
    padding: 8px 12px;
    border: 2px solid #2d2418;
    background: rgba(12, 10, 8, 0.82);
    color: #fff8ea;
    font-family: inherit;
    font-size: 9px;
    cursor: pointer;
}

body.spectator-mode .play-exit-spectate {
    display: block;
}

@media (max-width: 480px) {
    .play-landing-inner {
        padding: 22px 16px 18px;
    }

    .play-kicker {
        letter-spacing: 0.04em;
    }
}
