/* THE HANG — cozy idle den. pastels over dusk. */
* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; overflow: hidden; overscroll-behavior: none; }
body {
  background: #332A40;
  color: #4A3B54;
  font-family: "Quicksand", system-ui, sans-serif;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
}
button { font-family: inherit; cursor: pointer; }

#room { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }

/* ---------- HUD ---------- */
#hud {
  position: fixed; top: max(10px, env(safe-area-inset-top)); left: 0; right: 0;
  display: flex; justify-content: space-between; align-items: flex-start;
  padding: 0 12px; pointer-events: none; z-index: 20;
}
#vibePill {
  display: flex; align-items: center; gap: 9px;
  background: rgba(255,246,236,0.96); border: 2.5px solid #4A3B54; border-radius: 18px;
  padding: 7px 15px 7px 10px; pointer-events: auto;
  box-shadow: 0 3px 0 rgba(74,59,84,0.25);
}
#vibePill .blob { width: 26px; height: 26px; position: relative; flex: none; }
#vibePill .blob::before {
  content: ""; position: absolute; inset: 2px; border-radius: 50%;
  background: radial-gradient(circle at 38% 35%, #FFF1D6 0%, #FFC66B 55%, #f7ab45 100%);
  box-shadow: 0 0 10px 2px rgba(255,198,107,0.55);
}
#vibePill .blob i { position: absolute; top: 4px; right: 3px; width: 6px; height: 6px; border-radius: 50%; background: #FFF1D6; }
#vibePill .blob { animation: blobBreathe 3.2s ease-in-out infinite; }
@keyframes blobBreathe { 0%,100% { transform: scale(1); } 50% { transform: scale(1.09); } }
#vibePill .counts { display: flex; flex-direction: column; line-height: 1.05; }
#vibeCount {
  font-family: "Baloo 2", sans-serif; font-weight: 800; font-size: 22px;
  font-variant-numeric: tabular-nums; color: #4A3B54; transition: transform .12s ease;
}
#vibeCount.pulse { transform: scale(1.12); }
#vibeCount .suf { font-size: 70%; opacity: .8; }
#vibeRate { font-style: normal; font-weight: 600; font-size: 11px; opacity: .6; font-variant-numeric: tabular-nums; }
#chips { display: flex; gap: 8px; pointer-events: auto; }
.chip-btn {
  width: 44px; height: 44px; border-radius: 14px;
  background: rgba(255,246,236,0.96); border: 2.5px solid #4A3B54; color: #4A3B54;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 3px 0 rgba(74,59,84,0.25); font-size: 16px; font-weight: 700;
}
.chip-btn:active { transform: translateY(2px); box-shadow: 0 1px 0 rgba(74,59,84,0.25); }

/* ---------- toasts ---------- */
#toasts {
  position: fixed; top: calc(max(10px, env(safe-area-inset-top)) + 56px); left: 50%;
  transform: translateX(-50%); z-index: 30; display: flex; flex-direction: column;
  gap: 8px; align-items: center; pointer-events: none; width: max-content; max-width: 92vw;
}
.toast {
  background: #FFF6EC; border: 2.5px solid #4A3B54; border-radius: 14px;
  padding: 9px 16px; font-weight: 600; font-size: 14px; color: #4A3B54;
  box-shadow: 0 4px 0 rgba(74,59,84,0.25); text-align: center;
  opacity: 0; transform: translateY(-8px) rotate(-1deg); transition: opacity .25s, transform .25s;
  max-width: 92vw;
}
.toast.show { opacity: 1; transform: translateY(0) rotate(-1deg); }
.toast b { font-family: "Baloo 2", sans-serif; }
.toast.card { padding: 12px 20px; font-size: 15px; border-radius: 16px; }
.toast .fl { display: block; font-size: 12.5px; opacity: .7; font-weight: 500; }

/* ---------- intro ---------- */
#intro {
  position: fixed; inset: 0; z-index: 15; pointer-events: none;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 10px; padding: 24px; text-align: center;
  transition: opacity .8s ease;
}
#intro.gone { opacity: 0; }
#intro p {
  color: #FFF6EC; font-weight: 500; font-size: 18px; letter-spacing: .02em;
  text-shadow: 0 2px 12px rgba(51,42,64,.8); min-height: 1.4em;
}
#intro #introLine2 { font-weight: 700; }
#introFoot {
  position: absolute; bottom: max(14px, env(safe-area-inset-bottom)); left: 0; right: 0;
  font-size: 12px; color: rgba(255,246,236,.65); pointer-events: auto;
}
#introFoot a { color: rgba(255,246,236,.9); font-weight: 700; text-decoration: none; border-bottom: 1px solid rgba(255,246,236,.4); }

/* ---------- drawer / the shelf ---------- */
#drawer {
  position: fixed; left: 50%; bottom: 0; transform: translate(-50%, 0);
  width: min(560px, 100vw); z-index: 25;
  transition: transform .32s cubic-bezier(.3,1.4,.5,1);
  will-change: transform;
}
#drawer.closed { transform: translate(-50%, calc(100% - 56px - env(safe-area-inset-bottom, 0px))); }
#drawerHandle {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  width: 100%; height: calc(56px + env(safe-area-inset-bottom, 0px)); border: none;
  padding-bottom: env(safe-area-inset-bottom, 0px); /* handle content clears the home indicator */
  background: #B98A5E; border-radius: 18px 18px 0 0;
  border-top: 3px solid #4A3B54; border-left: 3px solid #4A3B54; border-right: 3px solid #4A3B54;
  box-shadow: inset 0 4px 0 rgba(255,246,236,.22);
  color: #FFF6EC; font-weight: 700; font-size: 13px;
}
#drawerHandle.sparkle { animation: handleGlow 1.6s ease-in-out infinite; }
@keyframes handleGlow {
  0%,100% { box-shadow: inset 0 4px 0 rgba(255,246,236,.22), 0 0 0 rgba(255,217,143,0); }
  50% { box-shadow: inset 0 4px 0 rgba(255,246,236,.22), 0 0 22px 4px rgba(255,217,143,.65); }
}
#drawerHandle .string { display: flex; gap: 7px; align-items: center; }
#drawerHandle .string i { width: 9px; height: 9px; border-radius: 50%; display: block; animation: dotPulse 2.4s ease-in-out infinite; }
#drawerHandle .d1 { background: #FFE8A3; } #drawerHandle .d2 { background: #A8E6CF; animation-delay: .3s; }
#drawerHandle .d3 { background: #E8A0AC; animation-delay: .6s; } #drawerHandle .d4 { background: #C9AEE8; animation-delay: .9s; }
#drawerHandle .d5 { background: #FFC4A8; animation-delay: 1.2s; }
@keyframes dotPulse { 0%,100% { transform: scale(1); opacity: .75; } 50% { transform: scale(1.35); opacity: 1; } }
#nextHint { font-variant-numeric: tabular-nums; }
#drawerBody {
  background: #FFF6EC; border-left: 3px solid #4A3B54; border-right: 3px solid #4A3B54;
  height: 56vh; max-height: 480px; display: flex; flex-direction: column;
  padding-bottom: env(safe-area-inset-bottom, 0px); /* shop list clears the home indicator */
}
#tabs { display: flex; gap: 6px; padding: 10px 10px 6px; }
.tab {
  flex: 1; border: 2.5px solid #4A3B54; border-radius: 13px; background: #F4E7DA;
  font-family: "Baloo 2", sans-serif; font-weight: 700; font-size: 13px; color: #4A3B54;
  padding: 2px; min-height: 44px; opacity: .6;
}
.tab.on { background: #FFD98F; opacity: 1; }
#shopList { flex: 1; overflow-y: auto; padding: 6px 10px 18px; -webkit-overflow-scrolling: touch; }
.card {
  display: flex; align-items: center; gap: 11px;
  background: rgba(255,246,236,.96); border: 2.5px solid #4A3B54; border-radius: 18px;
  padding: 9px 11px; margin-bottom: 9px; transition: background .2s, border-color .2s;
}
.card .icon { width: 46px; height: 46px; flex: none; }
.card .icon svg, .card .icon canvas { width: 100%; height: 100%; display: block; }
.card .mid { flex: 1; min-width: 0; }
.card .nm { font-family: "Baloo 2", sans-serif; font-weight: 700; font-size: 15.5px; line-height: 1.1; }
.card .nm .lv { font-size: 12px; opacity: .6; font-weight: 600; margin-left: 5px; }
.card .fl { font-size: 12px; opacity: .68; font-weight: 500; line-height: 1.25; }
.card .eff { font-size: 11.5px; font-weight: 700; color: #6FBFA0; }
.card .buy {
  flex: none; border: 2.5px solid #4A3B54; border-radius: 14px;
  background: #F4E7DA; color: #B9A8C9; font-family: "Baloo 2", sans-serif; font-weight: 800;
  font-size: 14px; padding: 8px 12px; min-width: 76px; text-align: center;
  font-variant-numeric: tabular-nums; line-height: 1.1;
}
.card .buy .eta { display: block; font-size: 10px; font-weight: 700; opacity: .8; }
.card .buy { transition: transform .08s ease; }
.card .buy:active { transform: scale(0.93); }
.card.ok { background: #DFF5EC; border-color: #6FBFA0; animation: breathe 1.6s ease-in-out infinite; }
.card.ok .buy { background: #A8E6CF; color: #4A3B54; }
.card.near { box-shadow: 0 0 14px rgba(255,217,143,.55); }
.card.dim { opacity: .55; }
.card.flash { background: #FFD98F !important; }
@keyframes breathe { 0%,100% { transform: scale(1); } 50% { transform: scale(1.013); } }
.shop-note { text-align: center; font-size: 12.5px; opacity: .6; font-weight: 600; padding: 10px 0 4px; }

/* ---------- overlays / panels ---------- */
.overlay {
  position: fixed; inset: 0; z-index: 40; background: rgba(51,42,64,.72);
  display: flex; align-items: center; justify-content: center; padding: 18px;
}
.overlay[hidden] { display: none; }
.panel {
  background: #FFF6EC; border: 3px solid #4A3B54; border-radius: 22px;
  width: min(440px, 94vw); max-height: 82vh; display: flex; flex-direction: column;
  padding: 16px; box-shadow: 0 8px 0 rgba(20,16,33,.35);
}
.panel-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.panel h2 { font-family: "Baloo 2", sans-serif; font-weight: 800; font-size: 22px; }
#panelBody { overflow-y: auto; -webkit-overflow-scrolling: touch; }
.ach-row { display: flex; gap: 10px; align-items: center; padding: 7px 4px; border-bottom: 2px dashed rgba(74,59,84,.15); }
.ach-row .dot { width: 30px; height: 30px; flex: none; border-radius: 50%; background: #F4E7DA; border: 2.5px solid #4A3B54; display:flex; align-items:center; justify-content:center; font-size: 14px; }
.ach-row.got .dot { background: #FFD98F; }
.ach-row .t { font-weight: 700; font-size: 14px; }
.ach-row .d { font-size: 12px; opacity: .65; font-weight: 500; }
.ach-row:not(.got) { opacity: .5; }
.set-row { display: flex; flex-direction: column; gap: 10px; }
.set-row .big-btn { width: 100%; }
.stats-box { font-size: 13.5px; font-weight: 600; line-height: 1.7; background: #F4E7DA; border-radius: 14px; padding: 10px 14px; margin: 4px 0 8px; }
.stats-box b { font-family: "Baloo 2", sans-serif; }
.stats-box .nw { white-space: nowrap; }
.fine { font-size: 11.5px; opacity: .6; font-weight: 500; text-align: center; margin-top: 8px; }
.fine a { color: inherit; font-weight: 700; }

.big-btn {
  font-family: "Baloo 2", sans-serif; font-weight: 800; font-size: 17px;
  background: #FFD98F; color: #4A3B54; border: 3px solid #4A3B54; border-radius: 16px;
  padding: 12px 22px; box-shadow: 0 4px 0 rgba(74,59,84,.3);
}
.big-btn:active { transform: translateY(3px); box-shadow: 0 1px 0 rgba(74,59,84,.3); }
.big-btn.ghost { background: #F4E7DA; }
.big-btn.danger { background: #E8907E; }

/* ---------- offline polaroid ---------- */
.polaroid {
  background: #FFF6EC; border: 3px solid #4A3B54; border-radius: 14px;
  padding: 14px 14px 18px; width: min(360px, 92vw); text-align: center;
  transform: rotate(-2deg); box-shadow: 0 10px 0 rgba(20,16,33,.35);
}
.pol-pic {
  height: 150px; border-radius: 8px; border: 2.5px solid #4A3B54;
  background: linear-gradient(180deg, #8D7BB8, #D89BC0 55%, #FFC9A3);
  display: flex; align-items: flex-end; justify-content: center; overflow: hidden;
}
.pol-pic canvas { width: 100%; height: 100%; }
.pol-line { margin-top: 12px; font-weight: 600; font-size: 15px; }
.pol-amount { font-family: "Baloo 2", sans-serif; font-weight: 800; font-size: 30px; color: #d99a2b; margin: 2px 0; font-variant-numeric: tabular-nums; }
.pol-sub { font-size: 12px; opacity: .6; font-weight: 600; margin-bottom: 12px; }

.move-panel { text-align: center; }
.move-line { font-weight: 600; margin: 8px 0 12px; }
#moveDetail { font-size: 13px; font-weight: 600; background: #F4E7DA; border-radius: 14px; padding: 10px; margin-bottom: 14px; text-align: left; line-height: 1.6; }
#moveDetail b { color: #d99a2b; font-family: "Baloo 2", sans-serif; }
.move-btns { display: flex; gap: 10px; justify-content: center; }

/* ---------- game night: room UI steps back from the CRT ---------- */
body.in-game #hud, body.in-game #drawer {
  opacity: 0; visibility: hidden;
  transition: opacity .35s ease, visibility 0s linear .35s;
}
body.in-game #hud *, body.in-game #drawer * { pointer-events: none !important; }

/* ---------- reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  #drawerHandle .string i, .card.ok, #drawerHandle.sparkle, #vibePill .blob { animation: none; }
  #drawer, .toast, #intro { transition-duration: .01s; }
}
