:root {
  --yellow: #f6c800;
  --yellow-soft: #ffe86a;
  --ink: #151515;
  --muted: #706f69;
  --paper: #f4f1e8;
  --card: #fffdf7;
  --line: #d8d3c6;
  --red: #c63527;
  --shadow: 0 18px 50px rgba(21, 21, 21, .12);
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(90deg, rgba(21,21,21,.025) 1px, transparent 1px) 0 0 / 44px 44px,
    var(--paper);
  font-family: "Hiragino Kaku Gothic ProN", "Yu Gothic", system-ui, sans-serif;
}
button, input { font: inherit; }
button { color: inherit; }
a { color: inherit; }
.hidden { display: none !important; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 68px;
  padding: 10px clamp(18px, 4vw, 56px);
  color: white;
  background: rgba(21,21,21,.96);
  backdrop-filter: blur(12px);
  border-bottom: 4px solid var(--yellow);
}
.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; font-weight: 900; letter-spacing: .04em; }
.header-actions { display: flex; gap: 8px; }
.quiet-button { border: 1px solid #505050; border-radius: 999px; padding: 8px 13px; color: white; background: transparent; cursor: pointer; }
.quiet-button:hover { border-color: var(--yellow); color: var(--yellow); }

main { width: min(1180px, calc(100% - 32px)); margin: 0 auto; }
.hero { display: grid; grid-template-columns: 1fr auto; align-items: end; gap: 40px; padding: clamp(54px, 9vw, 116px) 0 42px; }
.eyebrow { margin: 0 0 12px; color: var(--muted); font-size: 12px; font-weight: 900; letter-spacing: .16em; text-transform: uppercase; }
.lead { max-width: 680px; margin: 0; color: #56544f; font-size: clamp(15px, 2vw, 19px); line-height: 1.9; }
.hero-score { min-width: 150px; padding: 26px; background: var(--yellow); border: 3px solid var(--ink); box-shadow: 9px 9px 0 var(--ink); transform: rotate(1.5deg); }
.score-line { display: flex; align-items: baseline; gap: 3px; }
.hero-score span { font: 72px/1 Impact, sans-serif; }
.hero-score small { font-weight: 900; }
.hero-score p { margin: 5px 0 0 7px; font-weight: 900; }
.history-link { display: block; margin: 8px 0 0; padding: 0; color: var(--ink); background: none; border: 0; border-bottom: 1px solid currentColor; font-size: 11px; font-weight: 900; cursor: pointer; }

.draft-stage { min-height: 300px; padding: clamp(24px, 5vw, 54px); color: white; background: var(--ink); border-radius: 22px; box-shadow: var(--shadow); overflow: hidden; position: relative; }
.draft-stage::after { content: ""; position: absolute; inset: 0 0 0 68%; opacity: .13; background: repeating-linear-gradient(120deg, transparent 0 22px, var(--yellow) 22px 36px); pointer-events: none; }
.stage-idle { position: relative; z-index: 1; text-align: center; }
.stage-idle h2, .complete-state h2 { margin: 0; font-size: clamp(26px, 4vw, 42px); }
.stage-idle p { color: #aaa; }
.draft-roulette { display: flex; flex-direction: column; width: min(100%, 610px); margin: 4px auto 18px; }
.roulette-machine {
  position: relative;
  height: 250px;
  overflow: hidden;
  isolation: isolate;
  background: radial-gradient(ellipse at 50% 42%, #343434 0%, #202020 68%);
  border-block: 1px solid #666;
  perspective: 700px;
}
.roulette-machine::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 3;
  pointer-events: none;
  background: linear-gradient(#151515 0%, transparent 33%, transparent 67%, #151515 100%);
}
.roulette-focus {
  position: absolute;
  top: 50%;
  left: 0;
  right: 0;
  height: 78px;
  z-index: 0;
  transform: translateY(-50%);
  background: rgba(246, 200, 0, .08);
  border-block: 1px solid rgba(246, 200, 0, .5);
}
.roulette-arrow {
  position: absolute;
  top: 50%;
  left: 12px;
  z-index: 5;
  color: var(--yellow);
  font-size: 20px;
  transform: translateY(-50%);
}
.roulette-reel { position: absolute; inset: 0; transform-style: preserve-3d; }
.roulette-row {
  position: absolute;
  top: calc(50% - 39px);
  left: 9%;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 82%;
  height: 78px;
  color: #fffdf7;
  font-size: clamp(21px, 3.4vw, 40px);
  font-weight: 900;
  line-height: 1.12;
  text-align: center;
  overflow-wrap: anywhere;
  transform-origin: center;
  will-change: transform, opacity;
}
.roulette-machine.settled #rouletteDisplay {
  z-index: 4;
  animation: roulette-winner-grow 700ms cubic-bezier(.2,.8,.2,1) both;
}
.roulette-machine.settled .roulette-row:not(#rouletteDisplay) { transition: opacity 450ms; opacity: .1 !important; }
.roulette-status { min-height: 18px; margin: 9px 0 0 !important; color: #aaa; font-size: 12px; }
@keyframes roulette-winner-grow {
  0% { transform: translateY(0) scale(1); }
  65% { transform: translateY(0) scale(1.3); text-shadow: 0 0 30px rgba(246,200,0,.42); }
  100% { transform: translateY(0) scale(1.2); text-shadow: 0 0 22px rgba(246,200,0,.3); }
}
.year-range { display: flex; align-items: end; justify-content: center; flex-wrap: wrap; gap: 9px; margin: 22px 0; }
.year-range label { display: grid; gap: 5px; color: #aaa; font-size: 10px; font-weight: 800; text-align: left; }
.year-range select { min-width: 105px; padding: 10px 32px 10px 12px; color: white; background: #292929; border: 1px solid #656565; border-radius: 8px; font-weight: 900; }
.year-range select:disabled { opacity: .55; }
.year-range > span { padding-bottom: 10px; color: var(--yellow); font-weight: 900; }
.year-range small { padding-bottom: 11px; color: #aaa; }
.primary-button, .secondary-button { border: 2px solid var(--yellow); border-radius: 999px; padding: 14px 26px; font-weight: 900; cursor: pointer; transition: transform .15s, box-shadow .15s; }
.primary-button { color: var(--ink); background: var(--yellow); box-shadow: 0 6px 0 #806900; }
.primary-button:hover { transform: translateY(-2px); box-shadow: 0 8px 0 #806900; }
.primary-button:active { transform: translateY(4px); box-shadow: 0 2px 0 #806900; }
.primary-button.full { width: 100%; margin-top: 18px; }
.secondary-button { color: white; background: transparent; }
.draw-result, .complete-state { position: relative; z-index: 1; }
.draw-header { display: flex; align-items: end; justify-content: space-between; gap: 20px; margin-bottom: 24px; }
.condition { display: flex; align-items: baseline; flex-wrap: wrap; gap: 8px; }
.condition strong { color: var(--yellow); font: clamp(52px, 8vw, 88px)/.9 Impact, sans-serif; }
.condition span { font-size: 22px; font-weight: 900; }
.condition b { margin-left: 12px; padding: 8px 12px; color: var(--ink); background: white; border-radius: 7px; }
.candidate-count { color: #aaa; font-size: 13px; }
.draw-tools { display: flex; align-items: flex-end; flex-direction: column; gap: 10px; }
.skip-button { padding: 9px 14px; color: white; background: transparent; border: 1px solid #777; border-radius: 999px; font-size: 12px; font-weight: 800; cursor: pointer; }
.skip-button:hover:not(:disabled) { color: var(--yellow); border-color: var(--yellow); }
.skip-button:disabled { opacity: .35; cursor: not-allowed; }
.candidate-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 12px; max-height: 410px; overflow: auto; padding-right: 4px; }
.candidate-card { position: relative; padding: 18px; color: var(--ink); text-align: left; background: var(--card); border: 2px solid transparent; border-radius: 12px; cursor: pointer; }
.candidate-card:hover { border-color: var(--yellow); transform: translateY(-2px); }
.candidate-card[aria-disabled="true"] { opacity: .35; cursor: not-allowed; transform: none; }
.candidate-card strong { display: block; margin-bottom: 7px; font-size: 20px; }
.candidate-card small { display: block; color: var(--muted); line-height: 1.55; }
.pos-badge { float: right; display: grid; place-items: center; width: 30px; height: 30px; margin-left: 8px; color: white; background: var(--ink); border-radius: 50%; font-weight: 900; }
.npb-link { display: inline-block; margin-top: 10px; color: #3d4fa8; font-size: 12px; font-weight: 800; }
.complete-state { padding: 42px 0; text-align: center; }
.complete-state .eyebrow { color: var(--yellow); }
.complete-state p:not(.eyebrow) { color: #aaa; }
.complete-actions { display: flex; justify-content: center; flex-wrap: wrap; gap: 10px; margin-top: 22px; }

.roster-section { padding: 74px 0 0; }
.section-title { display: flex; align-items: end; justify-content: space-between; gap: 20px; margin-bottom: 22px; }
.section-title.compact { margin-bottom: 12px; }
.section-title h2 { margin: 0; font: 36px/1 Impact, sans-serif; letter-spacing: .03em; }
.text-button { padding: 8px 0; color: var(--muted); background: none; border: 0; border-bottom: 1px solid currentColor; cursor: pointer; }
.roster-layout { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(320px, .8fr); gap: 18px; }
.panel { padding: 20px; background: rgba(255,253,247,.88); border: 1px solid var(--line); border-radius: 16px; }
.panel-heading { display: flex; align-items: center; justify-content: space-between; margin-bottom: 15px; }
.panel-heading h3 { margin: 0; font-size: 15px; }
.panel-heading span { color: var(--muted); font-size: 12px; }
.lineup { display: grid; gap: 7px; margin: 0; padding: 0; list-style: none; }
.lineup-row, .slot-row { display: grid; align-items: center; min-height: 47px; background: white; border: 1px solid #e5e0d4; border-radius: 9px; }
.lineup-row { grid-template-columns: 34px 44px 1fr auto; gap: 8px; padding: 6px 10px 6px 6px; }
.bat-order { display: grid; place-items: center; height: 34px; color: var(--ink); background: var(--yellow); border-radius: 7px; font-weight: 900; }
.field-pos { color: var(--muted); font-size: 12px; font-weight: 900; text-align: center; }
.player-name { font-weight: 900; }
.player-name.empty { color: #aaa; font-weight: 500; }
.player-origin { color: var(--muted); font-size: 10px; }
.staff-grid { display: grid; gap: 12px; }
.slot-list { display: grid; gap: 7px; }
.slot-row { grid-template-columns: 66px minmax(0, 1fr) auto; gap: 8px; padding: 8px 10px; }
.slot-label { color: var(--muted); font-size: 11px; font-weight: 900; }
.history-list { display: grid; gap: 8px; }
.history-modal-list { max-height: 58vh; margin-top: 20px; overflow: auto; }
.history-row { display: grid; grid-template-columns: 42px 90px 1fr auto; gap: 12px; align-items: center; padding: 13px 16px; background: rgba(255,255,255,.6); border-bottom: 1px solid var(--line); }
.history-row.skipped { border-left: 3px solid var(--red); }
.history-row.skipped strong { color: var(--red); }
.history-index { color: var(--muted); font-family: monospace; }
.history-condition { font-size: 12px; font-weight: 800; }
.history-role { color: var(--muted); font-size: 12px; }
.empty-copy { color: var(--muted); }

footer { width: min(1180px, calc(100% - 32px)); margin: 70px auto 0; padding: 28px 0 46px; color: var(--muted); border-top: 1px solid var(--line); font-size: 11px; line-height: 1.7; }
.podcast-promo { display: flex; align-items: center; gap: 12px; width: min(100%, 680px); }
.podcast-copy { color: #8f3028; font-size: 12px; font-weight: 900; white-space: nowrap; }
.podcast-embed { display: block; flex: 1 1 420px; width: 100%; min-width: 0; max-width: 440px; height: 80px; border: 0; border-radius: 12px; }

.modal { width: min(620px, calc(100% - 24px)); padding: 0; color: var(--ink); background: var(--card); border: 0; border-radius: 18px; box-shadow: var(--shadow); }
.modal::backdrop { background: rgba(10,10,10,.72); backdrop-filter: blur(4px); }
.modal form { position: relative; padding: clamp(24px, 5vw, 42px); }
.modal.wide { width: min(900px, calc(100% - 24px)); }
.modal-close { position: absolute; top: 16px; right: 16px; width: 34px; height: 34px; background: #eee9dc; border: 0; border-radius: 50%; cursor: pointer; }
.modal h2 { margin: 0; font-size: 32px; }
.modal-sub { color: var(--muted); }
.reset-confirm { width: min(520px, calc(100% - 24px)); }
.reset-actions { display: flex; justify-content: flex-end; gap: 12px; margin-top: 28px; }
.reset-actions .secondary-button { color: var(--ink); background: #fffdf7; }
@media (max-width: 520px) {
  .reset-actions { flex-direction: column-reverse; }
  .reset-actions button { width: 100%; }
}
fieldset { margin: 24px 0 0; padding: 0; border: 0; }
legend { margin-bottom: 10px; font-size: 12px; font-weight: 900; }
.role-options, .order-options { display: grid; grid-template-columns: repeat(auto-fit, minmax(76px, 1fr)); gap: 7px; }
.choice input { position: absolute; opacity: 0; pointer-events: none; }
.choice span { display: grid; place-items: center; min-height: 44px; padding: 7px; background: white; border: 1px solid var(--line); border-radius: 8px; font-size: 12px; font-weight: 800; cursor: pointer; }
.choice input:checked + span { background: var(--yellow); border-color: var(--ink); box-shadow: 3px 3px 0 var(--ink); }
.choice input:disabled + span { opacity: .35; cursor: not-allowed; }
.form-error { min-height: 18px; margin: 14px 0 0; color: var(--red); font-size: 12px; font-weight: 800; }
.rule-list { padding-left: 20px; line-height: 1.9; }
.data-source { margin: 10px 0 0; color: var(--muted); font-size: 11px; line-height: 1.7; }
.data-toolbar { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 20px 0; }
.data-toolbar select { width: 100%; padding: 10px; background: white; border: 1px solid var(--line); border-radius: 8px; }
.data-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 6px; max-height: 55vh; overflow: auto; }
.data-person { padding: 10px; background: white; border: 1px solid var(--line); border-radius: 8px; font-size: 13px; }
.data-person small { display: block; color: var(--muted); margin-top: 3px; }
.desktop-share-preview { display: block; width: 100%; margin: 20px 0 14px; background: var(--ink); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 12px 30px rgba(21,21,21,.16); }
.desktop-share-actions { display: grid; grid-template-columns: 1fr 1fr 1.35fr; gap: 8px; align-items: stretch; }
.desktop-share-actions button { min-height: 52px; padding: 10px 14px; border-radius: 13px; font-weight: 900; cursor: pointer; }
.desktop-share-actions .save-image-button { color: var(--ink); background: white; border: 2px solid var(--ink); }
.desktop-share-actions .copy-image-button { color: var(--ink); background: var(--yellow); border: 2px solid var(--ink); }
.desktop-share-actions .open-x-button { color: white; background: var(--ink); border: 2px solid var(--ink); }
.desktop-share-actions .open-x-button span,
.desktop-share-actions .open-x-button small { display: block; }
.desktop-share-actions .open-x-button small { margin-top: 3px; color: #c8c8c8; font-size: 9px; font-weight: 700; line-height: 1.3; }

/* MacBookなどの横長画面では、ページ全体を1画面の編成ボードとして表示する。 */
@media (min-width: 1200px) {
  html, body { height: 100%; overflow: hidden; }
  body { display: grid; grid-template-rows: 58px minmax(0, 1fr) 92px; }

  .topbar {
    position: relative;
    min-height: 0;
    padding: 7px 24px;
    border-bottom-width: 3px;
  }
  .quiet-button { padding: 6px 11px; font-size: 12px; }

  main {
    display: grid;
    grid-template-columns: minmax(400px, .95fr) minmax(560px, 1.25fr);
    grid-template-rows: 64px minmax(0, 1fr);
    gap: 10px 12px;
    width: calc(100% - 28px);
    height: 100%;
    min-height: 0;
    padding: 8px 0;
  }

  .hero {
    grid-column: 1 / -1;
    grid-row: 1;
    align-items: center;
    gap: 18px;
    min-height: 0;
    padding: 0 4px;
  }
  .hero .eyebrow { margin-bottom: 4px; font-size: 10px; }
  .lead { max-width: none; font-size: 14px; line-height: 1.45; }
  .hero-score {
    min-width: 0;
    padding: 7px 14px;
    border-width: 2px;
    box-shadow: 4px 4px 0 var(--ink);
    transform: rotate(.5deg);
  }
  .hero-score span { font-size: 36px; }
  .hero-score p { margin-top: 0; font-size: 11px; }
  .history-link { margin-top: 1px; font-size: 9px; }

  .draft-stage {
    grid-column: 1;
    grid-row: 2;
    min-height: 0;
    height: 100%;
    padding: 18px;
    border-radius: 14px;
  }
  .stage-idle, .complete-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
  }
  .stage-idle h2, .complete-state h2 { font-size: 29px; }
  .stage-idle h2 { font-size: 22px; }
  .stage-idle > p { display: none; }
  .year-range { margin: 7px 0 9px; }
  .year-range select { min-width: 92px; padding: 8px 25px 8px 9px; }
  .draft-roulette { flex: 1 1 auto; min-height: 0; margin: 0 auto 9px; }
  .roulette-machine { flex: 1 1 auto; height: auto; min-height: 190px; }
  .roulette-row { font-size: clamp(18px, 2.2vw, 30px); }
  .roulette-status { margin-top: 5px !important; font-size: 10px; }
  .primary-button, .secondary-button { padding: 10px 19px; }
  .draw-result { display: flex; flex-direction: column; height: 100%; min-height: 0; }
  .draw-header { flex: 0 0 auto; gap: 10px; margin-bottom: 12px; }
  .condition { gap: 5px; }
  .condition strong { font-size: 47px; }
  .condition span { font-size: 16px; }
  .condition b { margin-left: 4px; padding: 6px 8px; font-size: 12px; }
  .draw-tools { gap: 6px; }
  .candidate-count { font-size: 11px; }
  .skip-button { padding: 6px 9px; font-size: 10px; }
  .candidate-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    flex: 1 1 auto;
    min-height: 0;
    max-height: none;
    gap: 7px;
  }
  .candidate-card { padding: 10px; border-radius: 8px; }
  .candidate-card strong { margin-bottom: 3px; font-size: 15px; }
  .candidate-card small { font-size: 10px; line-height: 1.35; }
  .pos-badge { width: 25px; height: 25px; font-size: 11px; }
  .npb-link { margin-top: 4px; font-size: 10px; }
  .complete-state { padding: 0; }

  .roster-section {
    grid-column: 2;
    grid-row: 2;
    display: flex;
    flex-direction: column;
    min-height: 0;
    padding: 0;
  }
  .section-title { flex: 0 0 auto; margin-bottom: 7px; }
  .section-title .eyebrow { display: none; }
  .section-title h2 { font-size: 25px; }
  .text-button { padding: 3px 0; font-size: 11px; }
  .roster-layout {
    grid-template-columns: minmax(0, 1.08fr) minmax(210px, .92fr);
    flex: 1 1 auto;
    min-height: 0;
    gap: 8px;
  }
  .panel { min-height: 0; padding: 9px; border-radius: 11px; }
  .panel-heading { margin-bottom: 6px; }
  .panel-heading h3 { font-size: 12px; }
  .panel-heading span { font-size: 10px; }
  .lineup { gap: 4px; }
  .lineup-row, .slot-row { min-height: 34px; border-radius: 6px; }
  .lineup-row { grid-template-columns: 28px 37px 1fr auto; gap: 5px; padding: 3px 6px 3px 3px; }
  .bat-order { height: 27px; border-radius: 5px; font-size: 12px; }
  .field-pos { font-size: 10px; }
  .field-pos:not(.empty) { font-size: 15px; }
  .player-name { font-size: 12px; }
  .player-name:not(.empty) { font-size: 15px; }
  .player-origin { font-size: 10px; }
  .staff-grid { align-content: start; gap: 7px; min-height: 0; }
  .slot-list { gap: 4px; }
  .slot-row { grid-template-columns: 57px minmax(0, 1fr) auto; gap: 5px; padding: 4px 7px; }
  .slot-label { font-size: 9px; }

  footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    width: calc(100% - 32px);
    height: 92px;
    margin: 0 auto;
    padding: 6px 0;
    border-top: 1px solid var(--line);
    font-size: 9px;
    line-height: 1.2;
  }
  footer p { margin: 0; }
  .podcast-promo { justify-content: flex-end; width: min(680px, 64vw); }
  .podcast-copy { font-size: 10px; }
}

@media (max-width: 760px) {
  .topbar { min-height: 60px; }
  .brand { font-size: 14px; }
  .quiet-button { padding: 7px 10px; font-size: 11px; }
  .hero { grid-template-columns: 1fr; padding-top: 48px; }
  .hero-score { width: fit-content; min-width: 0; padding: 14px 18px; box-shadow: 6px 6px 0 var(--ink); }
  .hero-score span { font-size: 42px; }
  .hero-score p { margin-left: 8px; }
  .draft-stage { padding: 24px 18px; border-radius: 16px; }
  .roulette-machine { height: 230px; }
  .roulette-row { font-size: clamp(19px, 5.5vw, 34px); }
  .roulette-arrow { left: 5px; }
  .draw-header { align-items: start; flex-direction: column; }
  .draw-tools { align-items: flex-start; }
  .condition b { flex-basis: 100%; width: fit-content; margin-left: 0; }
  .candidate-grid { grid-template-columns: 1fr; max-height: 460px; }
  .roster-layout { grid-template-columns: 1fr; }
  .history-row { grid-template-columns: 32px 76px 1fr; gap: 7px; }
  .history-role { grid-column: 3; }
  .complete-actions { flex-direction: column; }
  .desktop-share-actions { display: grid; grid-template-columns: 1fr; }
  footer p { margin: 0; }
  .podcast-promo { flex-direction: column; align-items: stretch; gap: 8px; margin-top: 16px; }
  .podcast-copy { font-size: 11px; }
  .podcast-embed { max-width: none; }
}
