  :root {
    --orange: #c0362c;      /* International Orange, the bridge paint */
    --orange-dark: #8f2219;
    --crab: #e8552f;
    --bay: #1f5f6b;
    --bay-dark: #12303a;
    --fog: #fbf5ea;
    --sand: #f1e3c8;
    --ink: #1c2b30;
    --muted: #6a7a7d;
    --line: #e4d6ba;
    --ok: #2e7d32;
    --display: "Titan One", "Arial Rounded MT Bold", system-ui, sans-serif;
    --body: "Nunito", system-ui, -apple-system, "Segoe UI", sans-serif;
  }
  * { box-sizing: border-box; }
  html { -webkit-text-size-adjust: 100%; }
  body {
    margin: 0;
    background: var(--fog);
    color: var(--ink);
    font: 500 16px/1.4 var(--body);
    padding-bottom: calc(120px + env(safe-area-inset-bottom));
  }
  button, input { font: inherit; color: inherit; }
  h1, h2 { font-family: var(--display); font-weight: 400; margin: 0; letter-spacing: .01em; }

  /* ---------- hero ---------- */
  .hero { position: relative; overflow: hidden; background: #f6b26b; color: #fff; max-width: 640px; margin: 0 auto; }
  @media (min-width: 672px) { .hero { margin-top: 16px; border: 2px solid var(--ink); border-radius: 22px; } }
  .hero svg.scene { display: block; width: 100%; aspect-ratio: 400 / 230; max-height: 300px; }
  .hero .fog { animation: drift 38s linear infinite; }
  .hero .fog.f2 { animation-duration: 55s; animation-direction: reverse; }
  @keyframes drift { from { transform: translateX(-60px); } 50% { transform: translateX(60px); } to { transform: translateX(-60px); } }
  .hero .title {
    position: absolute; left: 0; right: 0; top: 14px; text-align: center; padding: 0 16px;
    text-shadow: 0 2px 0 rgba(143, 34, 25, .55);
  }
  .hero h1 { font-size: clamp(26px, 8vw, 42px); line-height: 1; }
  .hero .sub { font-weight: 800; font-size: 13px; margin-top: 6px; opacity: .95; text-shadow: 0 1px 0 rgba(143,34,25,.5); }
  .hero .crab-hero { position: absolute; right: 6%; bottom: 2px; width: 92px; }
  .crab .claw-r { transform-origin: 92px 44px; animation: wave 1.6s ease-in-out infinite; }
  .crab .eye { animation: blink 4.5s infinite; transform-origin: center; transform-box: fill-box; }
  @keyframes wave { 0%, 100% { transform: rotate(0); } 50% { transform: rotate(-22deg); } }
  @keyframes blink { 0%, 94%, 100% { transform: scaleY(1); } 97% { transform: scaleY(.1); } }

  .ticket {
    margin: -18px 16px 0; position: relative; z-index: 2;
    background: #fff; border: 2px solid var(--ink); border-radius: 18px;
    box-shadow: 0 5px 0 var(--ink);
    padding: 12px 16px; display: flex; align-items: center; gap: 12px;
  }
  .ticket .big { font-family: var(--display); font-size: 30px; color: var(--orange); line-height: 1; }
  .ticket .lead { font-weight: 800; font-size: 14px; line-height: 1.25; }
  .ticket .small { font-size: 13px; color: var(--muted); font-weight: 700; }

  main { max-width: 640px; margin: 0 auto; }
  section { padding: 22px 16px 0; }
  h2 { font-size: 22px; color: var(--bay-dark); display: flex; align-items: center; gap: 8px; }
  h2 .num {
    display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 50%;
    background: var(--orange); color: #fff; font-size: 16px; flex: none;
  }
  .hint { color: var(--muted); font-size: 14px; font-weight: 700; margin: 4px 0 12px; }

  /* ---------- people ---------- */
  .people { display: flex; flex-wrap: wrap; gap: 8px; }
  .person {
    border: 2px solid var(--ink); background: #fff; border-radius: 999px;
    padding: 8px 14px; font-weight: 800; cursor: pointer; min-height: 44px;
    display: inline-flex; align-items: center; gap: 6px;
  }
  .person .dot { width: 10px; height: 10px; border-radius: 50%; }
  .person.on { background: var(--orange); color: #fff; box-shadow: 0 3px 0 var(--orange-dark); border-color: var(--orange-dark); }
  .person.on .dot { background: #fff !important; }
  .person.add { border-style: dashed; color: var(--bay); border-color: var(--bay); }
  form.newname { display: flex; gap: 8px; margin-top: 10px; }
  form.newname[hidden] { display: none; }
  form.newname input {
    flex: 1; min-width: 0; border: 2px solid var(--ink); border-radius: 14px; padding: 10px 14px;
    font-weight: 700; font-size: 16px; background: #fff;
  }
  .btn {
    border: 2px solid var(--ink); border-radius: 14px; background: var(--bay); color: #fff;
    font-family: var(--display); font-size: 18px; padding: 10px 18px; cursor: pointer;
    box-shadow: 0 4px 0 var(--ink); min-height: 48px;
  }
  .btn:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--ink); }
  .btn.primary { background: var(--orange); }
  .btn.ghost { background: #fff; color: var(--ink); }
  .btn[disabled] { opacity: .45; pointer-events: none; }

  /* ---------- menu ---------- */
  .row {
    background: #fff; border: 2px solid var(--line); border-radius: 18px; padding: 12px;
    margin-bottom: 10px;
  }
  .row .head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
  .row .name { font-weight: 800; }
  .row .price { text-align: right; white-space: nowrap; font-weight: 800; color: var(--bay); }
  .row .price small { display: block; font-weight: 700; color: var(--muted); font-size: 12px; }
  .chips { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 8px; margin-top: 10px; }
  .chip {
    min-width: 0; min-height: 48px; border-radius: 14px; cursor: pointer;
    border: 2px dashed #bfae8c; background: var(--fog); color: var(--muted);
    font-weight: 800; font-size: 14px; padding: 6px 8px;
    display: flex; align-items: center; justify-content: center; gap: 6px;
    touch-action: pan-y; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
    transition: transform .12s, background .12s;
    overflow: hidden; white-space: nowrap;
  }
  .chip .who { overflow: hidden; text-overflow: ellipsis; }
  .chip .ico { font-size: 20px; flex: none; }
  .chip.mine {
    border: 2px solid var(--orange-dark); background: var(--orange); color: #fff;
    box-shadow: 0 3px 0 var(--orange-dark); transform: rotate(-1.5deg);
  }
  .chip.mine.unsaved { background: var(--crab); border-style: dashed; }
  .chip.taken { border: 2px solid transparent; color: #fff; cursor: not-allowed; opacity: .92; }
  .chip.lifted { opacity: .25; }
  .ghost-chip {
    position: fixed; z-index: 50; pointer-events: none; left: 0; top: 0;
    transform: translate(-50%, -60%) rotate(-6deg) scale(1.12);
    box-shadow: 0 10px 20px rgba(18, 48, 58, .35) !important;
    width: 120px;
  }

  /* ---------- board ---------- */
  .board { background: #fff; border: 2px solid var(--ink); border-radius: 18px; box-shadow: 0 5px 0 var(--ink); overflow: hidden; }
  .board .line { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-bottom: 2px dashed var(--line); }
  .board .line:last-child { border-bottom: 0; }
  .board .dot { width: 14px; height: 14px; border-radius: 50%; flex: none; }
  .board .n { font-weight: 800; flex: 1; min-width: 0; }
  .board .n small { display: block; color: var(--muted); font-weight: 700; font-size: 12px; }
  .board .amt { font-family: var(--display); font-size: 20px; color: var(--bay-dark); }
  .board .x { border: 0; background: none; color: var(--muted); font-size: 20px; padding: 6px; cursor: pointer; }
  .board .line.rest { background: var(--sand); }
  .board .line.rest.done { background: #dff0d8; }
  .empty { padding: 18px 14px; color: var(--muted); font-weight: 700; text-align: center; }

  footer { text-align: center; color: var(--muted); font-size: 12px; font-weight: 700; padding: 22px 16px 0; }

  /* ---------- tray ---------- */
  .tray {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
    background: var(--bay-dark); color: #fff;
    border-top: 3px solid var(--ink);
    padding: 10px 14px calc(10px + env(safe-area-inset-bottom));
    transition: background .15s;
  }
  .tray::before {
    content: ""; position: absolute; left: 0; right: 0; top: -13px; height: 12px;
    background: radial-gradient(circle at 10px 14px, var(--bay-dark) 10px, transparent 11px) 0 0 / 20px 12px repeat-x;
  }
  .tray[hidden] { display: none; }
  body.no-tray { padding-bottom: calc(24px + env(safe-area-inset-bottom)); }
  .tray .in { max-width: 640px; margin: 0 auto; display: flex; align-items: center; gap: 10px; }
  .tray .crab { width: 58px; flex: none; margin-top: -26px; transition: transform .15s; }
  .tray.hot { background: var(--bay); }
  .tray.hot .crab { transform: scale(1.25) rotate(-8deg); }
  .tray .crab.snap { animation: snap .35s; }
  @keyframes snap { 40% { transform: scale(1.3) rotate(8deg); } }
  .tray .info { flex: 1; min-width: 0; }
  .tray .info .a { font-weight: 800; font-size: 13px; opacity: .8; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .tray .info .b { font-family: var(--display); font-size: 26px; line-height: 1.05; }
  .tray .btn { box-shadow: 0 4px 0 #000; border-color: #000; }

  /* ---------- dialog & toast ---------- */
  dialog {
    border: 3px solid var(--ink); border-radius: 22px; padding: 0; width: min(92vw, 420px);
    box-shadow: 0 8px 0 var(--ink); background: var(--fog); color: var(--ink);
  }
  dialog::backdrop { background: rgba(18, 48, 58, .7); }
  dialog .top { background: var(--orange); color: #fff; text-align: center; padding: 14px 16px 12px; }
  dialog .top .crab { width: 84px; }
  dialog .top h2 { color: #fff; justify-content: center; font-size: 26px; }
  dialog .body { padding: 14px 18px 18px; }
  dialog ul { list-style: none; padding: 0; margin: 0 0 12px; }
  dialog li { display: flex; justify-content: space-between; gap: 12px; padding: 6px 0; border-bottom: 2px dashed var(--line); font-weight: 700; }
  dialog .sumline { display: flex; justify-content: space-between; color: var(--muted); font-size: 13px; font-weight: 700; }
  dialog .pay { margin: 14px 0; background: #fff; border: 2px solid var(--ink); border-radius: 16px; padding: 12px; text-align: center; }
  dialog .pay .lbl { font-weight: 800; }
  dialog .pay .val { font-family: var(--display); font-size: 40px; color: var(--orange); line-height: 1.1; }
  dialog .acts { display: flex; gap: 10px; }
  dialog .acts .btn { flex: 1; }
  .toast {
    position: fixed; left: 50%; bottom: calc(110px + env(safe-area-inset-bottom)); transform: translate(-50%, 20px);
    background: var(--ink); color: #fff; font-weight: 800; padding: 10px 16px; border-radius: 999px;
    opacity: 0; pointer-events: none; transition: .2s; z-index: 60; max-width: 90vw; width: max-content; text-align: center;
  }
  .toast.show { opacity: 1; transform: translate(-50%, 0); }

  @media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation: none !important; transition: none !important; }
  }

/* ---------- shared additions ---------- */
#view { max-width: 640px; margin: 0 auto; }
.btn.small { font-size: 15px; padding: 6px 12px; min-height: 40px; box-shadow: 0 3px 0 var(--ink); }
.btn.wide { width: 100%; margin-top: 12px; }
.btn.danger { background: #fff; color: var(--orange); }
.ticket { justify-content: space-between; }
.badge { display: inline-block; font-size: 12px; font-weight: 800; border-radius: 999px; padding: 2px 9px; background: var(--sand); color: var(--ink); white-space: nowrap; }
.badge.ok { background: #dff0d8; color: var(--ok); }
.iconbtn { border: 2px solid var(--ink); background: #fff; border-radius: 12px; font-size: 20px; width: 44px; height: 44px; cursor: pointer; flex: none; }
.actions { display: flex; gap: 10px; margin-top: 12px; flex-wrap: wrap; }
.actions .btn { flex: 1; }

/* ---------- event view ---------- */
.billcard {
  display: flex; align-items: center; gap: 12px; text-decoration: none; color: inherit;
  background: #fff; border: 2px solid var(--ink); border-radius: 18px; box-shadow: 0 4px 0 var(--ink);
  padding: 12px 14px; margin-bottom: 12px;
}
.billcard .main { flex: 1; min-width: 0; }
.billcard .t { font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.billcard .meta { color: var(--muted); font-size: 13px; font-weight: 700; }
.billcard .mine { margin-top: 4px; font-size: 13px; font-weight: 800; color: var(--bay); }
.billcard .amt { font-family: var(--display); font-size: 20px; color: var(--orange); text-align: right; }
.eventlist a { display: block; }

/* ---------- new bill ---------- */
.form label { display: block; font-weight: 800; font-size: 13px; color: var(--muted); margin-top: 10px; }
.form input {
  display: block; width: 100%; margin-top: 4px; border: 2px solid var(--ink); border-radius: 12px;
  padding: 9px 12px; font-weight: 700; font-size: 16px; background: #fff; color: var(--ink);
}
.form .two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.rowedit {
  display: grid; grid-template-columns: 1fr 52px 84px 52px 40px; gap: 6px; align-items: end;
  background: #fff; border: 2px solid var(--line); border-radius: 14px; padding: 8px; margin-top: 8px;
}
.rowedit label { margin: 0; font-size: 11px; }
.rowedit input { padding: 7px 8px; font-size: 15px; }
.rowedit .del { border: 0; background: none; font-size: 22px; color: var(--muted); cursor: pointer; height: 40px; }
@media (max-width: 420px) { .rowedit { grid-template-columns: 1fr 1fr 1fr 40px; } .rowedit .nm { grid-column: 1 / -1; } }
.warn { background: #fff3cd; border: 2px solid #e0b93a; border-radius: 12px; padding: 8px 12px; margin-top: 10px; font-weight: 700; font-size: 14px; }
.tips { display: flex; gap: 8px; margin-top: 8px; }
.tips .btn { flex: 1; }
.totals { background: #fff; border: 2px solid var(--ink); border-radius: 16px; padding: 12px; margin: 14px 0; }
.totals div { display: flex; justify-content: space-between; font-weight: 700; }
.totals .sum { font-family: var(--display); font-size: 24px; color: var(--orange); margin-top: 6px; }
.photo { display: block; text-align: center; }
.photo input { display: none; }
.btn.disabled { opacity: .45; pointer-events: none; }

/* ---------- receipt viewer ---------- */
#viewer { padding: 0; width: auto; max-width: 96vw; max-height: 92vh; background: #000; }
#viewer img { display: block; max-width: 96vw; max-height: 92vh; }
