:root {
  color-scheme: light;
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Yu Gothic", sans-serif;
  color: #202e3b; background: #f7f5ef; font-synthesis: none;
  --ink: #202e3b; --muted: #59636a; --line: #dddcd5;
  --blue: #134e8c; --blue-light: #e9f2ff; --purple: #673c94; --purple-light: #f3eafb;
  --card-height: max(370px, calc(100svh - 258px - env(safe-area-inset-top) - env(safe-area-inset-bottom)));
}
* { box-sizing: border-box; }
body { margin: 0; }
[hidden] { display: none !important; }
button, input, select { font: inherit; }
button, input, select, summary { -webkit-tap-highlight-color: transparent; }
button { min-height: 48px; padding: 10px 14px; border: 1px solid transparent; border-radius: 12px; background: var(--ink); color: white; font-size: 1.125rem; font-weight: 750; cursor: pointer; touch-action: manipulation; overflow-wrap: anywhere; }
button:active { transform: translateY(1px); }
button:disabled { opacity: .45; cursor: default; }
:focus-visible { outline: 3px solid #bb651f; outline-offset: 3px; }
button, select, input, dialog { max-width: 100%; }
h1, h2, h3, p { margin: 0; }
img { display: block; max-width: 100%; }
.secondary-button { color: var(--ink); background: #fffefa; border-color: var(--line); }
.app-shell { width: min(100%, 460px); margin-inline: auto; padding: max(12px, env(safe-area-inset-top)) max(14px, env(safe-area-inset-right)) max(12px, env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left)); }
.app-header { display: flex; gap: 8px; align-items: center; justify-content: space-between; min-height: 48px; margin-bottom: 12px; }
.app-header h1 { display: flex; align-items: center; gap: 8px; font-size: 1.125rem; font-weight: 800; line-height: 1.35; min-width: 0; }
.brand-copy { min-width: 0; overflow-wrap: anywhere; }
.election-label { display: block; margin-top: 3px; color: var(--blue); font-size: .875rem; font-weight: 750; line-height: 1.4; }
.brand-mark { display: grid; place-items: center; flex: 0 0 1.875rem; width: 1.875rem; height: 2.25rem; border: 2px solid var(--ink); border-radius: 5px; font-size: 1.125rem; background: white; }
.find-button { background: transparent; color: var(--ink); border-color: var(--line); flex-shrink: 0; }
.find-button span { font-size: 1.25rem; padding-left: 6px; }
.detail-panel { display: grid; gap: 8px; min-width: 0; }
.card-heading { display: flex; gap: 8px; justify-content: space-between; align-items: baseline; min-height: 24px; }
.card-heading h2 { font-size: .875rem; font-weight: 750; line-height: 1.5; overflow-wrap: anywhere; }
.card-count { font-size: .875rem; font-variant-numeric: tabular-nums; white-space: nowrap; color: var(--muted); }
.flashcard { min-width: 0; border: 1px solid #d7d8d5; border-radius: 18px; background: white; box-shadow: 0 4px 0 #dfdfd6; touch-action: pan-y pinch-zoom; -webkit-user-select: none; user-select: none; }
.card-face { min-width: 0; border-radius: inherit; }
.card-face-front { display: grid; grid-template-rows: minmax(0, 1fr) auto; gap: 8px; width: 100%; padding: 10px 10px 12px; border: 0; background: #fff; color: var(--ink); height: min(var(--card-height), 650px); min-height: 370px; }
.card-face-front:active { transform: none; }
.card-photo-front { width: 100%; height: 100%; min-height: 0; object-fit: contain; object-position: center; }
.front-cue { justify-self: center; max-width: 100%; padding: 7px 12px; border-radius: 8px; background: #fffef9; border: 1px solid var(--line); color: var(--ink); font-size: .875rem; line-height: 1.4; white-space: normal; text-align: center; }
.photo-error { display: grid; place-content: center; height: 100%; padding: 24px; font-size: 1.25rem; line-height: 1.8; }
.card-face-back { min-height: min(var(--card-height), 650px); padding: 18px; background: #fffefa; overflow-wrap: anywhere; }
.back-header { margin-bottom: 14px; }
.card-name { font-size: clamp(2rem, 9.6vw, 2.5rem); font-weight: 850; letter-spacing: .015em; line-height: 1.3; }
.back-name-kana { margin-top: 5px; font-size: 1.125rem; font-weight: 700; line-height: 1.55; }
.district-block { padding: 12px 14px; border-radius: 10px; color: var(--blue); background: var(--blue-light); border-left: 5px solid var(--blue); }
[data-election="proportional"] .district-block { color: var(--purple); background: var(--purple-light); border-color: var(--purple); }
.detail-label { font-size: 1rem; font-weight: 700; line-height: 1.5; }
.district-value { font-size: 1.5rem; font-weight: 850; line-height: 1.4; margin-top: 2px; }
.back-grid { display: grid; grid-template-columns: minmax(0, 1.75fr) minmax(0, 1fr); gap: 10px; margin-top: 10px; }
.detail-block { min-width: 0; padding: 10px 12px; border-radius: 10px; }
.party-block { color: #215b43; background: #eaf5eb; }
.wins-block { color: #854212; background: #fff0dd; }
.detail-value { margin-top: 3px; font-size: 1.25rem; line-height: 1.5; font-weight: 800; }
.wins-value { font-size: 1.5rem; }
.card-more { margin-top: 10px; border-top: 1px solid var(--line); }
.card-more summary { min-height: 48px; display: flex; align-items: center; gap: 10px; font-size: 1.125rem; font-weight: 750; cursor: pointer; list-style: none; }
.card-more summary::-webkit-details-marker { display: none; }
.card-more summary::after { content: "+"; margin-left: auto; font-size: 1.5rem; }
.card-more[open] summary::after { content: "−"; }
.more-body { font-size: 1.125rem; line-height: 1.75; -webkit-user-select: text; user-select: text; }
.more-body h4 { font-size: 1.125rem; margin: 12px 0 4px; }
.career-list { margin: 4px 0 0; padding-left: 1.4em; }
.more-body p { white-space: pre-line; }
.card-controls { display: grid; grid-template-columns: 1fr 1.2fr 1fr; gap: 8px; }
.card-controls button { min-height: 52px; padding: 10px 4px; }
.card-status { color: var(--muted); font-size: .8125rem; line-height: 1.4; text-align: center; overflow-wrap: anywhere; }
.empty-state { padding: 24px 16px; font-size: 1.125rem; line-height: 1.7; color: var(--muted); }
.flashcard > .empty-state { min-height: 370px; display: grid; place-content: center; gap: 16px; }
.network-banner { background: #fff0dd; border: 1px solid #b77b3a; border-radius: 10px; padding: 12px; margin-bottom: 12px; font-size: 1rem; line-height: 1.6; }
.finder { width: min(100%, 640px); max-height: 100dvh; max-width: 100vw; padding: max(16px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(24px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left)); border: 1px solid var(--line); border-radius: 18px; color: var(--ink); background: #f7f5ef; overscroll-behavior: contain; }
.finder::backdrop { background: #13233280; }
body:has(.finder[open]) { overflow: hidden; }
.finder-header { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 16px; }
.finder-header h2 { font-size: 1.375rem; overflow-wrap: anywhere; }
.finder-header button { font-size: 1rem; flex-shrink: 0; }
.tab-bar { display: flex; flex-wrap: wrap; gap: 8px; padding-bottom: 16px; border-bottom: 1px solid var(--line); }
.tab-button { background: #fffefa; border-color: var(--line); color: var(--ink); font-size: 1rem; }
.tab-button.is-active { background: var(--ink); border-color: var(--ink); color: white; }
.section-heading { display: flex; flex-wrap: wrap; gap: 8px; justify-content: space-between; align-items: baseline; margin: 18px 0 12px; }
.section-heading h3 { font-size: 1.25rem; }
.section-heading p { font-size: .875rem; color: var(--muted); }
.control-field { display: grid; gap: 6px; min-width: 0; font-size: 1rem; font-weight: 700; }
select, input { min-height: 48px; min-width: 0; width: 100%; border: 1px solid #9babb6; background: #fff; color: var(--ink); border-radius: 8px; padding: 10px; font-size: 1.125rem; }
.filter-grid { display: grid; gap: 12px; }
.search-input-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; }
.search-input-row button { font-size: 1rem; padding-inline: 12px; }
.chip-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.filter-chip { color: var(--blue); background: #fff; border-color: #becfe0; font-size: 1rem; }
.filter-chip.is-active { background: var(--blue); color: #fff; }
.summary-copy, .result-note, .finder-note { margin-top: 12px; font-size: .9375rem; line-height: 1.7; color: var(--muted); }
.result-note { margin-bottom: 8px; }
.member-grid-inner { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-top: 12px; }
.member-tile { display: flex; flex-direction: column; padding: 0; border: 2px solid transparent; border-radius: 12px; color: var(--ink); background: white; text-align: left; min-width: 0; }
.member-tile.is-active { border-color: var(--blue); }
.member-tile-photo { display: block; width: 100%; aspect-ratio: 3/4; padding: 6px; background: #eeeee9; border-radius: 10px 10px 0 0; }
.member-thumb { width: 100%; height: 100%; object-fit: contain; object-position: center; }
.member-tile-body { display: grid; gap: 4px; padding: 10px; min-width: 0; }
.member-name { font-size: 1.125rem; font-weight: 800; line-height: 1.4; }
.member-copy { font-size: .875rem; color: var(--muted); font-weight: 600; line-height: 1.5; }
.load-more { width: 100%; margin-top: 16px; }
.install-banner { margin-top: 24px; padding-top: 20px; border-top: 1px solid var(--line); }
.install-banner h3 { font-size: 1.125rem; margin-bottom: 8px; }
.install-banner p { line-height: 1.7; font-size: 1rem; }
.install-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
@media (max-width: 600px) { .finder { min-height: 100dvh; margin: 0; border-radius: 0; border: 0; } }
@media (min-width: 650px) and (max-height: 550px) { .app-shell { width: min(100%, 540px); } :root { --card-height: 440px; } }
@media (prefers-reduced-motion: no-preference) { .card-face-back { animation: reveal 130ms ease-out; } @keyframes reveal { from { opacity: .5; } to { opacity: 1; } } }

/* Keep the same card-first layout across all four decks. */
.deck-picker { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 10px; align-items: center; margin: 0 0 12px; font-size: .9375rem; font-weight: 750; }
.deck-picker select { min-height: 44px; padding: 8px 10px; font-size: 1rem; }
.card-photo-front { justify-self: center; }
/* Match the reference photograph's whole rectangle, including short screens. */
.role-portrait-space, .role-portrait-frame { display: block; width: 100%; height: 100%; min-width: 0; min-height: 0; overflow: hidden; }
@supports (width: 1cqw) {
  .role-portrait-space { position: relative; container-type: size; }
  .role-portrait-frame {
    --portrait-unit: min(calc(100cqw / 392), calc(100cqh / 638));
    position: absolute; width: calc(392 * var(--portrait-unit)); height: calc(638 * var(--portrait-unit));
    left: 50%; top: 50%; transform: translate(-50%, -50%);
  }
  .role-portrait-frame .card-photo-front {
    position: absolute; max-width: none;
    width: calc(var(--portrait-width) * var(--portrait-unit));
    height: calc(var(--portrait-height) * var(--portrait-unit));
    left: calc(var(--portrait-left) * var(--portrait-unit));
    top: calc(var(--portrait-top) * var(--portrait-unit));
  }
}
.role-card-back { display: grid; align-content: start; gap: 14px; }
.role-card-back[hidden] { display: none; }
.role-list { margin: 6px 0 0; padding-left: 1.2em; font-size: 1.125rem; line-height: 1.6; }
.role-source-date { color: var(--muted); font-size: .875rem; line-height: 1.5; }
.tab-button[hidden] { display: none; }
