@font-face { font-family: 'Jersey 15'; src: url('assets/fonts/jersey-15-latin-400-normal.woff2') format('woff2'); font-weight: 400; font-display: swap; }
:root {
  --paper: #f8e9c4; --paper-2: #efdcae; --paper-3: #e2c98e; --ink: #3a2618; --ink-2: #6b4a34;
  --wood: #8a5a3c; --wood-d: #4f3322; --red: #d9534f; --green: #6dbb55; --green-d: #3f8a3c;
  --gold: #f4c542; --blue: #4f8fd9; --shadow: rgba(30, 18, 10, 0.4);
  --sat: env(safe-area-inset-top, 0px); --sab: env(safe-area-inset-bottom, 0px);
  --sal: env(safe-area-inset-left, 0px); --sar: env(safe-area-inset-right, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #243b2e; overscroll-behavior: none; }
body { font-family: 'Jersey 15', 'Trebuchet MS', system-ui, sans-serif; font-size: 20px; line-height: 1.15; font-synthesis: none; letter-spacing: 0.2px; color: var(--ink); user-select: none; -webkit-user-select: none; touch-action: none; }
#world { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; cursor: default; image-rendering: pixelated; }
img.px, canvas.px { image-rendering: pixelated; image-rendering: crisp-edges; }
button { font: inherit; color: inherit; }
[hidden] { display: none !important; }

.panel { background: var(--paper); border: 3px solid var(--wood-d); border-radius: 8px; box-shadow: inset 0 0 0 2px #fff7df, inset 0 -5px 0 0 var(--paper-3), 0 3px 0 var(--shadow); }
.btn { background: #fff3d2; border: 3px solid var(--wood-d); border-radius: 8px; box-shadow: inset 0 -4px 0 var(--paper-3), 0 3px 0 var(--shadow); padding: 8px 14px 10px; cursor: pointer; font-weight: 400; touch-action: manipulation; }
.btn:hover { filter: brightness(1.04); }
.btn:active { transform: translateY(2px); box-shadow: inset 0 -2px 0 var(--paper-3), 0 1px 0 var(--shadow); }
.btn.primary { background: #8fd46f; box-shadow: inset 0 -4px 0 #57a548, 0 3px 0 var(--shadow); color: #173a16; }
.btn.warn { background: #f3a79f; box-shadow: inset 0 -4px 0 #d9534f, 0 3px 0 var(--shadow); }
.btn.small { padding: 4px 10px 6px; font-size: 18px; }
.btn[disabled] { filter: grayscale(0.7) brightness(0.92); cursor: not-allowed; opacity: 0.75; }
.badge { background: var(--wood); color: #fff3d2; border-radius: 5px; padding: 1px 7px 2px; font-size: 16px; white-space: nowrap; }

#hud { position: fixed; inset: 0; pointer-events: none; }
#hud > * { pointer-events: auto; }

/* Top bar */
#top { position: absolute; top: calc(6px + var(--sat)); left: calc(6px + var(--sal)); right: calc(6px + var(--sar)); pointer-events: none; display: flex; justify-content: center; }
.topbar { pointer-events: auto; display: grid; grid-template-columns: auto 1fr; grid-template-areas: 'who stats' 'goal goal'; gap: 4px 14px; align-items: center; padding: 7px 10px 10px; max-width: 880px; width: 100%; }
.who { grid-area: who; display: flex; align-items: center; gap: 8px; min-width: 0; }
.who b { font-size: 23px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.date { color: var(--ink-2); font-size: 18px; white-space: nowrap; }
.stats { grid-area: stats; display: flex; justify-content: flex-end; gap: 6px; flex-wrap: wrap; }
.stat { display: inline-flex; align-items: center; gap: 5px; background: var(--paper-2); border: 2px solid var(--wood); border-radius: 6px; padding: 2px 8px 3px; font-weight: 400; white-space: nowrap; cursor: pointer; }
.stat img { width: 16px; height: 16px; }
.stat small { font-weight: 400; color: var(--green-d); font-size: 16px; }
.stat small.neg { color: #b03a34; }
#st-energy { cursor: default; gap: 3px; }
.pip { width: 9px; height: 13px; border: 2px solid var(--wood-d); border-radius: 2px; background: #fff7df; }
.pip.on { background: var(--gold); box-shadow: inset 0 -3px 0 #c98a1e; }
#goal { grid-area: goal; display: flex; align-items: center; gap: 8px; font-size: 16px; color: var(--ink-2); }
.bar { flex: 1; height: 10px; background: #fff7df; border: 2px solid var(--wood-d); border-radius: 5px; overflow: hidden; }
.bar i { display: block; height: 100%; width: 0; background: linear-gradient(#a6e085, #6dbb55); transition: width 0.5s; }
.bar.gold i { background: linear-gradient(#ffe58a, #f4c542); }
.bar.blue i { background: linear-gradient(#9fd0ff, #4f8fd9); }
.bar.red i { background: linear-gradient(#ffb0a8, #d9534f); }

/* Side buttons */
#side { position: absolute; right: calc(6px + var(--sar)); top: calc(112px + var(--sat)); display: flex; flex-direction: column; gap: 8px; }
.sidebtn { position: relative; width: 48px; height: 48px; padding: 0; display: grid; place-items: center; }
.sidebtn img { width: 24px; height: 24px; }
.sidebtn .dot { position: absolute; top: -6px; right: -6px; min-width: 20px; height: 20px; border-radius: 10px; background: var(--red); color: #fff; font-size: 15px; display: grid; place-items: center; border: 2px solid var(--wood-d); padding: 0 3px; }

/* Guide (Marjorie) and toasts */
#notices { position: absolute; left: calc(6px + var(--sal)); top: calc(112px + var(--sat)); width: min(380px, calc(100vw - 72px)); display: flex; flex-direction: column; gap: 6px; align-items: flex-start; pointer-events: none !important; }
#notices > * { pointer-events: auto; }
#guide { position: relative; padding: 8px 24px 12px 10px; display: flex; gap: 10px; align-items: flex-start; font-size: 19px; }
#guide img { width: 48px; height: 48px; border: 2px solid var(--wood-d); border-radius: 6px; flex: none; }
#guide .x { position: absolute; top: 2px; right: 6px; background: none; border: 0; cursor: pointer; font-size: 21px; color: var(--ink-2); padding: 2px 4px; }
#guide b { display: block; font-size: 16px; color: var(--ink-2); }

/* Bottom */
#bottom { position: absolute; left: calc(6px + var(--sal)); right: calc(6px + var(--sar)); bottom: calc(6px + var(--sab)); display: flex; flex-direction: column; gap: 6px; align-items: center; pointer-events: none; }
#bottom > * { pointer-events: auto; }
#bottom .row { display: flex; gap: 8px; align-items: stretch; max-width: 100%; }
#cats { display: flex; gap: 4px; padding: 5px 5px 9px; overflow-x: auto; scrollbar-width: none; }
#cats::-webkit-scrollbar { display: none; }
.cat .short { display: none; }
.cat { flex: none; background: transparent; border: 2px solid transparent; border-radius: 6px; padding: 3px 7px 4px; display: flex; flex-direction: column; align-items: center; gap: 1px; cursor: pointer; font-size: 15px; min-width: 56px; white-space: nowrap; touch-action: manipulation; }
.cat .ic { height: 30px; display: grid; place-items: end center; }
.cat .ic img { max-height: 30px; max-width: 40px; }
.cat.on { background: #fff7df; border-color: var(--wood); }
.cat:hover { background: var(--paper-2); }
#endday { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-width: 78px; font-size: 18px; padding: 6px 10px 9px; }
#endday img { width: 24px; height: 24px; }
#endday.ready { animation: nudge 1.1s infinite; }
@keyframes nudge { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-4px); } }

#tray { display: flex; gap: 6px; overflow-x: auto; max-width: 100%; padding: 4px 2px 6px; scrollbar-width: thin; }
.bcard { flex: none; width: 104px; background: var(--paper); border: 3px solid var(--wood-d); border-radius: 8px; box-shadow: inset 0 -4px 0 var(--paper-3), 0 3px 0 var(--shadow); padding: 5px 4px 8px; display: flex; flex-direction: column; align-items: center; gap: 2px; cursor: pointer; font-size: 16px; text-align: center; touch-action: manipulation; }
.bcard .ic { height: 52px; width: 100%; display: grid; place-items: end center; }
.bcard .ic img { max-height: 52px; max-width: 92px; }
.bcard .nm { font-weight: 400; line-height: 1.05; min-height: 30px; display: grid; place-items: center; }
.bcard .cost { display: inline-flex; align-items: center; gap: 3px; }
.bcard .cost img { width: 14px; height: 14px; }
.bcard.on { background: #fff7df; outline: 3px solid var(--gold); }
.bcard.poor .cost { color: #b03a34; }
.bcard.locked { filter: grayscale(0.85); opacity: 0.8; cursor: default; }
.bcard.locked .ic img { filter: brightness(0.45); }
.bcard .why { font-size: 14px; color: var(--ink-2); line-height: 1.05; }

#hint { padding: 6px 10px 10px; display: flex; gap: 10px; align-items: center; max-width: min(640px, 100%); font-size: 18px; }
#hint .txt { flex: 1; }
#hint .txt b { display: block; font-size: 19px; }
#hint .bad { color: #b03a34; }

/* Toasts */
#toasts { display: flex; flex-direction: column; gap: 6px; align-items: flex-start; pointer-events: none !important; }
.toast { background: var(--paper); border: 3px solid var(--wood-d); border-radius: 8px; padding: 5px 10px 7px; box-shadow: 0 3px 0 var(--shadow); display: flex; gap: 8px; align-items: center; font-size: 18px; animation: pop 0.25s ease-out; }
.toast img { width: 28px; height: 28px; border-radius: 4px; flex: none; }
.toast.good { background: #e3f6d4; } .toast.bad { background: #fbdcd6; } .toast.gold { background: #fff0b8; }
.toast.out { opacity: 0; transform: translateY(-8px); transition: all 0.4s; }
@keyframes pop { from { transform: scale(0.8); opacity: 0; } to { transform: scale(1); opacity: 1; } }

/* Talk bubble and building card */
#talk, #card { position: absolute; left: 50%; transform: translateX(-50%); bottom: calc(96px + var(--sab)); width: min(520px, calc(100vw - 16px)); padding: 10px 12px 14px; }
#talk { display: flex; gap: 12px; align-items: flex-start; cursor: pointer; }
#talk img.face { width: 72px; height: 72px; border: 3px solid var(--wood-d); border-radius: 8px; flex: none; }
#talk .nm { font-weight: 400; } #talk .role { color: var(--ink-2); font-size: 16px; }
#talk .hearts img, .hearts img { width: 16px; height: 16px; }
#talk p { margin: 4px 0 0; font-size: 20px; }
#card .head { display: flex; gap: 10px; align-items: flex-end; margin-bottom: 6px; }
#card .head .ic { width: 64px; height: 64px; display: grid; place-items: end center; flex: none; }
#card .head .ic img { max-width: 64px; max-height: 64px; }
#card h3 { margin: 0; font-size: 22px; } #card .sub { color: var(--ink-2); font-size: 18px; }
#card .x { position: absolute; top: 4px; right: 8px; background: none; border: 0; font-size: 23px; cursor: pointer; color: var(--ink-2); }
#card ul { list-style: none; margin: 6px 0; padding: 0; font-size: 18px; display: grid; grid-template-columns: 1fr 1fr; gap: 1px 12px; }
#card li { display: flex; justify-content: space-between; gap: 6px; }
#card li .p { color: var(--green-d); } #card li .n { color: #b03a34; } #card li .z { color: var(--ink-2); }
#card .tip { background: var(--paper-2); border-radius: 6px; padding: 5px 8px; font-size: 18px; margin: 6px 0; }
#card .acts { display: flex; gap: 8px; justify-content: flex-end; margin-top: 6px; }
.moodline { display: flex; align-items: center; gap: 8px; font-size: 18px; }
.moodline img { width: 16px; height: 16px; }

/* Modals */
#modal-root { position: fixed; inset: 0; pointer-events: none; }
.scrim { position: absolute; inset: 0; background: rgba(20, 14, 30, 0.45); pointer-events: auto; display: grid; place-items: center; padding: calc(10px + var(--sat)) 10px calc(10px + var(--sab)); animation: fade 0.2s; }
.scrim.clear { background: rgba(20, 14, 30, 0.12); }
.scrim.side { justify-items: end; padding-right: max(10px, 4vw); }
.scrim.side .modal { width: min(420px, 100%); }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.modal { width: min(560px, 100%); max-height: 100%; overflow-y: auto; padding: 14px 16px 18px; animation: pop 0.22s ease-out; overscroll-behavior: contain; touch-action: pan-y; }
.modal.wide { width: min(720px, 100%); }
.modal h2 { margin: 0 0 4px; font-size: 28px; text-align: center; }
.modal h2 small { display: block; font-size: 18px; font-weight: 400; color: var(--ink-2); }
.modal h3 { margin: 12px 0 4px; font-size: 20px; color: var(--ink-2); border-bottom: 2px dashed var(--paper-3); }
.modal p { margin: 6px 0; }
.modal .acts { display: flex; gap: 10px; justify-content: center; margin-top: 14px; flex-wrap: wrap; }
.modal .close { position: sticky; float: right; top: 0; background: var(--paper-2); border: 2px solid var(--wood); border-radius: 6px; font-size: 19px; cursor: pointer; padding: 0 8px 2px; }
.ledger { width: 100%; border-collapse: collapse; font-size: 19px; }
.ledger td { padding: 1px 0; } .ledger td:last-child { text-align: right; font-weight: 400; }
.ledger tr.total td { border-top: 2px solid var(--wood); padding-top: 3px; font-size: 21px; }
.pos { color: var(--green-d); } .neg { color: #b03a34; }
.news { list-style: none; padding: 0; margin: 6px 0; font-size: 19px; }
.news li { padding: 2px 0 2px 20px; position: relative; }
.news li::before { content: ''; position: absolute; left: 4px; top: 9px; width: 7px; height: 7px; background: var(--gold); border: 2px solid var(--wood-d); border-radius: 2px; }
.advice { display: flex; gap: 10px; align-items: center; background: var(--paper-2); border-radius: 8px; padding: 8px 10px; margin-top: 10px; font-size: 19px; }
.advice img { width: 48px; height: 48px; border: 2px solid var(--wood-d); border-radius: 6px; flex: none; }
.big-num { text-align: center; font-size: 35px; font-weight: 400; margin: 4px 0; }
.hero { display: grid; place-items: center; margin: 4px 0 8px; }
.hero img { width: 96px; height: 96px; border: 3px solid var(--wood-d); border-radius: 10px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; margin: 6px 0; }
.chip { background: var(--paper-2); border: 2px solid var(--wood); border-radius: 6px; padding: 1px 8px 3px; font-size: 18px; }
.choice { display: block; width: 100%; text-align: left; margin-top: 8px; }
.choice small { display: block; font-weight: 400; color: var(--ink-2); font-size: 16px; }

.req { display: flex; gap: 10px; align-items: flex-start; padding: 8px 0; border-bottom: 2px dashed var(--paper-3); }
.req:last-child { border-bottom: 0; }
.req img.face { width: 56px; height: 56px; border: 2px solid var(--wood-d); border-radius: 6px; flex: none; }
.req .body { flex: 1; min-width: 0; }
.req .meta { display: flex; align-items: center; gap: 8px; font-size: 16px; color: var(--ink-2); margin-top: 4px; }
.req .meta .bar { max-width: 160px; }
.req .reward { display: inline-flex; align-items: center; gap: 3px; font-weight: 400; color: var(--ink); }
.req .reward img { width: 14px; height: 14px; }
.person { display: flex; gap: 10px; align-items: center; padding: 7px 0; border-bottom: 2px dashed var(--paper-3); }
.person img.face { width: 56px; height: 56px; border: 2px solid var(--wood-d); border-radius: 6px; flex: none; }
.person.away img.face { filter: brightness(0) opacity(0.35); }
.person .body { flex: 1; min-width: 0; font-size: 18px; } .person .nm { font-weight: 400; font-size: 20px; }
.person .next { color: var(--ink-2); font-size: 16px; }
.stamps { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; margin-top: 8px; }
.stamp { border: 3px dashed var(--wood); border-radius: 8px; padding: 6px 8px 8px; font-size: 16px; background: #fff7df; }
.stamp b { display: flex; align-items: center; gap: 5px; font-size: 18px; } .stamp b img { width: 16px; height: 16px; }
.stamp.off { opacity: 0.55; background: transparent; }
.stamp.off b img { filter: grayscale(1); }
.needs { display: grid; grid-template-columns: auto 1fr auto; gap: 5px 10px; align-items: center; font-size: 18px; }
.field { display: flex; flex-direction: column; gap: 4px; margin: 10px 0; text-align: left; }
.field input, .field textarea { font: inherit; padding: 8px 10px; border: 3px solid var(--wood-d); border-radius: 8px; background: #fff7df; color: var(--ink); user-select: text; -webkit-user-select: text; width: 100%; }
.toggle { display: flex; justify-content: space-between; align-items: center; padding: 6px 0; border-bottom: 2px dashed var(--paper-3); }

/* Title screen */
#title { position: fixed; inset: 0; display: grid; place-items: center; background: radial-gradient(ellipse at center, rgba(20, 30, 50, 0.25), rgba(20, 20, 40, 0.7)); padding: 16px; overflow-y: auto; }
#title .box { width: min(460px, 100%); text-align: center; padding: 20px 20px 24px; }
#title h1 { margin: 6px 0 0; font-size: clamp(38px, 11vw, 56px); line-height: 0.95; letter-spacing: 1px; color: var(--ink); text-shadow: 3px 3px 0 var(--paper-3); }
#title .tag { color: var(--ink-2); margin: 8px 0 14px; font-size: 20px; }
#title .logo { width: 60px; height: 150px; margin: 0 auto; }
#title .save { background: var(--paper-2); border-radius: 8px; padding: 8px 10px; margin: 10px 0; font-size: 18px; }
#title .col { display: flex; flex-direction: column; gap: 10px; }
#title .btn { font-size: 22px; padding: 10px 14px 13px; }
#title .fine { font-size: 15px; color: var(--ink-2); margin-top: 12px; }

@media (max-width: 720px) {
  body { font-size: 19px; }
  .topbar { grid-template-columns: 1fr; grid-template-areas: 'who' 'stats' 'goal'; padding: 5px 8px 9px; gap: 4px; }
  .who b { font-size: 21px; }
  .stats { justify-content: space-between; gap: 4px; flex-wrap: nowrap; }
  .stat { padding: 1px 5px 2px; font-size: 18px; gap: 3px; }
  .stat small { font-size: 15px; }
  .pip { width: 6px; height: 11px; border-width: 1.5px; }
  #side { top: calc(134px + var(--sat)); gap: 6px; }
  .sidebtn { width: 44px; height: 44px; }
  #notices { top: calc(140px + var(--sat)); }
  #guide { font-size: 17px; }
  #guide img { width: 40px; height: 40px; }
  .cat { min-width: 0; flex: 1 0 auto; font-size: 14px; padding: 2px 1px 3px; }
  #cats { gap: 1px; padding: 4px 3px 8px; }
  #hint { font-size: 16px; padding: 5px 8px 9px; gap: 8px; }
  #hint .txt b { font-size: 18px; }
  .cat .long { display: none; } .cat .short { display: inline; }
  .scrim.side { justify-items: center; align-items: end; padding-right: 10px; }
  .scrim.side .modal { max-height: 62vh; }
  #side { top: calc(140px + var(--sat)); }
  .cat .ic { height: 26px; } .cat .ic img { max-height: 26px; max-width: 28px; }
  #endday { min-width: 64px; font-size: 16px; padding: 4px 6px 8px; }
  #bottom .row { width: 100%; } #cats { flex: 1; }
  .bcard { width: 92px; font-size: 15px; }
  #talk, #card { bottom: calc(88px + var(--sab)); }
  #card ul { grid-template-columns: 1fr; }
  .modal { padding: 12px 12px 16px; } .modal h2 { font-size: 25px; }
}
@media (max-height: 520px) {
  #guide { max-width: 300px; }
  .bcard .ic { height: 36px; } .bcard .ic img { max-height: 36px; }
}

b, strong, h1, h2, h3 { font-weight: 400; }

/* Overtime, map */
.ot { font: inherit; font-size: 16px; margin-left: 4px; padding: 0 7px 2px; background: #ffe58a; border: 2px solid var(--wood-d); border-radius: 5px; cursor: pointer; white-space: nowrap; touch-action: manipulation; }
.ot:active { transform: translateY(1px); }
.mapimg { display: block; width: min(100%, 62vh); aspect-ratio: 1; margin: 8px auto; border: 3px solid var(--wood-d); border-radius: 6px; cursor: crosshair; }
.legend .chip { display: inline-flex; align-items: center; gap: 5px; font-size: 16px; }
.legend .chip i { width: 10px; height: 10px; border: 1px solid var(--wood-d); display: inline-block; }
.person .btn { flex: none; }

/* Towns on the title screen */
#title .town { display: flex; flex-direction: column; align-items: flex-start; gap: 1px; text-decoration: none; color: var(--ink); text-align: left; font-size: 21px; padding: 8px 12px 11px; }
#title .town small { font-size: 15px; color: var(--ink-2); }
#title .town .addr { color: var(--green-d); }
#title .town:first-child { background: #8fd46f; box-shadow: inset 0 -4px 0 #57a548, 0 3px 0 var(--shadow); }
#title .town:first-child small { color: #1f4a1c; }
#title .box { max-height: 100%; overflow-y: auto; }

/* Visiting a town that is not yours: nothing to build with. */
body.visitor #bottom, body.visitor #sb-board, body.visitor #sb-people, body.visitor #sb-scrap, body.visitor #sb-gear, body.visitor #st-energy, body.visitor #card .acts { display: none !important; }
#guide a, #title a { color: var(--green-d); }
#title #t-codebox { margin-top: 4px; }
