* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: "Segoe UI", system-ui, sans-serif;
    background: #1f2127;
    color: #e6e6e6;
}

.layout {
    display: flex;
    gap: 16px;
    padding: 16px;
    height: 100vh;
}

.canvas-pane { flex: 1; display: flex; flex-direction: column; min-width: 0; order: 1; }

.toolbar { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 12px; }
.toolbar h1 { font-size: 20px; margin: 0; }
.controls { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.controls label { font-size: 13px; display: flex; align-items: center; gap: 8px; }

.btn {
    background: #353842; color: #e6e6e6; border: 1px solid #4a4e5a;
    padding: 6px 12px; border-radius: 8px; cursor: pointer; font-size: 13px;
}
.btn:hover { background: #424653; }

.canvas {
    flex: 1; margin-top: 12px;
    background: #2a2d35; border: 1px solid #3a3d47; border-radius: 12px;
    width: 100%;
}

.node { cursor: pointer; }
.node circle { transition: filter .1s; }
.node .emoji { font-size: 24px; text-anchor: middle; dominant-baseline: middle; pointer-events: none; }
.node .label { font-size: 11px; text-anchor: middle; fill: #b8bcc4; pointer-events: none; }

.node.selected circle:first-of-type { stroke: #f0c14b; stroke-width: 3; }
.node.neighbor circle:first-of-type { stroke: #6fb3ff; stroke-width: 3; stroke-dasharray: 4 3; }

.blob-ring { fill: none; stroke: #b86fff; stroke-width: 2.5; stroke-dasharray: 5 4; }
.radius-ring { fill: #6fb3ff14; stroke: #6fb3ff66; stroke-width: 1.5; stroke-dasharray: 6 5; }

.hint-line { font-size: 12px; color: #8a8f99; margin: 8px 2px 0; }

.io-bar { display: flex; align-items: center; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.io-bar input, .io-bar select {
    background: #353842; color: #e6e6e6; border: 1px solid #4a4e5a;
    border-radius: 6px; padding: 6px; font-size: 13px;
}
.io-bar input { width: 160px; }
.io-msg { font-size: 12px; color: #8a8f99; }

.inspector {
    order: 0;
    width: 300px; background: #2a2d35; border: 1px solid #3a3d47;
    border-radius: 12px; padding: 16px; overflow-y: auto;
}
.inspector h2 { margin: 0; font-size: 18px; }
.inspector .pos { font-size: 11px; color: #8a8f99; }
.inspector section { margin-top: 18px; }
.inspector h3 { font-size: 12px; text-transform: uppercase; letter-spacing: .5px; color: #8a8f99; margin: 0 0 8px; }

.kv { list-style: none; padding: 0; margin: 0; }
.kv li { display: flex; justify-content: space-between; padding: 4px 0; border-bottom: 1px solid #34373f; font-size: 13px; }
.kv li span { color: #b8bcc4; }
.kv li b { color: #fff; }

.tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tag { font-size: 12px; padding: 3px 8px; border-radius: 6px; }
.tag.concept { background: #34495e; color: #cfe0f0; }
.tag.effect { background: #3e3450; color: #e0cff0; }

.muted { color: #6b7078; font-size: 13px; }

.context-hud {
    position: fixed; left: 16px; bottom: 16px;
    width: 190px; max-height: 42vh; overflow-y: auto;
    background: rgba(30, 33, 39, 0.92); border: 1px solid #3a3d47;
    border-radius: 10px; padding: 10px 12px; z-index: 30;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
}
.context-hud h4 {
    margin: 0 0 8px; font-size: 12px; text-transform: uppercase;
    letter-spacing: .5px; color: #8a8f99;
}
.hud-row { display: flex; justify-content: space-between; gap: 10px; font-size: 12px; padding: 2px 0; }
.hud-row span { color: #b8bcc4; }
.hud-row b { color: #fff; }

.empty-dot { fill: none; stroke: #4a4e5a; stroke-width: 1.5; stroke-dasharray: 3 3; }

.phrase-debug {
    order: 2;
    width: 300px; flex-shrink: 0;
    background: #2a2d35; border: 1px solid #3a3d47; border-radius: 12px;
    padding: 16px; overflow-y: auto;
    display: flex; flex-direction: column;
}
.phrase-debug h2 { margin: 0 0 12px; font-size: 14px; text-transform: uppercase; letter-spacing: .5px; color: #8a8f99; }
.blob-as { font-size: 13px; color: #cfe0f0; margin: 0 0 14px; }
.first-phrase { font-size: 15px; color: #f4f6fa; font-style: italic; margin: 0 0 16px; padding: 10px 12px; background: #23262e; border-left: 3px solid #f0c14b; border-radius: 4px; }
.clue { margin-bottom: 12px; }
.clue-id { font-size: 11px; text-transform: uppercase; letter-spacing: .5px; color: #f0c14b; }
.phrases { list-style: none; padding: 0; margin: 5px 0 0; }
.phrases li { font-size: 12px; color: #d6d9df; padding: 2px 0 2px 10px; border-left: 2px solid #34373f; margin-bottom: 4px; }
.clue-catalog { margin-top: 18px; padding-top: 14px; border-top: 1px solid #3a3d47; }
.clue-box { background: #23262e; border: 1px solid #34373f; border-radius: 6px; margin-bottom: 8px; padding: 8px 10px; }
.clue-box summary { cursor: pointer; font-size: 11px; text-transform: uppercase; letter-spacing: .5px; color: #f0c14b; user-select: none; }
.clue-box[open] summary { margin-bottom: 6px; }

.slot-editor { display: flex; flex-direction: column; gap: 10px; align-items: flex-start; }
.assign { font-size: 13px; display: flex; flex-direction: column; gap: 4px; width: 100%; }
.assign select { background: #353842; color: #e6e6e6; border: 1px solid #4a4e5a; border-radius: 6px; padding: 6px; }

.object-maps .map-entry { margin-bottom: 12px; }
.object-maps .map-head { display: flex; gap: 6px; align-items: baseline; font-size: 12px; color: #cfe0f0; margin-bottom: 4px; }
.object-maps .map-head .muted { font-size: 11px; }
.occ-map { background: #23262e; border: 1px solid #34373f; border-radius: 4px; display: block; shape-rendering: crispEdges; }
.occ-map rect { fill: #6fb3ff; }

/* Play page */
.play { height: 100vh; display: flex; flex-direction: column; gap: 14px; padding: 16px 24px; overflow: hidden; background: #44b9fc; color: #1c1e22; }
.play-top { display: flex; justify-content: space-between; align-items: center; }
.play-title { font-size: 40px; font-weight: 800; color: #1a1c20; }
.play-top-right { display: flex; align-items: center; gap: 10px; }
.play-help {
    height: 40px; flex-shrink: 0; padding: 0 16px; border-radius: 20px;
    border: 2px solid #b8cbe8; background: #fff; color: #2f6fed;
    font-size: 18px; font-weight: 700; cursor: pointer;
    display: flex; align-items: center; justify-content: center; gap: 6px;
}
.play-help::after { content: "How to play"; font-size: 14px; font-weight: 600; }
.play-help:hover { background: #eaf2ff; }

.howto-overlay {
    position: fixed; inset: 0; z-index: 60;
    display: flex; align-items: center; justify-content: center;
    padding: 24px; background: rgba(15, 17, 22, 0.55);
}
.howto-card {
    position: relative; width: 100%; max-width: 460px;
    background: #fff; color: #1c1e22; border-radius: 20px;
    padding: 32px 36px; border-top: 6px solid #2f6fed;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.45);
}
.howto-close {
    position: absolute; top: 12px; right: 16px;
    border: none; background: transparent; cursor: pointer;
    font-size: 26px; line-height: 1; color: #8a8f99;
}
.howto-close:hover { color: #1c1e22; }
.howto-title { margin: 0 0 16px; font-size: 26px; font-weight: 800; color: #1a1c20; }
.howto-steps {
    margin: 0 0 24px; padding-left: 22px;
    display: flex; flex-direction: column; gap: 10px;
    font-size: 15px; line-height: 1.4; color: #3a3e46;
}
.howto-steps b { color: #2f6fed; }
.howto-start { width: 100%; }
.play-top select {
    background: #fff; color: #1c1e22; border: 1px solid #d3d6dc;
    border-radius: 6px; padding: 6px 10px; font-size: 13px;
}
.play-clue {
    align-self: center; text-align: center; max-width: 1100px; margin: 0 520px 0 0;
    font-size: 42px; line-height: 1.2; font-weight: 700; font-style: italic; color: #1a1c20;
}
.play-stage { flex: 1; display: flex; gap: 20px; min-height: 0; }
.play-board-area {
    flex: 1; min-width: 0; min-height: 0;
    display: flex; align-items: center; justify-content: center;
    container-type: size;
}
.play-board {
    width: min(100cqw, 100cqh * var(--board-ratio, 1));
    aspect-ratio: var(--board-ratio, 1);
    background: #ffffff; border: 2px solid #b8cbe8; border-radius: 16px;
}
.play-board svg { width: 100%; height: 100%; display: block; }
.play-board .emoji { font-size: 24px; text-anchor: middle; dominant-baseline: middle; pointer-events: none; }
.play-sprite { pointer-events: none; }
.play-hit { fill: transparent; pointer-events: all; cursor: pointer; }
.sel-fill { fill: #2f6fed; fill-opacity: 0.3; pointer-events: none; }
.sel-outline { fill: none; stroke: #2f6fed; stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; pointer-events: none; }

.play-side { width: 500px; flex-shrink: 0; display: flex; flex-direction: column; gap: 12px; min-height: 0; }
.play-spacer { flex: 1; }
.play-timer {
    flex-shrink: 0;
    display: flex; flex-direction: column; align-items: center; gap: 6px;
    background: #f5f6f8; border: 1px solid #e3e5e9; border-radius: 16px; padding: 18px;
}
.play-timer .time { font-size: 44px; font-weight: 700; color: #1a1c20; font-variant-numeric: tabular-nums; }
.play-timer .next { font-size: 12px; color: #8a8f99; text-align: center; }

.play-tips { display: flex; flex-direction: column; gap: 12px; }
.play-tip {
    display: flex; align-items: center; gap: 12px; width: 100%;
    padding: 18px; border-radius: 16px;
    background: #f5f6f8; border: 1px solid #e3e5e9;
    font-size: 24px; font-weight: 700; font-family: inherit; color: inherit; text-align: left;
}
.play-tip.locked { cursor: pointer; color: #5a5f68; }
.play-tip.locked:hover { background: #eceef1; border-color: #cfd3da; }
.play-tip.revealed { color: #1a1c20; }
.play-tip .tip-icon { font-size: 22px; flex-shrink: 0; line-height: 1; }

.play-guess {
    flex-shrink: 0; padding: 20px; border-radius: 12px; border: none;
    font-size: 20px; font-weight: 600; cursor: pointer; background: #2f6fed; color: #fff;
}
.play-guess:hover:not(:disabled) { background: #285fd0; }
.play-guess:disabled { background: #d3d6dc; color: #9aa0a8; cursor: not-allowed; }
.play-overlay {
    position: fixed; inset: 0; z-index: 50;
    background: transparent; pointer-events: none;
}
.play-overlay-card {
    position: fixed; pointer-events: auto;
    display: flex; flex-direction: column; align-items: center; gap: 14px;
    background: #fff; border-radius: 20px; padding: 32px 48px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.45); text-align: center;
    border-top: 6px solid #b3261e;
}
.play-overlay.win .play-overlay-card { border-top-color: #1e7a37; }
.play-overlay-title { font-size: 30px; font-weight: 800; color: #1a1c20; }
.play-overlay.win .play-overlay-title { color: #1e7a37; }
.play-overlay.lose .play-overlay-title { color: #b3261e; }
.play-overlay-sub { font-size: 15px; color: #5a5f68; }
.play-overlay-card .play-guess { margin-top: 8px; padding: 12px 28px; font-size: 15px; }
.howto-start { padding: 14px; font-size: 15px; }

.spotlight-backdrop { position: fixed; inset: 0; z-index: 40; pointer-events: none; background: rgba(15, 17, 22, 0.85); }

.blob-reveal {
    fill: none; stroke: #35d75f; stroke-width: 7;
    stroke-linecap: round; stroke-linejoin: round; pointer-events: none;
    filter: drop-shadow(0 0 6px rgba(53, 215, 95, 0.9));
}

.loading-progress {
    position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%);
    width: 8rem; height: 8rem;
}
.loading-progress circle {
    fill: none; stroke: #3a3d45; stroke-width: 0.6rem; transform-origin: 50% 50%;
    transform: rotate(-90deg);
}
.loading-progress circle:last-child {
    stroke: #2f6fed;
    stroke-dasharray: calc(3.141 * var(--blazor-load-percentage, 0%) * 0.8) 500%;
    transition: stroke-dasharray 0.05s ease-in-out;
}
.loading-progress-text {
    position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%);
    color: #e6e6e6; font-family: "Segoe UI", system-ui, sans-serif;
}
.loading-progress-text:after {
    content: var(--blazor-load-percentage-text, "Loading");
}
#blazor-error-ui {
    display: none; position: fixed; bottom: 0; left: 0; right: 0; z-index: 1000;
    background: #ffe9e9; color: #7a1f1f; padding: 12px 20px;
    box-shadow: 0 -2px 8px rgba(0,0,0,0.2);
}
#blazor-error-ui .dismiss { cursor: pointer; position: absolute; right: 16px; top: 12px; }
