:root {
  --bg: #fbf5ec;
  --surface: #ffffff;
  --ink: #2a1a14;
  --muted: #7a6458;
  --line: #ead9c6;
  --chili: #b3261e;
  --chili-dark: #7f1a14;
  --ember: #e8772e;
  --ok: #2f7a3e;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(60, 30, 10, .06), 0 6px 20px rgba(60, 30, 10, .06);
}

* { box-sizing: border-box; }

html, body { margin: 0; }

body {
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.5 "Inter", system-ui, -apple-system, sans-serif;
  -webkit-text-size-adjust: 100%;
}

a { color: var(--chili); }

.display { font-family: "Rye", Georgia, serif; font-weight: 400; letter-spacing: .5px; }

header.site {
  background: linear-gradient(135deg, var(--chili-dark), var(--chili));
  color: #fff;
  padding: 18px 16px;
}
header.site .inner { max-width: 760px; margin: 0 auto; display: flex; align-items: center; gap: 12px; }
header.site a { color: #fff; text-decoration: none; }
header.site .brand { font-size: 20px; line-height: 1.15; }
header.site .brand small { display: block; font-family: "Inter", sans-serif; font-size: 12px; opacity: .85; letter-spacing: .3px; }
header.site .avatar { flex: none; display: block; width: 52px; height: 52px; border-radius: 50%; padding: 2px; background: linear-gradient(135deg, #ffd9a8, var(--ember)); }
header.site .avatar img { display: block; width: 100%; height: 100%; border-radius: 50%; object-fit: cover; border: 2px solid var(--chili-dark); }

main { max-width: 760px; margin: 0 auto; padding: 24px 16px 64px; }
main.wide { max-width: 1100px; }

h1 { font-size: 28px; line-height: 1.2; margin: 0 0 8px; }
h2 { font-size: 20px; margin: 28px 0 10px; }
p.lead { color: var(--muted); margin: 0 0 20px; }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  margin-bottom: 16px;
}

label { display: block; font-weight: 600; margin: 16px 0 6px; }
label .hint { font-weight: 400; color: var(--muted); font-size: 14px; }
.field:first-child label { margin-top: 0; }

input[type=text], input[type=email], input[type=password], input[type=number], textarea, select {
  width: 100%;
  font: inherit;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: var(--ink);
}
input:focus, textarea:focus, select:focus { outline: 2px solid var(--ember); outline-offset: 1px; border-color: transparent; }
textarea { min-height: 96px; resize: vertical; }

.checks { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 8px; }
.checks label {
  display: flex; align-items: center; gap: 8px; margin: 0;
  font-weight: 500; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: #fff; cursor: pointer;
}
.checks input { width: 18px; height: 18px; accent-color: var(--chili); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font: 600 16px "Inter", sans-serif;
  padding: 13px 22px;
  border-radius: 999px;
  border: 0;
  background: var(--chili);
  color: #fff;
  cursor: pointer;
  text-decoration: none;
}
.btn:hover { background: var(--chili-dark); }
.btn:disabled { opacity: .55; cursor: default; }
.btn.block { width: 100%; }
.btn.ghost { background: transparent; color: var(--chili); border: 1px solid var(--chili); }
.btn.ghost:hover { background: #fbe9e7; }
.btn.small { padding: 7px 14px; font-size: 14px; }
.btn.danger { background: transparent; color: var(--chili); border: 1px solid var(--line); }

.actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 20px; }

.notice { padding: 12px 14px; border-radius: 10px; margin: 12px 0; }
.notice.error { background: #fde8e6; color: #8a1c14; }
.notice.ok { background: #e7f4ea; color: #1f5a2b; }
.notice.info { background: #fff3e0; color: #7a4210; }
.hidden { display: none !important; }

.tag {
  display: inline-block; font-size: 13px; font-weight: 600;
  padding: 3px 10px; border-radius: 999px; background: #fff3e0; color: #7a4210; margin: 0 6px 6px 0;
}

.num-badge {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 44px; height: 44px; padding: 0 10px; border-radius: 999px;
  background: var(--chili); color: #fff; font: 700 18px "Inter", sans-serif;
}

/* Score pickers */
.criterion { padding: 16px 0; border-top: 1px solid var(--line); }
.criterion:first-of-type { border-top: 0; padding-top: 0; }
.criterion .title { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.criterion .title strong { font-size: 17px; }
.criterion .title .val { font: 700 20px "Inter", sans-serif; color: var(--chili); min-width: 2ch; text-align: right; }
.criterion .desc { color: var(--muted); font-size: 14px; margin: 2px 0 10px; }
.scale { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.scale button {
  font: 600 18px "Inter", sans-serif; height: 52px; padding: 0;
  border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--ink); cursor: pointer;
}
.scale button.on { background: var(--chili); border-color: var(--chili); color: #fff; }
.scale button.in-range { background: #fbe0dc; border-color: #f2c2bb; }
.award-head {
  margin: 4px -20px 0; padding: 14px 20px 10px; border-top: 2px dashed var(--line);
  background: #fff8ee; display: flex; flex-direction: column; gap: 2px;
}
.award-head span { font-size: 13px; color: var(--muted); }
.criterion.award { background: #fff8ee; margin: 0 -20px; padding: 6px 20px 18px; border-top: 0; }
td.name-col, th.name-col { color: var(--ember); }
.scale-ends { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); margin-top: 4px; }

/* Lists & tables */
.chili-list { list-style: none; padding: 0; margin: 0; }
.chili-list li { display: flex; gap: 14px; align-items: center; padding: 14px 0; border-top: 1px solid var(--line); }
.chili-list li:first-child { border-top: 0; }
.chili-list .meta { flex: 1; min-width: 0; }
.chili-list .meta strong { display: block; }
.chili-list .voted { display: block; color: var(--ok); font-size: 13px; font-weight: 600; margin: 2px 0 4px; }
.chili-list .btn { flex: none; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 15px; }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); }
td.n, th.n { text-align: right; font-variant-numeric: tabular-nums; }
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: #fff8f0; }
.rank { font: 700 18px "Inter", sans-serif; color: var(--muted); }
tr.top1 .rank { color: #c9a227; }

.memorial {
  text-align: center;
  padding: 32px 20px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.memorial { padding-top: 36px; }
.portrait { position: relative; width: 200px; height: 200px; margin: 0 auto 4px; }
.portrait img {
  width: 100%; height: 100%; border-radius: 50%; object-fit: cover; display: block;
  border: 6px solid var(--surface);
  box-shadow: 0 0 0 4px var(--chili), 0 0 0 9px #f6d9b8, 0 12px 30px rgba(80, 20, 10, .25);
}
.portrait .badge {
  position: absolute; right: 4px; bottom: 6px; width: 46px; height: 46px; border-radius: 50%;
  background: var(--surface); box-shadow: var(--shadow); display: grid; place-items: center; font-size: 26px;
}
.memorial .caption { font-size: 14px; color: var(--muted); letter-spacing: .3px; margin: 14px auto 10px; }
.memorial .caption strong { color: var(--ink); }
.memorial .big { font-size: 34px; line-height: 1.15; margin: 8px 0 12px; color: var(--chili-dark); }
.memorial .neighborhood { font-size: 13px; font-weight: 700; letter-spacing: 2px; text-transform: uppercase; color: var(--ember); margin: -4px auto 14px; }
.memorial p { color: var(--muted); max-width: 520px; margin: 0 auto 8px; }

footer.site { text-align: center; color: var(--muted); font-size: 13px; padding: 24px 16px 40px; }

@media (max-width: 420px) {
  h1 { font-size: 24px; }
  .memorial .big { font-size: 28px; }
}

/* ---------- Phones ---------- */
@media (max-width: 640px) {
  /* Wide tables become stacked cards */
  table.stack thead { display: none; }
  table.stack, table.stack tbody { display: block; }
  table.stack tr {
    display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px 10px;
    padding: 14px 0; border-bottom: 1px solid var(--line);
  }
  table.stack tr:last-child { border-bottom: 0; }
  table.stack td { display: block; border: 0; padding: 0; text-align: left; min-width: 0; overflow-wrap: anywhere; }
  table.stack td.n { text-align: left; }
  table.stack td[data-label]::before {
    content: attr(data-label); display: block;
    font-size: 12px; font-weight: 600; color: var(--muted); overflow-wrap: normal; white-space: nowrap;
  }
  table.stack td.span3 { grid-column: span 3; }
  table.stack td.span2 { grid-column: span 2; }
  table.stack td.full, table.stack td[colspan] { grid-column: 1 / -1; }
  table.stack td.score strong { font-size: 20px; color: var(--chili); }
  table.stack td.actions-cell { white-space: normal !important; }
  table.stack .rank { font-size: 24px; }
  .table-wrap { overflow-x: visible; }
  .card { padding: 16px; }
  .award-head { margin-left: -16px; margin-right: -16px; padding-left: 16px; padding-right: 16px; }
  .criterion.award { margin-left: -16px; margin-right: -16px; padding-left: 16px; padding-right: 16px; }
  .btn.small { min-height: 40px; padding: 8px 16px; }
  /* Keep form fields at 16px so iPhones don't zoom in on focus */
  input, textarea, select { font-size: 16px !important; }
}

@media (max-width: 420px) {
  header.site { padding: 14px 16px; }
  header.site .brand { font-size: 18px; }
  header.site .avatar { width: 46px; height: 46px; }
  .chili-list li { gap: 10px; }
  .chili-list .num-badge { min-width: 40px; height: 40px; font-size: 16px; }
  .portrait { width: 170px; height: 170px; }
}
