:root {
  --panel: rgba(18, 20, 28, 0.78);
  --text: #f3efe8;
  --muted: #b9b3a6;
  --accent: #f2b63d;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #0b0d12; color: var(--text);
  font: 14px/1.4 system-ui, -apple-system, "Segoe UI", sans-serif; }
#view { position: fixed; inset: 0; width: 100vw; height: 100vh; image-rendering: pixelated; display: block; }
#hud { position: fixed; top: 12px; left: 12px; padding: 10px 14px; background: var(--panel); border-radius: 10px;
  max-width: min(360px, calc(100vw - 24px)); pointer-events: none; }
#hud-clock { font-weight: 600; color: var(--accent); font-variant-numeric: tabular-nums; }
#hud-where { color: var(--muted); font-size: 13px; }
#hud-doing { margin-top: 2px; }
#hud-needs { display: grid; grid-template-columns: auto 1fr; gap: 3px 8px; margin-top: 8px; font-size: 12px; color: var(--muted); align-items: center; }
#hud-needs .bar { height: 6px; background: rgba(255,255,255,0.12); border-radius: 3px; overflow: hidden; min-width: 120px; }
#hud-needs .fill { height: 100%; background: var(--accent); border-radius: 3px; transition: width 0.4s; }
#hud-needs .fill.low { background: #e07a5f; }
#hud-focus { margin-top: 8px; font-size: 13px; color: var(--accent); }
#hud-focus:empty { display: none; }
#hud-research { margin-top: 6px; font-size: 12px; color: #9cc7e6; white-space: pre-line; }
#hud-research:empty { display: none; }
#hud-hobbies .origin { color: #9cc7e6; margin-left: 4px; }
#hud-hobbies .more { color: var(--muted); font-style: italic; }
#hud-hobbies { list-style: none; margin: 6px 0 0; padding: 0; font-size: 12px; color: var(--muted); }
#hud-hobbies:empty { display: none; }
#hud-hobbies li { display: flex; justify-content: space-between; gap: 10px; }
#hud-hobbies .stage { color: var(--text); opacity: 0.7; white-space: nowrap; }
#hud-hobbies .named { color: var(--text); font-weight: 600; }
#hud-status:empty { display: none; }
#hud-status { color: #e07a5f; font-size: 13px; }
#controls { position: fixed; top: 12px; right: 12px; display: flex; gap: 8px; }
button, select { font: inherit; color: var(--text); background: var(--panel); border: 1px solid rgba(255,255,255,0.15);
  border-radius: 8px; padding: 6px 10px; cursor: pointer; }
button:hover { border-color: var(--accent); }
button:focus-visible, select:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
#debug { position: fixed; bottom: 12px; left: 12px; padding: 6px 10px; background: var(--panel); border-radius: 8px;
  font: 12px ui-monospace, Consolas, monospace; }
#dev { position: fixed; bottom: 12px; right: 12px; padding: 8px; background: var(--panel); border-radius: 10px;
  display: flex; gap: 6px; align-items: center; font-size: 13px; }
#dev[hidden], #debug[hidden] { display: none; }

dialog { width: min(460px, calc(100vw - 32px)); max-height: calc(100vh - 48px); overflow: auto; background: #1a1d26; color: var(--text);
  border: 1px solid rgba(255,255,255,0.15); border-radius: 12px; padding: 18px 20px; }
dialog::backdrop { background: rgba(0,0,0,0.55); }
dialog h2 { margin: 0 0 6px; font-size: 18px; }
dialog h3 { margin: 18px 0 6px; font-size: 14px; color: var(--muted); }
dialog label { display: block; margin: 12px 0 4px; font-size: 13px; color: var(--muted); }
dialog textarea { width: 100%; font: inherit; color: var(--text); background: #0f1118; border: 1px solid rgba(255,255,255,0.15); border-radius: 8px; padding: 8px; resize: vertical; }
dialog input[type=file] { font-size: 13px; color: var(--muted); max-width: 100%; }
dialog .row { display: flex; gap: 8px; justify-content: space-between; align-items: center; margin-top: 8px; }
dialog .hint { font-size: 13px; color: var(--muted); margin: 4px 0; }
#letter-count { font-size: 12px; color: var(--muted); }
#letter-status { min-height: 1.4em; font-size: 13px; color: var(--accent); }
#letter-status.error { color: #e07a5f; }
#letters-mine { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
#letters-mine li { background: #0f1118; border-radius: 8px; padding: 8px 10px; }
#letters-mine p { margin: 0 0 4px; white-space: pre-wrap; overflow-wrap: anywhere; }
#letters-mine .letter-meta { font-size: 12px; color: var(--muted); margin-bottom: 6px; }
button.danger { margin-top: 14px; border-color: rgba(224,122,95,0.5); }
button:disabled { opacity: 0.5; cursor: default; }

#btn-diary[hidden], #btn-wishes[hidden] { display: none; }
#diary-dialog { width: min(560px, calc(100vw - 32px)); }
#diary-dialog .row { margin-top: 0; }
#diary-list { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 14px; }
#diary-list h3 { margin: 0 0 6px; color: var(--accent); display: inline; }
#diary-list summary { cursor: pointer; margin-bottom: 6px; }
.diary-who { background: #0f1118; border-radius: 8px; padding: 8px 12px; margin: 8px 0 4px; }
.diary-who[hidden] { display: none; }
.diary-who h3 { margin: 0 0 4px; color: var(--accent); font-size: 14px; }
.diary-who .who-traits { margin: 0 0 4px; font-family: Georgia, "Times New Roman", serif; font-size: 15px; }
.who-bars { display: grid; grid-template-columns: auto 1fr auto 1fr; gap: 3px 8px; align-items: center; margin-top: 6px; font-size: 12px; color: var(--muted); }
.who-bars .bar { height: 5px; background: rgba(255,255,255,0.12); border-radius: 3px; overflow: hidden; }
.who-bars .fill { height: 100%; background: var(--accent); border-radius: 3px; }
@media (max-width: 420px) { .who-bars { grid-template-columns: auto 1fr; } }
.diary-entry.asleep { color: var(--muted); font-size: 13px; padding: 4px 12px; background: transparent; border: 1px dashed rgba(255,255,255,0.12); }
.diary-facts { display: grid; grid-template-columns: auto 1fr; gap: 2px 8px; margin: 6px 0 0; font-size: 12px; }
.diary-facts dt { color: var(--accent); opacity: 0.85; }
.diary-facts dd { margin: 0; color: var(--muted); overflow-wrap: anywhere; }
.diary-entry .diary-drawings { margin: 8px 0 0; }
.diary-entry { background: #0f1118; border-radius: 8px; padding: 8px 12px; margin-bottom: 6px; }
.diary-entry p { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; font-family: Georgia, "Times New Roman", serif; font-size: 15px; line-height: 1.5; }
.diary-meta { font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.diary-drawings { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 8px; margin-bottom: 8px; }
.diary-drawing { margin: 0; background: #0f1118; border-radius: 8px; padding: 6px; }
.diary-drawing img { display: block; width: 100%; height: auto; border-radius: 4px; background: #fbf7ec; }
.diary-drawing figcaption { font-size: 12px; color: var(--muted); margin-top: 4px; font-style: italic; }
#letters-mine .letter-reaction { margin: 4px 0 6px; font-family: Georgia, "Times New Roman", serif; color: var(--accent); }

#wishes-dialog { width: min(520px, calc(100vw - 32px)); }
#wishes-dialog .row { margin-top: 0; }
.wishes { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 10px; }
.wish { background: #0f1118; border-radius: 8px; padding: 10px 12px; border-left: 3px solid var(--accent); }
.wish-added { border-left-color: #7fbf7f; opacity: 0.8; }
.wish-dismissed { border-left-color: rgba(255,255,255,0.2); opacity: 0.6; }
.wish-title { font-weight: 600; color: var(--accent); }
.wish-text { margin: 4px 0; font-family: Georgia, "Times New Roman", serif; font-size: 15px; line-height: 1.45; overflow-wrap: anywhere; }
.wish-meta { font-size: 12px; color: var(--muted); }
.wish-actions { display: flex; gap: 8px; margin-top: 8px; }
#wishes-done-box summary { cursor: pointer; margin-top: 14px; color: var(--muted); }
.wish-built { font-size: 13px; color: #7fbf7f; margin-top: 4px; overflow-wrap: anywhere; }
