:root {
  --paper: #f4efe4;
  --paper-2: #e7dcc8;
  --ink: #1c2430;
  --muted: #5c6573;
  --line: #d9cbb6;
  --orange: #e06a2c;
  --orange-2: #c4551e;
  --green: #2f6f4e;
  --heat: #c44536;
  --clout: #5b4b8a;
  --grades: #2c6e8a;
  --shadow: 0 16px 40px rgba(40, 32, 24, 0.16);
  font-family: "Avenir Next", "Segoe UI", "Trebuchet MS", sans-serif;
  color: var(--ink);
}

* { box-sizing: border-box; }
html, body, #app { margin: 0; height: 100%; }
body { background: #c5d4bc; overflow: hidden; }
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
#view { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }

#ui { position: absolute; inset: 0; pointer-events: none; }
#ui button, #ui a, #ui input, #ui textarea, #ui .panel, #ui .screen, #ui .modal, #phone, #dialogue, #prompt { pointer-events: auto; }

#version {
  position: absolute;
  left: 14px;
  bottom: 12px;
  z-index: 30;
  font-size: 12px;
  letter-spacing: 0.04em;
  color: var(--ink);
  background: rgba(244, 239, 228, 0.88);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 10px;
  pointer-events: none;
}

#fb-btn, #mute-btn, #phone-btn {
  position: absolute;
  z-index: 40;
  border: 1px solid var(--ink);
  background: var(--paper);
  border-radius: 999px;
  padding: 8px 14px;
  box-shadow: 0 4px 0 rgba(28, 36, 48, 0.12);
}
#fb-btn { right: 14px; bottom: 12px; background: var(--orange); color: white; border-color: var(--orange-2); font-weight: 700; }
#mute-btn { left: 14px; bottom: 46px; font-size: 13px; }
#phone-btn { right: 14px; top: 14px; font-weight: 700; }
#phone-btn .dot {
  display: inline-block;
  min-width: 18px;
  margin-left: 6px;
  background: var(--heat);
  color: white;
  border-radius: 999px;
  font-size: 11px;
  padding: 0 5px;
}

.screen {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 28px 18px 72px;
  background:
    linear-gradient(180deg, rgba(244, 239, 228, 0.94), rgba(244, 239, 228, 0.9)),
    repeating-linear-gradient(0deg, transparent, transparent 27px, rgba(196, 90, 70, 0.08) 28px);
}
.screen[hidden], .modal[hidden], #hud[hidden], #dialogue[hidden], #phone[hidden], #prompt[hidden] { display: none !important; }

.sheet {
  width: min(880px, 100%);
  background: var(--paper);
  border: 1px solid var(--ink);
  border-radius: 18px;
  box-shadow: var(--shadow);
  padding: 28px 28px 22px;
  position: relative;
}
.sheet:before {
  content: "";
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 14px;
  background: var(--orange);
  border-radius: 18px 0 0 18px;
}
.kicker { letter-spacing: 0.16em; text-transform: uppercase; font-size: 12px; color: var(--muted); margin: 0 0 8px; }
h1 { font-size: clamp(40px, 7vw, 72px); line-height: 0.9; margin: 0 0 8px; letter-spacing: -0.04em; }
.deck { font-size: 18px; margin: 0 0 14px; }
.prose { max-width: 62ch; line-height: 1.45; color: var(--ink); }
.prose p { margin: 0 0 10px; }
.row { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 16px; }
.btn {
  border: 1px solid var(--ink);
  background: var(--ink);
  color: var(--paper);
  border-radius: 999px;
  padding: 10px 16px;
  font-weight: 700;
}
.btn.ghost { background: transparent; color: var(--ink); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.keys { display: flex; flex-wrap: wrap; gap: 8px 14px; margin-top: 18px; color: var(--muted); font-size: 13px; }
.keys b { color: var(--ink); font-weight: 700; }

.cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-top: 12px; }
.kid {
  text-align: left;
  border: 1px solid var(--line);
  background: white;
  border-radius: 14px;
  padding: 12px;
}
.kid:hover { border-color: var(--ink); }
.who { display: flex; gap: 10px; align-items: center; margin-bottom: 8px; }
.avatar { width: 46px; height: 54px; position: relative; flex: none; }
.avatar i { position: absolute; display: block; }
.avatar .hair { width: 28px; height: 16px; border-radius: 12px 12px 4px 4px; left: 9px; top: 0; }
.avatar .head { width: 22px; height: 22px; border-radius: 50%; left: 12px; top: 10px; }
.avatar .body { width: 30px; height: 22px; border-radius: 8px; left: 8px; top: 30px; }
.kid h2 { font-size: 18px; margin: 0; }
.kid .past { color: var(--green); font-size: 13px; margin: 2px 0 8px; }
.kid p { margin: 0 0 8px; font-size: 14px; line-height: 1.35; }
.later-note { color: var(--muted); font-size: 13px; margin-top: 12px; }

#hud {
  position: absolute;
  left: 12px;
  right: 12px;
  top: 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  pointer-events: none;
  max-width: 920px;
}
.chiprow { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  background: rgba(244, 239, 228, 0.94);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 13px;
  display: flex;
  gap: 8px;
  align-items: center;
}
.chip b { font-weight: 750; }
.meter { width: 64px; height: 8px; background: #e4d9c8; border-radius: 99px; overflow: hidden; }
.meter span { display: block; height: 100%; background: var(--green); }
.chip.heat .meter span { background: var(--heat); }
.chip.clout .meter span { background: var(--clout); }
.chip.grades .meter span { background: var(--grades); }
.chip.energy .meter span { background: #c48a2a; }
#questline {
  align-self: flex-start;
  background: rgba(28, 36, 48, 0.9);
  color: white;
  border-radius: 12px;
  padding: 8px 12px;
  font-size: 14px;
  max-width: min(640px, 100%);
}
#questline small { display: block; opacity: 0.7; font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; }

#prompt {
  position: absolute;
  left: 50%;
  bottom: 22px;
  transform: translateX(-50%);
  background: var(--ink);
  color: white;
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 14px;
  z-index: 5;
}
#prompt kbd { background: white; color: var(--ink); border-radius: 4px; padding: 0 5px; font-family: inherit; }

#dialogue {
  position: absolute;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  width: min(720px, calc(100% - 24px));
  background: var(--paper);
  border: 1px solid var(--ink);
  border-radius: 16px;
  padding: 14px 14px 12px;
  box-shadow: var(--shadow);
  z-index: 6;
}
#dialogue .who { margin-bottom: 6px; }
#dialogue .speaker { font-weight: 800; }
#dialogue .role { color: var(--muted); font-size: 12px; }
#dialogue p { margin: 0 0 10px; line-height: 1.4; }
.choices { display: flex; flex-direction: column; gap: 6px; }
.choices button {
  text-align: left;
  background: white;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 10px;
}
.choices button:hover:not(:disabled) { border-color: var(--ink); }
.choices button small { display: block; color: var(--muted); }

#phone {
  position: absolute;
  top: 64px;
  right: 14px;
  bottom: 64px;
  width: min(390px, calc(100% - 28px));
  background: #1c2430;
  color: var(--paper);
  border-radius: 28px;
  padding: 14px 12px 12px;
  box-shadow: var(--shadow);
  z-index: 7;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
#phone header { display: flex; justify-content: space-between; align-items: center; padding: 0 6px; }
#phone header b { font-size: 16px; }
#phone .tabs { display: flex; gap: 4px; flex-wrap: wrap; }
#phone .tabs button {
  background: transparent;
  color: #d9d3c7;
  border: 0;
  border-bottom: 2px solid transparent;
  padding: 6px 8px;
}
#phone .tabs button.on { color: white; border-color: var(--orange); }
#phone .body { overflow: auto; background: #f4efe4; color: var(--ink); border-radius: 16px; padding: 10px; flex: 1; }
.bubble { background: white; border-radius: 12px; padding: 8px 10px; margin-bottom: 8px; }
.bubble .from { font-size: 12px; font-weight: 800; }
.bubble .time { float: right; color: var(--muted); font-weight: 500; }
.post { border-bottom: 1px solid var(--line); padding: 8px 2px; }
.post .handle { color: var(--muted); font-size: 12px; }
.bar { height: 8px; background: #e4d9c8; border-radius: 99px; overflow: hidden; margin-top: 3px; }
.bar span { display: block; height: 100%; background: var(--green); }
.locked {
  border: 1px dashed var(--line);
  border-radius: 12px;
  padding: 10px;
  margin-bottom: 8px;
  color: var(--muted);
}
.sil {
  width: 36px; height: 36px; border-radius: 50%;
  background: #d9d3c7; display: inline-block; vertical-align: middle; margin-right: 8px;
}

.modal {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(28, 36, 48, 0.28);
  z-index: 20;
  padding: 18px;
}
.modal .sheet { width: min(560px, 100%); max-height: min(86vh, 760px); overflow: auto; }
label { display: block; font-size: 13px; font-weight: 700; margin: 10px 0 4px; }
textarea {
  width: 100%;
  min-height: 64px;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px;
  background: white;
  resize: vertical;
}
.note {
  border-top: 1px solid var(--line);
  padding-top: 8px;
  margin-top: 8px;
  font-size: 13px;
}
.note time { color: var(--muted); }

#toasts {
  position: absolute;
  top: 78px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 6px;
  z-index: 25;
  width: min(460px, calc(100% - 24px));
  pointer-events: none;
}
.toast {
  background: var(--paper);
  border: 1px solid var(--ink);
  border-left: 6px solid var(--orange);
  border-radius: 10px;
  padding: 8px 10px;
  box-shadow: var(--shadow);
}
.toast.unlock { border-left-color: var(--green); }
.toast.phone { border-left-color: var(--clout); }
.toast.bell { border-left-color: var(--grades); }

.hs { display: grid; gap: 8px; margin-top: 8px; }
.hs article { border: 1px solid var(--line); border-radius: 12px; padding: 8px 10px; background: white; }
.hs article.lean { border-color: var(--green); box-shadow: inset 3px 0 0 var(--green); }
.tiny { font-size: 12px; color: var(--muted); }

@media (max-width: 800px) {
  .cards { grid-template-columns: 1fr; }
  #phone { top: 58px; left: 10px; right: 10px; width: auto; }
  h1 { font-size: 42px; }
}
