/* ============================================================
   EMBERVALE — style.css
   Dark chrome, pixel-crisp canvas, phone-first safe-areas, ≥44px taps.
   DOM UI is fixed; only the canvas world moves.
   ============================================================ */

:root {
  --bar: #12161f;
  --bar2: #1a2130;
  --ink: #e7ecf3;
  --dim: #8b97a8;
  --ember: #ffb15a;
  --line: #2a3346;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #0c1017; }
body {
  font-family: ui-sans-serif, system-ui, -apple-system, sans-serif;
  color: var(--ink);
  user-select: none; -webkit-user-select: none; touch-action: none;
}
.mono { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; }
.dim { color: var(--dim); }

#scene { position: fixed; inset: 0; width: 100vw; height: 100vh; display: block; image-rendering: pixelated; image-rendering: crisp-edges; }

/* ---- top bar ---- */
#topbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 10;
  display: flex; align-items: center; gap: 10px; justify-content: space-between;
  padding: calc(6px + var(--safe-t)) calc(10px + var(--safe-r)) 6px calc(10px + var(--safe-l));
  background: linear-gradient(180deg, var(--bar) 85%, rgba(18,22,31,0.0));
  min-height: 46px; font-size: 13px;
}
.tb-left { display: flex; align-items: center; gap: 10px; min-width: 0; }
#townName { font-weight: 700; letter-spacing: 0.5px; color: var(--ember); white-space: nowrap; }
.clockwrap { display: flex; align-items: center; gap: 6px; }
#clock { font-size: 13px; }
#daystrip {
  position: relative; width: 90px; height: 6px; border-radius: 3px;
  background: linear-gradient(90deg,#1b2b4d 0%,#4a76b8 12%,#bfe0ef 30%,#ffd27a 60%,#e08a4a 72%,#2a2350 84%,#12161f 100%);
  border: 1px solid var(--line);
}
#daystripDot { position: absolute; top: -2px; width: 3px; height: 10px; background: #fff; border-radius: 2px; transform: translateX(-50%); box-shadow: 0 0 4px rgba(255,255,255,0.7); }
.tb-counters { display: flex; gap: 10px; font-size: 12px; }
.tb-counters span { display: inline-flex; align-items: center; gap: 3px; }
.tb-counters b { color: var(--ember); font-weight: 700; }
.tb-right { display: flex; gap: 4px; }
.tb-right button {
  min-height: 30px; padding: 4px 8px; font-size: 11px; font-weight: 700; letter-spacing: 0.5px;
  color: var(--ink); background: var(--bar2); border: 1px solid var(--line); border-radius: 6px; cursor: pointer;
}
.tb-right button:active { background: #26324a; }

@media (max-width: 620px) {
  .tb-counters { position: absolute; top: calc(46px + var(--safe-t)); right: 8px; background: rgba(18,22,31,0.8); padding: 4px 8px; border-radius: 8px; }
  #topbar { flex-wrap: wrap; }
}

/* ---- moments feed ---- */
#momentsWrap {
  position: fixed; left: calc(8px + var(--safe-l)); top: calc(58px + var(--safe-t)); z-index: 9;
  width: min(240px, 62vw);
}
.mhead { font-size: 10px; letter-spacing: 1.5px; color: var(--dim); margin-bottom: 6px; }
.moment {
  background: rgba(18,22,31,0.82); border: 1px solid var(--line); border-left: 3px solid var(--line);
  border-radius: 6px; padding: 6px 8px; margin-bottom: 5px; font-size: 11.5px; line-height: 1.35;
  animation: slidein 0.3s ease;
}
.moment.new { border-left-color: var(--ember); box-shadow: 0 0 0 1px rgba(255,177,90,0.25); }
.mstamp { display: block; font-family: ui-monospace, monospace; font-size: 9px; color: var(--dim); }
.mtext { color: var(--ink); }
@keyframes slidein { from { opacity: 0; transform: translateX(-8px); } to { opacity: 1; transform: none; } }

/* ---- tray (categories + item sub-tray) ---- */
#trayWrap {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 8px calc(10px + var(--safe-r)) calc(8px + var(--safe-b)) calc(10px + var(--safe-l));
  background: linear-gradient(0deg, var(--bar) 80%, rgba(18,22,31,0));
}
.trayrow { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; justify-content: center; max-width: 100%; }
#tray { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; justify-content: center; }
.catbtn {
  min-height: 44px; padding: 6px 14px; background: var(--bar2); color: var(--ink);
  border: 1px solid var(--line); border-radius: 10px; font-size: 13px; font-weight: 600; cursor: pointer;
  letter-spacing: 0.3px;
}
.catbtn.open { border-color: #6c7a94; background: #222a3a; }
.catbtn.on { border-color: var(--ember); color: var(--ember); background: #2a2130; box-shadow: 0 0 0 1px rgba(255,177,90,0.35); }
.removebtn { color: #d98b85; }
.removebtn.on { border-color: #e05a54; color: #ff8d86; background: #33201f; box-shadow: 0 0 0 1px rgba(230,90,84,0.35); }
.iremove {
  margin-top: 10px; width: 100%; min-height: 40px; background: #2c1c1c; color: #ff9a93;
  border: 1px solid #5a3230; border-radius: 10px; font-size: 12px; font-weight: 600; cursor: pointer;
  letter-spacing: 0.3px;
}
.iremove:active { background: #3a2422; }

.subtray {
  display: none; gap: 6px; align-items: stretch; max-width: 96vw; overflow-x: auto;
  padding: 6px; background: rgba(14,18,27,0.92); border: 1px solid var(--line); border-radius: 12px;
  -webkit-overflow-scrolling: touch; scrollbar-width: thin;
}
.subtray.show { display: flex; animation: slidein 0.18s ease; }
.itembtn {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  min-width: 72px; min-height: 44px; padding: 6px 10px; white-space: nowrap;
  background: var(--bar2); color: var(--ink); border: 1px solid var(--line); border-radius: 10px;
  font-size: 12.5px; font-weight: 600; cursor: pointer;
}
.itembtn .ihint { font-size: 9px; color: var(--dim); min-height: 10px; letter-spacing: 0.4px; }
.itembtn.locked { opacity: 0.5; }
.itembtn.locked .ihint { color: var(--ember); }
.itembtn:active { background: #26324a; }

#speeds { display: inline-flex; gap: 3px; }
.spbtn {
  min-width: 40px; min-height: 44px; padding: 4px 8px; background: var(--bar2); color: var(--ink);
  border: 1px solid var(--line); border-radius: 8px; font-size: 13px; font-weight: 700; cursor: pointer;
}
.spbtn.on { border-color: var(--ember); color: var(--ember); background: #221c17; }
.muteb { min-width: 44px; min-height: 44px; background: var(--bar2); border: 1px solid var(--line); border-radius: 10px; font-size: 16px; cursor: pointer; }

/* appeal stars in the inspect card */
.appeal .starz { color: var(--ember); letter-spacing: 1px; }

/* ---- inspect card ---- */
#inspect {
  position: fixed; top: calc(58px + var(--safe-t)); right: calc(8px + var(--safe-r)); z-index: 11;
  width: min(280px, 78vw); max-height: 66vh; overflow-y: auto;
  background: rgba(16,20,29,0.95); border: 1px solid var(--line); border-radius: 12px;
  padding: 12px; display: none; box-shadow: 0 8px 30px rgba(0,0,0,0.5);
}
#inspect.show { display: block; animation: slidein 0.2s ease; }
.ix { position: absolute; top: 8px; right: 8px; width: 26px; height: 26px; border-radius: 6px; background: var(--bar2); color: var(--dim); border: 1px solid var(--line); cursor: pointer; }
.ititle { font-weight: 700; font-size: 15px; color: var(--ember); margin-right: 28px; }
.ibadges { display: flex; gap: 5px; flex-wrap: wrap; margin: 8px 0; }
.badge { font-size: 10px; padding: 2px 7px; border: 1px solid var(--line); border-radius: 20px; color: var(--dim); }
.istat { font-size: 12px; color: var(--ink); margin-bottom: 8px; }
.growth { height: 8px; background: #0e1420; border: 1px solid var(--line); border-radius: 5px; overflow: hidden; }
.growthbar { height: 100%; background: linear-gradient(90deg,#7a5a34,var(--ember)); transition: width 0.4s; }
.gtext { font-size: 11px; color: var(--dim); margin: 5px 0 8px; }
.plist { display: flex; flex-direction: column; gap: 4px; }
.person { background: #0e1420; border: 1px solid var(--line); border-radius: 7px; padding: 6px 8px; font-size: 11.5px; display: flex; flex-direction: column; gap: 2px; }
.person b { color: var(--ink); }
.person span { color: var(--dim); }

/* ---- toast ---- */
#toast {
  position: fixed; left: 50%; bottom: calc(76px + var(--safe-b)); transform: translateX(-50%) translateY(10px);
  z-index: 20; background: rgba(16,20,29,0.95); border: 1px solid var(--line); color: var(--ink);
  padding: 8px 14px; border-radius: 10px; font-size: 12px; opacity: 0; pointer-events: none; transition: opacity 0.2s, transform 0.2s;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
