:root {
    color-scheme: dark;
    --page: #091113;
    --panel: #101b1d;
    --panel-raised: #142225;
    --line: #263a3c;
    --ink: #e9ecdf;
    --muted: #9aaca6;
    --gold: #d8bd70;
    --teal: #4a9e9e;
    --green: #809c56;
    --shadow: rgba(0, 0, 0, .34);
}

* { box-sizing: border-box; }

html { background: var(--page); }

body {
    margin: 0;
    min-width: 320px;
    color: var(--ink);
    background:
        radial-gradient(circle at 16% -10%, rgba(66, 117, 105, .16), transparent 32rem),
        radial-gradient(circle at 85% 8%, rgba(126, 105, 56, .11), transparent 34rem),
        var(--page);
    font: 15px/1.55 Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

a { color: inherit; }
button, select { font: inherit; }
button, select, a { -webkit-tap-highlight-color: transparent; }

.site-header,
main,
footer {
    width: min(1440px, calc(100% - 40px));
    margin-inline: auto;
}

.site-header {
    position: relative;
    display: grid;
    grid-template-columns: 180px minmax(0, 1fr) auto;
    gap: 34px;
    align-items: start;
    padding: 54px 0 34px;
}

.back-link,
.header-actions a {
    color: var(--muted);
    text-decoration: none;
    transition: color .16s ease;
}

.back-link:hover,
.header-actions a:hover { color: var(--ink); }

.header-copy { max-width: 760px; }

.eyebrow {
    margin: 0 0 8px;
    color: var(--gold);
    font-size: .72rem;
    font-weight: 800;
    letter-spacing: .16em;
    text-transform: uppercase;
}

h1, h2, p { margin-top: 0; }

h1 {
    margin-bottom: 10px;
    font-family: Georgia, "Times New Roman", serif;
    font-size: clamp(3rem, 6vw, 5.8rem);
    font-weight: 500;
    letter-spacing: -.045em;
    line-height: .92;
}

h2 {
    margin-bottom: 8px;
    font-family: Georgia, "Times New Roman", serif;
    font-size: clamp(1.9rem, 3vw, 3rem);
    font-weight: 500;
    letter-spacing: -.025em;
    line-height: 1;
}

.lede,
.section-heading p {
    color: var(--muted);
    max-width: 720px;
}

.lede {
    margin-bottom: 0;
    font-size: 1.03rem;
}

.header-actions {
    display: flex;
    gap: 20px;
    font-size: .86rem;
}

main { padding-bottom: 72px; }

.summary-strip {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    margin: 12px 0 24px;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 16px;
    background: rgba(16, 27, 29, .82);
    box-shadow: 0 20px 60px var(--shadow);
}

.summary-strip div {
    display: flex;
    align-items: baseline;
    gap: 12px;
    padding: 22px 24px;
    border-right: 1px solid var(--line);
}

.summary-strip div:last-child { border-right: 0; }
.summary-strip strong { color: var(--gold); font-family: Georgia, serif; font-size: 1.75rem; font-weight: 500; }
.summary-strip span { color: var(--muted); font-size: .8rem; }

.panel {
    margin-top: 24px;
    padding: clamp(24px, 3vw, 42px);
    border: 1px solid var(--line);
    border-radius: 18px;
    background: linear-gradient(145deg, rgba(20, 34, 37, .96), rgba(13, 23, 25, .96));
    box-shadow: 0 26px 80px var(--shadow);
}

.section-heading {
    display: flex;
    gap: 32px;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 28px;
}

.section-heading p { margin-bottom: 0; }

code {
    color: #d8e5db;
    font-family: "Cascadia Code", "SFMono-Regular", Consolas, monospace;
    font-size: .88em;
}

.map-controls,
.base-select {
    display: grid;
    gap: 7px;
    color: var(--muted);
    font-size: .72rem;
    font-weight: 700;
    letter-spacing: .08em;
    text-transform: uppercase;
}

.map-controls {
    grid-template-columns: auto auto;
    align-items: end;
}

.map-controls label { grid-column: 1 / -1; }

select,
button {
    min-height: 40px;
    border: 1px solid var(--line);
    border-radius: 9px;
    color: var(--ink);
    background: #0b1517;
}

select { padding: 8px 34px 8px 11px; }
button { padding: 8px 14px; cursor: pointer; }
button:hover { border-color: #4f6a6c; background: #132326; }
button:focus-visible, select:focus-visible, a:focus-visible { outline: 2px solid var(--gold); outline-offset: 3px; }

.canvas-frame {
    position: relative;
    min-height: 500px;
    overflow: hidden;
    border: 1px solid #294144;
    border-radius: 13px;
    background: #0d1117;
}

#map-preview {
    display: block;
    width: 100%;
    height: 500px;
}

.canvas-note {
    position: absolute;
    right: 12px;
    bottom: 12px;
    padding: 7px 10px;
    border: 1px solid rgba(255, 255, 255, .09);
    border-radius: 7px;
    color: rgba(233, 236, 223, .7);
    background: rgba(5, 10, 11, .76);
    font-size: .72rem;
    pointer-events: none;
}

.map-stats {
    display: flex;
    flex-wrap: wrap;
    gap: 10px 18px;
    margin-top: 16px;
    color: var(--muted);
    font-size: .78rem;
}

.map-stats strong { color: var(--ink); font-weight: 700; }

.palette {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 8px;
    max-width: 420px;
}

.swatch {
    display: grid;
    grid-template-columns: 19px auto;
    gap: 7px;
    align-items: center;
    color: var(--muted);
    font-size: .7rem;
}

.swatch i {
    width: 19px;
    height: 19px;
    border: 1px solid rgba(255, 255, 255, .16);
    border-radius: 50%;
    background: var(--swatch);
}

.variant-gallery {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(156px, 1fr));
    gap: 14px;
}

.variant-card {
    min-width: 0;
    padding: 13px;
    border: 1px solid rgba(126, 151, 145, .16);
    border-radius: 12px;
    background: rgba(7, 15, 17, .54);
}

.variant-card .hex-stack {
    width: min(100%, 164px);
    margin: 2px auto 14px;
}

.variant-card h3 {
    margin: 0;
    font-family: "Cascadia Code", Consolas, monospace;
    font-size: .77rem;
    font-weight: 600;
}

.variant-card p {
    margin: 2px 0 0;
    color: var(--muted);
    font-size: .7rem;
}

.hex-stack {
    position: relative;
    aspect-ratio: 1;
    overflow: hidden;
    clip-path: polygon(50% 0, 93.3% 25%, 93.3% 75%, 50% 100%, 6.7% 75%, 6.7% 25%);
    background: #0b1112;
}

.hex-stack img {
    position: absolute;
    inset: 0;
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.coast-workbench {
    display: grid;
    grid-template-columns: minmax(280px, .75fr) minmax(360px, 1.25fr);
    gap: clamp(32px, 6vw, 90px);
    align-items: center;
    max-width: 980px;
    margin: 0 auto;
}

.coast-preview-wrap { text-align: center; }

.coast-preview {
    width: min(100%, 310px);
    margin-inline: auto;
    filter: drop-shadow(0 22px 25px rgba(0, 0, 0, .32));
}

.mask-readout {
    display: inline-flex;
    gap: 10px;
    align-items: center;
    margin-top: 18px;
    padding: 7px 12px;
    border: 1px solid var(--line);
    border-radius: 999px;
    color: var(--muted);
    background: #0b1517;
    font-size: .72rem;
    letter-spacing: .08em;
    text-transform: uppercase;
}

.mask-readout code { color: var(--gold); font-size: .86rem; letter-spacing: .1em; }

.direction-controls {
    display: grid;
    grid-template-columns: repeat(3, minmax(92px, 1fr));
    gap: 10px;
}

.direction-button {
    display: grid;
    min-height: 66px;
    place-items: center;
    gap: 1px;
    color: var(--muted);
}

.direction-button strong { color: var(--ink); font-size: .84rem; }
.direction-button span { font-size: .68rem; }

.direction-button[aria-pressed="true"] {
    border-color: #91aa68;
    color: #d9e6bf;
    background: rgba(77, 100, 49, .48);
    box-shadow: inset 0 0 0 1px rgba(188, 208, 133, .12);
}

.secondary-button { margin-top: 12px; color: var(--muted); }
.direction-workbench p { margin: 18px 0 0; color: var(--muted); font-size: .8rem; }

.approval-badge {
    display: flex;
    gap: 8px;
    align-items: center;
    padding: 8px 11px;
    border: 1px solid rgba(123, 158, 88, .35);
    border-radius: 999px;
    color: #cad9ac;
    background: rgba(64, 87, 42, .25);
    font-size: .72rem;
    white-space: nowrap;
}

.approval-badge span {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #9dbb68;
    box-shadow: 0 0 10px rgba(157, 187, 104, .5);
}

.mask-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
    gap: 12px;
}

.mask-card {
    min-width: 0;
    padding: 8px;
    border: 1px solid rgba(126, 151, 145, .13);
    border-radius: 9px;
    background: rgba(7, 15, 17, .47);
}

.mask-card .hex-stack { width: 100%; }
.mask-card code { display: block; margin-top: 6px; color: var(--muted); font-size: .64rem; text-align: center; letter-spacing: .05em; }

footer {
    padding: 0 0 48px;
    color: #71837e;
    font-size: .75rem;
    text-align: center;
}

@media (max-width: 900px) {
    .site-header { grid-template-columns: 1fr; gap: 22px; }
    .header-actions { flex-wrap: wrap; }
    .summary-strip { grid-template-columns: repeat(2, 1fr); }
    .summary-strip div:nth-child(2) { border-right: 0; }
    .summary-strip div:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
    .section-heading { display: grid; }
    .palette { justify-content: flex-start; }
    .coast-workbench { grid-template-columns: 1fr; }
}

@media (max-width: 600px) {
    .site-header, main, footer { width: min(100% - 24px, 1440px); }
    .site-header { padding-top: 28px; }
    .summary-strip div { display: grid; gap: 2px; padding: 16px; }
    .panel { padding: 22px 16px; }
    .canvas-frame, #map-preview { min-height: 390px; height: 390px; }
    .canvas-note { display: none; }
    .map-controls { grid-template-columns: 1fr; width: 100%; }
    .map-controls label { grid-column: auto; }
    .direction-controls { grid-template-columns: repeat(2, 1fr); }
    .mask-grid { grid-template-columns: repeat(auto-fill, minmax(80px, 1fr)); gap: 8px; }
}
