/* Blockville — toy-block UI. Every colour, size and radius is a token here, named for its job. */
:root {
  --ink: #3b2f24;          /* text, outlines */
  --ink-soft: #7a6a58;     /* secondary text */
  --paper: #fff8ea;        /* panels: painted wood */
  --paper-edge: #e3cfa6;   /* the block's darker bottom edge */
  --gold: #ffc531;         /* coins, the selected tool, the main button */
  --gold-edge: #d29512;
  --leaf: #6fbf3b;         /* progress, good */
  --leaf-edge: #4f9324;
  --tomato: #ef5a3c;       /* needs, alerts, can't afford */
  --tomato-edge: #b93c24;
  --sky-top: #cdebff; --sky-bottom: #8fd0f2;
  --r-block: 14px; --r-pill: 999px;
  --edge: 0 4px 0;         /* the block-edge offset */
  --shade: 0 8px 18px rgba(40, 30, 10, .18);
  --tap: 48px;             /* smallest tap target */
  --gut: 10px;
  --font: 'Lilita One', 'Arial Rounded MT Bold', system-ui, sans-serif;
  --safe-t: env(safe-area-inset-top, 0px); --safe-b: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; overscroll-behavior: none; background: var(--sky-bottom);
  font-family: var(--font); color: var(--ink); -webkit-user-select: none; user-select: none; touch-action: none; }
button { font-family: inherit; color: inherit; border: 0; background: none; padding: 0; cursor: pointer; touch-action: manipulation; }
svg { display: block; }

#sky { position: fixed; inset: 0; background: linear-gradient(var(--sky-top), var(--sky-bottom)); }
#stars { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; }
#c { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }

/* ---------- block 1: status (top) ---------- */
#hud { position: fixed; top: calc(var(--safe-t) + var(--gut)); left: var(--gut); right: var(--gut); display: flex; gap: 6px; align-items: center; z-index: 5; pointer-events: none; }
#hud > * { pointer-events: auto; }
.pill { display: flex; align-items: center; gap: 5px; height: 40px; padding: 0 11px 0 6px; background: var(--paper); border-radius: var(--r-pill);
  box-shadow: var(--edge) var(--paper-edge), var(--shade); font-size: 20px; line-height: 1; white-space: nowrap; }
.pill .ico { width: 28px; height: 28px; flex: none; }
.pill small { font-size: 13px; color: var(--leaf-edge); margin-left: -1px; }
#coinPill { min-width: 0; }
#coinPill.shake { animation: shake .35s; }
#coinPill.bump b, #popPill.bump b { animation: bump .4s; display: inline-block; }
.time { margin-left: auto; display: flex; background: var(--paper); border-radius: var(--r-pill); box-shadow: var(--edge) var(--paper-edge), var(--shade); padding: 3px; }
.time button { width: 38px; height: 34px; border-radius: var(--r-pill); display: grid; place-items: center; color: var(--ink-soft); }
.time button svg { width: 20px; height: 20px; fill: currentColor; }
.time button.on { background: var(--gold); color: var(--ink); box-shadow: inset 0 -3px 0 var(--gold-edge); }

#sub { position: fixed; top: calc(var(--safe-t) + var(--gut) + 50px); left: var(--gut); right: var(--gut); display: flex; gap: 6px; align-items: center; z-index: 5; pointer-events: none; }
#sub > * { pointer-events: auto; }
#tier { display: flex; align-items: center; gap: 7px; height: 30px; padding: 0 10px; background: rgba(255, 248, 234, .9); border-radius: var(--r-pill); font-size: 15px; box-shadow: 0 3px 0 var(--paper-edge); }
#tier i { display: block; width: 54px; height: 9px; border-radius: 9px; background: #eadfc6; overflow: hidden; }
#tier em { display: block; height: 100%; width: 0; background: var(--leaf); border-radius: 9px; transition: width .6s; }
#day { display: flex; align-items: center; gap: 4px; height: 30px; padding: 0 10px 0 6px; background: rgba(255, 248, 234, .9); border-radius: var(--r-pill); font-size: 15px; box-shadow: 0 3px 0 var(--paper-edge); }
#day svg { width: 20px; height: 20px; }
#menuBtn { margin-left: auto; width: 40px; height: 34px; border-radius: 12px; background: rgba(255, 248, 234, .9); box-shadow: 0 3px 0 var(--paper-edge); display: grid; place-items: center; }
#menuBtn svg { width: 20px; height: 20px; }

/* ---------- block 3: action (bottom) ---------- */
#bar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 6; display: flex; gap: 8px; overflow-x: auto; overflow-y: hidden;
  padding: 10px var(--gut) calc(var(--safe-b) + 12px); background: linear-gradient(rgba(255, 248, 234, 0), rgba(255, 248, 234, .0) 0), var(--paper);
  border-top: 3px solid var(--paper-edge); border-radius: 22px 22px 0 0; box-shadow: 0 -6px 20px rgba(40, 30, 10, .16);
  scrollbar-width: none; touch-action: pan-x; scroll-snap-type: x proximity; }
#bar::-webkit-scrollbar { display: none; }
.tool { flex: none; width: 70px; height: 92px; border-radius: var(--r-block); background: #fff; box-shadow: var(--edge) var(--paper-edge);
  display: flex; flex-direction: column; align-items: center; padding-top: 3px; position: relative; scroll-snap-align: start; transition: transform .15s; }
.tool img { width: 56px; height: 56px; pointer-events: none; }
.tool .nm { font-size: 13px; line-height: 1; margin-top: 1px; white-space: nowrap; }
.tool .cost { display: flex; align-items: center; gap: 2px; font-size: 12px; color: var(--ink-soft); margin-top: 3px; }
.tool .cost::before { content: ''; width: 10px; height: 10px; border-radius: 50%; background: var(--gold); box-shadow: inset 0 0 0 1.5px var(--gold-edge); }
.tool.poor .cost { color: var(--tomato); }
.tool.sel { background: var(--gold); box-shadow: var(--edge) var(--gold-edge); transform: translateY(-6px); }
.tool.sel .cost { color: var(--ink); }
.tool.locked { background: #efe7d6; box-shadow: var(--edge) #d9ccb0; }
.tool.locked img { filter: grayscale(1) brightness(1.15) opacity(.45); }
.tool.locked .cost { color: var(--ink-soft); }
.tool.locked .cost::before { width: 11px; height: 11px; border-radius: 0; background: none; box-shadow: none;
  content: '🔒'; font-size: 10px; line-height: 11px; }
.tool.new::after { content: 'NEW'; position: absolute; top: -6px; right: -4px; background: var(--tomato); color: #fff; font-size: 10px; padding: 2px 5px; border-radius: 8px; box-shadow: 0 2px 0 var(--tomato-edge); }
.tool.hint { animation: hint 1.1s infinite; }
.tool.bulldoze img, .tool.look img { width: 40px; height: 40px; margin: 8px 0; }
.tool.bulldoze.sel { background: #ffb340; }
.sep { flex: none; width: 2px; margin: 10px 2px 18px; background: var(--paper-edge); border-radius: 2px; }

#side { position: fixed; right: var(--gut); bottom: calc(var(--safe-b) + 128px); display: flex; flex-direction: column; gap: 10px; z-index: 5; }
#side button { width: var(--tap); height: 52px; border-radius: var(--r-block); background: var(--paper); box-shadow: var(--edge) var(--paper-edge), var(--shade); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; }
#side button svg { width: 22px; height: 22px; }
#side button span { font-size: 11px; color: var(--ink-soft); }
#side button:disabled { opacity: .45; }

/* the guide sits with the action it asks for */
#guide { position: fixed; left: var(--gut); right: 72px; bottom: calc(var(--safe-b) + 126px); display: flex; align-items: flex-end; gap: 4px; z-index: 5; pointer-events: none; }
#bo { width: 56px; height: 56px; flex: none; pointer-events: auto; animation: bob 2.4s ease-in-out infinite; filter: drop-shadow(0 4px 4px rgba(40, 30, 10, .25)); }
#say { pointer-events: auto; position: relative; display: flex; align-items: center; gap: 8px; min-height: 52px; padding: 6px 14px 6px 8px; margin-bottom: 6px;
  background: var(--paper); border-radius: 16px; box-shadow: var(--edge) var(--paper-edge), var(--shade); font-size: 19px; text-align: left; max-width: 100%; }
#say::before { content: ''; position: absolute; left: -7px; bottom: 12px; border: 7px solid transparent; border-right-color: var(--paper); border-left: 0; }
#say img { width: 40px; height: 40px; flex: none; }
#say img[src=""], #say img:not([src]) { display: none; }
#sayN { font-size: 15px; color: var(--leaf-edge); white-space: nowrap; }
#say.cheer { animation: cheer .6s; }
#say.alert { background: #ffe4dc; }
#say.alert::before { border-right-color: #ffe4dc; }

/* ---------- in-world: bubbles above homes, floating numbers ---------- */
#bubbles, #floats { position: fixed; inset: 0; pointer-events: none; z-index: 3; }
.bub { position: absolute; left: 0; top: 0; pointer-events: auto; transform-origin: 50% 100%; display: flex; align-items: center; gap: 4px;
  padding: 5px 10px 5px 6px; min-height: 36px; background: #fff; border-radius: 14px; font-size: 14px; white-space: nowrap;
  box-shadow: 0 3px 0 #e2d6bd, 0 4px 10px rgba(40, 30, 10, .2); animation: pop .3s; }
.bub::after { content: ''; position: absolute; left: 50%; bottom: -7px; margin-left: -7px; border: 7px solid transparent; border-top-color: #fff; border-bottom: 0; }
.bub .e { font-size: 18px; line-height: 1; }
.bub.hard { background: #fff0ec; color: #8a2a17; }
.bub.hard::after { border-top-color: #fff0ec; }
.bub.fire { background: var(--tomato); color: #fff; font-size: 16px; animation: pop .3s, pulse 0.8s infinite; box-shadow: 0 3px 0 var(--tomato-edge); }
.bub.fire::after { border-top-color: var(--tomato); }
.fl { position: absolute; left: 0; top: 0; font-size: 18px; color: #fff; -webkit-text-stroke: 4px var(--ink); paint-order: stroke fill; white-space: nowrap; animation: rise 1.3s ease-out forwards; }
.fl.gold { color: var(--gold); }
.fl.red { color: #ff8c7a; }
.fl.green { color: #a8f07a; }

/* ---------- sheet (fix card, celebrations, menu) ---------- */
#sheet { position: fixed; inset: 0; z-index: 20; display: flex; align-items: flex-end; justify-content: center; background: rgba(30, 40, 60, .35); padding: 0 var(--gut) calc(var(--safe-b) + 14px); }
#sheet.hidden { display: none; }
#sheet .card { width: 100%; max-width: 420px; background: var(--paper); border-radius: 24px; box-shadow: 0 6px 0 var(--paper-edge), var(--shade); padding: 20px 18px 16px; text-align: center; animation: up .3s; }
#sheetBody h2 { margin: 0; font-size: 34px; font-weight: 400; line-height: 1.05; }
#sheetBody .big { font-size: 64px; line-height: 1.1; }
#sheetBody img { width: 110px; height: 110px; }
#sheetBody .row { display: flex; justify-content: center; gap: 10px; flex-wrap: wrap; margin-top: 8px; }
#sheetBody .row div { width: 74px; font-size: 13px; }
#sheetBody .row img { width: 64px; height: 64px; }
#sheetBody .sub { font-size: 18px; color: var(--ink-soft); margin-top: 4px; }
#sheet .acts { display: flex; gap: 10px; margin-top: 16px; }
#sheet .acts button { flex: 1; height: 56px; border-radius: 16px; font-size: 22px; }
#sheet .acts button.hidden { display: none; }
.go { background: var(--gold); box-shadow: var(--edge) var(--gold-edge); }
.go.green { background: var(--leaf); color: #fff; box-shadow: var(--edge) var(--leaf-edge); }
.go.red { background: var(--tomato); color: #fff; box-shadow: var(--edge) var(--tomato-edge); }
.quiet { background: #efe5d0; color: var(--ink-soft); box-shadow: 0 4px 0 #dccfb3; flex: 0 0 34% !important; }
#confetti { position: fixed; inset: 0; pointer-events: none; z-index: 30; overflow: hidden; }
#confetti i { position: absolute; top: -20px; width: 10px; height: 14px; border-radius: 2px; animation: fall linear forwards; }

@keyframes pop { from { transform: var(--t, none) scale(.2); opacity: 0; } }
@keyframes up { from { transform: translateY(40px); opacity: 0; } }
@keyframes bob { 50% { transform: translateY(-5px) rotate(-3deg); } }
@keyframes rise { 0% { opacity: 0; translate: 0 6px; } 15% { opacity: 1; } 100% { opacity: 0; translate: 0 -46px; } }
@keyframes shake { 25% { translate: -6px 0; } 50% { translate: 6px 0; } 75% { translate: -4px 0; } }
@keyframes bump { 40% { transform: scale(1.35); } }
@keyframes cheer { 30% { transform: scale(1.08) rotate(-2deg); } 60% { transform: scale(.98); } }
@keyframes hint { 50% { transform: translateY(-8px); box-shadow: 0 4px 0 var(--gold-edge), 0 0 0 4px var(--gold); } }
@keyframes pulse { 50% { filter: brightness(1.2); } }
@keyframes fall { to { transform: translate(var(--dx), 110vh) rotate(var(--rot)); } }

@media (min-width: 700px) {
  #bar { left: 50%; right: auto; transform: translateX(-50%); max-width: 760px; width: calc(100% - 40px); border-radius: 22px 22px 0 0; }
  #guide { left: max(var(--gut), calc(50% - 380px)); right: auto; }
}
@media (max-width: 370px) {
  .pill { font-size: 17px; padding-right: 8px; }
  .pill .ico { width: 24px; height: 24px; }
  .time button { width: 32px; }
}
