:root {
    --bg: #0f2a57;
    --fg: #efe9f6;
    --mute: rgba(239, 233, 246, 0.55);
    --line: rgba(239, 233, 246, 0.16);
    --accent: #ffb3c7;
    --mono: 'Geist Mono', ui-monospace, 'SF Mono', Menlo, monospace;
}

* {
    box-sizing: border-box;
    margin: 0;
}

html,
body {
    height: 100%;
    overflow: hidden;
}

body {
    background: var(--bg);
    color: var(--fg);
    font: 14px/1.7 var(--mono);
    -webkit-font-smoothing: antialiased;
}

a {
    color: inherit;
    text-decoration: underline;
    text-decoration-color: var(--line);
    text-underline-offset: 4px;
}

a:hover {
    text-decoration-color: var(--accent);
}

#world {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    display: block;
    image-rendering: pixelated;
    touch-action: none;
    cursor: grab;
    user-select: none;
    -webkit-user-select: none;
}

#world.grabbing {
    cursor: grabbing;
}

.ui {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 2;
    user-select: none;
    -webkit-user-select: none;
}

.ui a,
.ui button {
    pointer-events: auto;
}

nav.top {
    position: absolute;
    top: 22px;
    left: 24px;
    display: flex;
    gap: 12px;
    align-items: center;
    font-size: 14px;
    white-space: nowrap;
}

nav.top a {
    text-decoration: none;
    color: var(--mute);
    transition: color 0.2s;
}

nav.top a.on,
nav.top a:hover {
    color: var(--fg);
}

nav.top .sep {
    color: var(--line);
}

nav.top #theme {
    background: none;
    border: 0;
    color: var(--mute);
    font: inherit;
    cursor: pointer;
    width: 22px;
    height: 22px;
    display: grid;
    place-items: center;
}

nav.top #theme:hover {
    color: var(--fg);
}

@media (min-width: 1281px) {
    nav.top {
        left: 20vw;
    }
}

.count {
    position: absolute;
    top: 24px;
    right: 26px;
    text-align: right;
    font-size: 11px;
    line-height: 1.8;
    color: var(--mute);
    font-variant-numeric: tabular-nums;
}

.count b {
    font-weight: 400;
    color: var(--fg);
}

.count button {
    font: inherit;
    color: inherit;
    background: none;
    border: 0;
    padding: 0;
    cursor: pointer;
}

.count button:hover b,
.count button:hover {
    color: var(--accent);
}

@media (min-width: 1500px) {
    .count {
        right: 12vw;
    }
}

@media (max-width: 1280px) {
    .credit {
        display: none;
    }
}

.hero {
    text-shadow:
        0 1px 0 rgba(10, 25, 60, 0.55),
        0 0 18px rgba(10, 25, 60, 0.55);
    position: absolute;
    left: 24px;
    right: 24px;
    top: 15vh;
    max-width: 60ch;
}

@media (min-width: 1281px) {
    .hero {
        left: 20vw;
        top: 16vh;
    }
}

.poem {
    color: var(--mute);
    font-size: 15px;
    margin-bottom: 36px;
}

.hello {
    font-size: clamp(14px, 1.15vw, 16px);
    line-height: 1.95;
}

.hello .caret {
    display: inline-block;
    width: 0.55em;
    height: 1em;
    background: var(--fg);
    transform: translateY(0.15em);
    margin-left: 3px;
    animation: blink 1.1s steps(1) infinite;
}

@keyframes blink {
    50% {
        opacity: 0;
    }
}

.actions {
    display: flex;
    gap: 12px;
    margin-top: 26px;
    flex-wrap: wrap;
}

.px {
    font: 500 13px var(--mono);
    color: var(--bg);
    background: var(--fg);
    border: 0;
    padding: 9px 16px 10px;
    cursor: pointer;
    position: relative;
    text-decoration: none;
    text-shadow: none;
    clip-path: polygon(
        0 4px,
        4px 4px,
        4px 0,
        calc(100% - 4px) 0,
        calc(100% - 4px) 4px,
        100% 4px,
        100% calc(100% - 4px),
        calc(100% - 4px) calc(100% - 4px),
        calc(100% - 4px) 100%,
        4px 100%,
        4px calc(100% - 4px),
        0 calc(100% - 4px)
    );
    transition:
        transform 0.15s steps(2),
        background 0.3s;
}

.px:hover {
    transform: translateY(-2px);
    background: var(--accent);
}

.px:active {
    transform: translateY(1px);
}

.px.ghost {
    background: rgba(13, 15, 34, 0.55);
    color: var(--fg);
    box-shadow: inset 0 0 0 2px var(--line);
    -webkit-backdrop-filter: blur(2px);
    backdrop-filter: blur(2px);
}

.px.ghost:hover {
    color: var(--bg);
    background: var(--fg);
}

.hint {
    position: absolute;
    left: 24px;
    bottom: 16px;
    font-size: 11px;
    color: rgba(255, 255, 255, 0.75);
    text-shadow: 0 1px 0 rgba(0, 0, 0, 0.35);
    white-space: nowrap;
    pointer-events: none;
    transition: opacity 0.6s;
}

.credit {
    position: absolute;
    right: 18px;
    bottom: 16px;
    font-size: 10px;
    color: rgba(255, 255, 255, 0.55);
    text-shadow: 0 1px 0 rgba(0, 0, 0, 0.35);
    text-align: right;
    line-height: 1.5;
}

.toast {
    position: absolute;
    left: 50%;
    bottom: 52px;
    transform: translate(-50%, 8px);
    font-size: 12px;
    color: #2a2033;
    background: #fff6e0;
    padding: 7px 14px 8px;
    opacity: 0;
    transition:
        opacity 0.35s,
        transform 0.35s steps(3);
    pointer-events: none;
    white-space: nowrap;
    clip-path: polygon(
        0 3px,
        3px 3px,
        3px 0,
        calc(100% - 3px) 0,
        calc(100% - 3px) 3px,
        100% 3px,
        100% calc(100% - 3px),
        calc(100% - 3px) calc(100% - 3px),
        calc(100% - 3px) 100%,
        3px 100%,
        3px calc(100% - 3px),
        0 calc(100% - 3px)
    );
}

.toast.on {
    opacity: 1;
    transform: translate(-50%, 0);
}

@media (min-width: 1281px) {
    .hint {
        left: 20vw;
    }
}

.menu {
    position: fixed;
    inset: 0;
    z-index: 10;
    display: grid;
    place-items: center;
    background: rgba(8, 12, 30, 0.42);
    opacity: 0;
    visibility: hidden;
    transition:
        opacity 0.2s,
        visibility 0s 0.2s;
    user-select: none;
    -webkit-user-select: none;
}

.menu.open {
    opacity: 1;
    visibility: visible;
    transition: opacity 0.2s;
}

.box {
    width: min(780px, 92vw);
    height: min(520px, 84vh);
    display: grid;
    grid-template-rows: auto 1fr auto;
    background: #fff6e0;
    color: #2a2033;
    box-shadow:
        0 0 0 4px #2a2033,
        0 0 0 8px #fff6e0,
        0 0 0 12px #2a2033,
        8px 20px 0 12px rgba(10, 15, 40, 0.35);
    transform: translateY(18px);
    transition: transform 0.28s steps(4);
}

.menu.open .box {
    transform: none;
}

.mhead {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 16px;
    border-bottom: 4px solid #2a2033;
    font-weight: 500;
}

.mhead button,
.mfoot kbd {
    font: 500 11px var(--mono);
    background: #2a2033;
    color: #fff6e0;
    border: 0;
    padding: 4px 9px;
    cursor: pointer;
}

.mbody {
    display: grid;
    grid-template-columns: 168px 1fr;
    min-height: 0;
}

.tabs {
    padding: 12px 0;
    border-right: 4px solid #2a2033;
    display: flex;
    flex-direction: column;
}

.tabs button {
    all: unset;
    box-sizing: border-box;
    display: block;
    padding: 8px 14px 8px 30px;
    cursor: pointer;
    position: relative;
    font: 14px var(--mono);
}

.tabs button::before {
    content: '▸';
    position: absolute;
    left: 12px;
    opacity: 0;
}

.tabs button:hover {
    background: #ffe9b8;
}

.tabs button[aria-selected='true'] {
    background: #2a2033;
    color: #fff6e0;
}

.tabs button[aria-selected='true']::before,
.tabs button:hover::before {
    opacity: 1;
    animation: nudge 0.7s steps(2) infinite;
}

.tabs button:focus-visible {
    outline: 2px dashed #e0473f;
    outline-offset: -4px;
}

@keyframes nudge {
    50% {
        transform: translateX(3px);
    }
}

.panel {
    padding: 18px 22px;
    overflow: auto;
    display: none;
    font-size: 13.5px;
    line-height: 1.7;
    user-select: text;
    -webkit-user-select: text;
}

.panel.on {
    display: block;
}

.panel h3 {
    font-weight: 500;
    font-size: 15px;
}

.panel .sub {
    color: #7a7080;
    margin: 2px 0 14px;
    font-size: 12.5px;
}

.panel a {
    text-decoration-color: rgba(42, 32, 51, 0.3);
}

.rows {
    list-style: none;
    padding: 0;
}

.rows a {
    display: grid;
    grid-template-columns: 34px 1fr auto 14px;
    gap: 14px;
    align-items: center;
    padding: 9px 8px;
    border-bottom: 2px dashed rgba(42, 32, 51, 0.14);
    text-decoration: none;
}

.rows a:hover {
    background: #ffe9b8;
}

.rows canvas {
    width: 32px;
    height: 32px;
    image-rendering: pixelated;
    display: block;
}

.rows b {
    font-weight: 500;
    display: block;
}

.rows span {
    color: #7a7080;
    font-size: 12.5px;
}

.rows .go {
    color: #b8325b;
    opacity: 0;
}

.rows a:hover .go {
    opacity: 1;
}

.stats {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    margin: 6px 0 16px;
}

.stats div {
    background: #ffe9b8;
    padding: 8px 10px;
    font-size: 11.5px;
    color: #7a7080;
}

.stats b {
    display: block;
    font-size: 20px;
    font-weight: 500;
    color: #2a2033;
    font-variant-numeric: tabular-nums;
}

.dex {
    list-style: none;
    padding: 0;
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 8px;
}

.dex li {
    border: 2px dashed rgba(42, 32, 51, 0.25);
    padding: 8px 4px;
    text-align: center;
    font-size: 11.5px;
    color: #9a90a0;
}

.dex li.got {
    border-style: solid;
    border-color: #2a2033;
    color: #2a2033;
    background: #fff;
}

.dex canvas {
    width: 40px;
    height: 40px;
    image-rendering: pixelated;
    display: block;
    margin: 0 auto 4px;
}

.dex li:not(.got) canvas {
    filter: brightness(0) opacity(0.18);
}

.guide {
    list-style: none;
    padding: 0;
}

.guide li {
    display: grid;
    grid-template-columns: 112px 1fr;
    gap: 12px;
    padding: 7px 0;
    border-bottom: 2px dashed rgba(42, 32, 51, 0.12);
}

.guide kbd {
    font: 500 11.5px var(--mono);
    background: #2a2033;
    color: #fff6e0;
    padding: 2px 7px;
    justify-self: start;
    align-self: start;
}

.mfoot {
    padding: 7px 16px;
    border-top: 4px solid #2a2033;
    font-size: 11px;
    color: #7a7080;
    display: flex;
    justify-content: space-between;
    gap: 12px;
}

.mfoot kbd {
    cursor: default;
    padding: 1px 5px;
}

@media (max-width: 760px) {
    nav.top {
        top: 16px;
        left: 20px;
    }

    .count {
        top: 66px;
        left: 20px;
        right: 20px;
        font-size: 10.5px;
        display: flex;
        gap: 14px;
        text-align: left;
        flex-wrap: wrap;
    }

    .hero {
        top: 15vh;
        left: 20px;
        right: 20px;
    }

    .poem {
        font-size: 13px;
        margin-bottom: 18px;
    }

    .hello {
        font-size: 13px;
        line-height: 1.75;
    }

    .actions {
        margin-top: 18px;
    }

    .px {
        font-size: 12.5px;
        padding: 8px 13px 9px;
    }

    .hint {
        left: 20px;
        right: 20px;
        white-space: normal;
        bottom: 14px;
    }

    .credit {
        display: none;
    }

    .toast {
        bottom: 64px;
    }

    .box {
        height: 82vh;
    }

    .mbody {
        grid-template-columns: 1fr;
        grid-template-rows: auto 1fr;
    }

    .tabs {
        flex-direction: row;
        overflow-x: auto;
        border-right: 0;
        border-bottom: 4px solid #2a2033;
        padding: 0;
    }

    .tabs button {
        padding: 10px 12px 10px 24px;
        white-space: nowrap;
        font-size: 13px;
    }

    .tabs button::before {
        left: 9px;
    }

    .panel {
        padding: 14px 16px;
    }

    .rows a {
        grid-template-columns: 32px 1fr;
    }

    .rows .yr,
    .rows .go {
        display: none;
    }

    .stats {
        grid-template-columns: repeat(2, 1fr);
    }

    .dex {
        grid-template-columns: repeat(3, 1fr);
    }

    .guide li {
        grid-template-columns: 1fr;
        gap: 4px;
    }

    .mfoot span:first-child {
        display: none;
    }
}

@media (max-width: 760px) and (max-height: 700px) {
    .poem {
        display: none;
    }
}
