:root {
    --field: #c8b40a;
    --ink: #1a1700;
    --paper: #f6efc4;
    --junk: #00ff7f;
    --held: #ffa500;
    --font: "Helvetica Neue", Helvetica, Arial, system-ui, sans-serif;
}

* { box-sizing: border-box; }

html, body {
    width: 100%;
    height: 100%;
    margin: 0;
    padding: 0;
    overflow: hidden;
    background: var(--field);
    color: var(--ink);
    font-family: var(--font);
    font-size: 16px;
    line-height: 1.45;
}

canvas#sky {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    display: block;
    touch-action: manipulation;
}

.bar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px 24px;
    padding: max(16px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) 0 max(16px, env(safe-area-inset-left));
    pointer-events: none;
}

.bar > * { pointer-events: auto; }

.title h1 {
    margin: 0;
    font-size: 28px;
    line-height: 1;
    font-weight: 800;
    letter-spacing: -0.02em;
    text-transform: uppercase;
}

.title p {
    margin: 6px 0 0;
    font-size: 15px;
    max-width: 30ch;
}

.controls {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

button {
    font: inherit;
    font-size: 15px;
    font-weight: 600;
    min-width: 44px;
    min-height: 44px;
    padding: 0 14px;
    color: var(--ink);
    background: transparent;
    border: 2px solid var(--ink);
    border-radius: 0;
    cursor: pointer;
}

button:hover { background: rgba(26, 23, 0, 0.12); }

button.primary {
    background: var(--ink);
    color: var(--paper);
}

button.primary:hover { background: #3a3400; }

:focus-visible {
    outline: 3px solid var(--ink);
    outline-offset: 3px;
}

dialog {
    width: min(560px, calc(100vw - 32px));
    max-height: calc(100vh - 32px);
    max-height: calc(100dvh - 32px);
    padding: 20px;
    color: var(--paper);
    background: var(--ink);
    border: 2px solid var(--paper);
    border-radius: 0;
    overflow-y: auto;
}

dialog::backdrop { background: rgba(26, 23, 0, 0.55); }

dialog :focus-visible { outline-color: var(--junk); }

dialog a { color: var(--junk); }

dialog button {
    color: var(--paper);
    border-color: var(--paper);
}

dialog button:hover { background: rgba(246, 239, 196, 0.14); }

.dialog-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 12px;
}

.dialog-head h2 {
    margin: 0;
    font-size: 22px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: -0.01em;
}

dialog p { margin: 0 0 12px; }

.key {
    margin: 0 0 12px;
    padding-left: 20px;
}

.key li { margin-bottom: 6px; }

#pieces {
    list-style: none;
    margin: 0;
    padding: 0;
}

#pieces li { border-top: 1px solid rgba(246, 239, 196, 0.3); }

#pieces button {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    width: 100%;
    padding: 8px 4px;
    text-align: left;
    border: 0;
    font-weight: 400;
}

#pieces .name { display: block; font-weight: 700; }
#pieces .meta { display: block; font-size: 14px; opacity: 0.85; }

#pieces .state {
    flex: none;
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 2px 8px;
    border: 2px solid currentColor;
    color: var(--junk);
}

#pieces button[aria-pressed="true"] .state { color: var(--held); }

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
    border: 0;
}

.noscript {
    position: fixed;
    left: 16px;
    right: 16px;
    top: 45%;
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    text-align: center;
}

@media (max-width: 520px) {
    .title h1 { font-size: 24px; }
    .title p { font-size: 14px; }
    button { padding: 0 12px; }
}
