/* Coaster Tycoon chrome. Self-contained: no Tailwind. Colors are CSS custom
   properties ../_shared/harness.js sets from the site theme (with fallbacks). */

* { box-sizing: border-box; }

html, body { margin: 0; height: 100%; }

body {
    font-family: "Inter", "Segoe UI", system-ui, sans-serif;
    color: var(--text, #e4e4e7);
    background: var(--bg, #09090b);
    overflow: hidden;
    -webkit-user-select: none;
    user-select: none;
}

#app { display: flex; flex-direction: column; height: 100%; }

/* --- top bar --- */
#hud {
    display: flex;
    align-items: center;
    gap: 8px 14px;
    padding: 8px 12px;
    background: var(--surface, #16161a);
    border-bottom: 1px solid var(--line, #3f3f46);
    font-size: 13px;
    color: var(--dim, #a1a1aa);
    flex-wrap: wrap;
}

/* Readouts fill the row and wrap among themselves; the controls stay a fixed
   cluster pinned right, so they never jump as a number's width changes. */
.hud-readouts { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 14px; flex: 1 1 auto; min-width: 0; }
.hud-controls { display: flex; align-items: center; gap: 8px; flex: 0 0 auto; margin-left: auto; }

#hud .stat b { color: var(--text, #e4e4e7); font-variant-numeric: tabular-nums; }
#hud #hud-net.neg { color: #f87171; }
#hud .msg { color: var(--accent, #a78bfa); font-size: 12px; }

.transport { display: flex; gap: 4px; }

.iconbtn {
    min-width: 34px;
    height: 32px;
    padding: 0 8px;
    display: grid;
    place-items: center;
    border: 1px solid var(--line, #3f3f46);
    border-radius: 8px;
    background: transparent;
    color: var(--dim, #a1a1aa);
    font-size: 13px;
    line-height: 1;
    cursor: pointer;
}

.iconbtn:hover { color: var(--text, #e4e4e7); border-color: var(--accent, #a78bfa); }
.iconbtn.is-active { color: #fff; background: var(--accent, #a78bfa); border-color: var(--accent, #a78bfa); }

/* --- body: tool rail + play stage --- */
#body { flex: 1; min-height: 0; display: flex; }

#toolbar {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 10px 8px;
    background: var(--surface, #16161a);
    border-right: 1px solid var(--line, #3f3f46);
    overflow-y: auto;     /* scroll when there are more tools than the frame is tall */
    min-height: 0;
}

.tool {
    display: flex;
    flex: 0 0 auto;       /* keep full size and let #toolbar scroll, never squish */
    flex-direction: column;
    align-items: center;
    gap: 2px;
    width: 72px;
    padding: 8px 4px;
    border: 1px solid var(--line, #3f3f46);
    border-radius: 10px;
    background: transparent;
    color: var(--dim, #a1a1aa);
    cursor: pointer;
}

.tool .glyph { font-size: 20px; line-height: 1; }
.tool .label { font-size: 11px; }
.tool .cost { font-size: 10px; color: var(--dim, #a1a1aa); font-variant-numeric: tabular-nums; }
.tool:hover { color: var(--text, #e4e4e7); border-color: var(--accent, #a78bfa); }
.tool.is-active { color: #fff; background: var(--accent, #a78bfa); border-color: var(--accent, #a78bfa); }
.tool.is-active .cost { color: rgba(255, 255, 255, 0.85); }

#stage { position: relative; flex: 1; min-height: 0; min-width: 0; touch-action: none; }

/* --- scenario overlay --- */
#overlay {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    background: color-mix(in oklab, var(--bg, #09090b) 70%, transparent);
    backdrop-filter: blur(2px);
    z-index: 5;
}

#overlay[hidden] { display: none; }

#overlay .card {
    text-align: center;
    padding: 22px 26px;
    border-radius: 14px;
    background: var(--surface, #16161a);
    border: 1px solid var(--line, #3f3f46);
    max-width: 320px;
}

#ov-title { margin: 0; font-size: 22px; font-weight: 700; color: var(--text, #e4e4e7); }
#overlay .sub { margin: 6px 0 16px; font-size: 14px; color: var(--dim, #a1a1aa); }

.primary {
    border: 0;
    border-radius: 9px;
    padding: 10px 18px;
    background: var(--accent, #a78bfa);
    color: #fff;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
}

.primary:hover { filter: brightness(1.08); }

/* --- inspector panel (per-attraction) --- */
#inspector {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 208px;
    padding: 12px 14px;
    border-radius: 12px;
    background: var(--surface, #16161a);
    border: 1px solid var(--line, #3f3f46);
    z-index: 6;
    font-size: 13px;
    color: var(--dim, #a1a1aa);
}

#inspector[hidden] { display: none; }

.insp-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
#insp-title { color: var(--text, #e4e4e7); font-weight: 600; }
.insp-x { border: 0; background: transparent; color: var(--dim, #a1a1aa); font-size: 18px; line-height: 1; cursor: pointer; }
.insp-x:hover { color: var(--text, #e4e4e7); }

.insp-row { display: flex; align-items: center; justify-content: space-between; margin: 6px 0; }
.insp-row b { color: var(--text, #e4e4e7); font-variant-numeric: tabular-nums; }

.insp-price-ctl { display: inline-flex; align-items: center; gap: 8px; }
.insp-step {
    width: 26px;
    height: 26px;
    border-radius: 7px;
    border: 1px solid var(--line, #3f3f46);
    background: transparent;
    color: var(--text, #e4e4e7);
    font-size: 15px;
    line-height: 1;
    cursor: pointer;
}
.insp-step:hover { border-color: var(--accent, #a78bfa); }

.insp-actions { display: flex; gap: 6px; margin-top: 10px; }
.insp-actions .iconbtn { flex: 1; }

/* --- help overlay (how to play) --- */
#help {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    background: color-mix(in oklab, var(--bg, #09090b) 72%, transparent);
    backdrop-filter: blur(2px);
    z-index: 8;
    padding: 16px;
}

#help[hidden] { display: none; }

.help-card {
    text-align: left;
    max-width: 470px;
    padding: 20px 22px;
    border-radius: 14px;
    background: var(--surface, #16161a);
    border: 1px solid var(--line, #3f3f46);
}

.help-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
#help-title { margin: 0; font-size: 20px; font-weight: 700; color: var(--text, #e4e4e7); }
.help-list { margin: 0 0 16px; padding-left: 18px; display: flex; flex-direction: column; gap: 8px; font-size: 13px; color: var(--dim, #a1a1aa); line-height: 1.45; }
.help-list b { color: var(--text, #e4e4e7); }

:focus-visible { outline: 2px solid var(--accent, #a78bfa); outline-offset: 2px; }

@media (max-width: 620px) {
    #body { flex-direction: column-reverse; }
    #toolbar { flex-direction: row; border-right: 0; border-top: 1px solid var(--line, #3f3f46); overflow-x: auto; }
    .tool { width: auto; flex: 1 0 auto; flex-direction: row; justify-content: center; gap: 6px; }
}
