:root {
  --bg: #ffffff;
  --soft: #f1f0ec;
  --ink: #111114;
  --muted: #6b6a66;
  --line: #e4e2dc;
  --pink: #ff4f7b;
  color-scheme: light only; /* owner: always white, even when the phone is in dark mode */
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); }
body { font-family: "IBM Plex Sans Thai", system-ui, sans-serif; -webkit-font-smoothing: antialiased; }
button { font: inherit; color: inherit; cursor: pointer; }
.head, h1, .logo, .lbl, .pct, .vs, .primary, .ghost, dialog h2 { font-family: "Mitr", "IBM Plex Sans Thai", sans-serif; }

/* one screen, no scroll: photos take whatever height is left */
.app { max-width: 520px; margin: 0 auto; height: 100dvh; display: flex; flex-direction: column;
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom)); }
.top { display: flex; justify-content: space-between; align-items: center; padding: 4px 4px 6px; }
.logo { font-size: 19px; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.tools { display: flex; align-items: center; gap: 12px; }
.mute { background: var(--soft); border: 0; border-radius: 50%; width: 38px; height: 38px; display: grid; place-items: center; padding: 0; }
.mute .x, .mute.off .on { display: none; }
.mute.off .x { display: inline; }
.mute.off { color: var(--muted); }
.link { background: none; border: 0; padding: 0; color: var(--muted); text-decoration: underline; font-size: 13px; }

.card { flex: 1; min-height: 0; display: flex; flex-direction: column; }
h1 { margin: 0 4px 10px; font-size: 26px; font-weight: 600; line-height: 1.25; }

.clock { display: flex; align-items: center; gap: 10px; margin: -2px 4px 10px; }
.clock .track { flex: 1; height: 8px; border-radius: 4px; background: var(--soft); overflow: hidden; }
.clock i { display: block; height: 100%; background: var(--ink); border-radius: 4px; transform-origin: left; }
.clock b { font-family: "Mitr", sans-serif; font-size: 18px; font-weight: 600; min-width: 26px; text-align: right; }
/* last 10 seconds: red bar, bigger red number that shakes */
.clock.hurry i { background: #e5202e; }
.clock.hurry b { color: #e5202e; font-size: 24px; animation: shake .45s ease-in-out infinite; }
@keyframes shake {
  0%, 100% { transform: translateX(0) rotate(0); }
  20% { transform: translateX(-3px) rotate(-8deg); }
  40% { transform: translateX(3px) rotate(8deg); }
  60% { transform: translateX(-2px) rotate(-5deg); }
  80% { transform: translateX(2px) rotate(5deg); }
}
@media (prefers-reduced-motion: reduce) { .clock.hurry b { animation: none; } }
.card.voted .clock { visibility: hidden; }

.opts { flex: 1; min-height: 0; display: flex; flex-direction: column; gap: 8px; position: relative; }
.opt { flex: 1; min-height: 0; position: relative; padding: 0; border: 0; border-radius: 22px; overflow: hidden;
  background: var(--soft); transition: transform .12s ease; }
.opt:active { transform: scale(.985); }
.opt img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; transition: filter .35s; }
.lbl { position: absolute; left: 12px; bottom: 12px; max-width: calc(100% - 24px); background: #fff; border-radius: 14px;
  padding: 5px 14px; font-size: 20px; font-weight: 600; line-height: 1.3; text-align: left; }
.vs { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%) rotate(-8deg); z-index: 2;
  width: 58px; height: 58px; border-radius: 50%; display: grid; place-items: center; background: var(--pink);
  color: #fff; font-size: 21px; font-weight: 600; border: 4px solid #fff; pointer-events: none;
  transition: transform .3s, opacity .3s; }
.pct { position: absolute; right: 14px; bottom: 8px; font-size: 48px; font-weight: 600; color: #fff;
  text-shadow: 0 2px 14px rgba(0,0,0,.55); opacity: 0; transform: translateY(8px); transition: opacity .3s, transform .3s; }
.bar { position: absolute; left: 0; right: 0; bottom: 0; height: 8px; }
.bar i { display: block; height: 100%; width: 0; background: var(--pink); transition: width .7s cubic-bezier(.2,.8,.2,1); }

.card.voted .opt { cursor: default; }
.card.voted .opt:active { transform: none; }
.card.voted .pct { opacity: 1; transform: none; }
.card.voted .vs { opacity: 0; transform: translate(-50%, -50%) scale(.4); }
.card.voted .opt:not(.picked) img { filter: grayscale(1) brightness(.92); }
.card.voted .opt:not(.picked) .bar i { background: #bbb; }
.card.voted .opt.picked::after { content: ""; position: absolute; inset: 0; border: 5px solid var(--pink); border-radius: 22px; pointer-events: none; }

.verdict { margin: 8px 4px 0; font-size: 17px; font-weight: 500; }
.verdict:empty { display: none; }
.verdict em { font-style: normal; color: var(--pink); }

.actions { display: flex; gap: 8px; margin-top: 10px; justify-content: flex-end; }
.actions .primary { flex: 1; }
.card .actions .ghost { min-width: 150px; }
.primary, .ghost { border-radius: 999px; padding: 13px 22px; font-size: 16px; font-weight: 600; border: 0; }
.primary { background: var(--ink); color: #fff; }
.ghost { background: var(--soft); }
[hidden] { display: none !important; }
.sponsor { margin: -6px 4px 8px; font-size: 13px; color: var(--muted); }
.sponsor a { color: var(--ink); font-weight: 500; }
/* fixed-height ad / house-promo slot: never changes size, so the vote buttons never jump */
.adslot { flex: none; height: 60px; margin-top: 8px; border: 1px dashed var(--line); border-radius: 14px;
  display: grid; place-items: center; overflow: hidden; }
.house { padding: 0 12px; font-size: 12px; color: var(--muted); text-decoration: none; text-align: center; line-height: 1.4; }
.foot { text-align: center; padding: 6px 4px 0; font-size: 11px; color: var(--muted); line-height: 1.4; }
.foot p { margin: 0; }
.foot .legal { font-size: 10px; }
.foot a { color: var(--muted); }

dialog { border: 0; border-radius: 22px; padding: 20px; width: min(440px, calc(100vw - 32px)); background: #fff; color: var(--ink); }
dialog::backdrop { background: rgba(0,0,0,.4); }
dialog h2 { margin: 0 0 12px; font-size: 20px; font-weight: 600; }
dialog label { display: block; font-size: 14px; color: var(--muted); margin-bottom: 10px; }
dialog input { display: block; width: 100%; margin-top: 4px; padding: 10px 12px; font: inherit; font-size: 16px;
  border: 1px solid var(--line); border-radius: 12px; background: var(--soft); color: var(--ink); }
dialog.sheet { margin: auto auto 0; width: min(520px, 100vw); max-width: 100vw; border-radius: 22px 22px 0 0;
  padding: 18px 16px calc(22px + env(safe-area-inset-bottom)); }
.sheet .pic { width: 100%; background: var(--pink); margin-bottom: 16px; }
.sheet .apps { display: flex; justify-content: space-between; }
.sheet .apps button { background: none; border: 0; padding: 0; width: 72px; display: grid; justify-items: center; gap: 6px; font-size: 13px; }
.sheet .apps i { width: 52px; height: 52px; border-radius: 50%; display: grid; place-items: center; color: #fff;
  font: 600 14px "Mitr", sans-serif; font-style: normal; }
.sheet .apps i.cp { background: var(--soft); color: var(--ink); }
.note { font-size: 13px; color: var(--muted); margin: 4px 0 0; }
