:root {
  --bg: #1b1530; --card: #261d44; --ink: #f4ecd8; --muted: #b9acd6; --gold: #e8c15a;
  --good: #7be0a0; --bad: #ff8d8d;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.5 Georgia, 'Times New Roman', serif; }
header { text-align: center; padding: 28px 16px 8px; }
h1 { margin: 0; color: var(--gold); letter-spacing: .03em; }
header p { color: var(--muted); margin: 6px 0 0; font-style: italic; }
main { max-width: 1050px; margin: 0 auto; padding: 16px; display: grid; gap: 18px; }
.grid { display: grid; gap: 18px; grid-template-columns: 1fr 1fr; }
@media (max-width: 760px) { .grid { grid-template-columns: 1fr; } }
.card { background: var(--card); border: 1px solid #3b3066; border-radius: 12px; padding: 18px; }
h2 { margin: 0 0 12px; color: var(--gold); font-size: 1.2rem; }

.houses { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.house { border-radius: 12px; padding: 14px; text-align: center; color: #fff; border: 2px solid rgba(255,255,255,.25); }
.house .rank { font-size: .8rem; opacity: .85; }
.house .name { font-size: 1.15rem; font-weight: bold; }
.house .total { font-size: 2.2rem; font-weight: bold; }
.house.first { box-shadow: 0 0 0 3px var(--gold); }

form { display: grid; gap: 12px; }
label { display: grid; gap: 4px; font-weight: bold; }
small { font-weight: normal; color: var(--muted); }
input, select, textarea { font: inherit; padding: 9px; border-radius: 8px; border: 1px solid #54478a; background: #14102a; color: var(--ink); width: 100%; }
button { font: inherit; font-weight: bold; padding: 10px 16px; border: 0; border-radius: 8px; background: var(--gold); color: #2a2000; cursor: pointer; }
button:disabled { opacity: .6; cursor: wait; }
form.inline { grid-template-columns: 1fr 52px auto; margin-top: 14px; align-items: center; }
input[type=color] { padding: 2px; height: 40px; cursor: pointer; }
.warn { margin: 0; color: var(--gold); font-size: .9rem; }
.msg { margin: 0; min-height: 1.2em; }
.msg.error { color: var(--bad); } .msg.ok { color: var(--good); }
.muted { color: var(--muted); }

.people { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.people li { display: flex; align-items: center; gap: 10px; padding: 8px 10px; background: #14102a; border-radius: 8px; }
.dot { width: 14px; height: 14px; border-radius: 50%; flex: none; }
.p-name { flex: 1; }
button.secondary { background: #3b3066; color: var(--ink); }
button.small { padding: 4px 10px; font-size: .85rem; }
.row { display: flex; gap: 10px; justify-content: flex-end; }

dialog { background: var(--card); color: var(--ink); border: 1px solid var(--gold); border-radius: 12px; padding: 20px; width: min(380px, 92vw); }
dialog::backdrop { background: rgba(0,0,0,.7); }
dialog h2 { margin-top: 0; }

/* Floating candles: always behind the content. The body is its own stacking context and the
   candles sit at z-index -1 inside it; content layers are promoted so Safari keeps them on top. */
body { position: relative; z-index: 0; isolation: isolate; }
#candles { position: fixed; inset: 0; overflow: hidden; pointer-events: none; z-index: -1; }
header, main, footer { position: relative; z-index: 1; transform: translateZ(0); }
.candle { position: absolute; width: 12px; animation: float var(--dur) ease-in-out infinite; animation-delay: var(--delay); opacity: .5; }
.candle .wax { width: 12px; height: var(--h); background: linear-gradient(90deg, #d8cfae, #fff6d6 50%, #cfc3a0); border-radius: 3px 3px 2px 2px; }
.candle .flame { position: absolute; left: 50%; bottom: calc(var(--h) + 1px); width: 7px; height: 16px; margin-left: -3.5px;
  background: radial-gradient(ellipse at 50% 75%, #fff 0%, #ffd56b 35%, #ff9a2e 70%, transparent 100%);
  border-radius: 50% 50% 50% 50% / 65% 65% 35% 35%; transform-origin: 50% 100%;
  animation: flicker .6s ease-in-out infinite alternate; filter: drop-shadow(0 0 8px #ffb347) drop-shadow(0 0 20px #ff9a2e); }
.candle .flame::after { content: ''; position: absolute; left: 50%; top: 50%; width: 80px; height: 80px; margin: -40px 0 0 -40px;
  background: radial-gradient(circle, rgba(255,190,90,.18), transparent 70%); border-radius: 50%; }
@keyframes float { 0%,100% { transform: translate(0, 0) rotate(-2deg); } 50% { transform: translate(var(--dx), -26px) rotate(2deg); } }
@keyframes flicker { from { transform: scale(1, 1) rotate(-3deg); } to { transform: scale(.88, 1.1) rotate(3deg); } }
@media (prefers-reduced-motion: reduce) { .candle, .candle .flame { animation: none; } }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .95rem; }
th, td { text-align: left; padding: 8px; border-bottom: 1px solid #3b3066; vertical-align: top; }
th { color: var(--muted); font-weight: normal; }
.pos { color: var(--good); font-weight: bold; } .neg { color: var(--bad); font-weight: bold; }
td.name-cell { font-weight: bold; }
td.when { white-space: nowrap; }

.login { max-width: 420px; margin: 0 auto; width: 100%; }
.who { margin: 0; text-align: right; color: var(--muted); }
a { color: var(--gold); }
[hidden] { display: none !important; }
.people li .p-name { min-width: 0; overflow-wrap: anywhere; }

.stack { display: grid; gap: 12px; }
form.inline .file { grid-column: 1 / -1; }
.file { font-weight: normal; color: var(--muted); }
.file input { padding: 6px; }
label.check { display: flex; align-items: center; gap: 8px; font-weight: normal; }
label.check input { width: auto; }
form.inline-2 { grid-template-columns: 1fr auto; margin-top: 14px; align-items: center; }
/* feed */
.people li .sub { display: block; font-size: .8rem; color: var(--muted); }

.feed { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; max-height: 70vh; overflow-y: auto; }
.feed li { background: #14102a; border-radius: 10px; padding: 10px 12px; border-left: 4px solid var(--c, var(--gold)); display: grid; gap: 4px; }
.feed .top { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.feed .who-name { font-weight: bold; }
.feed .pts { font-size: 1.25rem; }
.feed .reason { overflow-wrap: anywhere; }
.feed .meta { font-size: .85rem; color: var(--muted); display: flex; flex-wrap: wrap; gap: 6px 12px; align-items: center; }
dialog img { max-width: 100%; max-height: 70vh; display: block; margin: 0 auto 10px; border-radius: 8px; }

h2.household { text-align: center; margin: 0; font-size: 1.5rem; }
.banner { background: #3b3066; border: 1px solid var(--gold); border-radius: 8px; padding: 10px 12px; margin: 0 0 12px; }
