/* 手機選票：一張藍墨印在黃紙上的選票，圈選就是蓋一個紅章。
   Layout avoids flex gap, aspect-ratio and inset so it also works on older iPhones. */

body {
  background: var(--ballot);
  font-size: 18px;
  line-height: 1.5;
}

body.locked {
  overflow: hidden;
}

.en {
  display: block;
  font-size: 0.78em;
  font-weight: 400;
  line-height: 1.35;
  letter-spacing: 0;
  opacity: 0.85;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
}

.ballot {
  max-width: 560px;
  margin: 0 auto;
  padding: 14px 12px 128px;
}

/* The header, the notice and every team row share rules, so the page reads as one ruled sheet. */
.head,
.notice,
.teams li {
  border: 2px solid var(--ink);
  border-bottom-width: 0;
}

.teams li:last-child {
  border-bottom-width: 2px;
}

.head {
  padding: 14px 14px 0;
  text-align: center;
}

.kicker {
  margin: 0;
  font-size: 13px;
  line-height: 1.4;
}

.title {
  margin: 4px 0 12px;
  font-size: 23px;
  font-weight: 700;
  line-height: 1.3;
  text-wrap: balance; /* avoids a two-character last line where supported */
}

.sheet-name {
  margin: 0 -14px;
  padding: 8px 12px;
  background: var(--ink);
  color: var(--ballot);
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 0.14em;
}

.notice {
  padding: 16px 14px;
}

.notice-main {
  margin: 0;
  font-size: 22px;
  font-weight: 700;
  line-height: 1.35;
}

.notice-sub {
  margin: 8px 0 0;
  font-size: 16px;
}

.notice .secondary,
.notice .plain {
  margin-top: 14px;
}

[data-mode='done'] .notice,
[data-mode='closed'] .notice {
  background: #fff;
}

.done-head {
  display: flex;
  align-items: center;
}

.done-stamp {
  flex: none;
  width: 58px;
  height: 58px;
  margin-right: 14px;
  transform: rotate(-11deg);
}

.teams {
  margin: 0;
  padding: 0;
  list-style: none;
}

.team {
  display: flex;
  align-items: stretch;
  width: 100%;
  min-height: 78px;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.team:disabled {
  cursor: default;
  opacity: 1;
  color: var(--ink);
  -webkit-text-fill-color: currentColor;
}

.team[aria-pressed='true'] {
  background: #fff;
}

.team:focus-visible {
  outline: 3px solid var(--seal);
  outline-offset: -3px;
}

.no {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 58px;
  border-right: 2px solid var(--ink);
  font-family: var(--num);
  font-size: 36px;
  line-height: 1;
}

.who {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-width: 0;
  padding: 10px 12px;
}

.name {
  font-size: 21px;
  font-weight: 700;
  line-height: 1.3;
  overflow-wrap: anywhere;
}

.topic {
  margin-top: 2px;
  color: var(--ink-2);
  font-size: 15px;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

/* 圈選欄 */
.mark {
  flex: none;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 74px;
  border-left: 2px solid var(--ink);
}

.mark::before {
  content: '';
  width: 46px;
  height: 46px;
  border: 2px dashed var(--ink);
  border-radius: 50%;
  opacity: 0;
}

[data-mode='pick'] .mark::before {
  opacity: 0.35;
}

[data-mode='pick'] .team[aria-pressed='true'] .mark::before {
  opacity: 0;
}

.tilt {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 54px;
  height: 54px;
  margin: -27px 0 0 -27px;
}

.stamp {
  display: block;
  width: 100%;
  height: 100%;
  opacity: 0;
}

.stamp circle,
.stamp path,
.done-stamp circle,
.done-stamp path {
  fill: none;
  stroke: var(--seal);
  stroke-width: 9;
  stroke-linecap: round;
}

.team[aria-pressed='true'] .stamp {
  opacity: 0.92;
  animation: press 0.24s cubic-bezier(0.2, 0.9, 0.3, 1.2);
}

@keyframes press {
  from {
    opacity: 0;
    transform: scale(1.9);
  }
  55% {
    opacity: 1;
    transform: scale(0.9);
  }
  to {
    opacity: 0.92;
    transform: scale(1);
  }
}

.rules {
  margin: 14px 2px 0;
  font-size: 15px;
}

/* Buttons */
.primary,
.secondary,
.plain {
  display: block;
  width: 100%;
  min-height: 56px;
  margin: 0;
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 20px;
  font-weight: 700;
  line-height: 1.25;
  text-align: center;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.primary {
  border: 2px solid var(--ink);
  background: var(--ink);
  color: #fff;
}

.primary:disabled {
  border-style: dashed;
  background: transparent;
  color: var(--ink-2);
  cursor: default;
  opacity: 1;
  -webkit-text-fill-color: currentColor;
}

.secondary {
  border: 2px solid var(--ink);
  background: transparent;
  color: var(--ink);
}

.plain {
  min-height: 48px;
  border: 0;
  background: transparent;
  color: var(--ink);
  font-size: 18px;
  font-weight: 400;
  text-decoration: underline;
}

.primary:focus-visible,
.secondary:focus-visible,
.plain:focus-visible {
  outline: 3px solid var(--seal);
  outline-offset: 2px;
}

/* Bottom tray: the three picks so far and the one action. */
.tray {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 5;
  padding: 10px 12px;
  padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px));
  background: var(--ink);
  color: var(--ballot);
}

.tray-inner {
  display: flex;
  align-items: center;
  max-width: 536px;
  margin: 0 auto;
}

.slots {
  flex: none;
  display: flex;
  margin-right: 6px;
}

.slot {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 56px;
  margin-right: 6px;
  border: 2px dashed rgba(255, 240, 166, 0.55);
  font-family: var(--num);
  font-size: 30px;
  line-height: 1;
}

.slot.filled {
  border-style: solid;
  border-color: var(--ballot);
  background: var(--ballot);
  color: var(--ink);
}

.tray .primary {
  flex: 1;
  border-color: var(--ballot);
  background: var(--ballot);
  color: var(--ink);
}

.tray .primary:disabled {
  border-color: rgba(255, 240, 166, 0.55);
  background: transparent;
  color: var(--ballot);
}

.tray.nudge .slots {
  animation: nudge 0.3s;
}

@keyframes nudge {
  25% {
    transform: translateX(-5px);
  }
  75% {
    transform: translateX(5px);
  }
}

.toast {
  position: fixed;
  right: 12px;
  bottom: 92px;
  bottom: calc(92px + env(safe-area-inset-bottom, 0px));
  left: 12px;
  z-index: 6;
  max-width: 536px;
  margin: 0 auto;
  padding: 12px 14px;
  border: 2px solid var(--seal);
  background: #fff;
  font-size: 16px;
  font-weight: 700;
  line-height: 1.4;
}

/* Confirmation sheet */
.overlay {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 10;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  background: rgba(20, 35, 138, 0.6);
}

.dialog {
  width: 100%;
  max-width: 560px;
  max-height: 94%;
  padding: 20px 16px 12px;
  padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  border-top: 2px solid var(--ink);
  background: #fff;
}

.dialog h2 {
  margin: 0 0 12px;
  font-size: 22px;
  line-height: 1.3;
}

.picked {
  margin: 0;
  padding: 0;
  border: 2px solid var(--ink);
  list-style: none;
}

.picked li {
  display: flex;
  align-items: stretch;
  min-height: 54px;
  border-bottom: 2px solid var(--ink);
}

.picked li:last-child {
  border-bottom: 0;
}

.picked .no {
  width: 52px;
  font-size: 30px;
}

.picked .name {
  align-self: center;
  padding: 8px 12px;
  font-size: 20px;
}

.attend {
  display: flex;
  align-items: center;
  margin: 14px 0;
  padding: 12px;
  border: 2px solid var(--ink);
  border-radius: 8px;
  background: var(--ballot);
  font-size: 18px;
  font-weight: 700;
  line-height: 1.35;
  cursor: pointer;
}

.attend input {
  flex: none;
  width: 30px;
  height: 30px;
  margin: 0 12px 0 0;
  accent-color: var(--ink);
}

.dialog-error {
  margin: 0 0 12px;
  padding: 10px 12px;
  border: 2px solid var(--seal);
  color: var(--seal);
  font-size: 16px;
  font-weight: 700;
  line-height: 1.4;
}

.dialog .plain {
  margin-top: 4px;
}

@media (min-width: 600px) {
  .overlay {
    align-items: center;
  }

  .dialog {
    border: 2px solid var(--ink);
  }
}

@media (prefers-reduced-motion: reduce) {
  .team[aria-pressed='true'] .stamp,
  .tray.nudge .slots {
    animation: none;
  }
}
