/* The Peter Pan game page (/game/peter-pan). The stage is a dark box holding the canvas, the start and end
   panels and, on touch screens, the buttons. While playing on a phone it fills the screen. */

.game {
    max-width: 1100px;
    margin-inline: auto;
    padding-block: 1.5rem 3rem;
}

.game-head {
    text-align: center;
    margin-block-end: 1.25rem;
}

.game-title {
    font-size: clamp(1.6rem, 4vw, 2.4rem);
    margin-block-end: 0.5rem;
}

.game-lead {
    max-width: 40rem;
    margin-inline: auto;
    color: var(--ink-soft, #555);
}

/* A phone on its side: keep the Play button in sight */
@media (max-height: 500px) {
    .game {
        padding-block-start: 0.5rem;
    }

    .game-lead {
        display: none;
    }
}

.game-stage {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 9;
    max-height: calc(100vh - 90px);
    margin-inline: auto;
    background: #120c22;
    border-radius: 10px;
    overflow: hidden;
    color: #fbf3e4;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
    outline: none;
}

.game-stage:focus-visible {
    box-shadow: 0 0 0 3px rgba(255, 214, 90, 0.8);
}

.game-stage canvas {
    display: block;
    width: 100%;
    height: 100%;
    image-rendering: crisp-edges;
    image-rendering: pixelated;  /* the game is pixel art: no smoothing when the browser scales it */
}

/* On a phone, playing fills the whole screen */
body.game-touch-device.game-playing {
    overflow: hidden;
}

body.game-touch-device.game-playing .game-stage {
    position: fixed;
    inset: 0;
    z-index: 2000;
    aspect-ratio: auto;
    max-height: none;
    border-radius: 0;
    height: 100dvh;
}

/* Upright phones: a taller stage before and after playing */
@media (orientation: portrait) and (pointer: coarse) {
    .game-stage {
        aspect-ratio: 3 / 4;
    }
}

.game-panel {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    padding: 1.25rem;
    text-align: center;
    background: rgba(10, 6, 22, 0.55);
}

.game-panel[hidden] {
    display: none;
}

.game-play {
    font-size: 1.25rem;
    padding: 0.7rem 2.6rem;
}

.game-controls {
    max-width: 30rem;
    margin: 0;
    font-size: 0.95rem;
    opacity: 0.9;
}

.game-controls-touch,
.game-turn {
    display: none;
}

body.game-touch-device .game-controls-keys {
    display: none;
}

body.game-touch-device .game-controls-touch {
    display: block;
}

@media (orientation: portrait) {
    body.game-touch-device .game-turn {
        display: block;
        margin: 0;
        font-size: 0.9rem;
        opacity: 0.75;
    }
}

.game-end {
    background: rgba(8, 6, 20, 0.82);
    overflow-y: auto;
}

.game-won {
    font-size: clamp(1.4rem, 4vw, 2rem);
    margin: 0;
}

.game-time,
.game-best {
    margin: 0;
}

.game-best {
    opacity: 0.75;
    font-size: 0.95rem;
}

.game-quote {
    margin: 0.5rem 0;
    font-size: clamp(1.1rem, 3vw, 1.5rem);
    font-style: italic;
}

.game-quote p {
    margin: 0;
}

.game-quote footer {
    font-size: 0.85rem;
    font-style: normal;
    opacity: 0.75;
    margin-block-start: 0.25rem;
}

.game-end-links {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.6rem;
    margin: 0;
}

/* The ink buttons are made for paper: on the dark stage they need light ink */
.game-stage .ink-btn {
    color: #fbf3e4;
    border-color: rgba(251, 243, 228, 0.7);
    background: transparent;
}

.game-stage .ink-btn-solid {
    color: #1a1030 !important;  /* paper.css sets the solid button's text with !important */
    background: #f4d27a;
    border-color: #f4d27a;
}

.game-stage .ink-btn-solid:hover,
.game-stage .ink-btn-solid:focus-visible {
    background: #ffe39a;
    border-color: #ffe39a;
}

/* The name of each scene, shown for a moment as Peter reaches it */
.game-scene {
    position: absolute;
    inset-block-start: 12%;
    inset-inline: 0;
    margin: 0;
    text-align: center;
    font-size: clamp(1.1rem, 3.4vw, 1.9rem);
    letter-spacing: 0.04em;
    text-shadow: 0 2px 12px rgba(0, 0, 0, 0.7);
    opacity: 0;
    transition: opacity 0.6s ease;
    pointer-events: none;
}

.game-scene.is-shown {
    opacity: 1;
}

.game-bar {
    position: absolute;
    inset-block-start: 8px;
    right: 8px; /* direction-neutral */  /* the canvas draws the hearts top left in every language */
    display: flex;
    gap: 6px;
    z-index: 2;
}

.game-icon {
    width: 40px;
    height: 40px;
    display: grid;
    place-items: center;
    border: 0;
    border-radius: 50%;
    color: #fbf3e4;
    background: rgba(0, 0, 0, 0.35);
}

.game-icon .game-sound-off,
.game-icon.is-off .game-sound-on {
    display: none;
}

.game-icon.is-off .game-sound-off {
    display: block;
}

/* Touch buttons along the bottom: running on one side, jump and strike on the other */
.game-touch {
    position: absolute;
    inset-inline: 0;
    inset-block-end: 0;
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    padding: 0 max(12px, env(safe-area-inset-left)) max(12px, env(safe-area-inset-bottom));
    pointer-events: none;
}

.game-touch[hidden] {
    display: none;
}

.game-touch-group {
    display: flex;
    gap: 12px;
    pointer-events: auto;
}

.game-pad {
    width: 64px;
    height: 64px;
    display: grid;
    place-items: center;
    border: 2px solid rgba(255, 255, 255, 0.35);
    border-radius: 50%;
    color: rgba(255, 255, 255, 0.85);
    background: rgba(0, 0, 0, 0.28);
    touch-action: none;
}

.game-pad.is-down {
    background: rgba(255, 214, 90, 0.35);
}

.game-pad-jump {
    width: 76px;
    height: 76px;
}

@media (max-height: 420px) {
    .game-pad {
        width: 54px;
        height: 54px;
    }

    .game-pad-jump {
        width: 64px;
        height: 64px;
    }
}

.game-about {
    max-width: 44rem;
    margin: 2rem auto 0;
}
