:root {
  --ink: #3a2c3a; --ink-2: #6a5a68; --paper: #fff6e8; --paper-2: #ffeccf; --line: #eedcc4;
  --coral: #ff7a59; --coral-2: #ff5c3a; --mint: #7fd3b0; --butter: #ffd166; --lav: #c9b6f2;
  --shadow: 0 14px 40px rgba(60, 30, 50, .22), 0 2px 6px rgba(60, 30, 50, .12);
  --r: 22px;
  --display: "Fredoka", "Nunito", ui-rounded, system-ui, sans-serif;
  --text: "Nunito", ui-rounded, system-ui, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; }
body { font-family: var(--text); color: var(--ink); background: #5a4a8c; -webkit-font-smoothing: antialiased; }

#sky { position: fixed; inset: 0; z-index: 0; background: linear-gradient(180deg, #4d3f86 0%, #7a5aa6 22%, #c77fa8 46%, #f0a58c 66%, #f7c59a 80%, #f6d3a6 100%); }
#sky .moon { position: absolute; right: 12vw; top: 9vh; width: 74px; height: 74px; border-radius: 50%; background: radial-gradient(circle at 35% 35%, #fff9e6, #ffe8b3 60%, #f2cf8a); box-shadow: 0 0 60px 18px rgba(255, 236, 190, .35), 0 0 140px 60px rgba(255, 210, 160, .18); }
#sky .star { position: absolute; width: 3px; height: 3px; border-radius: 50%; background: #fff6e0; opacity: .8; box-shadow: 0 0 6px 1px rgba(255, 246, 224, .6); animation: twinkle 3.4s ease-in-out infinite; }
#sky .s1 { left: 12%; top: 8%; } #sky .s2 { left: 30%; top: 15%; animation-delay: .7s; } #sky .s3 { left: 55%; top: 6%; animation-delay: 1.4s; } #sky .s4 { left: 72%; top: 18%; animation-delay: 2.1s; } #sky .s5 { left: 88%; top: 27%; animation-delay: .3s; }
@keyframes twinkle { 0%, 100% { opacity: .35; transform: scale(.8); } 50% { opacity: .95; transform: scale(1.2); } }
#c { position: fixed; inset: 0; z-index: 1; width: 100%; height: 100%; display: block; touch-action: none; }
#vignette { position: fixed; inset: 0; z-index: 2; pointer-events: none; background: radial-gradient(ellipse at center, rgba(0,0,0,0) 55%, rgba(50, 20, 50, .28) 100%); }

#ui { position: fixed; inset: 0; z-index: 3; pointer-events: none; }
#ui > * { pointer-events: auto; }
.top { position: absolute; left: 0; right: 0; top: 0; display: flex; align-items: center; padding: 16px 20px; gap: 12px; pointer-events: none; }
.top > * { pointer-events: auto; }
.brand { font-family: var(--display); font-weight: 700; font-size: 32px; line-height: 1; margin: 0 auto 0 0; color: #fff4e0; letter-spacing: -.5px; text-shadow: 0 2px 0 rgba(90, 50, 90, .25), 0 10px 30px rgba(60, 30, 70, .35); white-space: nowrap; }
.brand span { color: var(--butter); }
#find { flex: 0 1 340px; min-width: 0; }
#find input { width: 100%; min-width: 0; }

.btn { font: 700 15px/1 var(--text); border: 0; border-radius: 999px; padding: 13px 18px; cursor: pointer; background: var(--paper); color: var(--ink); box-shadow: 0 6px 18px rgba(60, 30, 50, .2), inset 0 -2px 0 rgba(90, 50, 60, .12); transition: transform .12s ease, box-shadow .12s ease, filter .12s ease; white-space: nowrap; }
.btn:hover { transform: translateY(-1px); box-shadow: 0 10px 24px rgba(60, 30, 50, .25), inset 0 -2px 0 rgba(90, 50, 60, .12); }
.btn:active { transform: translateY(1px) scale(.98); }
.btn.primary { background: linear-gradient(180deg, var(--coral), var(--coral-2)); color: #fff8ee; text-shadow: 0 1px 0 rgba(120, 30, 10, .25); box-shadow: 0 8px 22px rgba(255, 92, 58, .38), inset 0 -2px 0 rgba(120, 30, 10, .22); }
.btn.primary b { font-weight: 800; opacity: .95; }
.btn.small { padding: 9px 13px; font-size: 13px; }
.btn.tiny { padding: 7px 11px; font-size: 12px; }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }
.link { background: none; border: 0; color: #fff2dc; font: 700 13px var(--text); cursor: pointer; opacity: .85; padding: 6px 8px; text-shadow: 0 1px 0 rgba(90, 50, 90, .3); }
.link:hover { opacity: 1; text-decoration: underline; }

.pill { display: flex; align-items: center; background: rgba(255, 246, 232, .92); border-radius: 999px; padding: 4px 6px 4px 16px; box-shadow: 0 6px 18px rgba(60, 30, 50, .18); backdrop-filter: blur(6px); }
.pill input { border: 0; background: transparent; font: 600 14px var(--text); color: var(--ink); outline: none; width: 190px; }
.pill button { flex: 0 0 auto; }
.pill input::placeholder { color: #a08f9b; }
.pill button { border: 0; background: var(--ink); color: #fff; width: 32px; height: 32px; border-radius: 50%; font-size: 16px; cursor: pointer; }

.paper { background: var(--paper); border-radius: var(--r); box-shadow: var(--shadow); color: var(--ink); }
.paper .close { position: absolute; right: 10px; top: 10px; width: 30px; height: 30px; border-radius: 50%; border: 0; background: var(--paper-2); color: var(--ink-2); font-size: 18px; line-height: 1; cursor: pointer; }
.paper .close:hover { background: var(--line); }

.card { position: absolute; left: 0; top: 0; width: 290px; padding: 16px 18px 14px; transform: translate(-9999px, -9999px); transition: opacity .15s; }
.card.hidden { display: none; }
.card .close { display: none; }
.card.pinned .close { display: block; }
.card.pinned .head { padding-right: 44px; }
.card .row { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.card .name { font-family: var(--display); font-size: 22px; font-weight: 700; }
.card .stage, .mname .stage { font: 800 11px/1 var(--text); letter-spacing: .06em; text-transform: uppercase; padding: 5px 8px; border-radius: 999px; background: var(--mint); color: #1f4d3a; }
.stage[data-stage="hungry"] { background: var(--butter); color: #5a4000; }
.stage[data-stage="starving"], .stage[data-stage="ghost"] { background: #f4a6a6; color: #5a1c1c; }
.stage[data-stage="fat"] { background: var(--lav); color: #3c2b6e; }
.stage[data-stage="chonk"] { background: linear-gradient(90deg, var(--butter), #ff9ab0); color: #4a1d2a; }
.card .host { font-weight: 800; color: var(--coral-2); font-size: 14px; margin-top: 2px; }
.card .tag { margin: 4px 0 10px; font-size: 13px; color: var(--ink-2); font-style: italic; }
.bar { height: 8px; border-radius: 999px; background: var(--paper-2); overflow: hidden; }
.bar i { display: block; height: 100%; border-radius: 999px; background: var(--mint); transition: width .4s ease; }
.bar i[data-stage="hungry"] { background: var(--butter); } .bar i[data-stage="starving"], .bar i[data-stage="ghost"] { background: #f08080; } .bar i[data-stage="fat"] { background: var(--lav); } .bar i[data-stage="chonk"] { background: linear-gradient(90deg, var(--butter), #ff9ab0); }
.card .food { font-size: 12px; font-weight: 700; color: var(--ink-2); margin: 6px 0 8px; }
.card .props { display: flex; flex-wrap: wrap; gap: 5px; margin-bottom: 10px; }
.chip { font: 700 12px var(--text); padding: 5px 9px; border-radius: 999px; background: var(--paper-2); }
.chip.none { opacity: .6; font-style: italic; }
.card .clicks { font-size: 13px; color: var(--ink-2); } .card .clicks b { color: var(--ink); font-size: 15px; }
.card .acts { display: flex; gap: 6px; }

.bottom { position: absolute; left: 0; right: 0; bottom: 0; display: flex; justify-content: center; align-items: center; padding: 14px 22px; pointer-events: none; }
.bottom > * { pointer-events: auto; }
#stats { font-size: 13px; color: #fff2dc; background: rgba(60, 35, 70, .35); backdrop-filter: blur(6px); padding: 9px 14px; border-radius: 999px; }
#stats b { color: var(--butter); }
#stats .short { display: none; }
#stats .live i { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: #7fe29a; box-shadow: 0 0 0 3px rgba(127, 226, 154, .25); margin: 0 6px 1px 0; animation: pulse 2.4s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { box-shadow: 0 0 0 3px rgba(127, 226, 154, .25); } 50% { box-shadow: 0 0 0 6px rgba(127, 226, 154, .08); } }

.panel { position: absolute; right: 22px; bottom: 60px; width: min(420px, calc(100vw - 44px)); padding: 22px 24px; max-height: 70vh; overflow: auto; }
.panel.hidden { display: none; }
.panel h2 { font-family: var(--display); margin: 0 0 10px; font-size: 24px; }
.panel ol { padding-left: 20px; margin: 0; } .panel li { margin: 8px 0; font-size: 14px; line-height: 1.45; }
.fine { font-size: 12px; color: var(--ink-2); margin: 12px 0 0; }
#gravelist { list-style: none; margin: 10px 0 0; padding: 0; }
#gravelist li { display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; padding: 10px 0; border-top: 1px solid var(--line); align-items: center; font-size: 13px; }
#gravelist .gname { font-family: var(--display); font-size: 17px; } #gravelist .ghost { color: var(--coral-2); font-weight: 800; grid-column: 1; } #gravelist .gwhen { color: var(--ink-2); font-size: 12px; grid-column: 1; } #gravelist .btn { grid-column: 2; grid-row: 1 / span 3; }
#gravelist .empty { font-style: italic; color: var(--ink-2); }

#modal { position: absolute; inset: 0; background: rgba(50, 25, 55, .45); backdrop-filter: blur(3px); display: flex; align-items: center; justify-content: center; padding: 16px; }
#modal.hidden { display: none; }
.sheet { position: relative; width: min(880px, 100%); max-height: min(92vh, 760px); display: grid; grid-template-columns: 300px 1fr; overflow: hidden; animation: rise .28s cubic-bezier(.2, .9, .3, 1.2); }
@keyframes rise { from { transform: translateY(24px) scale(.97); opacity: 0; } }
.sheet .left { padding: 26px 24px; background: linear-gradient(180deg, #fff1db, #ffe6c8); border-right: 1px solid var(--line); display: flex; flex-direction: column; }
.sheet .right { padding: 24px 24px 0; overflow: auto; display: flex; flex-direction: column; }
.sheet .right .grid:last-of-type { margin-bottom: 10px; }
.sheet h2 { font-family: var(--display); margin: 0; font-size: 28px; }
.sheet .sub { margin: 4px 0 14px; font-size: 13px; color: var(--ink-2); min-height: 34px; }
.field { display: block; } .field span { display: block; font: 800 11px var(--text); letter-spacing: .08em; text-transform: uppercase; color: var(--ink-2); margin-bottom: 6px; }
.field input { width: 100%; font: 700 16px var(--text); color: var(--ink); border: 2px solid var(--line); background: #fff; border-radius: 14px; padding: 11px 13px; outline: none; }
.field input:focus { border-color: var(--coral); } .field input:disabled { background: var(--paper-2); color: var(--ink-2); }
#mPreview { position: relative; margin: 14px auto 6px; width: 240px; height: 240px; border-radius: 50%; background: radial-gradient(circle at 50% 60%, #ffd9b0, #ffc79a 70%, #f9b98e); box-shadow: inset 0 -14px 30px rgba(160, 80, 60, .18), 0 10px 30px rgba(120, 60, 60, .18); overflow: visible; }
#mPreview canvas { width: 100%; height: 100%; display: block; }
#mPreview .btn { position: absolute; right: -8px; bottom: 6px; }
.mname .money { color: var(--coral-2); }
.mname { font-family: var(--display); font-size: 22px; text-align: center; display: flex; align-items: center; justify-content: center; gap: 8px; min-height: 30px; }
.sheet h3 { font-family: var(--display); font-size: 18px; margin: 0 0 10px; } .sheet h3 small { font: 600 12px var(--text); color: var(--ink-2); margin-left: 6px; }
.grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 18px; }
.grid.props { grid-template-columns: repeat(5, 1fr); }
.tile { position: relative; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 10px 6px 8px; border: 2px solid var(--line); background: #fff; border-radius: 16px; cursor: pointer; font-family: var(--text); transition: transform .1s, border-color .1s, background .1s; }
.tile:hover { transform: translateY(-2px); border-color: #f3c9a8; }
.tile.on { border-color: var(--coral); background: #fff3ea; }
.tile.owned { opacity: .55; cursor: default; }
.tile .ico { font-size: 26px; line-height: 1.1; } .tile .lbl { font-weight: 800; font-size: 12px; color: var(--ink); } .tile .sub { font-size: 10px; color: var(--ink-2); } .tile .price { margin-top: 3px; font-weight: 800; font-size: 11px; color: var(--coral-2); }
.tile .qty { position: absolute; top: -7px; right: -5px; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px; background: var(--coral); color: #fff; font: 800 11px/20px var(--text); text-align: center; }
.tile .qty:empty { display: none; }
.tile.owned .qty { background: var(--ink-2); }
.cart { position: sticky; bottom: 0; margin-top: auto; background: var(--paper); border-top: 2px dashed var(--line); padding: 12px 0 14px; box-shadow: 0 -12px 16px -10px rgba(60, 30, 50, .12); }
#mCart { list-style: none; margin: 0 0 8px; padding: 0; font-size: 13px; }
#mCart li { display: flex; justify-content: space-between; padding: 4px 0; } #mCart small { color: var(--ink-2); font-weight: 600; } #mCart .empty { color: var(--ink-2); font-style: italic; }
.total { display: flex; justify-content: space-between; align-items: center; gap: 12px; font-family: var(--display); font-size: 22px; }
.total small { font: 600 12px var(--text); color: var(--ink-2); display: block; }
.cart .fine { margin-top: 8px; }
.prices { margin: -4px 0 10px; min-height: 14px; }

#toast { position: absolute; left: 50%; bottom: 64px; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast { background: var(--paper); color: var(--ink); padding: 12px 18px; border-radius: 999px; font-size: 14px; box-shadow: var(--shadow); opacity: 0; transform: translateY(10px); transition: opacity .3s, transform .3s; }
.toast.in { opacity: 1; transform: none; }

body, #ui { touch-action: manipulation; }
@media (max-width: 720px) {
  .top { padding: 10px 10px; gap: 8px; }
  .brand { font-size: 22px; }
  #find { flex: 1 1 90px; } .pill { padding: 3px 4px 3px 12px; } .pill input { font-size: 13px; } .pill button { width: 28px; height: 28px; font-size: 14px; }
  .btn.primary#new { padding: 11px 13px; font-size: 13px; } #new .long { display: none; }
  .card { position: fixed; left: 10px; right: 10px; bottom: 92px; top: auto; width: auto; transform: none !important; padding: 14px 16px 12px; }
  .card .close { display: block; }
  #mPreview { width: 200px; height: 200px; }
  .sheet .left { padding: 18px 18px 14px; } .sheet .right { padding: 16px 16px 0; }
  .sheet h2 { font-size: 24px; } .sheet .sub { min-height: 0; }
  #stats { font-size: 12px; padding: 7px 12px; white-space: nowrap; } #stats .long { display: none; } #stats .short { display: inline; }
  .sheet { grid-template-columns: 1fr; max-height: 94vh; overflow: auto; }
  .sheet .left { border-right: 0; border-bottom: 1px solid var(--line); }
  .grid { grid-template-columns: repeat(2, 1fr); } .grid.props { grid-template-columns: repeat(3, 1fr); }
  .panel { right: 12px; left: 12px; width: auto; }
  .bottom { padding: 10px 14px; flex-direction: column; gap: 6px; align-items: stretch; } #stats { text-align: center; }
}
