:root {
  color: #30232c; background: #fff8fc; font-family: "Hiragino Sans", "Yu Gothic", system-ui, sans-serif;
  font-synthesis: none; --pink: #ff4f93; --deep: #c91f68; --ink: #30232c; --line: #f0d2df;
}
* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; background: radial-gradient(circle at 50% -8%, #ffd7e8 0, transparent 32%), linear-gradient(180deg,#fff8fc,#fff); }
button, summary { -webkit-tap-highlight-color: transparent; }
button { font: inherit; }
.app-shell { width: min(100%, 790px); min-height: 100vh; margin: auto; padding: 24px 16px 120px; }
.panel { background: rgba(255,255,255,.94); border: 1px solid var(--line); border-radius: 30px; box-shadow: 0 18px 55px rgba(176,39,98,.1); padding: 42px 26px; }
.hero { position: relative; overflow: hidden; text-align: center; margin-top: 4vh; }
.hero::before, .hero::after { content: ""; position: absolute; width: 190px; height: 190px; border-radius: 50%; background: #ffe4ef; z-index: -1; }
.hero::before { top: -95px; left: -75px; }.hero::after { right: -90px; bottom: -110px; }
.sparkle { color: #ffb100; font-size: 2rem; line-height: 1; }
.eyebrow { color: var(--deep); font-size: .78rem; font-weight: 900; letter-spacing: .16em; }
.hero h1 { font-size: clamp(2.8rem, 12vw, 5rem); line-height: .96; margin: 20px 0; letter-spacing: -.05em; }
.hero h1 span { color: var(--pink); text-shadow: 3px 3px 0 #ffe0ed; }
.lead { font-size: 1.05rem; line-height: 1.8; font-weight: 700; }
.muted { color: #806e78; line-height: 1.7; }
.tiny { color: #8b7882; font-size: .78rem; line-height: 1.6; margin: 22px auto 0; }
.flow-card { display: flex; align-items: center; justify-content: center; gap: 9px; margin: 28px 0; padding: 15px 12px; background: #fff3f8; border: 1px solid #ffd5e6; border-radius: 18px; font-size: .83rem; }
.flow-card span { color: #c69bad; }
.primary, .secondary, .ghost { border-radius: 999px; cursor: pointer; font-weight: 800; min-height: 48px; padding: 13px 24px; transition: transform .15s, box-shadow .15s, opacity .15s; }
.primary { border: 0; background: linear-gradient(135deg,#ff4f93,#e92c77); color: white; min-width: 220px; box-shadow: 0 8px 20px rgba(255,79,147,.28); }
.secondary { border: 1px solid #e8c5d5; background: white; color: #b52263; }
.ghost { display: block; margin: 12px auto 0; border: 0; background: transparent; color: #8a6c7a; text-decoration: underline; }
.primary:hover, .secondary:hover { transform: translateY(-1px); }.primary:active, .secondary:active { transform: translateY(1px); }
button:disabled { cursor: not-allowed; opacity: .38; transform: none !important; box-shadow: none; }
details { margin-top: 25px; border-top: 1px solid var(--line); padding-top: 18px; text-align: left; }
summary { cursor: pointer; color: #775e6a; font-size: .9rem; font-weight: 700; }
.details-body { color: #715e67; font-size: .86rem; line-height: 1.75; }.details-body a { color: var(--deep); }
.stage-header { position: sticky; top: 0; z-index: 5; background: rgba(255,248,252,.94); backdrop-filter: blur(13px); padding: 8px 4px 16px; }
.stage-line { display: grid; grid-template-columns: auto auto 1fr; align-items: center; gap: 10px; font-size: .9rem; }
.stage-pill { display: inline-flex; align-items: center; min-height: 32px; padding: 5px 12px; background: white; border: 1px solid #efcddd; border-radius: 999px; color: var(--deep); font-weight: 900; }
.text-button { justify-self: end; border: 0; background: transparent; color: #806e78; cursor: pointer; text-decoration: underline; }
.progress { height: 7px; margin: 13px 0 22px; overflow: hidden; background: #f4dae5; border-radius: 10px; }
.progress span { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg,#ff75aa,#ff3f88); transition: width .25s; }
.stage-header h1 { margin: 0; font-size: clamp(1.35rem,5vw,2rem); }.stage-header p { margin: 7px 0 0; color: #816d77; font-size: .92rem; }
.candidate-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 14px; padding: 8px 0 105px; }
.candidate { min-width: 0; padding: 0 0 13px; overflow: hidden; border: 2px solid transparent; border-radius: 20px; background: white; color: var(--ink); box-shadow: 0 6px 20px rgba(80,35,57,.09); cursor: pointer; transition: transform .16s, border .16s, box-shadow .16s; }
.candidate:hover { transform: translateY(-2px); box-shadow: 0 10px 26px rgba(80,35,57,.14); }
.candidate.selected { border-color: var(--pink); box-shadow: 0 0 0 4px #ffd9e8, 0 10px 26px rgba(208,45,112,.2); }
.candidate strong { display: block; min-height: 2.6em; padding: 11px 7px 0; font-size: .94rem; line-height: 1.3; }
.photo, .result-photo { position: relative; display: block; aspect-ratio: 4/5; overflow: hidden; background: linear-gradient(135deg,#f8e4ed,#f3edf0); }
.photo img, .result-photo img { display: block; width: 100%; height: 100%; object-fit: cover; object-position: center 18%; }
.photo i { position: absolute; right: 9px; bottom: 8px; display: grid; place-items: center; width: 33px; height: 33px; border-radius: 50%; background: white; color: #d7bdc8; font-style: normal; box-shadow: 0 4px 12px #63334a33; }
.selected .photo i { color: var(--pink); }.badge { position: absolute; left: 9px; top: 9px; display: grid; place-items: center; width: 36px; height: 36px; border-radius: 50%; background: #ffca3a; color: #5f4400; font-size: 1.05rem; box-shadow: 0 3px 10px #61440044; }
.fallback { display: none; position: absolute; inset: 0; place-items: center; color: #aa8f9b; font-size: .72rem; }.fallback.show { display: grid; }
.action-bar { position: fixed; z-index: 8; left: 50%; bottom: max(12px, env(safe-area-inset-bottom)); transform: translateX(-50%); width: min(calc(100% - 24px),750px); display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 10px; padding: 12px; border: 1px solid #ebccd9; border-radius: 24px; background: rgba(255,255,255,.96); box-shadow: 0 12px 35px rgba(86,30,55,.18); backdrop-filter: blur(16px); }
.action-bar span { font-size: .8rem; font-weight: 800; text-align: center; }.compact { min-width: 0; padding-inline: 15px; }
.toast { position: fixed; z-index: 20; left: 50%; bottom: 105px; transform: translateX(-50%); width: max-content; max-width: calc(100% - 40px); padding: 12px 18px; border-radius: 14px; background: #38252e; color: white; font-size: .9rem; box-shadow: 0 8px 25px #0004; }
.duel { display: grid; grid-template-columns: minmax(0,1fr) 46px minmax(0,1fr); align-items: center; gap: 10px; padding: 14px 0 30px; }.duel .candidate { width: 100%; }.versus { display: grid; place-items: center; width: 46px; height: 46px; border-radius: 50%; background: #3a2730; color: white; font-size: .76rem; font-weight: 900; }
.rank-footer { display: flex; justify-content: center; align-items: center; gap: 18px; color: #806e78; font-size: .85rem; }
.result-head { padding: 38px 8px 26px; text-align: center; }.result-head h1 { margin: 10px 0; font-size: clamp(2rem,8vw,3.7rem); line-height: 1.08; letter-spacing: -.04em; }.result-head p:last-child { color: #816d77; }
.result-grid { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 10px; padding: 15px; border: 1px solid #efcfdd; border-radius: 28px; background: linear-gradient(145deg,#fff,#fff2f8); box-shadow: 0 15px 45px rgba(135,40,80,.12); }
.result-card { min-width: 0; overflow: hidden; border: 2px solid transparent; border-radius: 15px; background: white; box-shadow: 0 5px 15px #6d334d18; }.result-card a { color: inherit; text-decoration: none; }.result-card strong { display: block; min-height: 3.5em; padding: 8px 4px; font-size: clamp(.7rem,2.6vw,.9rem); line-height: 1.35; text-align: center; }
.result-card.rank-1 { border: 5px solid #e2b529; box-shadow: 0 0 0 4px #fff0a9, 0 8px 22px #8f6d1740; }
.result-card.rank-2 { border-color: #b9bec7; box-shadow: 0 5px 16px #75809235; }
.result-card.rank-3 { border-color: #bb7b50; box-shadow: 0 5px 16px #8a4c2b35; }
.result-photo b { position: absolute; left: 6px; top: 6px; display: inline-flex; align-items: center; min-height: 30px; padding: 4px 9px; border-radius: 999px; background: rgba(255,255,255,.92); color: #4f3b44; border: 2px solid white; font-size: .78rem; box-shadow: 0 2px 8px #4f263733; }
.rank-1 .result-photo b { background: linear-gradient(135deg,#f7d354,#dca719); color: #543a00; }
.rank-2 .result-photo b { background: linear-gradient(135deg,#f7f8fa,#cbd0d8); color: #4b515c; }
.rank-3 .result-photo b { background: linear-gradient(135deg,#e7b18f,#b87348); color: #4f2814; }
.ranking-list { margin: 28px 0; padding: 24px; border-radius: 24px; background: white; border: 1px solid var(--line); }.ranking-list h2 { margin-top: 0; text-align: center; }.ranking-list p { display: flex; align-items: center; gap: 14px; margin: 0; padding: 10px 0; border-bottom: 1px solid #f5e5ec; }.ranking-list p:last-child { border: 0; }.ranking-list p b { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; background: #fff0f6; color: var(--deep); }
.result-actions { display: grid; justify-items: center; gap: 10px; }.result-actions .secondary { min-width: 220px; }.center-text { text-align: center; }
@media (min-width: 640px) { .candidate-grid { grid-template-columns: repeat(4,minmax(0,1fr)); }.candidate strong { font-size: 1rem; }.result-grid { gap: 16px; padding: 22px; }.duel { max-width: 620px; margin: auto; gap: 22px; } }
@media (max-width: 390px) { .app-shell { padding-inline: 10px; }.panel { padding-inline: 17px; }.flow-card { gap: 5px; font-size: .72rem; }.action-bar { gap: 6px; }.action-bar button { padding-inline: 10px; font-size: .82rem; }.duel { grid-template-columns: minmax(0,1fr) 34px minmax(0,1fr); gap: 5px; }.versus { width: 34px; height: 34px; font-size: .65rem; } }
@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto !important; transition: none !important; } }

/* Keep each four-person round inside Safari's visible area. */
@media (max-width: 639px) {
  .app-shell:has(> .candidate-grid) {
    height: 100svh;
    min-height: 540px;
    padding: 8px 12px max(8px, env(safe-area-inset-bottom));
    display: flex;
    flex-direction: column;
    gap: 10px;
  }
  .app-shell:has(> .candidate-grid) .stage-header {
    position: static;
    flex: none;
    padding: 0 2px;
  }
  .app-shell:has(> .candidate-grid) .progress { height: 5px; margin: 8px 0 10px; }
  .app-shell:has(> .candidate-grid) .stage-header h1 { font-size: 1.25rem; line-height: 1.4; }
  .app-shell:has(> .candidate-grid) .stage-header p { font-size: .875rem; margin-top: 4px; }
  .candidate-grid {
    flex: 1;
    min-height: 0;
    grid-template-rows: repeat(2, minmax(0, 1fr));
    gap: 10px;
    padding: 0;
  }
  .candidate-grid .candidate { display: flex; flex-direction: column; min-height: 0; padding: 0; border-radius: 16px; }
  .candidate-grid .photo { flex: 1; min-height: 0; width: 100%; aspect-ratio: auto; background: white; }
  .candidate-grid .photo img { object-fit: contain; object-position: center; }
  .candidate-grid .candidate strong { flex: none; width: 100%; min-height: 0; padding: 7px 3px; font-size: .875rem; line-height: 1.4; }
  .candidate-grid .photo i { width: 28px; height: 28px; right: 6px; bottom: 6px; }
  .app-shell:has(> .candidate-grid) .action-bar {
    position: static;
    flex: none;
    transform: none;
    width: 100%;
    gap: 8px;
    padding: 8px;
    border-radius: 20px;
  }
  .app-shell:has(> .candidate-grid) .action-bar button { min-width: 0; min-height: 44px; padding: 10px 8px; font-size: .875rem; }
}
