@font-face {
    font-family: 'Qordhion';
    src: url('fonts/Qordhion.otf') format('opentype');
    font-weight: normal;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'Migra';
    src: url('fonts/Migra-ExtraLight.otf') format('opentype');
    font-weight: 200;
    font-style: normal;
    font-display: swap;
}

*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --crimson:      #650000;
    --crimson-dark: #400000;
    --green:        #00AA00;
    --cream:        #FFFFFF;
    --cream-dim:    rgba(255, 255, 255, 0.55);
}

html, body {
    height: 100%;
    overflow: hidden;
    overscroll-behavior: none;
}

body {
    background-color: var(--crimson);
    color: var(--cream);
    font-family: 'Migra', serif;
    font-size: 16px;
    line-height: 1.6;
}

body::before {
    content: '';
    position: fixed;
    inset: 0;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='1'/%3E%3C/svg%3E");
    opacity: 0.04;
    pointer-events: none;
    z-index: 9999;
}

/* ── APP SHELL — the canvas fills the whole viewport; everything else
   is a floating overlay on top of it, wplace.live-style. ──────────── */
#app {
    position: fixed;
    inset: 0;
    overflow: hidden;
}

#pixelCanvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
    cursor: grab; /* matches the default Move mode; setMode() overrides this once app.js runs */
    touch-action: none;
    display: block;
}

#pixelCanvas.is-grabbing {
    cursor: grabbing;
}

#app.is-loading #pixelCanvas {
    opacity: 0.3;
}

.canvas-status {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    color: var(--cream-dim);
    font-style: italic;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s;
    z-index: 3;
}

#app.is-loading .canvas-status,
#app.has-error .canvas-status {
    opacity: 1;
}

#app.has-error .canvas-status {
    color: #ff8888;
}

/* ── GLASS — shared frosted-panel look for all floating chrome ─── */
.glass-panel {
    background: rgba(90, 20, 20, 0.32);
    backdrop-filter: blur(16px) saturate(160%);
    -webkit-backdrop-filter: blur(16px) saturate(160%);
    border: 1px solid rgba(255, 255, 255, 0.16);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

/* ── TOP BAR ──────────────────────────────────── */
.topbar {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 24px 16px;
    z-index: 5;
    pointer-events: none;
}

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

.topbar__logo {
    /* Scales with viewport the same way question-select does — was a
       flat 32px, which read as small next to the now-bigger prompt pill
       on a real desktop monitor. */
    height: clamp(38px, 4vw, 68px);
    width: auto;
    filter: drop-shadow(0 0 20px rgba(0, 180, 0, 0.3));
}

.question-picker {
    position: absolute;
    top: 24px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 6;
}

.question-select {
    display: flex;
    align-items: center;
    gap: 0.6em;
    max-width: min(70vw, 640px);
    color: var(--cream);
    font-family: 'Qordhion', serif;
    /* Fixed px was fine at phone/tablet width but reads as tiny floating
       alone at the top of a real desktop monitor — scale with viewport
       instead, capped at both ends so it neither vanishes on a small
       screen nor gets cartoonishly large on an ultrawide one. */
    font-size: clamp(14px, 1.7vw, 22px);
    letter-spacing: 0.6px;
    padding: clamp(9px, 0.9vw, 15px) clamp(14px, 1.6vw, 26px);
    border-radius: 24px;
    cursor: pointer;
    transition: border-color 0.15s;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.question-select:hover,
.question-select[aria-expanded="true"] {
    border-color: rgba(0, 170, 0, 0.5);
}

.question-select__chevron {
    flex-shrink: 0;
    font-size: 0.7em;
    opacity: 0.7;
    transition: transform 0.15s;
}

.question-select[aria-expanded="true"] .question-select__chevron {
    transform: rotate(180deg);
}

/* Dropdown panel — replaces the browser's native <select> popup with
   something styled to match the rest of the glass UI, opening below the
   trigger instead of as an OS-chrome overlay. */
.question-menu {
    position: absolute;
    top: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    width: max-content;
    min-width: 100%;
    max-width: min(80vw, 480px);
    margin: 0;
    padding: 6px;
    border-radius: 16px;
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.question-menu[hidden] {
    display: none;
}

.question-menu__item {
    padding: 10px 16px;
    border-radius: 10px;
    color: var(--cream-dim);
    font-family: 'Qordhion', serif;
    font-size: clamp(13px, 1.3vw, 17px);
    line-height: 1.35;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}

.question-menu__item:hover {
    background: rgba(0, 170, 0, 0.18);
    color: var(--cream);
}

.question-menu__item.is-active {
    color: var(--green);
}

.question-menu__item[aria-disabled="true"] {
    opacity: 0.45;
    cursor: default;
    pointer-events: none;
}

/* ── ZOOM CONTROLS ────────────────────────────── */
.zoom-controls {
    position: absolute;
    top: 108px;
    right: 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 5;
}

.zoom-controls button {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    color: var(--cream);
    font-family: 'Migra', serif;
    font-size: 16px;
    line-height: 1;
    cursor: pointer;
    transition: border-color 0.15s, color 0.15s;
}

.zoom-controls button:hover {
    border-color: rgba(0, 170, 0, 0.5);
    color: var(--green);
}

.zoom-controls #zoomReset {
    font-size: 14px;
}

/* ── MODE TOGGLE ──────────────────────────────── */
.mode-toggle {
    position: absolute;
    top: 108px; /* matches zoom-controls' top, mirrored on the left */
    left: 16px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 4px;
    border-radius: 14px;
    z-index: 5;
}

.mode-btn {
    width: 64px;
    padding: 8px 0;
    border-radius: 10px;
    background: transparent;
    border: none;
    color: var(--cream-dim);
    font-family: 'Migra', serif;
    font-size: 12px;
    letter-spacing: 0.5px;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}

.mode-btn:hover {
    color: var(--cream);
}

.mode-btn.is-active {
    background: rgba(0, 170, 0, 0.3);
    color: var(--cream);
}

/* ── BOTTOM BAR ───────────────────────────────── */
.bottombar {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    justify-content: center;
    padding: 0 16px calc(20px + env(safe-area-inset-bottom, 0px));
    z-index: 5;
}

.palette-panel {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    padding: 14px 16px;
    border-radius: 20px;
}

.palette {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 6px;
    max-width: min(88vw, 400px);
}

.swatch {
    width: 26px;
    height: 26px;
    border-radius: 4px;
    border: 2px solid rgba(255, 255, 255, 0.15);
    cursor: pointer;
    padding: 0;
    transition: transform 0.12s, border-color 0.12s;
}

.swatch:hover {
    transform: translateY(-2px);
}

.swatch.is-active {
    border-color: var(--cream);
    transform: translateY(-2px) scale(1.08);
    box-shadow: 0 0 0 2px var(--green);
}

/* The eraser swatch's fill deliberately matches the empty-cell
   background (see BASE_COLOR in app.js) — without a visual cue it would
   just look like a broken/missing swatch sitting in the row. */
.swatch--eraser {
    position: relative;
    border-style: dashed;
    border-color: rgba(255, 255, 255, 0.3);
}

.swatch--eraser::after {
    content: '✕';
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    color: rgba(255, 255, 255, 0.55);
    pointer-events: none;
}

.bottombar__meta {
    display: flex;
    align-items: baseline;
    gap: 12px;
}

.place-status {
    font-size: 11px;
    letter-spacing: 1px;
    color: var(--cream-dim);
}

.place-status.is-error {
    color: #ff8888;
}

.stats {
    font-size: 10px;
    letter-spacing: 2px;
    color: var(--cream-dim);
    text-transform: uppercase;
}
