:root { --fg: #222; --bg: #fff; --muted: #888; --accent: #c2185b; --line: #fff; }
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body { font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Yu Gothic UI", "Meiryo", sans-serif; color: var(--fg); background: var(--bg); line-height: 1.6; -webkit-text-size-adjust: 100%; }
.plain-page { padding: 24px 16px; }
.app-version { text-align: right; font-size: 11px; color: var(--muted); padding: 4px 8px 8px; }

/* ---- 投票画面 ---- */
.vote-page { background: #000; color: #fff; }
.vote-page .app-version { color: #777; }
.banner { height: 56px; display: flex; align-items: center; justify-content: center; background: #111; overflow: hidden; }
.banner img { height: 100%; width: 100%; object-fit: cover; }
.banner__text { font-weight: bold; font-size: 18px; padding: 0 12px; text-align: center; line-height: 1.2; }

.grid { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: 2px; }
.grid li { margin: 0; }
.tile { position: relative; display: block; width: 100%; aspect-ratio: 3 / 4; padding: 0; border: 0; background: #333; cursor: pointer; overflow: hidden; -webkit-tap-highlight-color: transparent; }
.grid--many .tile { aspect-ratio: auto; height: min(calc((100vw - 4px) / 3 * 1.25), calc((100vh - 62px) / 4)); }
/* 10人以上：4段が1画面（バナー56px＋区切り線）に収まるよう、高さを 4:5 と「画面の高さ÷4」の小さい方に */
@supports (height: 100svh) {
  .grid--many .tile { height: min(calc((100vw - 4px) / 3 * 1.25), calc((100svh - 62px) / 4)); }
}
.tile img { width: 100%; height: 100%; object-fit: cover; display: block; }
.tile:active { opacity: .75; }
.tile__noimg { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: #ccc; font-size: 20px; font-weight: bold; }
.tile__label { position: absolute; left: 0; right: 0; bottom: 0; padding: 14px 6px 4px; text-align: left; font-size: 12px; font-weight: bold; color: #fff; line-height: 1.25; text-shadow: 0 1px 2px rgba(0,0,0,.9); background: linear-gradient(transparent, rgba(0,0,0,.55)); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.notice { padding: 12px 16px; font-size: 14px; color: #ddd; }
.notice p { margin: 0 0 8px; }
.notice__alert { color: #ffd54f; font-weight: bold; }
.message { padding: 48px 16px; text-align: center; font-size: 18px; }

.modal { position: fixed; inset: 0; background: rgba(0,0,0,.75); display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 10; }
.modal[hidden] { display: none; }
.modal__box { background: #fff; color: #222; border-radius: 12px; padding: 20px 16px; width: 100%; max-width: 360px; text-align: center; max-height: 100%; overflow-y: auto; }
.modal__img { width: 70%; max-width: 240px; aspect-ratio: 3 / 4; object-fit: cover; border-radius: 8px; }
.modal__img[hidden] { display: none; }
.modal__name { font-size: 20px; font-weight: bold; margin: 8px 0; }
.modal__done { font-size: 18px; font-weight: bold; margin: 12px 0; }
.modal__error { color: #c62828; font-weight: bold; }
.modal__buttons { display: flex; flex-direction: column; gap: 10px; margin-top: 16px; }
.btn { font-size: 17px; padding: 12px; border-radius: 8px; border: 1px solid #bbb; background: #f5f5f5; color: #222; cursor: pointer; }
.btn--primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: bold; }
.btn:disabled { opacity: .5; }

/* ---- 集計画面 ---- */
.results-page { background: #fafafa; }
.rs-head { padding: 12px 16px 4px; background: #fff; border-bottom: 1px solid #e5e5e5; }
.rs-head h1 { font-size: 18px; margin: 0 0 6px; }
.rs-meta { display: flex; flex-wrap: wrap; gap: 6px 14px; align-items: center; font-size: 13px; }
.rs-status { font-weight: bold; color: #fff; padding: 2px 10px; border-radius: 999px; background: #888; }
.rs-status--open { background: #2e7d32; }
.rs-status--closed { background: #c62828; }
.rs-toggle { margin-left: auto; }
.rs-types { font-size: 12px; color: #555; margin: 6px 0; display: flex; flex-wrap: wrap; gap: 4px 12px; }
.rs-error { color: #c62828; font-size: 13px; margin: 4px 0; }
.rs-list { list-style: none; margin: 0; padding: 8px 12px; }
.rs-row { display: grid; grid-template-columns: 3.2em 1fr auto auto; gap: 2px 10px; align-items: baseline; background: #fff; border: 1px solid #e5e5e5; border-radius: 8px; padding: 8px 10px; margin-bottom: 8px; }
.rs-row--top { border-color: var(--accent); }
.rs-rank { font-weight: bold; font-size: 18px; }
.rs-name { font-weight: bold; }
.rs-points { font-weight: bold; font-size: 18px; color: var(--accent); }
.rs-votes { color: #555; font-size: 13px; }
.rs-bar { grid-column: 1 / -1; height: 8px; background: #eee; border-radius: 4px; overflow: hidden; }
.rs-bar__fill { display: block; height: 100%; background: var(--accent); transition: width .4s; }
.rs-detail { grid-column: 1 / -1; font-size: 12px; color: #666; }
.rank-hidden .rs-rank, .rank-hidden .rs-points, .rank-hidden .rs-votes, .rank-hidden .rs-bar, .rank-hidden .rs-detail { visibility: hidden; }
@media (min-width: 900px) {
  .rs-head h1 { font-size: 28px; }
  .rs-meta { font-size: 18px; }
  .rs-types { font-size: 16px; }
  .rs-list { max-width: 1100px; margin: 0 auto; }
  .rs-row { font-size: 22px; padding: 12px 16px; }
  .rs-rank, .rs-points { font-size: 28px; }
  .rs-votes, .rs-detail { font-size: 16px; }
  .rs-bar { height: 14px; }
}

/* ---- 管理画面（PC 前提） ---- */
.admin-page { background: #f4f5f7; }
.ad-head { display: flex; justify-content: space-between; align-items: center; padding: 10px 16px; background: #263238; color: #fff; }
.ad-head__title { color: #fff; font-weight: bold; text-decoration: none; }
.ad-head form { margin: 0; }
.ad-main { max-width: 1000px; margin: 0 auto; padding: 16px; }
.ad-main h1 { font-size: 22px; margin: 8px 0 16px; }
.ad-box { background: #fff; border: 1px solid #ddd; border-radius: 8px; padding: 12px 16px; margin-bottom: 16px; }
.ad-box h2 { font-size: 17px; margin: 0 0 8px; }
.ad-flash { background: #e8f5e9; border: 1px solid #a5d6a7; padding: 8px 12px; border-radius: 6px; }
.ad-errors { background: #ffebee; border: 1px solid #ef9a9a; padding: 8px 12px; border-radius: 6px; color: #b71c1c; }
.ad-errors p { margin: 2px 0; }
.ad-form { display: flex; flex-direction: column; gap: 12px; max-width: 640px; }
.ad-form label { display: flex; flex-direction: column; gap: 4px; font-weight: bold; }
.ad-form label.ad-check { flex-direction: row; align-items: center; font-weight: normal; gap: 8px; }
.ad-form input[type=text], .ad-form input[type=password], .ad-form input[type=number], .ad-form textarea { font-size: 16px; padding: 8px; border: 1px solid #bbb; border-radius: 6px; font-weight: normal; }
.ad-note { color: #666; font-size: 13px; }
.ad-btn { display: inline-block; font-size: 15px; padding: 8px 14px; border-radius: 6px; border: 1px solid #999; background: #fff; color: #222; text-decoration: none; cursor: pointer; }
.ad-btn--primary { background: #1565c0; border-color: #1565c0; color: #fff; font-weight: bold; }
.ad-btn--small { font-size: 13px; padding: 4px 10px; }
.ad-btn--big { font-size: 18px; padding: 14px 20px; font-weight: bold; }
.ad-btn--go { background: #2e7d32; border-color: #2e7d32; color: #fff; }
.ad-btn--stop { background: #c62828; border-color: #c62828; color: #fff; }
.ad-btn--danger { background: #fff; border-color: #c62828; color: #c62828; }
.ad-status-buttons { display: flex; flex-wrap: wrap; gap: 10px; }
.ad-status-buttons form { margin: 0; }
.ad-status { display: inline-block; padding: 1px 10px; border-radius: 999px; color: #fff; background: #888; font-size: 13px; }
.ad-bigstatus { display: inline-block; font-size: 26px; font-weight: bold; padding: 4px 24px; border-radius: 8px; color: #fff; background: #888; margin: 4px 0; }
.ad-status--open { background: #2e7d32; }
.ad-status--closed { background: #c62828; }
.ad-table { border-collapse: collapse; width: 100%; background: #fff; }
.ad-table th, .ad-table td { border: 1px solid #ddd; padding: 6px 8px; text-align: left; vertical-align: middle; }
.ad-table th { background: #eceff1; }
.ad-url input { width: 100%; font-size: 13px; padding: 4px; }
.ad-banner-preview { max-width: 100%; max-height: 80px; }
.ad-thumb { width: 48px; height: 64px; object-fit: cover; display: block; }
.ad-inline { display: inline; margin: 0; }
