@import url("https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@400;500;700&family=JetBrains+Mono:wght@400;600&display=swap");

:root {
    --stone-050: #fafaf9;
    --stone-100: #f5f5f4;
    --stone-200: #e7e5e4;
    --stone-300: #d6d3d1;
    --stone-400: #a8a29e;
    --stone-500: #78716c;
    --stone-600: #57534e;
    --stone-700: #44403c;
    --stone-800: #292524;
    --stone-900: #1c1917;
    --stone-950: #0c0a09;
    --blue: #3b82f6;
    --red: #ef4444;
    --green: #22c55e;
    --amber: #f59e0b;
    --bg: var(--stone-950);
    --bg-raised: var(--stone-900);
    --bg-surface: var(--stone-800);
    --border: var(--stone-800);
    --border-strong: var(--stone-500);
    --text: var(--stone-200);
    --text-muted: var(--stone-400);
    --text-faint: var(--stone-500);
    --text-bright: var(--stone-100);
    --accent: var(--blue);
    --accent-hover: #5193f8;
    --font-sans: "Space Grotesk", "Segoe UI", Helvetica, Arial, sans-serif;
    --font-mono: "JetBrains Mono", "SF Mono", "Fira Code", "Roboto Mono", monospace;
    --line-height: 1.5;
    --line-height-tight: 1.2;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    border-radius: 0 !important;
}

html,
body {
    min-height: 100%;
    background-color: var(--bg);
    color: var(--text);
    font-family: var(--font-sans);
    line-height: var(--line-height);
}

body {
    padding: 2.5rem 1rem 4rem;
}

body.pwa-installed .pwa-hide {
    display: none !important;
}

@media (display-mode: standalone), (display-mode: window-controls-overlay) {
    .pwa-hide {
        display: none !important;
    }
}

#app {
    width: min(1180px, 100%);
    margin: 0 auto;
    display: grid;
    gap: 1.5rem;
}

.hero,
.controls,
.workspace,
.history {
    border: 1px solid var(--border);
    background-color: var(--bg-raised);
}

.hero,
.controls,
.history {
    padding: 1.25rem;
}

.hero-title {
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 1rem;
}

.hero-char {
    width: clamp(72px, 9vw, 110px);
    height: auto;
    image-rendering: auto;
}

.eyebrow {
    margin-bottom: 0.45rem;
    color: var(--text-faint);
    font-family: var(--font-mono);
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

h1,
h2 {
    color: var(--text-bright);
    font-family: var(--font-mono);
    line-height: var(--line-height-tight);
    font-weight: 600;
}

h1 {
    margin-bottom: 0.75rem;
    font-size: clamp(1.6rem, 2.8vw, 2.2rem);
}

h2 {
    margin-bottom: 0.55rem;
    font-size: 1rem;
}

.lede {
    max-width: 68ch;
    color: var(--text-muted);
}

.locations-intro {
    margin-top: 0.9rem;
    color: var(--text-muted);
}

.locations {
    margin-top: 0.75rem;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1rem;
}

.locations h2 {
    margin-bottom: 0.4rem;
    font-size: 0.9rem;
}

.rules {
    margin-top: 0.9rem;
    margin-left: 1rem;
    color: var(--text-muted);
    font-size: 0.95rem;
}

.controls {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.8rem 1rem;
}

.switch-row {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-muted);
    user-select: none;
}

button,
input,
textarea {
    border: 1px solid var(--border-strong);
    background-color: var(--bg-surface);
    color: var(--text-bright);
    font: inherit;
}

button {
    padding: 0.5rem 0.7rem;
    cursor: pointer;
    transition: background-color 0.2s ease, border-color 0.2s ease;
}

button:hover {
    border-color: var(--accent-hover);
    background-color: var(--stone-700);
}

button:focus-visible,
input:focus-visible,
textarea:focus-visible {
    outline: 1px solid var(--accent);
    outline-offset: 1px;
}

input,
textarea {
    width: 100%;
    padding: 0.5rem 0.6rem;
}

input[type="checkbox"] {
    width: 1rem;
    height: 1rem;
    accent-color: var(--accent);
}

#status {
    color: var(--text-faint);
    font-family: var(--font-mono);
    font-size: 0.86rem;
}

.status-ok {
    color: var(--green);
}

.status-warn {
    color: var(--amber);
}

.status-error {
    color: var(--red);
}

#file-input {
    position: fixed;
    left: 0;
    top: 0;
    width: 0;
    height: 0;
    opacity: 0;
    pointer-events: none;
}

.workspace {
    display: grid;
    grid-template-columns: minmax(240px, 300px) 1fr;
}

.guided {
    padding: 1rem;
    border-right: 1px solid var(--border);
    display: grid;
    gap: 0.5rem;
    align-content: start;
}

.guided label,
.sub,
.editor-label {
    color: var(--text-muted);
    font-family: var(--font-mono);
    font-size: 0.82rem;
}

.sub {
    margin-bottom: 0.35rem;
}

.inline-field {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 0.4rem;
}

.subhead {
    margin-top: 0.5rem;
    color: var(--text-muted);
    font-size: 0.82rem;
    text-transform: uppercase;
    letter-spacing: 0.07em;
}

.ability-grid {
    display: grid;
    gap: 0.35rem;
    grid-template-columns: 1fr;
}

.ability-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text);
    font-size: 0.9rem;
}

.ability-item input {
    width: 1rem;
    height: 1rem;
    flex: 0 0 auto;
}

#sync-guided {
    margin-top: 0.4rem;
}

.editor-panel {
    padding: 1rem;
    display: grid;
    gap: 0.75rem;
}

.stats {
    display: grid;
    gap: 0.45rem;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
}

.stat-card {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    border: 1px solid var(--border);
    background-color: var(--bg-surface);
    padding: 0.5rem;
}

.stat-label {
    color: var(--text-faint);
    font-family: var(--font-mono);
    font-size: 0.74rem;
    text-transform: uppercase;
}

.stat-value {
    color: var(--text-bright);
    font-weight: 600;
}

.stat-icon {
    width: 20px;
    height: 20px;
    object-fit: contain;
}

.editor-head {
    display: grid;
    gap: 0.7rem;
}

#editor-name {
    color: var(--text-bright);
    font-family: var(--font-mono);
    font-size: 0.95rem;
}

.editor-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem;
}

#editor {
    min-height: 560px;
    resize: vertical;
    font-family: var(--font-mono);
    font-size: 0.86rem;
    line-height: 1.45;
}

.history ul {
    list-style: none;
    margin-top: 0.8rem;
    display: grid;
    gap: 0.5rem;
}

.history-item {
    padding: 0.65rem;
    border: 1px solid var(--border);
    background-color: var(--bg-surface);
    cursor: pointer;
    user-select: none;
}

.history-item:hover {
    border-color: var(--accent-hover);
}

.history-name {
    color: var(--text-bright);
    font-family: var(--font-mono);
    font-size: 0.88rem;
}

.history-date {
    color: var(--text-muted);
    font-size: 0.83rem;
}

#cover {
    position: fixed;
    inset: 0;
    background-color: color-mix(in srgb, var(--stone-950) 70%, transparent);
    border: 2px dashed var(--accent);
    pointer-events: none;
}

.hidden {
    display: none !important;
}

@media (max-width: 920px) {
    .hero-title {
        grid-template-columns: 1fr;
        justify-items: center;
        text-align: center;
    }

    .locations {
        grid-template-columns: 1fr;
    }

    .workspace {
        grid-template-columns: 1fr;
    }

    .guided {
        border-right: none;
        border-bottom: 1px solid var(--border);
    }
}