:root {
    --ink: #edf1ff;
    --muted: #8d91ab;
    --muted-strong: #b7b9ca;
    --canvas: #12131f;
    --panel: #1a1b2a;
    --line: rgba(235, 239, 255, .1);
    --line-strong: rgba(235, 239, 255, .18);
    --violet: #8c7cff;
    --cyan: #62e2ec;
    --coral: #ff927f;
    --radius-lg: 24px;
    --shadow: 0 20px 60px #05061161;
    color-scheme: dark;
    font-family: 'Manrope', 'Noto Sans JP', system-ui, sans-serif;
    color: var(--ink);
    background: var(--canvas);
}
* { box-sizing: border-box; }
body { margin: 0; background: radial-gradient(circle at 90% 0, #7162ff1a, transparent 28rem), var(--canvas); }
header { height: 66px; padding: 0 30px; display: flex; align-items: center; justify-content: space-between; gap: 12px; border-bottom: 1px solid var(--line); }
a { color: inherit; text-decoration: none; }
.brand { display: flex; align-items: center; gap: 11px; flex-shrink: 0; }
.brand-mark { display: grid; place-items: center; width: 31px; height: 31px; border: 1px solid #62e2ec99; border-radius: 9px; color: var(--cyan); font: 500 23px/1 monospace; transform: rotate(-6deg); }
.brand-name { font: 700 15px/1 'Space Grotesk', system-ui, sans-serif; letter-spacing: -.02em; }
.brand-name span { color: var(--cyan); }
.header-links { display: flex; align-items: center; gap: 16px; }
.legacy-link { color: var(--muted-strong); font-size: 11px; line-height: 1.5; padding: 10px 0; white-space: nowrap; text-decoration: underline; text-underline-offset: 4px; text-decoration-color: var(--line-strong); }
.legacy-link:hover { color: var(--cyan); text-decoration-color: currentColor; }
.source-link { display: inline-flex; align-items: center; justify-content: center; min-height: 32px; padding: 0 14px; border: 1px solid var(--line-strong); border-radius: 10px; background: var(--panel); color: var(--ink); font-size: 12px; font-weight: 600; line-height: 1; text-decoration: none; white-space: nowrap; }
.source-link:hover { border-color: var(--cyan); background: #222337; color: var(--cyan); }
main { height: calc(100dvh - 66px); padding: 20px 28px 28px; gap: 18px; display: grid; grid-template-columns: 280px minmax(0, 1fr); grid-template-rows: minmax(0, 1fr); }
aside, .stage { border: 1px solid var(--line); border-radius: var(--radius-lg); box-shadow: var(--shadow); }
aside { padding: 28px 24px; overflow-y: auto; background: #191a2adb; scrollbar-width: thin; scrollbar-color: #7467c5 transparent; }
.eyebrow { font-size: 10px; font-weight: 650; letter-spacing: .1em; color: var(--cyan); margin: 0 0 12px; }
h1 { font: 600 30px/1.15 'Space Grotesk', system-ui, sans-serif; letter-spacing: -.045em; margin: 0 0 14px; }
.intro, .privacy, .note { font-size: 12px; line-height: 1.6; color: var(--muted-strong); }
.intro { margin: 0 0 28px; }
nav { display: grid; gap: 6px; }
button, .primary { border: 1px solid var(--line); border-radius: 10px; color: var(--muted-strong); background: var(--panel); font: inherit; font-size: 12px; padding: 11px 12px; cursor: pointer; }
button:hover { border-color: var(--line-strong); background: #222337; color: var(--ink); }
button:focus-visible, a:focus-visible, summary:focus-visible, #viewport:focus-visible { outline: 2px solid var(--cyan); outline-offset: 3px; }
nav button { position: relative; text-align: left; border-color: transparent; background: #0b0c1747; font-weight: 600; }
nav button span { margin-right: 14px; color: var(--muted); font-size: 10px; }
nav .active { border-color: #8c7cff80; background: #8c7cff24; color: var(--ink); }
nav button.super-rare { border-color: #ff927fa6; background: #ff927f1f; color: #ffe2d8; box-shadow: 0 0 10px #ff927f19; animation: rare-map-glow 3s ease-in-out infinite; }
nav button.super-rare span { color: #ffbdaf; }
nav button.super-rare.active { border-color: #ffd4b5; background: #ff927f33; }
nav button.super-rare::after { content: ''; position: absolute; width: 6px; height: 6px; right: 10px; bottom: 10px; border-radius: 50%; background: var(--coral); }
@keyframes rare-map-glow {
    0%, 100% { box-shadow: 0 0 10px #ff927f19; }
    50% { box-shadow: 0 0 18px #ff927f4d, inset 0 0 12px #ff927f0d; }
}
.map-break { display: none; }
.imports { display: grid; gap: 8px; margin-top: 28px; }
.primary { display: flex; justify-content: space-between; background: var(--violet); color: var(--canvas); font-weight: 700; border-color: var(--violet); box-shadow: 0 8px 22px #8c7cff38; }
.primary:hover { background: #a298ff; border-color: #a298ff; color: var(--canvas); }
.privacy { margin: 10px 0 26px; font-size: 10px; }
#mapDetails > summary { display: none; }
#selection { padding-top: 20px; border-top: 1px solid var(--line); }
#selectionHint { font-size: 12px; color: var(--muted-strong); line-height: 1.6; }
#rewards { display: grid; gap: 7px; }
.reward { display: flex; align-items: center; gap: 10px; padding: 7px; background: var(--panel); border-radius: 10px; font-size: 11px; }
.reward img { width: 30px; height: 30px; object-fit: contain; }
.reward strong { margin-left: auto; font-size: 13px; }
.note { margin-top: 24px; font-size: 10px; }
.stage { min-width: 0; min-height: 0; overflow: hidden; position: relative; display: grid; grid-template-columns: minmax(0, 1fr); grid-template-rows: 78px minmax(0, 1fr) 42px; background: var(--panel); }
.stage-toolbar { padding: 17px 25px; display: flex; align-items: center; justify-content: space-between; gap: 12px; border-bottom: 1px solid var(--line); }
.stage-toolbar .eyebrow { margin-bottom: 6px; }
h2 { font-size: 16px; margin: 0; font-weight: 600; }
.view-buttons { display: flex; gap: 8px; }
.view-buttons button { padding: 9px 11px; }
#viewport { width: 100%; height: 100%; min-height: 0; touch-action: none; position: relative; overflow: hidden; cursor: grab; }
#viewport:active { cursor: grabbing; }
.harvest-labels { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.harvest-label { position: absolute; top: 0; left: 0; display: grid; grid-template-columns: repeat(3, auto); gap: 3px 8px; padding: 6px 8px; border: 1px solid #d8cefb9c; background: #171a29ee; box-shadow: 0 3px 10px #0005; pointer-events: auto; transform-origin: center bottom; }
.harvest-label[hidden] { display: none; }
.harvest-label:empty { display: none; }
.harvest-label::after { content: ''; position: absolute; top: 100%; left: calc(50% - 4px); width: 7px; height: 7px; transform: rotate(45deg); background: #171a29ee; border-right: 1px solid #d8cefb9c; border-bottom: 1px solid #d8cefb9c; }
.harvest-label.selected { border-color: #f4d484; background: #393128f2; }
.harvest-label.super-rare { border-color: var(--coral); background: #3a2630f2; }
.harvest-label.super-rare::after { border-color: var(--coral); background: #3a2630f2; }
.harvest-label.super-rare.selected { border-color: #ffd4b5; background: #482d30; }
.harvest-label.super-rare.selected::after { border-color: #ffd4b5; background: #482d30; }
.drop-item { display: flex; align-items: center; gap: 2px; white-space: nowrap; }
.drop-item img { width: 28px; height: 28px; object-fit: contain; }
.drop-item strong { color: white; font-size: 12px; font-variant-numeric: tabular-nums; }
.preview-options { display: grid; gap: 12px; font-size: 12px; color: var(--muted-strong); margin-top: 26px; }
.preview-options label { display: flex; align-items: center; gap: 8px; }
.preview-options .privacy { margin: 0; }
.preview-options input { accent-color: var(--violet); }
canvas { display: block; }
#loading { position: absolute; top: 100px; left: 24px; max-width: calc(100% - 48px); padding: 12px 16px; border: 1px solid #6c5b8d; background: #242030ed; border-radius: 8px; font-size: 12px; }
#loading[hidden] { display: none; }
footer { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 0 24px; color: var(--muted-strong); font-size: 10px; border-top: 1px solid var(--line); }
footer #status { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#controlsHelp { flex-shrink: 0; text-align: right; }
.touch-help { display: none; }
@media (pointer: coarse) {
    .mouse-help { display: none; }
    .touch-help { display: inline; }
    nav button, .primary, .view-buttons button, .preview-options label { min-height: 44px; }
    .legacy-link { display: flex; align-items: center; min-height: 44px; }
    .preview-options input { width: 18px; height: 18px; }
}
@media (max-width: 700px), (max-width: 1000px) and (orientation: portrait) {
    header {
        height: calc(52px + env(safe-area-inset-top));
        padding: env(safe-area-inset-top) max(16px, env(safe-area-inset-right)) 0 max(16px, env(safe-area-inset-left));
    }
    .header-links { gap: 12px; }
    .source-link { padding: 0 10px; font-size: 11px; }
    main {
        height: calc(100dvh - 52px - env(safe-area-inset-top));
        padding: 8px;
        gap: 8px;
        grid-template-columns: minmax(0, 1fr);
        grid-template-rows: auto minmax(0, 1fr) auto;
        grid-template-areas: 'controls' 'stage' 'details';
    }
    aside { display: contents; }
    .overview { display: none; }
    .map-controls {
        grid-area: controls;
        display: grid;
        grid-template-columns: minmax(120px, 1fr) minmax(0, 1fr);
        grid-template-areas: 'import privacy' 'maps maps';
        gap: 10px 16px;
        padding: 10px max(12px, env(safe-area-inset-right)) 10px max(12px, env(safe-area-inset-left));
        border: 1px solid var(--line);
        border-radius: 18px;
        background: var(--panel);
    }
    .imports { grid-area: import; margin: 0; }
    .primary { min-height: 44px; align-items: center; }
    .map-controls > .privacy { grid-area: privacy; margin: 0; align-self: center; font-size: 11px; }
    nav { grid-area: maps; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 4px; }
    nav button { min-height: 48px; padding: 6px 2px; text-align: center; font-size: clamp(10px, 2.8vw, 11px); line-height: 1.5; }
    nav button span { display: none; }
    nav button.super-rare::after { right: 6px; bottom: 6px; }
    .map-break { display: initial; }
    .stage { grid-area: stage; min-height: 0; border-radius: 18px; grid-template-rows: 64px minmax(0, 1fr) 46px; }
    .stage-toolbar { padding: 8px 12px; gap: 8px; }
    .stage-toolbar .eyebrow { margin-bottom: 4px; }
    h2 { font-size: 14px; }
    .view-buttons { gap: 6px; flex-shrink: 0; }
    .view-buttons button { min-height: 44px; padding: 8px 10px; font-size: 11px; }
    footer { padding: 6px 12px; flex-direction: column; align-items: flex-start; justify-content: center; gap: 3px; }
    footer #status { max-width: 100%; }
    #controlsHelp { text-align: left; }
    #loading { top: 76px; left: 12px; max-width: calc(100% - 24px); }
    #mapDetails { grid-area: details; position: relative; z-index: 1001; border: 1px solid var(--line); border-radius: 12px; background: var(--panel); }
    #mapDetails > summary {
        display: flex;
        align-items: center;
        justify-content: space-between;
        min-height: calc(48px + env(safe-area-inset-bottom));
        padding: 12px max(16px, env(safe-area-inset-right)) calc(12px + env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
        color: var(--muted-strong);
        font-size: 12px;
        cursor: pointer;
        list-style: none;
    }
    #mapDetails > summary::-webkit-details-marker { display: none; }
    #mapDetails > summary::after { content: '+'; font-size: 20px; line-height: 1; color: var(--cyan); }
    #mapDetails[open] > summary::after { content: '−'; }
    .details-body {
        position: absolute;
        bottom: 100%;
        left: 0;
        right: 0;
        max-height: min(48dvh, 360px);
        overflow-y: auto;
        overscroll-behavior: contain;
        padding: 20px max(16px, env(safe-area-inset-right)) 16px max(16px, env(safe-area-inset-left));
        border: 1px solid var(--line-strong);
        border-bottom: 0;
        border-radius: 14px 14px 0 0;
        background: #1a1b2af5;
        box-shadow: 0 -8px 24px #0003;
    }
    #selection { padding-top: 0; border-top: 0; }
    #selectionHint { margin: 8px 0 12px; }
    .reward { font-size: 12px; }
    .preview-options { gap: 4px; margin-top: 18px; }
    .preview-options label { min-height: 44px; }
    .preview-options input { width: 18px; height: 18px; }
    .note { font-size: 11px; margin-top: 16px; }
}
@media (min-width: 701px) and (max-height: 500px) and (orientation: landscape) {
    header { height: 44px; padding: 0 max(16px, env(safe-area-inset-right)) 0 max(16px, env(safe-area-inset-left)); }
    main { height: calc(100dvh - 44px); padding: 12px 16px 16px; gap: 12px; grid-template-columns: 220px minmax(0, 1fr); }
    aside { padding: 12px 16px 12px max(16px, env(safe-area-inset-left)); }
    .overview { display: none; }
    .stage { grid-template-rows: 64px minmax(0, 1fr) 42px; }
    .stage-toolbar { padding: 8px 12px; }
    footer { padding: 0 max(12px, env(safe-area-inset-right)) 0 12px; }
}
@media (prefers-reduced-motion: reduce) {
    nav button.super-rare { animation: none; }
}
