:root {
  --bg: #15161a;
  --panel: #1f2127;
  --panel-edge: #2e313a;
  --text: #eceef3;
  --muted: #9097a6;
  --accent: #ffb347;
  --money: #3ddc84;
  --locked: #6b7180;
  --room: #f4efe6;
  --grid: rgba(0, 0, 0, 0.05);
  --ink: #23201c;
  --bubble: #ffffff;
  --radius: 10px;
  --gap: 12px;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

.bar {
  display: flex;
  align-items: center;
  gap: var(--gap);
  padding: 10px 16px;
  border-bottom: 1px solid var(--panel-edge);
  flex-wrap: wrap;
}

.bar h1 { font-size: 18px; margin: 0 8px 0 0; }

.picker { display: flex; gap: 8px; align-items: center; }

select, input, button {
  font: inherit;
  color: var(--text);
  background: var(--panel);
  border: 1px solid var(--panel-edge);
  border-radius: 8px;
  padding: 6px 10px;
}

button { cursor: pointer; }
button:hover { border-color: var(--accent); }
button:focus-visible, select:focus-visible, input:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

.stats { display: flex; gap: 16px; align-items: center; margin-left: auto; }
.stat { display: flex; gap: 6px; align-items: center; font-size: 13px; color: var(--muted); }
meter { width: 110px; height: 12px; }
.money { font-weight: 800; font-size: 20px; color: var(--money); min-width: 80px; text-align: right; }
.muted { color: var(--muted); font-size: 13px; }

.layout {
  display: grid;
  grid-template-columns: 200px minmax(0, 1fr) 200px;
  gap: var(--gap);
  padding: var(--gap);
}

.toolbox, .shop {
  background: var(--panel);
  border: 1px solid var(--panel-edge);
  border-radius: var(--radius);
  padding: 10px;
  align-self: start;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

h2 { font-size: 12px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); margin: 6px 0 0; }

.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }

.item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 6px 4px;
  font-size: 12px;
  line-height: 1.2;
}
.item .icon { font-size: 20px; }
.item .price { color: var(--money); font-weight: 700; }
.item.locked { color: var(--locked); }
.item.locked .icon { filter: grayscale(1); opacity: 0.6; }
.item.affordable .price { color: var(--accent); }
.item[aria-pressed="true"] { border-color: var(--accent); background: #3a2f1d; }

.stage { display: flex; flex-direction: column; gap: 8px; min-width: 0; }

canvas {
  width: 100%;
  height: auto;
  aspect-ratio: 960 / 560;
  border-radius: var(--radius);
  border: 1px solid var(--panel-edge);
  touch-action: none;
  cursor: grab;
  display: block;
}

/* The 3D look draws into a WebGL canvas under #room; #room stays on top for
   the pointer and the text overlay. */
.room-wrap { position: relative; }
.room-wrap #room { position: relative; z-index: 1; }
.room-wrap .room-3d {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  aspect-ratio: auto;
  pointer-events: none;
}

.chat { display: flex; gap: 8px; }
.chat input { flex: 1; }
.hint { margin: 0; min-height: 1.2em; }

.check { display: flex; gap: 6px; align-items: center; font-size: 13px; }
.check input { padding: 0; }

/* On a phone the 3D camera follows the buddy in a square stage, so it is
   big enough to see and to tap (user test 2026-11-23, finding 2). */
@media (max-width: 600px) {
  .look-3d #room { aspect-ratio: 1 / 1; }
}

@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .stage { order: -1; }
  .grid { grid-template-columns: repeat(4, 1fr); }
}

[hidden] { display: none !important; }

.back { color: var(--muted); text-decoration: none; font-size: 13px; }
.back:hover { color: var(--accent); }

/* Phones: keep the money in view (user test 2026-11-23, finding 1). */
@media (max-width: 600px) {
  .stats { margin-left: 0; width: 100%; gap: 10px; }
  meter { width: 72px; }
  .money { margin-left: auto; min-width: 0; font-size: 18px; }
}
