:root {
  color-scheme: light;
  --leaf: #405c3d;
  --leaf-dark: #2c432f;
  --paper: #fffdf4;
  --canvas: #f4efd9;
  --ink: #28372c;
  --muted: #687364;
  --gold: #f0cf69;
  --orange: #c97149;
  --line: #d8d3bc;
  --bad: #a23b2a;
  --body: 'Nunito', 'Trebuchet MS', sans-serif;
  --display: 'Fredoka', 'Trebuchet MS', sans-serif;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  color: var(--ink);
  font-family: var(--body);
  background-color: var(--canvas);
  background-image: radial-gradient(rgba(112, 103, 71, .13) .7px, transparent .8px);
  background-size: 18px 18px;
}
a { color: var(--leaf-dark); }
button, input, select, textarea { font: inherit; color: inherit; }
:is(a, button, input, select, textarea):focus-visible { outline: 3px dashed var(--orange); outline-offset: 3px; }
h1, h2, h3 { font-family: var(--display); color: var(--leaf-dark); margin: 0 0 .4em; line-height: 1.15; }
h1 { font-size: clamp(2rem, 6vw, 3rem); }
p { line-height: 1.5; }

.site-header { max-width: 1100px; margin: 0 auto; padding: 14px 20px; display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.brand { display: inline-flex; gap: 9px; align-items: center; text-decoration: none; font: 700 1.3rem var(--display); color: var(--leaf-dark); }
main { max-width: 1100px; margin: 0 auto; padding: 8px 20px 60px; }

.card { background: var(--paper); border: 2px solid var(--line); border-radius: 18px; padding: 22px; margin-bottom: 20px; box-shadow: 0 3px 0 var(--line); }
.narrow { max-width: 620px; }
.muted { color: var(--muted); }
.notice { background: #fff4cf; border: 2px solid var(--gold); border-radius: 12px; padding: 12px 16px; }
.error { background: #fbe4df; border: 2px solid var(--bad); border-radius: 12px; padding: 12px 16px; color: var(--bad); font-weight: 700; }

label { display: block; font-weight: 700; margin: 14px 0 4px; }
input[type=text], input[type=password], input[type=number], select, textarea {
  width: 100%; padding: 11px 12px; border: 2px solid var(--line); border-radius: 10px; background: #fff;
}
textarea { min-height: 70px; resize: vertical; }

.button {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 12px 22px; border: 0; border-radius: 999px; cursor: pointer; text-decoration: none;
  background: var(--leaf); color: #fff; font: 600 1.05rem var(--display); box-shadow: 0 3px 0 var(--leaf-dark);
}
.button:hover { background: var(--leaf-dark); }
.button:disabled { opacity: .45; cursor: not-allowed; }
.button.secondary { background: var(--paper); color: var(--leaf-dark); border: 2px solid var(--leaf); box-shadow: none; }
.button.danger { background: var(--bad); box-shadow: 0 3px 0 #6f2417; }
.button.big { font-size: 1.5rem; padding: 16px 34px; }
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; margin-top: 16px; }

.choice-row { display: grid; grid-template-columns: 76px 1fr auto; gap: 10px; align-items: center; margin-top: 10px; }
.thumb { width: 76px; height: 76px; border-radius: 12px; border: 2px dashed var(--line); background: #fff center/cover no-repeat; display: grid; place-items: center; cursor: pointer; font-size: 1.6rem; color: var(--muted); }
.choice-row input[type=file] { display: none; }

.linkbox { display: flex; gap: 8px; margin-top: 6px; }
.linkbox input { flex: 1; min-width: 0; font-family: monospace; font-size: .85rem; }

/* Booth */
body.booth-mode .site-header { display: none; }
body.booth-mode main { padding-top: 12px; }
.booth-bar { margin-bottom: 6px; }
.booth-title { font-size: clamp(1.25rem, 4vw, 1.8rem); margin: 0; }
.status-line { font-size: .85rem; color: var(--muted); }
.status-line b { color: var(--ink); }
.instruction { margin: 8px 0; font-size: .98rem; }
.booth-bar + .notice, #window { margin: 8px 0; padding: 8px 12px; font-size: .92rem; }
.choice-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 340px), 1fr)); gap: 10px; }
.choice-card {
  display: flex; align-items: center; gap: 12px; padding: 8px 12px 8px 8px; text-align: left; cursor: pointer;
  background: var(--paper); border: 3px solid var(--line); border-radius: 14px; box-shadow: 0 3px 0 var(--line);
  -webkit-tap-highlight-color: transparent; touch-action: manipulation;
}
.choice-card img, .choice-card .noimg { flex: none; width: 60px; height: 60px; object-fit: cover; border-radius: 10px; background: #ece6c8; display: grid; place-items: center; font-size: 1.6rem; }
.choice-card .label { flex: 1; font: 600 1.25rem var(--display); line-height: 1.15; }
.choice-card.picked { border-color: var(--leaf); background: #eaf2dd; box-shadow: 0 3px 0 var(--leaf); }
.rank-badge {
  flex: none; width: 46px; height: 46px; border-radius: 50%; display: grid; place-items: center;
  background: var(--gold); color: var(--leaf-dark); border: 3px solid var(--leaf); font: 700 1.6rem var(--display);
}
.rank-badge[hidden] { display: none; }
.ballot-actions { position: sticky; bottom: 0; display: flex; gap: 10px; justify-content: center; padding: 12px 0 8px; margin-top: 8px; background: linear-gradient(transparent, var(--canvas) 30%); }
.ballot-actions .button.big { font-size: 1.25rem; padding: 12px 26px; }
.finish-area { margin-top: 36px; padding-top: 14px; border-top: 2px dashed var(--line); }
.button.small { font-size: .95rem; padding: 8px 16px; box-shadow: none; }
.thanks { position: fixed; inset: 0; background: var(--leaf); color: #fff; display: grid; place-content: center; text-align: center; gap: 10px; cursor: pointer; z-index: 10; padding: 20px; }
.thanks h1 { color: #fff; font-size: clamp(2.5rem, 10vw, 5rem); }
.thanks .big-emoji { font-size: 5rem; }

/* Results */
.winner { display: flex; gap: 18px; align-items: center; background: #eaf2dd; border: 3px solid var(--leaf); border-radius: 18px; padding: 16px; margin-bottom: 20px; }
.winner img { width: 120px; height: 90px; object-fit: cover; border-radius: 12px; }
.winner h2 { margin: 0; font-size: 2rem; }
.round { margin-bottom: 18px; }
.bar-line { display: grid; grid-template-columns: minmax(90px, 160px) 1fr 44px; gap: 10px; align-items: center; margin: 5px 0; }
.bar-track { height: 22px; background: #ece6c8; border-radius: 6px; overflow: hidden; }
.bar { height: 100%; background: var(--leaf); }
.bar-line.out .bar { background: var(--orange); }
.bar-line.out .name { text-decoration: line-through; color: var(--muted); }
.bar-line .num { text-align: right; font-weight: 800; }
table { border-collapse: collapse; width: 100%; }
th, td { text-align: left; padding: 8px; border-bottom: 1px solid var(--line); }

@media (max-width: 520px) {
  .choice-row { grid-template-columns: 64px 1fr; }
  .choice-row .remove { grid-column: 1 / -1; }
  .winner { flex-direction: column; text-align: center; }
}

label.inline { display: flex; align-items: center; gap: 8px; font-weight: 600; margin: 6px 0; }
label.inline input[type=time] { width: auto; }
.choice-card:disabled { opacity: .5; cursor: not-allowed; }
fieldset { border: 2px solid var(--line); border-radius: 12px; margin: 12px 0; }
legend { font-weight: 800; padding: 0 6px; }

.net { font-weight: 700; }
.net::before { content: ''; display: inline-block; width: .6em; height: .6em; border-radius: 50%; margin-right: .4em; background: currentColor; vertical-align: baseline; }
.net.ok { color: #2f7a3a; }
.net.warn { color: #b25a14; }
.net.idle { color: var(--muted); }
.net.bad { color: var(--bad); }
.sendstate { margin: 0 0 12px; padding: 12px 14px; border-radius: 12px; font-weight: 700; border: 2px solid var(--line); background: #fff; }
.sendstate.ok { background: #eaf2dd; border-color: #2f7a3a; color: #1f5a29; }
.sendstate.warn { background: #fff0cf; border-color: var(--orange); color: #7a3d0b; }
.sendstate.bad { background: #fbe4df; border-color: var(--bad); color: var(--bad); }

.hand-list { display: grid; gap: 8px; }
.hand-row { display: flex; align-items: center; gap: 8px; background: var(--paper); border: 3px solid var(--line); border-radius: 14px; padding: 8px; }
.hand-row img, .hand-row .noimg { flex: none; width: 52px; height: 52px; object-fit: cover; border-radius: 10px; background: #ece6c8; display: grid; place-items: center; font-size: 1.4rem; }
.hand-row .label { flex: 1; font: 600 1.15rem var(--display); line-height: 1.15; }
.hand-row input[type=number] { width: 4.2em; text-align: center; font: 700 1.4rem var(--display); padding: 8px 4px; }
.step { flex: none; width: 46px; height: 46px; border-radius: 50%; border: 3px solid var(--leaf); background: var(--paper); font: 700 1.6rem var(--display); color: var(--leaf-dark); cursor: pointer; line-height: 1; }
.step:disabled { opacity: .4; cursor: not-allowed; }
.hand-total { font-size: 1.15rem; margin: 12px 0 0; text-align: right; }
.groups { padding-left: 20px; line-height: 1.7; }

.mypolls { list-style: none; padding: 0; margin: 0; }
.mypolls li { padding: 10px 0; border-bottom: 1px solid var(--line); }
.mypolls .row-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 6px; }

.site-nav { display: flex; gap: 16px; flex-wrap: wrap; font-size: .95rem; }
.site-nav a { color: var(--leaf-dark); }
body.booth-mode .site-nav { display: none; }

/* The about text: real page text for search engines. It shows on the home view only. */
.about, .site-footer, .page { max-width: 760px; margin: 0 auto; padding: 8px 20px 24px; }
.about h2, .page h2 { font-size: 1.4rem; margin-top: 1.6em; }
.about p, .about li, .page p, .page li { line-height: 1.6; }
.about details { border-bottom: 1px solid var(--line); padding: 8px 0; }
.about summary, .page summary { cursor: pointer; font-weight: 700; }
.site-footer { font-size: .9rem; color: var(--muted); padding-bottom: 48px; }
body[data-view]:not([data-view="home"]) .about,
body[data-view]:not([data-view="home"]) .site-footer { display: none; }
.page h1 { margin-top: .6em; }
.page table { margin: 1em 0; }
.page .cta { margin: 1.5em 0; }

.poll-choices { list-style: none; padding: 0; margin: 0 0 12px; }
.poll-choices li { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line, rgba(128, 128, 128, 0.3)); font-weight: 600; }
.poll-choices img { width: 40px; height: 40px; object-fit: cover; border-radius: 8px; }
