html, body {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    background: #000;
    overflow: hidden;
}

body {
    color: #ffffff;
    font-family: Arial, Helvetica, sans-serif;
}

* {
    box-sizing: border-box;
}

#page-layout {
    --maze-size: min(calc((100vw - 16px) * 0.75), calc(100vh - 16px));
    --side-width: calc(var(--maze-size) / 3);
    width: 100vw;
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0;
    padding: 8px;
    background: #000;
}

#game-wrap {
    position: relative;
    width: var(--maze-size);
    height: var(--maze-size);
    display: flex;
    align-items: center;
    justify-content: center;
    background: #000;
}

#side-ui {
    width: var(--side-width);
    min-width: var(--side-width);
    height: var(--maze-size);
    display: grid;
    grid-template-rows: auto auto auto 1fr;
    gap: clamp(6px, 0.8vw, 10px);
    padding: 4px 10px 14px;
    background: #000;
}

.side-logo-panel {
    display: flex;
    align-items: flex-start;
}

#titleLogoCanvas {
    display: block;
    width: 100%;
    max-width: none;
    height: auto;
    margin: 0;
    background: transparent;
}

.utility-buttons {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 7px;
}

.utility-button {
    height: clamp(22px, 2.5vw, 30px);
    border: 0;
    border-radius: 0;
    background: #000;
    color: #ffffff;
    font: 400 clamp(0.58rem, 0.74vw, 0.68rem) Arial, Helvetica, sans-serif;
    letter-spacing: 0.42px;
    text-transform: uppercase;
    text-shadow: none;
    box-shadow: none;
    cursor: pointer;
    position: relative;
    overflow: visible;
    outline: none;
    appearance: none;
    -webkit-appearance: none;
}

.utility-button:focus,
.utility-button:focus-visible,
.utility-button:active {
    outline: none;
    border: 0;
    box-shadow: none;
}

.icon-button {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    padding: 0;
    overflow: visible;
}

.utility-label {
    color: rgba(255, 255, 255, 0.82);
    font-size: clamp(0.62rem, 0.78vw, 0.74rem);
    font-weight: 400;
    letter-spacing: 0.25px;
    text-transform: none;
    white-space: nowrap;
    text-shadow: 0 0 3px rgba(255, 255, 255, 0.32);
}

.utility-icon {
    display: block;
    width: clamp(20px, 2.05vw, 27px);
    height: clamp(20px, 2.05vw, 27px);
    object-fit: contain;
    pointer-events: none;
    filter: none;
}

.side-middle {
    display: flex;
    flex-direction: column;
    gap: clamp(7px, 0.9vw, 11px);
}

.side-panel {
    border: 1px solid rgba(255, 255, 255, 0.20);
    border-radius: 10px;
    padding: clamp(6px, 0.75vw, 9px) clamp(7px, 0.82vw, 10px);
    background: #000;
    box-shadow: inset 0 0 10px rgba(255, 255, 255, 0.032);
}

.play-panel {
    overflow: visible;
}

body.is-demo .play-panel {
    border: 0;
    padding: 0;
    box-shadow: none;
    background: #000;
}

.panel-label {
    color: rgba(255, 255, 255, 0.70);
    font-size: clamp(0.54rem, 0.72vw, 0.66rem);
    font-weight: 400;
    letter-spacing: 1.1px;
    line-height: 1;
    margin-bottom: 6px;
    text-transform: uppercase;
    text-shadow: 0 0 4px rgba(255, 255, 255, 0.32);
}

.high-score-value {
    color: #ffffff;
    font-weight: 400;
    font-size: clamp(0.84rem, 1.12vw, 1rem);
    line-height: 1;
    letter-spacing: 0.9px;
    text-shadow: 0 0 6px rgba(255, 255, 255, 0.58);
}

.high-score-panel {
    padding-top: clamp(7px, 0.82vw, 10px);
    padding-bottom: clamp(7px, 0.82vw, 10px);
}

.high-score-line {
    display: grid;
    grid-template-columns: max-content 1fr;
    column-gap: clamp(9px, 1vw, 13px);
    align-items: center;
}
.side-stats {
    display: grid;
    grid-template-columns: max-content minmax(0, 1fr);
    column-gap: clamp(9px, 1vw, 13px);
    row-gap: clamp(6px, 0.8vw, 9px);
    align-items: center;
}

.stat-label {
    color: rgba(255, 255, 255, 0.84);
    text-shadow: 0 0 5px rgba(255, 255, 255, 0.5);
    font-weight: 400;
    font-size: clamp(0.78rem, 1.05vw, 0.95rem);
    line-height: 1;
    white-space: nowrap;
}

.stat-value {
    min-width: 0;
    color: #ffffff;
    text-shadow: 0 0 6px rgba(255, 255, 255, 0.6);
    font-weight: 400;
    font-size: clamp(0.84rem, 1.12vw, 1rem);
    line-height: 1;
    white-space: nowrap;
}

.hint,
.demo-start-hint {
    color: #ffffff;
    text-shadow: 0 0 4px rgba(255, 255, 255, 0.42);
}

.hint {
    font-size: clamp(0.62rem, 0.78vw, 0.72rem);
    line-height: 1.25;
}

.demo-start-hint {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 0;
}

.demo-start-main {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    width: 100%;
    font-weight: 400;
    font-size: clamp(0.66rem, 0.84vw, 0.78rem);
    line-height: 1;
    white-space: nowrap;
}

.start-nag-panel {
    position: relative;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 4px;
    padding: clamp(8px, 0.95vw, 11px) clamp(9px, 1vw, 12px);
    border-radius: 10px;
    background: #000;
    overflow: hidden;
}

.start-main-line {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    position: relative;
    z-index: 1;
    font-size: 14px;
    white-space: nowrap;
}

.start-sound-reminder {
    position: relative;
    z-index: 1;
    display: block;
    font-size: 14px;
    margin-top: 5px;
    max-width: 300px;
    white-space: normal;
    overflow-wrap: break-word;
    text-align: center;
    line-height: 1.25;
    opacity: 0.72;
    letter-spacing: 0.15px;
    /* allow wrapping */
}

.demo-start-hint,
.demo-start-main,
.start-nag-panel {
    height: auto;
    min-height: 0;
    overflow: visible;
}

.start-nag-panel {
    box-sizing: border-box;
    padding-top: 12px;
    padding-bottom: 14px;
}


.start-nag-panel::before {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: inherit;
    background:
        linear-gradient(90deg, currentColor 50%, transparent 50%) 0 0 / 12px 1px repeat-x,
        linear-gradient(90deg, currentColor 50%, transparent 50%) 0 100% / 12px 1px repeat-x,
        linear-gradient(0deg, currentColor 50%, transparent 50%) 0 0 / 1px 12px repeat-y,
        linear-gradient(0deg, currentColor 50%, transparent 50%) 100% 0 / 1px 12px repeat-y;
    color: #ffff00;
    pointer-events: none;
    animation:
        startMarch 680ms linear infinite,
        startColourCycle 12600ms steps(1, end) infinite;
}

.start-nag-panel::after {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: inherit;
    box-shadow: 0 0 7px currentColor;
    color: #ffff00;
    opacity: 0.12;
    pointer-events: none;
    animation: startColourCycle 12600ms steps(1, end) infinite;
}

.start-nag-panel span {
    position: relative;
    z-index: 1;
}

.game-version {
    position: absolute;
    right: 18px;
    bottom: 14px;
    color: rgba(255, 255, 255, 0.65);
    font-family: Arial, Helvetica, sans-serif;
    font-size: 13px;
    font-weight: 400;
    letter-spacing: 0.08em;
    text-shadow: none;
}

@keyframes startMarch {
    from {
        background-position:
            0 0,
            0 100%,
            0 0,
            100% 0;
    }
    to {
        background-position:
            12px 0,
            -12px 100%,
            0 -12px,
            100% 12px;
    }
}

@keyframes startColourCycle {
    0% {
        color: #ffff00;
    }
    16% {
        color: #ff2020;
    }
    32% {
        color: #ff4cff;
    }
    48% {
        color: #00ffff;
    }
    64% {
        color: #ff9900;
    }
    80% {
        color: #0066ff;
    }
}

.demo-start-hint .key-label {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 52px;
    height: 19px;
    padding: 0 8px;
    border: 1px solid rgba(255, 255, 255, 0.64);
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.028);
    box-shadow: inset 0 0 4px rgba(255, 255, 255, 0.045), 0 0 3px rgba(255, 255, 255, 0.10);
    font-weight: 400;
    font-size: inherit;
    letter-spacing: 0.45px;
}

.demo-start-hint .small-line {
    display: inline;
    font-size: inherit;
    opacity: 1;
}

.control-chooser {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding-top: 0;
}

.pause-key-row {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 6px;
    justify-content: flex-start;
    width: auto;
    align-self: flex-start;
    margin-left: 10px;
    color: #ffffff;
    font-size: clamp(0.62rem, 0.78vw, 0.74rem);
    font-weight: 400;
    opacity: 0.88;
    text-shadow: 0 0 3px rgba(255, 255, 255, 0.30);
}

.pause-key {
    width: 22px;
    height: 18px;
    flex: 0 0 22px;
    font-size: 0.54rem;
}

.pause-key-text {
    margin-left: 16px;
}

.control-panel {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: auto;
    min-height: 56px;
    flex: 0 0 auto;
}

#demoControlsHint {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 72px;
    min-height: 56px;
    flex: 0 0 auto;
}

.controls-title {
    display: none;
}

.control-chooser-row {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    column-gap: clamp(6px, 0.72vw, 9px);
    width: 100%;
}

.key-cluster {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
}

.key-row {
    display: flex;
    justify-content: center;
    gap: 2px;
}

.key-row-top {
    min-height: 18px;
}

.keycap {
    width: 18px;
    height: 18px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid rgba(255, 255, 255, 0.64);
    border-radius: 4px;
    background: #000;
    box-shadow: inset 0 0 4px rgba(255, 255, 255, 0.04), 0 0 3px rgba(255, 255, 255, 0.09);
    font-size: 0.54rem;
    font-weight: 400;
    line-height: 1;
    text-shadow: 0 0 3px rgba(255, 255, 255, 0.30);
}

.arrow-key {
    font-size: 0.64rem;
}

.control-or {
    align-self: center;
    font-size: clamp(0.52rem, 0.62vw, 0.58rem);
    font-weight: 400;
    opacity: 0.72;
    text-align: center;
    padding: 0;
}

body.is-demo .side-stats,
body.is-demo #gameHint {
    display: none;
}

body.is-playing #demoStartHint {
    display: none;
}

body.is-game-over:not(.game-over-input-ready) #demoStartHint {
    display: none;
}

body.is-playing #demoControlsHint {
    display: none;
}

#livesDisplay {
    width: 96px;
    height: 20px;
    display: block;
    background: transparent;
}


.side-cast {
    align-self: end;
    display: flex;
    flex-direction: column;
    gap: 7px;
    font-weight: 400;
    line-height: 1.1;
    padding: clamp(8px, 0.95vw, 11px) clamp(9px, 1vw, 12px);
    border: 1px solid rgba(255, 255, 255, 0.20);
    border-radius: 10px;
    background: #000;
    box-shadow: inset 0 0 10px rgba(255, 255, 255, 0.032);
}

.side-cast-label {
    color: rgba(255, 255, 255, 0.78);
    text-shadow: 0 0 5px rgba(255, 255, 255, 0.4);
    font-size: clamp(0.62rem, 0.78vw, 0.74rem);
    font-weight: 400;
    letter-spacing: 0.35px;
    margin-bottom: 6px;
}

.side-cast-row {
    display: flex;
    align-items: center;
    gap: 9px;
    min-height: 31px;
    padding: 0;
}

.cast-sprite {
    width: 35px;
    height: 31px;
    flex: 0 0 35px;
    background: #000;
}

.side-cast-player,
.side-cast-name {
    font-size: clamp(0.72rem, 0.92vw, 0.84rem);
    font-weight: 400;
    letter-spacing: 0.45px;
    white-space: nowrap;
}

.side-cast-player {
    color: #ffff00;
    text-shadow: 0 0 7px rgba(255, 255, 0, 0.70);
}

canvas {
    display: block;
    background: #000;
    border: 0;
    outline: none;
    box-shadow: none;
    width: 100%;
    height: 100%;
    image-rendering: auto;
}

canvas:focus {
    outline: none;
}

#focus-start-screen {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #000;
    cursor: pointer;
}

#focus-start-screen.is-hidden {
    display: none;
}

.focus-start-content {
    width: min(82vw, 720px);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 28px;
    text-align: center;
    color: #ffffff;
    text-shadow: 0 0 8px rgba(255, 255, 255, 0.7);
    font-size: clamp(0.95rem, 2vw, 1.25rem);
    font-weight: 400;
}

#focus-logo {
    width: 100%;
    height: auto;
    display: block;
    filter: none;
}

@media (max-aspect-ratio: 1/1) {
    #page-layout {
        --maze-size: min(calc((100vw - 12px) * 0.75), calc(100vh - 12px));
        gap: 0;
        padding: 6px;
    }

    #side-ui {
        padding-left: 8px;
        padding-right: 8px;
    }

    .keycap {
        width: 16px;
        height: 16px;
        font-size: 0.5rem;
    }

    .arrow-key {
        font-size: 0.58rem;
    }
}

#levelFruits {
    width: 146px;
    height: 60px;
    display: block;
    background: transparent;
}

.level-display {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: 46px 146px;
    column-gap: 0;
    align-items: start;
}

.level-label-stack {
    align-self: start;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

#levelCrown {
    width: 54px;
    height: 28px;
    display: block;
    background: transparent;
}

/* Development-only cheat panel. Hide or remove before release. */
.dev-cheat-panel {
    position: fixed;
    left: 10px;
    top: 10px;
    z-index: 50;
    display: none;
    flex-direction: column;
    gap: 6px;
    width: 130px;
    padding: 10px;
    box-sizing: border-box;
    background: rgba(0, 0, 0, 0.78);
    border: 1px solid rgba(255, 255, 255, 0.25);
    border-radius: 8px;
    font-family: Arial, Helvetica, sans-serif;
}

.dev-cheat-title {
    color: #ffffff;
    font-size: 11px;
    font-weight: 700;
    text-align: center;
    letter-spacing: 0.08em;
    margin-bottom: 2px;
}

.dev-cheat-panel button {
    min-height: 25px;
    padding: 4px 6px;
    border: 1px solid rgba(255, 255, 255, 0.35);
    border-radius: 5px;
    background: #202020;
    color: #ffffff;
    font-size: 11px;
    cursor: pointer;
}

.dev-cheat-panel button:hover {
    background: #303030;
}

.bugvictim-credit {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin: 12px 0 16px;
    color: #ffffff;
    font-family: Arial, Helvetica, sans-serif;
    font-size: 27px;
    font-weight: 500;
}

.bugvictim-credit img {
    width: 63px;
    height: 63px;
    display: block;
}

body.dev-cheats-enabled .dev-cheat-panel {
    display: flex;
}
