/* Potluck — banana leaf + kasavu gold. Gold means "covered". */
:root {
    --leaf-950: #0F2716;
    --leaf-900: #16361F;
    --leaf-700: #23562F;
    --leaf-500: #3F8A4A;
    --leaf-200: #CFE5C6;
    --leaf-100: #E6F1E0;
    --kasavu:   #FBF8F0;
    --gold:     #C8962B;
    --gold-deep:#9A6F14;
    --gold-soft:#F4E6BD;
    --ink:      #1D2A20;
    --ink-soft: #55655A;
    --chili:    #B3402A;

    --display: "Baloo Chettan 2", "Trebuchet MS", system-ui, sans-serif;
    --body: "Atkinson Hyperlegible", "Segoe UI", system-ui, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }

/* ============================================================
   PHONE SIGN-UP PAGE
   ============================================================ */
body.signup {
    margin: 0;
    background: var(--kasavu);
    color: var(--ink);
    font: 400 17px/1.5 var(--body);
    -webkit-font-smoothing: antialiased;
    padding-bottom: env(safe-area-inset-bottom, 0px);
}

.su-head {
    background: var(--leaf-900);
    color: var(--kasavu);
    padding: calc(1.4rem + env(safe-area-inset-top, 0px)) 1.25rem 1.3rem;
    /* kasavu border: gold band with a thin second stripe */
    border-bottom: 6px solid var(--gold);
    box-shadow: 0 3px 0 var(--kasavu), 0 5px 0 var(--gold);
    margin-bottom: 5px;
}
.su-head h1 {
    font: 800 2rem/1.05 var(--display);
    margin: 0;
    letter-spacing: -0.01em;
}
.su-head p { margin: .35rem 0 0; color: var(--leaf-200); }

.su-main { max-width: 36rem; margin: 0 auto; padding: 1.25rem 1rem 3rem; }

.su-banner {
    background: var(--gold-soft);
    border-left: 5px solid var(--gold);
    padding: .8rem 1rem;
    border-radius: 6px;
    margin-bottom: 1rem;
}

.su-mine {
    background: var(--leaf-900);
    color: var(--kasavu);
    border-radius: 14px;
    padding: 1rem 1.1rem;
    margin-bottom: 1.25rem;
    border: 2px solid var(--gold);
}
.su-mine[hidden] { display: none; }
.su-mine h2 { font: 700 1rem/1.2 var(--body); margin: 0 0 .25rem; color: var(--gold-soft); }
.su-mine ul { list-style: none; margin: 0; padding: 0; }
.su-mine li { display: flex; align-items: center; justify-content: space-between; gap: .75rem; padding: .2rem 0; }
.su-mine .mine-dish { font: 800 1.6rem/1.1 var(--display); }
.su-mine .mine-help { margin: .5rem 0 0; font-size: .9rem; color: var(--leaf-200); }

.btn-text {
    background: none; border: 0; color: var(--gold-soft);
    font: 700 .95rem var(--body); text-decoration: underline; text-underline-offset: 3px;
    padding: .4rem .2rem; cursor: pointer;
}

.su-name label { display: block; font-weight: 700; margin-bottom: .35rem; }
.su-name input {
    width: 100%;
    font: 400 1.15rem var(--body);
    padding: .8rem .9rem;
    border: 2px solid var(--leaf-200);
    border-radius: 10px;
    background: #fff;
    color: var(--ink);
}
.su-name input:focus { outline: none; border-color: var(--leaf-500); box-shadow: 0 0 0 4px rgba(63,138,74,.18); }
.su-name .hint { min-height: 1.4em; margin: .3rem 0 0; font-size: .92rem; color: var(--chili); font-weight: 700; }
.su-name.shake input { animation: shake .4s; border-color: var(--chili); }

.su-cat { margin-top: 1.4rem; }
.su-cat h2 {
    font: 700 1.25rem/1.2 var(--display);
    color: var(--leaf-700);
    margin: 0 0 .5rem;
}
.dish-list { display: grid; gap: .55rem; }

.dish {
    display: grid;
    grid-template-columns: 1fr auto;
    grid-template-areas: "name left" "slots slots";
    gap: .45rem .75rem;
    align-items: center;
    width: 100%;
    text-align: left;
    background: #fff;
    border: 2px solid var(--leaf-200);
    border-radius: 12px;
    padding: .85rem 1rem;
    color: var(--ink);
    font: inherit;
    cursor: pointer;
    transition: border-color .15s, transform .1s;
}
.dish:active { transform: scale(.985); }
.dish:focus-visible { outline: 3px solid var(--leaf-500); outline-offset: 2px; }
.dish-name { grid-area: name; font: 700 1.2rem/1.2 var(--display); }
.dish-left { grid-area: left; font-weight: 700; color: var(--leaf-700); white-space: nowrap; }
.dish-slots { grid-area: slots; display: flex; gap: 5px; }
.dish-slots i {
    flex: 1; height: 7px; border-radius: 4px;
    background: var(--leaf-100);
    box-shadow: inset 0 0 0 1px var(--leaf-200);
}
.dish-slots i.on { background: var(--leaf-500); box-shadow: none; }

.dish.is-full { background: var(--kasavu); border-color: var(--gold-soft); cursor: default; }
.dish.is-full .dish-name { color: var(--ink-soft); }
.dish.is-full .dish-left { color: var(--gold-deep); }
.dish.is-full .dish-slots i.on { background: var(--gold); }

.dish.is-mine { border-color: var(--gold); background: var(--gold-soft); }
.dish.is-mine .dish-left { color: var(--gold-deep); }

.dish.just-filled { animation: filledFlash 1.1s ease-out; }
.dish.shake { animation: shake .45s; }

body.is-closed .dish:not(.is-mine) { cursor: default; }

/* Waiting + countdown */
.su-ready {
    background: var(--leaf-100);
    border: 2px solid var(--leaf-500);
    border-radius: 12px;
    padding: .9rem 1rem;
    margin-bottom: 1.1rem;
}
.su-ready[hidden] { display: none; }
.su-ready strong { display: block; font: 800 1.4rem/1.1 var(--display); color: var(--leaf-700); margin-bottom: .2rem; }

.su-count {
    position: sticky; top: 0; z-index: 15;
    display: flex; align-items: center; justify-content: center; gap: .9rem;
    background: var(--gold);
    color: var(--leaf-950);
    padding: .55rem 1rem;
    box-shadow: 0 4px 14px rgba(15,39,22,.25);
}
.su-count[hidden] { display: none; }
.cd-label { font-weight: 700; }
.cd-num { font: 800 2.6rem/1 var(--display); min-width: 2ch; text-align: center; font-variant-numeric: tabular-nums; }
.cd-num.tick { animation: cdTick .35s ease-out; }
.su-count.go { background: var(--leaf-500); color: #fff; }
.su-count.go .cd-num { animation: cdTick .5s ease-out; }

body.is-locked .dish:not(.is-full):not(.is-mine) { border-style: dashed; }
body.is-locked .dish .dish-left { color: var(--ink-soft); }
body.go-flash .dish:not(.is-full) { animation: goFlash .7s ease-out; }

/* Confirm sheet */
.sheet {
    position: fixed; inset: 0; z-index: 20;
    background: rgba(15, 39, 22, .55);
    display: flex; align-items: flex-end; justify-content: center;
    animation: fadeIn .15s ease-out;
}
.sheet[hidden] { display: none; }
.sheet-card {
    width: 100%; max-width: 36rem;
    background: var(--kasavu);
    border-radius: 18px 18px 0 0;
    border-top: 6px solid var(--gold);
    padding: 1.4rem 1.25rem calc(1.25rem + env(safe-area-inset-bottom, 0px));
    animation: sheetUp .22s cubic-bezier(.2,.9,.3,1.1);
}
.sheet-card h2 { font: 800 1.7rem/1.1 var(--display); margin: 0 0 .4rem; }
.sheet-card p { margin: 0 0 .5rem; color: var(--ink-soft); }
.sheet-error { color: var(--chili) !important; font-weight: 700; min-height: 1.2em; }
.sheet-actions { display: flex; gap: .75rem; margin-top: 1rem; }
.sheet-actions button { flex: 1; }

.btn-primary, .btn-ghost {
    font: 700 1.05rem var(--body);
    padding: .95rem 1rem;
    border-radius: 12px;
    cursor: pointer;
    border: 2px solid var(--leaf-900);
}
.btn-primary { background: var(--leaf-900); color: var(--kasavu); }
.btn-primary:disabled { opacity: .6; cursor: progress; }
.btn-ghost { background: transparent; color: var(--leaf-900); }
.btn-primary:focus-visible, .btn-ghost:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }

/* Success */
.done {
    position: fixed; inset: 0; z-index: 30;
    background: var(--leaf-900);
    color: var(--kasavu);
    display: flex; align-items: center; justify-content: center;
    text-align: center; padding: 2rem;
    overflow: hidden;
    animation: fadeIn .2s ease-out;
}
.done[hidden] { display: none; }
.done-card { position: relative; z-index: 1; max-width: 22rem; }
.done-check { width: 112px; height: 112px; margin: 0 auto 1rem; display: block; }
.done-check circle { fill: none; stroke: var(--gold); stroke-width: 3; stroke-dasharray: 152; stroke-dashoffset: 152; animation: draw .6s .1s ease-out forwards; }
.done-check path { fill: none; stroke: var(--kasavu); stroke-width: 4; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 40; stroke-dashoffset: 40; animation: draw .35s .6s ease-out forwards; }
.done h2 { font: 800 2.1rem/1.1 var(--display); margin: 0 0 .4rem; }
.done p { color: var(--leaf-200); margin: 0 0 1.6rem; }
.done .btn-primary { background: var(--gold); border-color: var(--gold); color: var(--leaf-950); min-width: 10rem; }

.burst { position: absolute; left: 50%; top: 42%; width: 0; height: 0; }
.burst span {
    position: absolute; width: 10px; height: 16px; border-radius: 50% 50% 50% 0;
    background: var(--gold);
    opacity: 0;
    animation: burst 1.1s cubic-bezier(.15,.7,.3,1) forwards;
}
.burst span:nth-child(3n) { background: var(--leaf-200); }
.burst span:nth-child(4n) { background: var(--kasavu); }

.toast {
    position: fixed; left: 50%; bottom: calc(1rem + env(safe-area-inset-bottom, 0px));
    transform: translateX(-50%);
    background: var(--ink); color: #fff;
    padding: .75rem 1.1rem; border-radius: 10px;
    max-width: calc(100% - 2rem);
    z-index: 40; font-weight: 700;
    animation: sheetUp .2s ease-out;
}
.toast[hidden] { display: none; }

/* ============================================================
   PROJECTOR BOARD
   ============================================================ */
html.is-board { font-size: clamp(12px, min(0.85vw, 1.55vh), 26px); height: 100%; }
body.board {
    margin: 0;
    height: 100%;
    overflow: hidden;
    color: var(--kasavu);
    font-family: var(--body);
    background:
        radial-gradient(ellipse 70% 60% at 50% 45%, rgba(63,138,74,.28), transparent 70%),
        repeating-linear-gradient(108deg, rgba(255,255,255,.028) 0 2px, transparent 2px 3.2rem),
        linear-gradient(160deg, var(--leaf-900), var(--leaf-950));
    display: grid;
    grid-template-rows: auto 1fr auto;
}

.board-head {
    display: grid;
    grid-template-columns: 1fr auto auto;
    align-items: center;
    gap: 2.5rem;
    padding: 1.4rem 2.2rem 1.2rem;
    border-bottom: .35rem solid var(--gold);
    box-shadow: 0 .25rem 0 var(--leaf-900), 0 .45rem 0 var(--gold);
    margin-bottom: .45rem;
}
.board-head h1 { font: 800 3.6rem/1 var(--display); margin: 0; letter-spacing: -0.015em; }
.board-head p { margin: .3rem 0 0; font-size: 1.35rem; color: var(--leaf-200); }

.board-progress { min-width: 22rem; }
.prog-num { font-size: 1.3rem; color: var(--leaf-200); margin-bottom: .5rem; }
.prog-num strong { font: 800 3.2rem/1 var(--display); color: var(--kasavu); margin-right: .35rem; font-variant-numeric: tabular-nums; }
.prog-bar { height: .9rem; background: rgba(255,255,255,.12); border-radius: 1rem; overflow: hidden; }
.prog-bar span { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--gold-deep), var(--gold)); border-radius: 1rem; transition: width .9s cubic-bezier(.3,.9,.3,1); }

.board-qr { display: flex; align-items: center; gap: 1rem; }
.board-qr .qr-box { background: var(--kasavu); padding: .5rem; border-radius: .6rem; line-height: 0; }
.board-qr .qr-box img, .board-qr .qr-box canvas { width: 8.5rem !important; height: 8.5rem !important; }
.board-qr p { margin: 0; font: 700 1.35rem/1.25 var(--body); max-width: 12rem; }
.board-qr .qr-url { display: block; font-weight: 400; font-size: .95rem; color: var(--leaf-200); margin-top: .3rem; word-break: break-all; }

.board-cols {
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: 1fr;
    gap: 1.4rem;
    padding: 1.2rem 2.2rem;
    min-height: 0;
}
.b-col { display: flex; flex-direction: column; gap: .8rem; min-height: 0; }
.b-col h2 { font: 700 1.5rem/1 var(--display); margin: 0 0 .1rem; color: var(--gold-soft); }

.tile {
    position: relative;
    background: var(--kasavu);
    color: var(--ink);
    border-radius: .8rem;
    padding: .8rem 1rem .9rem;
    border: .2rem solid transparent;
    transition: background .5s, border-color .5s;
}
.tile-top { display: flex; justify-content: space-between; align-items: baseline; gap: .75rem; margin-bottom: .55rem; }
.tile-name { font: 800 1.75rem/1.05 var(--display); }
.tile-left { font: 700 1.2rem/1 var(--body); color: var(--leaf-700); white-space: nowrap; }
.tile-left strong { font: 800 1.9rem/1 var(--display); margin-right: .2rem; }

.pills { display: grid; grid-template-columns: 1fr 1fr; gap: .4rem; }
.pill {
    height: 2.5rem;
    display: flex; align-items: center;
    padding: 0 .75rem;
    border-radius: 1.25rem;
    font: 700 1.1rem/1 var(--body);
    overflow: hidden; white-space: nowrap; text-overflow: ellipsis;
    min-width: 0;
}
.pill > span { overflow: hidden; text-overflow: ellipsis; }
.pill.open { border: .14rem dashed var(--leaf-500); color: var(--leaf-500); font-weight: 400; }
.pill.taken { background: var(--leaf-700); color: var(--kasavu); }

.tile.is-full { background: var(--gold-soft); border-color: var(--gold); }
.tile.is-full .tile-name { color: var(--leaf-950); }
.tile.is-full .tile-left { color: var(--gold-deep); }
.tile.is-full .pill.taken { background: var(--gold); color: var(--leaf-950); }

.tile.pulse { animation: tilePulse 1.3s ease-out; }
.pill.pop { animation: pillPop .75s cubic-bezier(.2,1.4,.4,1); }
.pill.drop { animation: pillDrop .5s ease-out; }
.tile.stamp { animation: stamp .9s cubic-bezier(.2,1.2,.4,1); }

.board-feed {
    display: flex; align-items: center; gap: 1.2rem;
    padding: .9rem 2.2rem 1.1rem;
    background: rgba(0,0,0,.18);
    font-size: 1.25rem;
    overflow: hidden;
}
.feed-label { color: var(--gold-soft); font-weight: 700; flex: none; }
.board-feed ol { -webkit-mask-image: linear-gradient(90deg,#000 85%,transparent); mask-image: linear-gradient(90deg,#000 85%,transparent); list-style: none; margin: 0; padding: 0; display: flex; gap: 2.2rem; overflow: hidden; white-space: nowrap; flex: 1; }
.board-feed li { flex: none; color: var(--leaf-200); }
.board-feed li b { color: var(--kasavu); }
.board-feed li.new { animation: feedIn .6s cubic-bezier(.2,.9,.3,1); }
.board-feed li.new b { color: var(--gold); }
.conn { flex: none; color: var(--gold); font-weight: 700; }
.conn[hidden] { display: none; }

.callout {
    position: fixed; left: 50%; top: 50%;
    transform: translate(-50%, -50%) scale(.8);
    background: var(--leaf-950);
    color: var(--kasavu);
    border: .35rem solid var(--gold);
    border-radius: 1.2rem;
    padding: 1.6rem 3rem;
    text-align: center;
    box-shadow: 0 2rem 5rem rgba(0,0,0,.55);
    opacity: 0; pointer-events: none;
    z-index: 10;
}
.callout.show { animation: callout 2.4s ease-in-out forwards; }
.callout .c-dish { font: 800 4.4rem/1 var(--display); color: var(--gold); display: block; }
.callout .c-line { font-size: 1.8rem; display: block; margin-top: .4rem; }

.confetti { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 11; }
.confetti span {
    position: absolute; top: -3rem;
    width: 1.1rem; height: 1.7rem;
    border-radius: 50% 50% 50% 0;
    animation: fall linear forwards;
}

/* Board: waiting / countdown stage */
.stage {
    position: fixed; inset: 0; z-index: 9;
    display: grid; place-items: center;
    background: rgba(10, 28, 15, .88);
    backdrop-filter: blur(3px);
    text-align: center;
    transition: opacity .5s;
}
.stage[hidden] { display: none; }
.stage.leaving { opacity: 0; }
.stage-inner { display: flex; align-items: center; gap: 4rem; }
.stage .qr-big { background: var(--kasavu); padding: 1rem; border-radius: 1rem; line-height: 0; }
.stage .qr-big img, .stage .qr-big canvas { width: 26rem !important; height: 26rem !important; }
.stage-copy { text-align: left; max-width: 34rem; }
.stage-copy h2 { font: 800 5rem/1 var(--display); margin: 0 0 1.2rem; color: var(--kasavu); }
.stage-copy ol { margin: 0; padding-left: 2.2rem; font-size: 2rem; line-height: 1.5; color: var(--leaf-200); }
.stage-copy ol li::marker { color: var(--gold); font-weight: 700; }
.stage-copy .stage-url { margin-top: 1.4rem; font-size: 1.4rem; color: var(--gold-soft); word-break: break-all; }

.stage-count { display: none; flex-direction: column; align-items: center; }
.stage.counting .stage-inner { display: none; }
.stage.counting .stage-count { display: flex; }
.stage-count .sc-label { font-size: 2.4rem; color: var(--leaf-200); margin-bottom: 1rem; }
.stage-count .sc-num {
    font: 800 22rem/1 var(--display); color: var(--gold);
    font-variant-numeric: tabular-nums;
    text-shadow: 0 .5rem 3rem rgba(200,150,43,.35);
}
.stage-count .sc-num.tick { animation: bigTick .9s ease-out; }
.stage-count .sc-num.go { color: var(--kasavu); animation: goPop 1.2s cubic-bezier(.2,1.3,.4,1); }
.feed-label.closed { color: #F2A28F; }

/* ============================================================
   KEYFRAMES
   ============================================================ */
@keyframes shake { 20%,60% { transform: translateX(-6px); } 40%,80% { transform: translateX(6px); } }
@keyframes fadeIn { from { opacity: 0; } }
@keyframes sheetUp { from { transform: translateY(40px); opacity: 0; } }
@keyframes draw { to { stroke-dashoffset: 0; } }
@keyframes burst {
    0% { opacity: 1; transform: translate(0,0) rotate(0) scale(.6); }
    100% { opacity: 0; transform: translate(var(--dx), var(--dy)) rotate(var(--rot)) scale(1); }
}
@keyframes filledFlash { 0% { background: var(--gold); } 100% { background: var(--kasavu); } }
@keyframes tilePulse {
    0% { box-shadow: 0 0 0 0 rgba(200,150,43,.9); }
    100% { box-shadow: 0 0 0 1.4rem rgba(200,150,43,0); }
}
@keyframes pillPop {
    0% { transform: scale(.4); background: var(--gold); }
    60% { transform: scale(1.08); background: var(--gold); }
    100% { transform: scale(1); }
}
@keyframes pillDrop { 0% { transform: scale(1.05); opacity: .3; } 100% { transform: scale(1); opacity: 1; } }
@keyframes stamp {
    0% { transform: scale(1); }
    30% { transform: scale(1.06) rotate(-.6deg); background: var(--gold); }
    100% { transform: scale(1); }
}
@keyframes feedIn { from { transform: translateX(-2rem); opacity: 0; } }
@keyframes callout {
    0% { opacity: 0; transform: translate(-50%,-50%) scale(.8); }
    12% { opacity: 1; transform: translate(-50%,-50%) scale(1.03); }
    18%, 82% { opacity: 1; transform: translate(-50%,-50%) scale(1); }
    100% { opacity: 0; transform: translate(-50%,-50%) scale(.96); }
}
@keyframes cdTick { 0% { transform: scale(1.35); } 100% { transform: scale(1); } }
@keyframes goFlash { 0% { border-color: var(--leaf-500); box-shadow: 0 0 0 6px rgba(63,138,74,.35); } 100% { box-shadow: 0 0 0 0 rgba(63,138,74,0); } }
@keyframes bigTick { 0% { transform: scale(1.25); opacity: .3; } 25% { opacity: 1; } 100% { transform: scale(.92); opacity: .85; } }
@keyframes goPop { 0% { transform: scale(.4); opacity: 0; } 60% { transform: scale(1.1); opacity: 1; } 100% { transform: scale(1); } }
@keyframes fall { to { transform: translate(var(--drift), 110vh) rotate(var(--rot)); } }

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
    .callout.show { animation: none; opacity: 1; transform: translate(-50%,-50%); }
}
