/* Kawaii palette: pastel pink, peach, lavender, cream, midnight purple */
:root {
  --panel-bg: #fff7f0;
  --card: #ffffff;
  --ink: #3d2b4f;
  --muted: #9a86a8;
  --line: #f6e4ec;
  --accent: #ff8fb3;
  --accent2: #ffb98a;
  --lav: #b9a2ff;
  --midnight: #2a1f5c;
  --chip: #fff0f4;
  --fan: #ff8fb3;
  --shadow: 0 10px 30px rgba(61, 43, 79, .12);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --panel-bg: #171236;
    --card: #221b4a;
    --ink: #f6eeff;
    --muted: #b3a5d1;
    --line: #342b66;
    --chip: #2c2459;
    --shadow: 0 10px 30px rgba(0, 0, 0, .35);
  }
}
:root[data-theme="dark"] {
  --panel-bg: #171236; --card: #221b4a; --ink: #f6eeff; --muted: #b3a5d1; --line: #342b66; --chip: #2c2459;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--panel-bg); color: var(--ink); font: 16px/1.6 "IBM Plex Sans Thai", system-ui, sans-serif; }
button { font: inherit; color: inherit; }
h1, h2, .btn, .tabs button, .done-title, .dress-title, .fortune-text { font-family: "Mali", "IBM Plex Sans Thai", sans-serif; }
[hidden] { display: none !important; }

/* ================= scene ================= */
.scene {
  position: relative; height: min(70vh, 640px); min-height: 460px; overflow: hidden;
  background: linear-gradient(#0d0b2e 0%, #26205e 36%, #3b2f7a 44%); user-select: none; -webkit-user-select: none;
}
.sky { position: absolute; inset: 0 0 56% 0; }
.stars span { position: absolute; width: 2px; height: 2px; border-radius: 50%; background: #fff; animation: tw 3s ease-in-out infinite; }
@keyframes tw { 50% { opacity: .2; } }
.moon {
  position: absolute; right: 12%; top: 16%; width: 70px; height: 70px; border-radius: 50%;
  background: radial-gradient(circle at 40% 40%, #fffbe6, #ffe9a8 60%, #f5d27a);
  box-shadow: 0 0 40px 12px rgba(255, 233, 168, .35), 0 0 120px 40px rgba(255, 233, 168, .12);
}
.moon span { position: absolute; left: 20px; top: 24px; width: 20px; height: 14px; border-radius: 50%; background: rgba(214, 178, 96, .35); box-shadow: 14px 10px 0 -3px rgba(214, 178, 96, .3); }
.lantern {
  position: absolute; bottom: -20px; width: 12px; height: 16px; border-radius: 6px 6px 4px 4px;
  background: linear-gradient(#ffcf6b, #ff8a3d); box-shadow: 0 0 14px 4px rgba(255, 170, 80, .45); animation: rise linear infinite;
}
@keyframes rise { 0% { transform: translate(0, 0) scale(1); opacity: 0; } 10% { opacity: 1; } 100% { transform: translate(var(--dx, 30px), -55vh) scale(.4); opacity: 0; } }

.far { position: absolute; left: 0; right: 0; top: calc(44% - 40px); height: 44px; }
.bank { position: absolute; inset: 0; width: 100%; height: 100%; }
.crowd { position: absolute; left: 0; right: 0; bottom: 2px; height: 12px; }
.crowd i {
  position: absolute; bottom: 0; width: 3px; height: 3px; border-radius: 50%;
  background: var(--c, #ffd77a); box-shadow: 0 0 6px 1px var(--c, #ffd77a);
  animation: tw 2.4s ease-in-out infinite;
}
.scene.cheer .crowd i { background: var(--fan); box-shadow: 0 0 7px 2px var(--fan); animation: wavey .5s ease-in-out infinite alternate; width: 4px; height: 4px; }
@keyframes wavey { from { transform: translate(-2px, 0); } to { transform: translate(2px, -5px); } }

.water { position: absolute; left: 0; right: 0; bottom: 0; top: 44%; background: linear-gradient(#2a2466, #1a1650 50%, #110e3a); }
.moon-glow {
  position: absolute; right: calc(12% + 8px); top: 0; width: 54px; height: 100%;
  background: repeating-linear-gradient(transparent 0 6px, rgba(255, 233, 168, .35) 6px 8px);
  opacity: .7; -webkit-mask-image: linear-gradient(#000, transparent 80%); mask-image: linear-gradient(#000, transparent 80%);
}
.waves { position: absolute; left: -50%; width: 200%; height: 22px; opacity: .25;
  background: radial-gradient(ellipse 18px 3px at 50% 50%, #8fa8ff 60%, transparent 62%) 0 0 / 60px 22px repeat-x; animation: wave 9s linear infinite; }
.waves.w1 { top: 30%; } .waves.w2 { top: 64%; animation-duration: 6s; animation-direction: reverse; opacity: .18; }
@keyframes wave { to { transform: translateX(60px); } }

/* river history: every floated krathong keeps drifting */
.drifter {
  position: absolute; left: 0; top: 0; padding: 0; border: 0; background: none; cursor: pointer;
  display: flex; flex-direction: column; align-items: center;
  animation: drift linear infinite; filter: drop-shadow(0 0 6px rgba(255, 210, 94, .45));
}
.drifter .krathong-svg { width: 100%; height: auto; display: block; }
.drifter .d-tag {
  font: 700 10px/1.5 "Mali", sans-serif; color: #3a2a3f; background: var(--c, #ffd23f);
  border-radius: 999px; padding: 0 7px; white-space: nowrap; margin-bottom: -4px;
  box-shadow: 0 0 10px var(--c, #ffd23f); max-width: 120px; overflow: hidden; text-overflow: ellipsis;
}
.drifter.mine .d-tag::before { content: "♥ "; }
.drifter.plain { pointer-events: none; }
.drifter.world .d-tag { opacity: .85; font-size: 9px; }

.world-count {
  display: inline-block; margin-top: 6px; padding: 2px 10px; border-radius: 999px;
  background: rgba(255, 255, 255, .16); font: 600 .78rem "Mali", sans-serif; backdrop-filter: blur(4px);
}
.peek .report { display: block; margin-top: 6px; border: 0; background: none; color: #c0566b; font-size: .75rem; padding: 0; cursor: pointer; }
.public-row { display: flex; gap: 10px; align-items: flex-start; margin-top: 14px; font-size: .85rem; cursor: pointer; }
.public-row input { width: 20px; height: 20px; margin-top: 2px; flex: none; accent-color: var(--accent); }
.public-row small { color: var(--muted); font-size: .75rem; }
.btn:disabled { opacity: .6; cursor: wait; }
@keyframes drift { from { transform: translateX(-140px); } to { transform: translateX(calc(100vw + 40px)); } }
.drifter:focus-visible { outline: 2px solid #fff; border-radius: 8px; }

/* your krathong */
.stage { position: absolute; left: 50%; bottom: calc(56px + 4%); width: 240px; margin-left: -120px; transform-origin: 50% 100%; touch-action: none; cursor: grab; }
.stage.dragging { cursor: grabbing; }
.bob { display: flex; align-items: flex-end; justify-content: center; animation: bob 3.2s ease-in-out infinite; }
@keyframes bob { 50% { transform: translateY(-5px) rotate(-1.2deg); } }
.kt { width: 140px; position: relative; }
.kt svg { display: block; width: 100%; height: auto; }
.raft { position: relative; width: 92px; margin-right: -18px; z-index: 1; }
.raft.group { width: 130px; margin-right: -26px; }
.doll { width: 80px; margin: 0 auto -14px; position: relative; }
.raft.group .doll { width: 124px; }
.doll svg { display: block; width: 100%; height: auto; }
.doll:empty, .doll:empty + .leaf { display: none; }
.leaf { width: 100%; height: 22px; border-radius: 50%; background: radial-gradient(ellipse at 50% 40%, #6fcf7f, #2f8f45 70%); box-shadow: inset 0 -3px 0 rgba(0, 0, 0, .2); }
.glow { position: absolute; left: 50%; bottom: -8px; width: 180px; height: 26px; margin-left: -60px; background: radial-gradient(ellipse, rgba(255, 210, 94, .45), transparent 70%); }
.stage.fan .glow { background: radial-gradient(ellipse, var(--fan), transparent 70%); opacity: .6; }
.tag { position: absolute; left: 2%; bottom: 46%; display: flex; flex-direction: column; align-items: center; transform: rotate(-8deg); transform-origin: 50% 100%; }
.tag span {
  background: var(--fan); color: #3a2a3f; border-radius: 999px; padding: 1px 9px; font: 700 .72rem/1.6 "Mali", sans-serif;
  white-space: nowrap; max-width: 150px; overflow: hidden; text-overflow: ellipsis; box-shadow: 0 0 12px var(--fan), 0 2px 0 rgba(0, 0, 0, .2);
}
.tag::after { content: ""; width: 2px; height: 30px; background: #b8894f; }
.flame { animation: flick .18s ease-in-out infinite alternate; transform-origin: 59.5px 27px; }
@keyframes flick { to { transform: scale(.88, 1.08) rotate(3deg); } }
.ember { animation: tw 1.6s ease-in-out infinite; }
.ls-arm { transform-origin: 78px 92px; animation: wave-ls 1.6s ease-in-out infinite alternate; }
.ls-bulb { filter: drop-shadow(0 0 4px currentColor); }
@keyframes wave-ls { from { transform: rotate(-6deg); } to { transform: rotate(8deg); } }
.cheering .ls-arm { animation-duration: .35s; }
.cheering .doll { animation: hop .5s ease-in-out infinite alternate; }
@keyframes hop { to { transform: translateY(-6px); } }

.swipe-hint {
  position: absolute; left: 0; right: 0; bottom: 32px; margin: 0; text-align: center; color: rgba(255, 255, 255, .8);
  font: 600 .82rem "Mali", sans-serif; animation: nudge 1.6s ease-in-out infinite; pointer-events: none;
}
@keyframes nudge { 50% { transform: translateY(-4px); opacity: .6; } }

.bubble {
  position: absolute; left: -10px; bottom: calc(100% + 6px); width: 220px; background: #fff; color: #3a2a3f;
  border-radius: 16px; padding: 8px 12px; font: 600 .9rem/1.4 "Mali", sans-serif; box-shadow: 0 6px 20px rgba(0, 0, 0, .25);
  animation: popin .35s cubic-bezier(.3, 1.6, .5, 1);
}
.bubble::after { content: ""; position: absolute; left: 40px; bottom: -8px; border: 8px solid transparent; border-top-color: #fff; border-bottom: 0; }
.bubble small { display: block; font: 400 .78rem "IBM Plex Sans Thai", sans-serif; color: #8d7a90; margin-top: 2px; }
@keyframes popin { from { transform: scale(.6); opacity: 0; } }

.heart { position: absolute; pointer-events: none; line-height: 1; color: var(--fan); text-shadow: 0 0 8px var(--fan); z-index: 3; }
.fireworks { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }

.brand { position: absolute; left: 16px; top: 14px; color: #fff; text-shadow: 0 2px 12px rgba(0, 0, 0, .4); pointer-events: none; }
.brand h1 { margin: 0; font-size: 1.6rem; line-height: 1.2; }
.brand p { margin: 0; opacity: .85; font-size: .9rem; }
.top-btns { position: absolute; right: 12px; top: 12px; display: flex; gap: 8px; }
.round { position: relative; width: 42px; height: 42px; border-radius: 50%; border: 0; background: rgba(255, 255, 255, .16); color: #fff; cursor: pointer; font-size: 1.1rem; backdrop-filter: blur(4px); }
.round b { position: absolute; right: -4px; top: -4px; min-width: 20px; height: 20px; padding: 0 5px; border-radius: 999px; background: var(--accent); font: 700 .7rem/20px "Mali", sans-serif; }

.peek {
  position: absolute; left: 50%; top: 18%; transform: translateX(-50%); width: min(300px, calc(100% - 32px));
  background: #fff; color: #3a2a3f; border-radius: 18px; padding: 12px 14px; box-shadow: 0 10px 30px rgba(0, 0, 0, .35);
  animation: popin .3s cubic-bezier(.3, 1.6, .5, 1); z-index: 4;
}
.peek b { font: 700 1rem "Mali", sans-serif; }
.peek p { margin: 2px 0 0; font-size: .88rem; }
.peek small { color: #8d7a90; }

/* ================= sheet ================= */
.sheet { max-width: 560px; margin: -26px auto 0; padding: 0 16px 24px; position: relative; z-index: 2; }
.card { background: var(--card); border-radius: 24px; padding: 16px 18px 18px; margin-bottom: 14px; box-shadow: 0 10px 30px rgba(58, 42, 63, .12); border: 1px solid var(--line); }
.tabs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-bottom: 6px; background: var(--chip); padding: 4px; border-radius: 18px; }
.tabs button { border: 0; background: transparent; border-radius: 14px; padding: 6px 4px; cursor: pointer; font-weight: 600; font-size: .9rem; color: var(--muted); display: flex; flex-direction: column; align-items: center; line-height: 1.2; }
.tabs button span { font-size: 1.25rem; }
.tabs button.on { background: var(--card); color: var(--ink); box-shadow: 0 2px 8px rgba(58, 42, 63, .12); }
.step h2 { font-size: 1.05rem; margin: 12px 0 8px; }
.hint { color: var(--muted); font-size: .85rem; margin: 0 0 8px; }
.hint.center { text-align: center; margin-top: 8px; }

.tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.tile { border: 2px solid var(--line); background: var(--chip); border-radius: 16px; padding: 6px 4px 8px; cursor: pointer; text-align: center; font-size: .85rem; transition: transform .15s; }
.tile svg { width: 100%; height: 60px; }
.tile[aria-pressed="true"] { border-color: var(--accent); background: var(--card); transform: translateY(-2px); }
.chips { display: flex; flex-wrap: wrap; gap: 7px; }
.chip { border: 2px solid var(--line); background: var(--chip); border-radius: 999px; padding: 5px 12px; cursor: pointer; font-size: .86rem; display: inline-flex; align-items: center; gap: 6px; }
.chip i { width: 16px; height: 16px; border-radius: 50%; display: inline-block; border: 1px solid rgba(0, 0, 0, .1); }
.chip[aria-pressed="true"] { border-color: var(--accent); background: var(--card); color: var(--accent); font-weight: 600; }
.chips.small .chip { padding: 3px 11px; font-size: .8rem; }

input, textarea { width: 100%; border: 2px solid var(--line); border-radius: 14px; padding: 10px 12px; font: inherit; background: var(--panel-bg); color: var(--ink); resize: none; }
input:focus, textarea:focus { outline: none; border-color: var(--accent); }
.count { text-align: right; font-size: .75rem; color: var(--muted); margin: 2px 4px 8px; }
.name-row { display: block; font-size: .85rem; color: var(--muted); margin-top: 12px; }
.name-row input { margin-top: 4px; }

.fan-input { position: relative; }
.fan-input input { padding-right: 38px; }
.x { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); width: 28px; height: 28px; border: 0; border-radius: 50%; background: var(--chip); color: var(--muted); cursor: pointer; font-size: 1.1rem; }
.x.static { position: static; transform: none; }
.fan-picks { margin-top: 10px; }
.list-row { display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.link { border: 0; background: none; color: var(--accent); padding: 6px 0; cursor: pointer; font-size: .82rem; }
.link.danger { color: #e0576f; }
.all-fans { max-height: 240px; overflow-y: auto; padding: 4px 2px 8px; }
.all-fans h3 { font-size: .78rem; color: var(--muted); margin: 8px 0 4px; font-weight: 500; }
.all-fans .chips { gap: 6px; }
.all-fans .chip { padding: 3px 10px; font-size: .78rem; }

.dress { margin-top: 12px; padding: 12px 14px 14px; border-radius: 20px; background: var(--chip); }
.dress-head { display: flex; gap: 12px; align-items: center; }
.dress-preview { width: 92px; flex: none; background: radial-gradient(circle at 50% 60%, var(--fan), transparent 70%); border-radius: 18px; padding: 4px; }
.dress-preview.group { width: 130px; }
.dress-preview svg { display: block; width: 100%; height: auto; }
.dress-title { margin: 0; font-weight: 700; font-size: 1.05rem; }
.mini-label { margin: 10px 0 5px; font-size: .78rem; color: var(--muted); }
.dots { display: flex; gap: 8px; flex-wrap: wrap; }
.dot { width: 30px; height: 30px; border-radius: 50%; border: 3px solid var(--card); cursor: pointer; box-shadow: 0 0 0 1px var(--line); transition: transform .15s; }
.dot[aria-pressed="true"] { box-shadow: 0 0 0 2px var(--ink); transform: scale(1.12); }
.sticks .dot[aria-pressed="true"] { box-shadow: 0 0 0 2px var(--ink), 0 0 14px 3px var(--glow); }

.btn { border: 0; border-radius: 999px; padding: 10px 18px; cursor: pointer; font-weight: 600; background: var(--chip); color: var(--ink); }
.btn.primary { background: linear-gradient(135deg, var(--accent), var(--accent2)); color: #fff; box-shadow: 0 6px 16px rgba(255, 122, 162, .35); }
.btn.wide { width: 100%; margin-top: 16px; font-size: 1rem; padding: 12px; }
.btn.big { font-size: 1.15rem; padding: 14px; }
.btn:active { transform: scale(.97); }
.row { display: flex; gap: 8px; flex-wrap: wrap; }
.row .btn { flex: 1; }

.shared .eyebrow { margin: 0; color: var(--muted); font-size: .85rem; }
.shared-wish { font: 600 1.2rem/1.45 "Mali", sans-serif; margin: 4px 0 14px; }
.done-title { font-size: 1.3rem; font-weight: 700; margin: 0; }
.fortune {
  margin: 10px 0 14px; padding: 14px; border-radius: 18px; text-align: center;
  background: linear-gradient(135deg, #fff4d6, #ffe1ea); color: #5a3a2a; border: 2px dashed #f0c27a;
}
.fortune-label { margin: 0; font-size: .8rem; opacity: .8; }
.fortune-text { margin: 4px 0; font-size: 1.1rem; font-weight: 700; line-height: 1.45; }
.fortune-lucky { margin: 0; font-size: .82rem; }
.fortune-lucky i { display: inline-block; width: 12px; height: 12px; border-radius: 50%; vertical-align: -1px; border: 1px solid rgba(0, 0, 0, .15); }

.foot { text-align: center; color: var(--muted); font-size: .72rem; padding: 8px 0 24px; }

.modal { position: fixed; inset: 0; background: rgba(13, 11, 46, .55); display: flex; align-items: flex-end; justify-content: center; z-index: 20; padding: 16px; }
.modal-card { background: var(--card); color: var(--ink); width: 100%; max-width: 480px; max-height: 80vh; overflow: auto; border-radius: 24px; padding: 16px 18px; animation: popin .3s; }
.modal-head { display: flex; justify-content: space-between; align-items: center; }
.modal-head h2 { margin: 0; font-size: 1.15rem; }
.history { list-style: none; margin: 8px 0; padding: 0; }
.history li { display: flex; gap: 10px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--line); }
.history .h-kt { width: 48px; flex: none; }
.history .h-kt svg { width: 100%; height: auto; display: block; }
.history b { font: 600 .92rem "Mali", sans-serif; }
.history p { margin: 0; font-size: .82rem; color: var(--muted); }
.history .h-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 4px; vertical-align: 0; }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 16px); z-index: 30; background: var(--ink); color: var(--panel-bg); padding: 10px 18px; border-radius: 999px; opacity: 0; transition: .2s; pointer-events: none; font-size: .88rem; max-width: calc(100% - 32px); }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (min-width: 900px) {
  .scene { height: 72vh; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
}
