@font-face {
    font-family: dungeon;
    src: url("../font/sf.ttf") format("truetype");
}

body {
    cursor: url("../img/m.png"), auto;
    font-family: dungeon, serif;
}

/* The original fixed-pixel layout uses the document's existing quirks mode. */
.initially-hidden {
    display: none;
}

.centered,
.button,
.death-title,
.help-description,
.transfer-description,
.home-description,
.alert-description,
.merchant-description {
    text-align: center;
}

.panel,
.main,
.equipment-rack,
.inventory,
.merchant-inventory,
.button {
    border: 2px solid black;
}

.panel,
.panel-overlay {
    position: absolute;
    top: 60px;
}

/* Display changes restart the entrance; embedded panels animate with their overlay. */
.panel:not(.panel--embedded),
.panel-overlay,
.joystick {
    animation: panel-appear 180ms cubic-bezier(0.2, 0.7, 0.3, 1);
}

@keyframes panel-appear {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.panel {
    width: 250px;
}

.panel--embedded {
    position: static;
}

.panel--menu {
    height: 280px;
}

.panel--upgrades {
    height: 210px;
}

.panel--help,
.panel--large {
    height: 300px;
}

.panel--large {
    width: 300px;
}

.panel--death {
    top: 150px;
    height: 160px;
}

.panel--alert,
.panel--merchant,
.panel--status {
    width: 200px;
}

.panel--alert {
    height: 200px;
}

.panel--merchant {
    height: 350px;
}

.panel--status {
    height: 250px;
    font-size: 18px;
}

.panel--quest {
    top: 330px;
    left: 0;
    width: 390px;
    height: 120px;
    background: white;
    font-size: 18px;
}

.button {
    position: absolute;
    width: 200px;
    height: 40px;
    border-radius: 10px;
    background: blue;
    color: white;
    font-size: 32px;
}

button.button {
    box-sizing: content-box;
    padding: 0;
    font-family: inherit;
    cursor: inherit;
}

.button:focus-visible {
    outline: 3px solid #e5ad00;
    outline-offset: 3px;
}

.button--wide {
    width: 250px;
}

.button--narrow {
    width: 150px;
}

.button--skin {
    width: 125px;
}

.button--compact {
    width: 100px;
}

.button--compact,
.button--arrow,
.button--volume,
.status-resume {
    border-radius: 5px;
}

.button--arrow,
.button--volume {
    color: black;
    font-size: 16px;
}

.button--arrow {
    top: 0;
    width: 20px;
}

.button--volume {
    left: 50px;
    width: 50px;
    height: 20px;
}

.menu-resume,
.menu-shop,
.menu-help,
.menu-restart,
.death-resume,
.death-restart,
.help-joystick,
.help-back {
    left: 30px;
}

.menu-resume,
.upgrade-health {
    top: 20px;
}

.menu-shop,
.upgrade-defense {
    top: 90px;
}

.menu-help {
    top: 160px;
}

.menu-restart {
    top: 230px;
}

.upgrade-health,
.upgrade-defense {
    left: 80px;
}

.upgrade-icon {
    position: absolute;
    left: 10px;
}

.upgrade-health-icon {
    top: 10px;
}

.upgrade-defense-icon {
    top: 80px;
}

.death-title,
.help-description {
    position: absolute;
    width: 250px;
}

.death-title {
    font-size: 32px;
}

.death-resume {
    top: 60px;
}

.death-restart {
    top: 110px;
}

.help-description {
    font-size: 20px;
}

.help-joystick {
    top: 190px;
}

.help-back,
.transfer-secondary,
.merchant-sell {
    top: 250px;
}

.transfer-description,
.alert-description {
    position: absolute;
    left: 20px;
    font-size: 25px;
}

.transfer-description {
    top: 40px;
    width: 250px;
}

.transfer-primary,
.transfer-secondary,
.alert-confirm,
.merchant-buy,
.merchant-sell,
.merchant-back,
.status-resume {
    left: 20px;
}

.transfer-primary,
.home-description,
.status-resume {
    top: 200px;
}

.alert-description {
    top: 10px;
    width: 150px;
    max-height: 130px;
    overflow-y: auto;
}

.alert-confirm {
    top: 150px;
}

.home-resume {
    top: 5px;
    left: 25px;
}

.skin-left {
    left: 10px;
}

.skin-right {
    left: 150px;
}

.skin-first {
    top: 55px;
}

.skin-second {
    top: 105px;
}

.skin-third {
    top: 155px;
}

.home-description {
    position: absolute;
    width: 100%;
    height: 40px;
    font-size: 32px;
}

.merchant-description {
    position: absolute;
    width: 100%;
    font-size: 18px;
}

.merchant-buy-description {
    top: 70px;
}

.merchant-sell-description {
    top: 170px;
}

.merchant-buy {
    top: 110px;
}

.merchant-back {
    top: 300px;
}

.quest-accept,
.quest-decline {
    top: 75px;
}

.quest-accept {
    left: 50px;
}

.quest-decline {
    left: 240px;
}

.hud-icon,
.hud-value,
.main {
    position: absolute;
}

.hud-health,
.hud-level,
.hud-menu {
    top: 0;
}

.hud-health,
.hud-gold,
.main {
    left: 0;
}

.hud-level,
.hud-status {
    left: 120px;
}

.hud-gold,
.hud-status {
    top: 30px;
}

.hud-menu {
    left: 240px;
}

.hud-health-value,
.hud-level-value {
    top: 10px;
}

.hud-health-value,
.hud-gold-value {
    left: 35px;
}

.hud-level-value {
    left: 155px;
}

.hud-gold-value {
    top: 40px;
}

.main {
    top: 60px;
}

.music-controls {
    position: absolute;
    top: 60px;
    left: 390px;
}

.music-icon {
    position: absolute;
    width: 50px;
    height: 50px;
    background-image: url("../img/music.png");
}

.music-indicator {
    top: 25px;
    left: 50px;
    background-position: -200px 0;
}

.music-stop,
.music-play {
    top: 30px;
    left: 0;
}

.music-stop {
    background-position: 0 -50px;
}

.music-play {
    background-position: -50px -50px;
}

.volume-up {
    top: 0;
}

.volume-down {
    top: 90px;
}

.equipment-rack,
.inventory {
    position: absolute;
    top: 10px;
}

.equipment-rack {
    width: 40px;
}

.armor-rack {
    left: 500px;
    height: 200px;
}

.weapon-rack {
    left: 560px;
    height: 40px;
}

.item-sprite {
    width: 40px;
    height: 40px;
    background-image: url("../img/items.png");
    background-position: 0 0;
}

.armor-helmet { background-position: 0 -40px; }
.armor-chest { background-position: 0 -80px; }
.armor-gloves { background-position: 0 -120px; }
.armor-legs { background-position: 0 -160px; }
.armor-boots { background-position: 0 -200px; }
.weapon-sword { background-position: 0 -240px; }

.inventory,
.merchant-inventory {
    width: 194px;
}

.inventory {
    left: 620px;
    height: 144px;
}

.inventory-row,
.inventory-slot {
    position: absolute;
    top: 0;
}

.inventory-row,
.previous-page {
    left: 0;
}

.inventory-row--second {
    top: 50px;
}

.inventory-row--third {
    top: 100px;
}

.slot-first { left: 30px; }
.slot-second { left: 75px; }
.slot-third { left: 120px; }
.next-page { left: 170px; }

.arrow-symbol {
    position: absolute;
    top: 10px;
    left: 2px;
}

.merchant-inventory {
    position: absolute;
    top: 10px;
    left: 1px;
    height: 40px;
}

.joystick {
    position: absolute;
    top: 160px;
    left: 550px;
    width: 300px;
    height: 300px;
    border: 5px solid red;
    border-radius: 150px;
}

.joystick-button {
    position: absolute;
    width: 100px;
    height: 100px;
}

/* One arrow tile supplies every direction; the control keeps its own press transform. */
.joystick-button::before {
    content: "";
    position: absolute;
    inset: 0;
    background-image: url("../img/btn.png");
    background-repeat: no-repeat;
    background-position: -100px 0;
    transform: rotate(var(--joystick-rotation, 0deg));
    pointer-events: none;
}

.joystick-up,
.joystick-attack,
.joystick-down {
    left: 100px;
}

.joystick-left,
.joystick-attack,
.joystick-right {
    top: 100px;
}

.joystick-up {
    top: 0;
}

.joystick-left {
    left: 0;
    --joystick-rotation: 270deg;
}

.joystick-attack::before {
    background-position: 0 0;
    transform: none;
}

.joystick-right {
    left: 200px;
    --joystick-rotation: 90deg;
}

.joystick-down {
    top: 200px;
    --joystick-rotation: 180deg;
}

/* Animate the controls themselves, never sprite-sheet positions or layout sizes. */
.button,
.item-sprite,
.joystick-button,
.music-play,
.music-stop,
.hud-status,
.hud-menu {
    transition: transform 140ms cubic-bezier(0.2, 0.7, 0.3, 1),
        background-color 140ms ease-out,
        filter 140ms ease-out;
}

@media (hover: hover) {
    .button:hover {
        transform: scale(1.015);
    }

    .item-sprite:hover,
    .joystick-button:hover,
    .music-play:hover,
    .music-stop:hover,
    .hud-status:hover,
    .hud-menu:hover {
        filter: brightness(1.15);
        transform: scale(1.06);
    }
}

.button:active,
.item-sprite:active,
.joystick-button:active,
.music-play:active,
.music-stop:active,
.hud-status:active,
.hud-menu:active {
    filter: brightness(0.9);
    transform: scale(0.96);
    transition-duration: 70ms;
}

@media (prefers-reduced-motion: reduce) {
    .panel:not(.panel--embedded),
    .panel-overlay,
    .joystick {
        animation: none;
    }

    .button,
    .item-sprite,
    .joystick-button,
    .music-play,
    .music-stop,
    .hud-status,
    .hud-menu {
        transition: none;
    }

    :is(.button, .item-sprite, .joystick-button, .music-play, .music-stop, .hud-status, .hud-menu):is(:hover, :active) {
        transform: none;
    }
}
