:root {
            --bg-color: #1a252f;
            --ui-panel: #2c3e50;
            --ui-border: #141e26;
            --accent: #d35400;
            --accent-bright: #e67e22;
            --text: #ecf0f1;
            --text-dim: #bdc3c7;
            --danger: #c0392b;
            --success: #27ae60;
        }

        body { margin: 0; padding: 0; background: var(--bg-color); font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; color: var(--text); overflow: hidden; user-select: none; }
        #game-container { position: relative; width: 100vw; height: 100vh; display: flex; flex-direction: column; }
        canvas { background: #4a5d33; cursor: crosshair; image-rendering: pixelated; flex-grow: 1; }

        #top-bar { height: 52px; background: var(--ui-panel); display: flex; align-items: center; padding: 0 16px; border-bottom: 4px solid var(--ui-border); justify-content: space-between; font-weight: bold; z-index: 10; }
        .stat-group { display: flex; gap: 12px; align-items: center; }
        .stat { background: rgba(0,0,0,0.3); padding: 5px 12px; border-radius: 4px; display: flex; align-items: center; gap: 6px; border: 1px solid rgba(255,255,255,0.05); }

        #bottom-toolbar { height: 80px; background: var(--ui-panel); border-top: 4px solid var(--ui-border); display: flex; justify-content: center; align-items: center; gap: 6px; z-index: 10; padding: 0 10px; overflow-x: auto; }
        .tool-btn { background: #34495e; border: 2px solid #1a252f; border-radius: 4px; padding: 6px; color: white; cursor: pointer; min-width: 70px; height: 60px; display: flex; flex-direction: column; align-items: center; justify-content: center; font-size: 10px; transition: all 0.1s; }
        .tool-btn:hover { background: #4a6278; }
        .tool-btn.active { background: var(--accent-bright); border-color: #fff; transform: translateY(-3px); box-shadow: 0 4px 0 rgba(0,0,0,0.2); }
        .speed-control { display: flex; flex-direction: column; justify-content: center; align-items: center; gap: 5px; color: var(--text); font-size: 11px; min-width: 150px; }
        .speed-control input { width: 140px; accent-color: var(--accent-bright); cursor: pointer; }
        .utility-btn { min-width: 62px; }
        .sim-controls { display: flex; align-items: center; gap: 8px; }
        .sim-toggle { background: rgba(255,255,255,0.06); border: 1px solid rgba(255,255,255,0.15); border-radius: 4px; color: var(--text); cursor: pointer; font-weight: 700; padding: 6px 10px; }
        .speed-selector { display: inline-flex; background: rgba(0,0,0,0.2); border: 1px solid rgba(255,255,255,0.08); border-radius: 4px; overflow: hidden; }
        .speed-btn { background: transparent; border: none; color: var(--text-dim); cursor: pointer; font-weight: 700; padding: 6px 10px; }
        .speed-btn.active { background: var(--accent-bright); color: #fff; }

        .context-panel { position: absolute; right: 16px; top: 68px; width: 240px; background: var(--ui-panel); border: 3px solid var(--ui-border); border-radius: 6px; padding: 12px; display: block; z-index: 5; box-shadow: 0 8px 16px rgba(0,0,0,0.5); }
        .context-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; padding-bottom: 4px; border-bottom: 1px solid #4a6278; }
        .context-label { font-size: 10px; text-transform: uppercase; letter-spacing: 0.12em; color: var(--text-dim); }
        .context-close { width: 28px; height: 28px; border: 1px solid rgba(255,255,255,0.12); border-radius: 4px; background: rgba(0,0,0,0.2); color: var(--text); font-size: 22px; line-height: 1; cursor: pointer; }
        .inspector-title { font-size: 1.1em; color: var(--accent-bright); margin-bottom: 8px; }
        .context-body { color: var(--text); font-size: 12px; line-height: 1.5; min-height: 32px; }
        .condition-track { width: 100%; height: 8px; margin: 4px 0 9px; background: #17232d; border: 1px solid rgba(255,255,255,.14); border-radius: 4px; overflow: hidden; }
        .condition-fill { height: 100%; transition: width .25s ease; }
        .context-actions { display: flex; flex-direction: column; gap: 6px; margin-top: 10px; }
        .btn-action { width: 100%; padding: 8px; margin-top: 0; background: var(--success); border: none; border-radius: 4px; color: white; cursor: pointer; font-weight: bold; font-size: 11px; }
        .btn-action:hover { filter: brightness(1.1); }
        .btn-action:disabled { opacity: 0.45; cursor: not-allowed; filter: grayscale(0.25); }

        #toast { position: absolute; top: 70px; left: 50%; transform: translateX(-50%); background: rgba(0,0,0,0.9); border: 1px solid #e67e22; color: #fff; padding: 10px 20px; border-radius: 20px; font-size: 13px; display: none; z-index: 100; pointer-events: none; }
        #interaction-hint { position: absolute; left: 16px; top: 68px; background: rgba(0,0,0,0.75); border: 1px solid #4a6278; color: var(--text); padding: 8px 12px; border-radius: 4px; font-size: 12px; z-index: 4; pointer-events: none; }
        
        .satisfaction-bar { height: 4px; width: 100%; background: #c0392b; margin-top: 4px; border-radius: 2px; overflow: hidden; }
        #satisfaction-fill { height: 100%; background: #27ae60; width: 50%; transition: width 0.5s; }
        .demand-stat { display: grid; grid-template-columns: auto minmax(70px, 100px); gap: 2px 8px; min-width: 180px; }
        .demand-track { height: 6px; background: #17232d; border-radius: 3px; overflow: hidden; }
        #demand-fill { height: 100%; width: 0; background: #e67e22; transition: width 0.4s, background-color 0.4s; }
        #demand-capacity { grid-column: 1 / -1; color: var(--text-dim); font-size: 10px; font-weight: normal; }


/* Responsive management menu: keep the park visible and move tools off the bottom edge. */
#game-container { height: 100dvh; min-height: 0; }
#top-bar { flex: 0 0 auto; min-height: 48px; height: auto; box-sizing: border-box; gap: 8px; padding: 5px 10px; border-bottom-width: 2px; }
#top-bar .stat-group { gap: 6px; flex-wrap: wrap; }
#top-bar .stat { padding: 4px 7px; font-size: 12px; }
#park-name { white-space: nowrap; font-size: 13px; }
.demand-stat { min-width: 135px; grid-template-columns: auto minmax(45px, 70px); }
canvas { display: block; width: 100%; flex: 1 1 auto; min-height: 0; }
#build-menu { position: absolute; z-index: 20; left: 10px; top: 62px; display: flex; align-items: flex-start; gap: 8px; max-height: calc(100dvh - 74px); }
#menu-tabs { display: flex; flex-direction: column; gap: 5px; padding: 5px; background: rgba(26,37,47,.96); border: 1px solid var(--ui-border); border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,.35); }
.menu-tab { width: 54px; min-height: 52px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; border: 1px solid transparent; border-radius: 5px; background: #34495e; color: var(--text); cursor: pointer; font-size: 19px; }
.menu-tab span { font-size: 10px; }
.menu-tab:hover { background: #4a6278; }
.menu-tab.active { background: var(--accent); border-color: #ffd2a8; }
.menu-panel { display: none; width: min(320px, calc(100vw - 88px)); max-height: calc(100dvh - 86px); overflow-y: auto; box-sizing: border-box; padding: 12px; background: rgba(35,50,64,.97); border: 1px solid #526779; border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,.4); }
.menu-panel.active { display: block; }
.menu-heading { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding-bottom: 9px; margin-bottom: 10px; border-bottom: 1px solid #526779; color: #ffd0a4; }
.menu-close { border: 0; border-radius: 4px; color: var(--text); background: #34495e; font-size: 22px; width: 30px; height: 28px; cursor: pointer; }
.menu-description { margin: 0 0 10px; color: var(--text-dim); font-size: 11px; line-height: 1.4; }
.tool-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 7px; }
.tool-btn { min-width: 0; width: 100%; min-height: 60px; height: auto; box-sizing: border-box; padding: 8px 5px; gap: 5px; border: 1px solid #18232d; border-radius: 6px; background: #34495e; color: white; cursor: pointer; display: flex; flex-direction: column; align-items: center; justify-content: center; font-size: 19px; transition: background .12s, border-color .12s; }
.tool-btn span { font-size: 11px; line-height: 1.25; text-align: center; overflow-wrap: anywhere; }
.tool-btn:hover { background: #4a6278; }
.tool-btn.active { background: var(--accent-bright); border-color: #fff; box-shadow: inset 0 0 0 1px rgba(0,0,0,.2); transform: none; }
.speed-control { align-items: stretch; gap: 8px; font-size: 12px; }
.speed-control input { width: 100%; }
.settings-group { margin-top: 14px; padding: 12px 4px 2px; border-top: 1px solid #526779; }
#menu-reopen { display: none; align-self: flex-start; width: 48px; height: 48px; border: 1px solid #607586; border-radius: 8px; background: rgba(35,50,64,.96); color: white; font-size: 22px; cursor: pointer; box-shadow: 0 5px 16px rgba(0,0,0,.35); }
#build-menu.collapsed #menu-tabs, #build-menu.collapsed .menu-panel { display: none !important; }
#build-menu.collapsed #menu-reopen { display: block; }
#interaction-hint { top: auto; bottom: 12px; left: 12px; max-width: min(430px, calc(100vw - 24px)); font-size: 11px; padding: 6px 9px; }
.context-panel { top: 62px; right: 10px; width: min(240px, calc(100vw - 28px)); box-sizing: border-box; max-height: calc(100dvh - 76px); overflow-y: auto; padding: 10px; }
#toast { top: 62px; max-width: calc(100vw - 32px); text-align: center; box-sizing: border-box; }
.start-screen { position: absolute; inset: 0; z-index: 200; display: grid; place-items: center; padding: 20px; box-sizing: border-box; background: rgba(12, 20, 26, .88); }
.start-screen[hidden] { display: none; }
.start-card { width: min(600px, 100%); box-sizing: border-box; padding: clamp(20px, 5vw, 36px); border: 2px solid #866044; border-radius: 12px; background: linear-gradient(145deg, #34495e, #1f2e39); box-shadow: 0 20px 60px rgba(0,0,0,.55); }
.start-kicker { margin: 0 0 8px; color: #f0a45e; font-size: 11px; font-weight: 800; letter-spacing: .18em; }
.start-card h1 { margin: 0 0 10px; color: #ffe0ba; font-size: clamp(25px, 6vw, 36px); line-height: 1.1; }
.start-card > p:not(.start-kicker) { color: var(--text-dim); line-height: 1.5; }
.controls-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin: 22px 0 16px; }
.controls-grid > div { display: flex; flex-direction: column; gap: 4px; padding: 11px; border: 1px solid rgba(255,255,255,.1); border-radius: 6px; background: rgba(0,0,0,.16); }
.controls-grid strong { color: #fff; font-size: 12px; }
.controls-grid span { color: var(--text-dim); font-size: 11px; line-height: 1.4; }
.start-tip { padding-left: 10px; border-left: 3px solid var(--accent-bright); font-size: 12px; }
.start-button { width: 100%; min-height: 46px; margin-top: 8px; border: 0; border-radius: 6px; background: var(--accent-bright); color: #fff; font-size: 15px; font-weight: 800; cursor: pointer; }
.start-button:hover { filter: brightness(1.1); }
.sleep-actions { display: flex; gap: 8px; }
.sleep-cancel { min-height: 46px; margin-top: 8px; padding: 0 18px; border: 1px solid rgba(255,255,255,.2); border-radius: 6px; background: #34495e; color: var(--text); font-weight: 700; cursor: pointer; }
.sleep-transition { position: absolute; inset: 0; z-index: 250; background: #000; opacity: 0; pointer-events: none; transition: opacity .6s ease; }
.sleep-transition.active { opacity: 1; pointer-events: auto; }
@media (max-width: 900px) {
  #top-bar { align-items: flex-start; }
  #top-bar .stat-group { gap: 4px; }
  .demand-stat { display: none; }
}
@media (max-width: 600px) {
  .controls-grid { grid-template-columns: 1fr; gap: 6px; margin: 14px 0 10px; }
  .controls-grid > div { padding: 8px; }
  .start-card { max-height: calc(100dvh - 24px); overflow-y: auto; padding: 20px; }
  #top-bar { padding: 4px 6px; }
  #top-bar .stat { font-size: 10px; padding: 3px 5px; }
  #park-name { display: none; }
  #build-menu { left: 5px; top: 58px; gap: 5px; max-height: calc(100dvh - 64px); }
  #menu-tabs { padding: 3px; gap: 3px; }
  .menu-tab { width: 43px; min-height: 46px; font-size: 16px; }
  .menu-tab span { font-size: 9px; }
  .menu-panel { width: min(280px, calc(100vw - 64px)); max-height: calc(100dvh - 70px); padding: 9px; }
  .tool-grid { gap: 5px; }
  .tool-btn { min-height: 52px; }
  .tool-btn span { font-size: 10px; }
  #inspector { top: auto; bottom: 42px; right: 6px; width: min(220px, calc(100vw - 70px)); max-height: 55dvh; }
  #interaction-hint { bottom: 6px; left: 6px; max-width: calc(100vw - 12px); font-size: 9px; }
}


/* Player avatar creator: intentionally uses the same chunky canvas style as the prototype. */
.start-card { width: min(860px, 100%); }
.avatar-creator { display: grid; grid-template-columns: 150px minmax(0, 1fr); gap: 18px; margin: 18px 0 12px; padding: 14px; border: 1px solid #526575; border-radius: 8px; background: rgba(10, 18, 24, .38); }
.avatar-preview-panel { display: flex; flex-direction: column; align-items: stretch; gap: 8px; }
#avatar-preview { width: 96px; height: 112px; max-width: 100%; align-self: center; image-rendering: pixelated; border: 1px solid #526575; border-radius: 5px; background: repeating-conic-gradient(#263845 0% 25%, #2c3e50 0% 50%) 50% / 12px 12px; }
.avatar-preview-panel label, .avatar-options label { display: flex; flex-direction: column; gap: 5px; color: #f2d7b5; font-size: 12px; font-weight: 700; text-align: left; }
.avatar-options { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); align-content: start; gap: 10px 12px; }
.avatar-options select, #player-name { width: 100%; min-width: 0; box-sizing: border-box; padding: 9px 8px; border: 1px solid #667988; border-radius: 5px; background: #182630; color: #f3f5f6; font: inherit; font-size: 13px; }
#player-name { font-size: 12px; }
.secondary-button { min-height: 36px; padding: 8px 10px; border: 1px solid #718391; border-radius: 5px; background: #34495e; color: #fff; font-size: 12px; font-weight: 800; cursor: pointer; }
.secondary-button:hover { background: #496276; }
.visitor-randomiser { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 12px 0 18px; padding: 12px; border: 1px solid #526575; border-radius: 8px; background: rgba(10, 18, 24, .25); }
.visitor-randomiser div { display: flex; flex-direction: column; gap: 4px; text-align: left; }
.visitor-randomiser strong { color: #ffe0ba; font-size: 13px; }
.visitor-randomiser span { color: var(--text-dim); font-size: 12px; }
.visitor-randomiser .secondary-button { flex-shrink: 0; }
@media (max-width: 600px) {
  .avatar-creator { grid-template-columns: 1fr; gap: 12px; }
  .avatar-preview-panel { display: grid; grid-template-columns: 82px minmax(0, 1fr); align-items: center; }
  #avatar-preview { grid-row: span 2; width: 82px; height: 96px; }
  .avatar-preview-panel label { grid-column: 2; }
  #player-name { grid-column: 2; }
  .avatar-preview-panel .secondary-button { grid-column: 1 / -1; }
  .avatar-options { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .visitor-randomiser { align-items: stretch; flex-direction: column; }
}


/* Compact welcome menu with optional detail panels. */
.start-card.start-card-compact { width: min(470px, 100%); padding: clamp(20px, 4vw, 30px); }
.start-card-compact h1 { margin: 0 0 22px; text-align: center; }
.start-menu-buttons { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.start-menu-buttons button { min-height: 46px; margin: 0; padding: 10px 12px; }
.start-menu-buttons #start-game { grid-column: 1 / -1; }
.menu-button { border: 1px solid #718391; border-radius: 6px; background: #34495e; color: #f3f5f6; font: inherit; font-size: 13px; font-weight: 800; cursor: pointer; }
.menu-button:hover { background: #496276; }
.start-status { margin: 14px 0 0; color: var(--text-dim); font-size: 12px; line-height: 1.45; text-align: center; }
.start-options-panel { margin-top: 16px; padding: 14px; border: 1px solid #526575; border-radius: 8px; background: rgba(10, 18, 24, .38); }
.start-options-panel[hidden] { display: none; }
.panel-heading { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
.panel-heading h2 { margin: 0; color: #ffe0ba; font-size: 16px; }
.panel-close { width: 32px; height: 32px; border: 1px solid #667988; border-radius: 5px; background: #263845; color: #fff; font-size: 17px; cursor: pointer; }
.panel-done { width: 100%; min-height: 38px; margin-top: 12px; border: 0; border-radius: 5px; background: var(--accent-bright); color: #fff; font-weight: 800; cursor: pointer; }
.start-options-panel .avatar-creator { margin-top: 8px; }
.start-options-panel .controls-grid { margin: 12px 0 8px; }
.start-options-panel .start-tip { margin-bottom: 8px; font-size: 12px; }
@media (max-width: 520px) {
  .start-menu-buttons { grid-template-columns: 1fr; }
  .start-menu-buttons #start-game { grid-column: auto; }
  .start-card.start-card-compact { max-height: calc(100dvh - 20px); overflow-y: auto; }
}

.vendor-dialog { position: absolute; inset: 0; z-index: 40; display: grid; place-items: center; padding: 14px; background: rgba(5, 12, 18, .78); }
.vendor-dialog[hidden] { display: none; }
.vendor-card { width: min(760px, 100%); max-height: min(88dvh, 820px); display: flex; flex-direction: column; overflow: hidden; border: 2px solid #667988; border-radius: 9px; background: #243442; box-shadow: 0 14px 44px rgba(0,0,0,.6); }
.vendor-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 14px; border-bottom: 1px solid #526779; background: #1a252f; }
.vendor-heading h2 { margin: 0; color: #ffd0a4; font-size: 18px; }
.vendor-content { min-height: 0; overflow-y: auto; padding: 14px; }
.vendor-content h3 { margin: 14px 0 7px; color: #ffe0ba; font-size: 14px; }
.vendor-content p, .vendor-content li { color: var(--text-dim); font-size: 12px; line-height: 1.45; }
.vendor-content ul { margin: 5px 0 12px; padding-left: 20px; }
.vendor-select { width: 100%; margin: 5px 0 10px; padding: 9px; border: 1px solid #667988; border-radius: 5px; background: #182630; color: var(--text); font: inherit; font-size: 12px; }
.vendor-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.vendor-item { padding: 9px; border: 1px solid #526779; border-radius: 6px; background: rgba(10,18,24,.3); }
.vendor-item strong { display: block; margin-bottom: 4px; color: #fff; font-size: 12px; }
.vendor-item p { margin: 3px 0 7px; }
.vendor-item button { width: 100%; min-height: 34px; border: 0; border-radius: 4px; background: var(--accent); color: #fff; font-weight: 700; cursor: pointer; }
.vendor-item button:disabled { opacity: .45; cursor: not-allowed; }
.vendor-note { padding: 8px; border-left: 3px solid var(--accent-bright); background: rgba(0,0,0,.16); }
@media (max-width: 560px) {
  .vendor-dialog { padding: 6px; }
  .vendor-card { max-height: 94dvh; }
  .vendor-list { grid-template-columns: 1fr; }
}
