/* Phone UI: mobile-first, big tap targets. */

html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
html, body { background-size: 96px auto; }
body {
  min-height: 100vh;
  min-height: 100dvh;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}

.sticky-top { position: sticky; top: 0; z-index: 10; }
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: calc(env(safe-area-inset-top, 0px) + 10px) 16px 10px;
  background: var(--brown);
  color: var(--cream);
  box-shadow: 0 3px 0 var(--brown-2);
}
.brand { font-weight: 700; font-size: 18px; text-transform: uppercase; letter-spacing: 0.04em; white-space: nowrap; }
.me {
  display: flex; align-items: center; gap: 8px;
  min-width: 0;
  font-weight: 600; font-size: 16px;
}
.me .dot { width: 14px; height: 14px; border-radius: 50%; background: var(--team, #999); flex: 0 0 auto; }
.me-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.me-score { background: var(--cream); color: var(--brown); border-radius: 999px; padding: 1px 10px; font-weight: 700; font-variant-numeric: tabular-nums; }

.ptimer {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 16px;
  background: rgba(59, 33, 18, 0.88);
}
.ptimer .timer-track { flex: 1; height: 12px; }
.ptimer-secs { color: var(--cream); font-weight: 700; font-size: 18px; min-width: 2.2em; text-align: right; font-variant-numeric: tabular-nums; }

.offline {
  position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom, 0px) + 16px); transform: translateX(-50%);
  z-index: 20; background: #a1180e; color: #fff; font-weight: 600; padding: 8px 18px; border-radius: 999px;
}

main {
  max-width: 540px;
  margin: 0 auto;
  padding: 18px 16px calc(env(safe-area-inset-bottom, 0px) + 28px);
}

.view { display: none; }
.view.active { display: block; animation: rise-in 280ms ease both; }
#v-connecting, #v-wait, #v-written, #v-voted, #v-results, #v-final { text-align: center; padding-top: 6vh; }

h2 {
  font-size: 32px; margin: 10px 0 12px; line-height: 1.1;
  color: var(--cream-2);
  -webkit-text-stroke: 5px var(--brown);
  paint-order: stroke fill;
  text-shadow: 0 4px 0 var(--brown-2);
  text-transform: uppercase;
}
.muted { color: var(--brown); font-size: 19px; font-weight: 500; }
.center { text-align: center; }

.logo-small {
  display: flex; flex-direction: column; align-items: center;
  margin: 8px 0 18px;
  font-size: 54px; line-height: 0.95; font-weight: 700; text-transform: uppercase;
  color: var(--cream-2);
  -webkit-text-stroke: 6px var(--brown);
  paint-order: stroke fill;
  text-shadow: 0 6px 0 var(--brown-2);
  transform: rotate(-4deg);
}
.logo-small span:nth-child(2) { color: #ffe08a; margin-left: 40px; }

.card {
  background: var(--cream);
  border: 6px solid var(--gold);
  border-radius: 22px;
  box-shadow: inset 0 0 0 2px var(--cream-line), 0 6px 0 var(--gold-dark);
  padding: 18px 16px 16px;
}
label { display: block; font-weight: 700; font-size: 19px; color: var(--brown); margin-bottom: 8px; }
input[type=text], textarea {
  display: block;
  width: 100%;
  font-size: 21px; /* >= 16px so iOS Safari doesn't zoom */
  line-height: 1.25;
  padding: 12px 14px;
  border: 4px solid var(--gold);
  border-radius: 14px;
  background: #fff;
  color: var(--ink);
  outline: none;
  resize: none;
  -webkit-appearance: none;
  appearance: none;
}
input[type=text]:focus, textarea:focus { border-color: var(--brown); }
.row { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; min-height: 26px; margin: 6px 2px 10px; }
.count { color: var(--brown-3); font-size: 15px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.error { color: var(--lie); font-weight: 700; font-size: 17px; }
.hint { color: var(--brown-3); font-size: 15px; text-align: center; margin: 12px 0 0; }
.notice {
  background: var(--brown); color: var(--cream); border-radius: 16px; padding: 12px 14px; margin-bottom: 14px;
  font-weight: 600; text-align: center;
}

.btn {
  display: block;
  width: 100%;
  min-height: 62px;
  border: 0;
  border-radius: 999px;
  background: var(--brown);
  color: var(--cream);
  font-size: 23px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  box-shadow: 0 6px 0 var(--brown-2);
  cursor: pointer;
  touch-action: manipulation;
}
.btn:active { transform: translateY(4px); box-shadow: 0 2px 0 var(--brown-2); }
.btn:disabled { opacity: 0.6; }

.round-label {
  display: inline-block;
  margin: 0 0 10px;
  padding: 3px 14px;
  border-radius: 999px;
  background: var(--brown);
  color: var(--cream);
  font-size: 15px;
  font-weight: 600;
  text-transform: uppercase;
}
.p-prompt {
  margin: 4px -16px 22px;
  padding: 26px 26px 30px;
  font-size: 23px;
  transform: rotate(-2deg);
}
.instruct { text-align: center; font-weight: 700; font-size: 22px; color: var(--brown); margin: 0 0 12px; text-transform: uppercase; }

.options { display: flex; flex-direction: column; gap: 14px; }
.option {
  width: 100%;
  min-height: 66px;
  padding: 12px 16px;
  font-size: 20px;
  border-width: 5px;
  border-radius: 18px;
  cursor: pointer;
  touch-action: manipulation;
  box-shadow: inset 0 0 0 2px var(--cream-line), 0 5px 0 var(--gold-dark);
}
.option:active, .option.chosen { transform: translateY(3px); box-shadow: inset 0 0 0 2px var(--cream-line), 0 2px 0 var(--gold-dark); }
.option.chosen { background: #fff2b8; border-color: var(--brown); }
.option:disabled { cursor: default; }

.my-lie { margin: 18px auto; padding: 18px; font-size: 22px; max-width: 420px; }

.shake { animation: shake 420ms ease; }
@keyframes shake {
  20% { transform: translateX(-10px); } 40% { transform: translateX(9px); }
  60% { transform: translateX(-6px); } 80% { transform: translateX(4px); }
}

.wait-icon {
  width: 120px; height: 120px; margin: 0 auto 10px;
  border-radius: 50%;
  background: var(--cream) url('/img/favicon.svg') center / 70% no-repeat;
  border: 6px solid var(--gold);
  box-shadow: 0 6px 0 var(--gold-dark);
  animation: bob 2.2s ease-in-out infinite;
}
@keyframes bob { 50% { transform: translateY(-8px); } }

.spinner {
  width: 54px; height: 54px; margin: 20px auto;
  border: 7px solid rgba(59, 33, 18, 0.25);
  border-top-color: var(--brown);
  border-radius: 50%;
  animation: spin 900ms linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.result-delta {
  font-size: 64px; font-weight: 700; color: var(--cream-2);
  -webkit-text-stroke: 6px var(--green-dark); paint-order: stroke fill;
  text-shadow: 0 5px 0 #174d10;
  margin-bottom: 14px;
}
.result-delta.zero { -webkit-text-stroke-color: var(--brown); text-shadow: 0 5px 0 var(--brown-2); font-size: 40px; }
.result-card { max-width: 360px; margin: 0 auto 14px; }
.result-rank { font-size: 26px; font-weight: 700; color: var(--brown); }
.result-score { font-size: 46px; font-weight: 700; color: var(--ink); font-variant-numeric: tabular-nums; }

.final-place {
  width: 170px; height: 170px; margin: 0 auto 8px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: var(--brown); color: #ffd77a;
  border: 10px solid #d79a12;
  font-size: 76px; font-weight: 700;
  box-shadow: 0 8px 0 var(--brown-2);
  animation: pop-in 600ms cubic-bezier(.2, 1.4, .4, 1) both;
}

@media (max-width: 360px) {
  .brand { font-size: 15px; }
  .p-prompt { font-size: 20px; }
  .option { font-size: 18px; }
}
