/* ============ Buffet Buster — diner-arcade theme ============ */
@font-face {
  font-family: "Lilita One";
  src: url("/static/fonts/lilita_one.ttf") format("truetype");
  font-weight: 400;
  font-display: swap;
}

:root {
  --tomato: #EF5A3A;
  --gold: #FFC24B;
  --teal: #2FB6A8;
  --cream: #FBE9D6;
  --cream-text: #FBF3E4;
  --tan: #CBB99F;
  --espresso: #241A12;
  --surface: #34271B;
  --surface-hi: #43331F;
  --border: #553F28;
  --profit: #3DDC84;
  --deficit: #EF5A3A;
  --on-accent: #2A0E07;

  --shadow: 0 6px 0 rgba(0,0,0,0.35);
  --radius: 18px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background: var(--espresso);
  color: var(--cream-text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  overscroll-behavior-y: contain;
}

body {
  background-image: linear-gradient(rgba(36,26,18,0.72), rgba(36,26,18,0.86)), url("/static/img/bg.jpg");
  background-size: cover;
  background-position: center;
  background-attachment: fixed;
}

.display { font-family: "Lilita One", "Arial Black", sans-serif; letter-spacing: 0.5px; }
.hidden { display: none !important; }

.app {
  max-width: 520px;
  margin: 0 auto;
  padding: 14px 14px calc(28px + env(safe-area-inset-bottom));
  min-height: 100vh;
}

/* ---------- buttons ---------- */
button { font-family: inherit; cursor: pointer; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: none; border-radius: 14px;
  font-family: "Lilita One", sans-serif; font-size: 19px; letter-spacing: 0.5px;
  padding: 15px 18px; width: 100%;
  color: var(--on-accent); background: var(--gold);
  box-shadow: 0 5px 0 rgba(0,0,0,0.32); transition: transform .05s, box-shadow .05s;
}
.btn:active { transform: translateY(4px); box-shadow: 0 1px 0 rgba(0,0,0,0.32); }
.btn.primary { background: var(--tomato); color: #fff; }
.btn.teal { background: var(--teal); color: #08312d; }
.btn.ghost { background: var(--surface-hi); color: var(--cream-text); box-shadow: 0 5px 0 rgba(0,0,0,0.28); }
.btn.small { width: auto; font-size: 15px; padding: 9px 14px; }
.btn:disabled { opacity: .55; }

.linkbtn {
  background: none; border: none; color: var(--tan); font-size: 14px;
  text-decoration: underline; padding: 6px;
}

/* ---------- cards ---------- */
.card {
  background: var(--surface);
  border: 3px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
}

/* ---------- sign in ---------- */
.signin-wrap { min-height: 82vh; display: flex; align-items: center; justify-content: center; }
.signin { text-align: center; width: 100%; max-width: 400px; }
.signin .icon { width: 96px; height: 96px; border-radius: 22px; box-shadow: var(--shadow); margin-bottom: 14px; }
.wordmark { font-size: 40px; line-height: 1; color: var(--gold); margin: 4px 0; text-shadow: 3px 3px 0 var(--on-accent); }
.slogan { color: var(--tomato); font-weight: 800; font-size: 16px; margin-bottom: 20px; }
.field {
  width: 100%; padding: 15px; font-size: 17px; border-radius: 12px;
  border: 3px solid var(--border); background: #2b2014; color: var(--cream-text);
  margin-bottom: 12px; text-align: center;
}
.field:focus { outline: none; border-color: var(--gold); }
.notice { margin-top: 14px; color: var(--profit); font-weight: 700; min-height: 22px; }
.notice.err { color: var(--tomato); }

/* ---------- top bar ---------- */
.topbar { display: flex; align-items: center; gap: 8px; margin-bottom: 14px; }
.topbar .brand { display: flex; align-items: center; gap: 8px; flex: 1; }
.topbar .brand img { width: 34px; height: 34px; border-radius: 9px; }
.topbar .brand .name { font-size: 22px; color: var(--gold); }

/* ---------- venue chip ---------- */
.chip {
  display: flex; align-items: center; gap: 8px; width: 100%;
  background: var(--surface-hi); border: 3px solid var(--border);
  border-radius: 14px; padding: 12px 14px; margin-bottom: 14px;
  color: var(--cream-text); text-align: left;
}
.chip .venue-name { flex: 1; font-family: "Lilita One", sans-serif; font-size: 17px; }
.chip .venue-price { color: var(--gold); font-family: "Lilita One", sans-serif; }
.chip .edit-hint { color: var(--tan); font-size: 13px; }

/* ---------- scoreboard ---------- */
.scoreboard { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; margin-bottom: 16px; }
.scorecell {
  background: var(--surface); border: 3px solid var(--border); border-radius: 14px;
  padding: 12px 6px; text-align: center; overflow: hidden;
}
.scorecell .label { font-size: 12px; letter-spacing: 1px; color: var(--tan); font-weight: 800; }
.scorecell .value {
  font-family: "Lilita One", sans-serif; font-size: 30px; line-height: 1.05; margin-top: 4px;
  white-space: nowrap;
}
.scorecell.door .value { color: var(--cream-text); }
.scorecell.food .value { color: var(--gold); }
.scorecell.net.up .value { color: var(--profit); }
.scorecell.net.down .value { color: var(--deficit); }
.scorecell.net.up .label { color: var(--profit); }
.scorecell.net.down .label { color: var(--deficit); }

.beaten-banner {
  text-align: center; font-family: "Lilita One", sans-serif; font-size: 20px;
  color: var(--espresso); background: var(--profit); border-radius: 12px;
  padding: 10px; margin-bottom: 14px;
}

/* banked banner (no price set) */
.banked {
  text-align: center; background: var(--surface); border: 3px solid var(--border);
  border-radius: 14px; padding: 14px; margin-bottom: 10px;
}
.banked .label { color: var(--tan); font-size: 13px; letter-spacing: 1px; font-weight: 800; }
.banked .value { font-family: "Lilita One", sans-serif; font-size: 40px; color: var(--gold); }
.setprice-cta {
  display: block; width: 100%; text-align: center; margin-bottom: 16px;
  background: var(--teal); color: #08312d; border: none; border-radius: 12px;
  padding: 13px; font-weight: 800; font-size: 15px;
  animation: pulse 1.6s ease-in-out infinite;
}
@keyframes pulse { 0%,100%{ transform: scale(1); opacity: .92;} 50%{ transform: scale(1.03); opacity: 1;} }

/* ---------- action buttons ---------- */
.actions { display: grid; gap: 10px; margin-bottom: 18px; }
.snap-plate { font-size: 24px; padding: 20px; }

/* ---------- plates strip ---------- */
.section-title { font-family: "Lilita One", sans-serif; font-size: 16px; color: var(--cream-text); margin: 6px 0 8px; }
.strip { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 6px; }
.strip .thumb {
  flex: 0 0 auto; width: 78px; height: 78px; border-radius: 12px; overflow: hidden;
  border: 3px solid var(--border); background: var(--surface); position: relative; padding: 0;
}
.strip .thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.strip .thumb .badge {
  position: absolute; bottom: 0; left: 0; right: 0; background: rgba(0,0,0,0.6);
  color: var(--gold); font-family: "Lilita One", sans-serif; font-size: 12px; text-align: center; padding: 1px 0;
}

/* ---------- haul list ---------- */
.haul { margin-top: 14px; }
.haul .row {
  display: flex; align-items: center; gap: 10px; padding: 11px 12px;
  background: var(--surface); border: 2px solid var(--border); border-radius: 12px; margin-bottom: 7px;
}
.haul .row .n { flex: 1; min-width: 0; }
.haul .row .n .nm { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.haul .row .n .po { font-size: 12px; color: var(--tan); }
.haul .row .v { font-family: "Lilita One", sans-serif; color: var(--gold); font-size: 18px; white-space: nowrap; }
.empty { color: var(--tan); text-align: center; padding: 20px 6px; }

/* ---------- capture ---------- */
.capture { text-align: center; }
.preview-box {
  width: 100%; aspect-ratio: 1/1; border-radius: 16px; overflow: hidden; background: var(--surface);
  border: 3px dashed var(--border); display: flex; align-items: center; justify-content: center;
  margin: 12px 0; position: relative;
}
.preview-box img { width: 100%; height: 100%; object-fit: cover; }
.preview-box .placeholder { color: var(--tan); padding: 20px; }
.hidden-file { display: none; }

/* ---------- item result list (after analyze) ---------- */
.result-total { font-family: "Lilita One", sans-serif; font-size: 30px; color: var(--gold); text-align: center; margin: 10px 0; }
.quip { text-align: center; font-style: italic; color: var(--teal); margin-bottom: 10px; }
.highlights { margin: 10px 0; }
.highlights .h { background: var(--surface-hi); border-left: 4px solid var(--gold); padding: 8px 10px; border-radius: 8px; margin-bottom: 6px; }
.scout-kind { text-align: center; color: var(--tan); font-size: 13px; letter-spacing: 1px; margin-bottom: 8px; }

/* ---------- spinner ---------- */
.spinner-wrap { text-align: center; padding: 30px 0; }
.robot { width: 120px; height: 120px; animation: bob 1.2s ease-in-out infinite; }
@keyframes bob { 0%,100%{ transform: translateY(0);} 50%{ transform: translateY(-10px);} }
.spinner-text { font-family: "Lilita One", sans-serif; color: var(--gold); margin-top: 8px; font-size: 18px; }

/* ---------- modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,0.7); display: flex; align-items: center;
  justify-content: center; padding: 20px; z-index: 60;
}
.modal { width: 100%; max-width: 400px; }
.modal h2 { font-family: "Lilita One", sans-serif; color: var(--gold); margin: 0 0 14px; text-align: center; }
.modal label { display: block; font-size: 13px; color: var(--tan); margin: 8px 0 4px; font-weight: 700; }
.modal .row2 { display: flex; gap: 8px; margin-top: 14px; }

/* ---------- image viewer ---------- */
.viewer {
  position: fixed; inset: 0; background: rgba(0,0,0,0.92); z-index: 80;
  display: flex; align-items: center; justify-content: center; padding: 12px;
}
.viewer img { max-width: 100%; max-height: 90vh; border-radius: 12px; }
.viewer-close {
  position: absolute; top: calc(14px + env(safe-area-inset-top)); right: 16px; background: var(--surface);
  color: var(--cream-text); border: 2px solid var(--border); border-radius: 50%;
  width: 44px; height: 44px; font-size: 18px;
}

/* ---------- fx layer (floating money / yum words / confetti) ---------- */
.fx-layer { position: fixed; inset: 0; pointer-events: none; z-index: 70; overflow: hidden; }
.fx-float {
  position: absolute; font-family: "Lilita One", sans-serif; font-size: 30px;
  animation: floatUp 1.5s ease-out forwards; will-change: transform, opacity;
}
@keyframes floatUp {
  0% { transform: translateY(0) scale(0.7); opacity: 0; }
  15% { opacity: 1; transform: translateY(-10px) scale(1.1); }
  100% { transform: translateY(-160px) scale(1); opacity: 0; }
}
.fx-confetti {
  position: absolute; width: 10px; height: 14px; top: -20px; border-radius: 2px;
  animation: confettiFall 2.2s linear forwards;
}
@keyframes confettiFall {
  0% { transform: translateY(-20px) rotate(0deg); opacity: 1; }
  100% { transform: translateY(105vh) rotate(720deg); opacity: 0.9; }
}
.pop { animation: popScale .4s ease; }
@keyframes popScale { 0%{ transform: scale(1);} 40%{ transform: scale(1.35);} 100%{ transform: scale(1);} }

/* ---------- admin ---------- */
.admin-card { margin-bottom: 14px; }
.admin-list .row { display: flex; align-items: center; gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--border); }
.admin-list .row .em { flex: 1; word-break: break-all; }
.admin-list .row .tag { font-size: 11px; background: var(--tomato); color:#fff; padding: 2px 6px; border-radius: 6px; }

/* ---------- admin dashboards ---------- */
.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.statcell {
  background: var(--surface-hi); border: 2px solid var(--border); border-radius: 12px;
  padding: 10px 8px; text-align: center; overflow: hidden;
}
.statcell .s-label { font-size: 11px; letter-spacing: 1px; color: var(--tan); font-weight: 800; }
.statcell .s-value {
  font-family: "Lilita One", sans-serif; font-size: 22px; color: var(--gold);
  margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* per-day bars */
.bars { display: flex; flex-direction: column; gap: 5px; }
.bar-row { display: flex; align-items: center; gap: 8px; font-size: 12px; }
.bar-row .bar-day { width: 44px; color: var(--tan); flex: 0 0 auto; }
.bar-row .bar-track { flex: 1; height: 12px; background: var(--surface-hi); border-radius: 6px; overflow: hidden; }
.bar-row .bar-fill { display: block; height: 100%; background: var(--teal); border-radius: 6px; }
.bar-row .bar-val { width: 62px; text-align: right; color: var(--gold); flex: 0 0 auto; font-family: "Lilita One", sans-serif; }

/* mini tables (recent calls / errors) */
.mini-table { display: flex; flex-direction: column; }
.mt-head, .mt-row {
  display: grid; grid-template-columns: 58px 52px 1fr 40px 62px; gap: 6px;
  align-items: center; font-size: 12px; padding: 6px 0; border-bottom: 1px solid var(--border);
}
.mt-head { color: var(--tan); font-weight: 800; letter-spacing: .5px; }
.mt-row .r, .mt-head .r { text-align: right; }
.mt-row .r { color: var(--gold); font-family: "Lilita One", sans-serif; }
.mt-row .ell { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.err-row { display: grid; grid-template-columns: 58px 84px 1fr; gap: 6px; font-size: 12px; padding: 6px 0; border-bottom: 1px solid var(--border); }
.err-row .err-ts { color: var(--tan); }
.err-row .err-type { color: var(--tomato); font-weight: 700; }
.err-row .err-detail { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--cream-text); }

/* ---- Add-to-Home-Screen install banner ---- */
.install-banner {
  position: fixed; left: 12px; right: 12px; bottom: 12px; z-index: 9999;
  display: flex; align-items: center; gap: 10px;
  background: #34271B; border: 2px solid #EF5A3A; border-radius: 14px;
  padding: 10px 12px; box-shadow: 0 6px 24px rgba(0,0,0,.45);
  animation: ib-rise .25s ease-out;
}
@keyframes ib-rise { from { transform: translateY(20px); opacity: 0; } to { transform: none; opacity: 1; } }
.install-banner .ib-text { flex: 1; color: #FBE9D6; font-size: 14px; line-height: 1.3; }
.install-banner .ib-text b { color: #FFC24B; }
.install-banner .ib-go { padding: 8px 16px; font-size: 14px; white-space: nowrap; }
.install-banner .ib-x { background: none; border: none; color: #CBB99F; font-size: 18px; cursor: pointer; padding: 4px 6px; line-height: 1; }
@media (min-width: 560px) { .install-banner { left: auto; right: 16px; max-width: 360px; } }

/* ---- Bug reporter ---- */
.bugreport-link {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(8px + env(safe-area-inset-bottom));
  z-index: 50; background: none; border: none;
  color: var(--tan); font-size: 12px; opacity: 0.45;
  padding: 6px 10px; cursor: pointer; transition: opacity .15s;
}
.bugreport-link:hover { opacity: 1; }
.modal .thanks { text-align: center; color: var(--profit); font-weight: 700; font-size: 17px; padding: 18px 6px; }
textarea.field { text-align: left; resize: vertical; min-height: 90px; font-family: inherit; }
.bug-row { padding: 10px 0; border-bottom: 1px solid var(--border); }
.bug-row .bug-meta { display: flex; gap: 8px; font-size: 12px; margin-bottom: 4px; }
.bug-row .bug-ts { color: var(--tan); }
.bug-row .bug-user { color: var(--gold); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bug-row .bug-msg { color: var(--cream-text); font-size: 14px; line-height: 1.4; white-space: pre-wrap; word-break: break-word; }
.bug-row .bug-path { color: var(--tan); font-size: 11px; margin-top: 3px; word-break: break-all; }

/* ---- How-it-works guide ---- */
.modal.guide { max-width: 440px; }
.guide-steps { list-style: none; margin: 4px 0 18px; padding: 0; text-align: left; }
.guide-steps li {
  display: flex; gap: 12px; align-items: flex-start;
  padding: 10px 0; border-bottom: 1px solid var(--border);
  color: var(--cream); font-size: 14px; line-height: 1.42;
}
.guide-steps li:last-child { border-bottom: none; }
.guide-steps .gi { font-size: 24px; line-height: 1.1; flex: none; width: 30px; text-align: center; }
.guide-steps b { color: var(--gold); }

/* ---- capture size-reference tip + detected-reference tag ---- */
.cap-tip {
  margin: 10px 2px 2px; padding: 9px 12px;
  background: rgba(47,182,168,.12); border: 1px solid var(--teal);
  border-radius: 12px; color: var(--cream); font-size: 13px; line-height: 1.35;
}
.sized {
  display: inline-block; margin-left: 6px; padding: 1px 7px;
  background: rgba(255,194,75,.16); border-radius: 8px;
  color: var(--gold); font-size: 11px; font-weight: 700; white-space: nowrap;
}
