:root {
  color-scheme: dark;
  --bg: #0c1020;
  --surface: #171c31;
  --surface-2: #202640;
  --line: #343b59;
  --text: #f7f3ea;
  --muted: #aeb5cc;
  --accent: #f2b45e;
  --accent-ink: #291c0a;
  --danger: #e78b91;
  --radius: 20px;
  font-family: "Hiragino Sans", "Yu Gothic UI", "Noto Sans JP", system-ui, sans-serif;
}
* { box-sizing: border-box; }
html { scroll-padding-bottom: calc(100px + env(safe-area-inset-bottom)); }
body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background:
    radial-gradient(circle at 85% 5%, rgba(138, 49, 80, .28), transparent 36rem),
    radial-gradient(circle at 5% 35%, rgba(53, 79, 121, .25), transparent 32rem),
    var(--bg);
  color: var(--text);
}
button, input { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .45; }
button:focus-visible, input:focus-visible { outline: 3px solid rgba(242, 180, 94, .65); outline-offset: 2px; }
#app { min-height: 100vh; padding: 20px 16px calc(110px + env(safe-area-inset-bottom)); }
.shell { width: min(100%, 720px); margin: 0 auto; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 26px; }
.brand { display: flex; align-items: center; gap: 12px; margin: 4px 0; }
.brand-mark { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 14px; background: var(--accent); color: var(--accent-ink); font-weight: 900; transform: rotate(3deg); }
.brand h1 { margin: 0; font-size: clamp(1.45rem, 6vw, 2.15rem); letter-spacing: .02em; }
.brand p { margin: 2px 0 0; color: var(--muted); font-size: .875rem; }
.card { border: 1px solid var(--line); background: rgba(23, 28, 49, .94); border-radius: var(--radius); padding: clamp(18px, 5vw, 30px); box-shadow: 0 24px 70px rgba(0,0,0,.24); }
.eyebrow { color: var(--accent); font-weight: 800; font-size: .82rem; letter-spacing: .08em; text-transform: uppercase; }
h2 { margin: 8px 0 10px; font-size: clamp(1.5rem, 7vw, 2.35rem); line-height: 1.22; }
.lead { margin: 0 0 24px; color: var(--muted); line-height: 1.7; }
.count-picker { display: grid; grid-template-columns: 56px 1fr 56px; align-items: center; gap: 12px; margin: 18px 0 26px; }
.count-button { height: 54px; border: 1px solid var(--line); border-radius: 16px; background: var(--surface-2); color: var(--text); font-size: 1.45rem; font-weight: 800; }
.count-value { text-align: center; }
.count-value strong { display: block; font-size: 2.5rem; line-height: 1; }
.count-value span { color: var(--muted); font-size: .85rem; }
.participants { display: grid; gap: 10px; margin: 0 0 22px; }
.participant-row { display: grid; grid-template-columns: 42px 1fr; gap: 12px; align-items: center; }
.participant-chip { display: grid; place-items: center; width: 42px; height: 42px; border-radius: 50%; color: #11162a; font-size: .9rem; font-weight: 900; border: 2px solid rgba(255,255,255,.55); }
.participant-row input { width: 100%; min-height: 48px; border: 1px solid var(--line); border-radius: 14px; background: #11162a; color: var(--text); padding: 11px 14px; font-size: 1rem; }
.participant-row input::placeholder { color: #7f87a2; }
.actions { display: grid; gap: 10px; }
.primary, .secondary { min-height: 54px; border-radius: 16px; padding: 12px 16px; font-weight: 850; border: 1px solid transparent; }
.primary { background: var(--accent); color: var(--accent-ink); }
.secondary { background: var(--surface-2); color: var(--text); border-color: var(--line); }
.wide { width: 100%; }
.danger-button { min-height: 54px; border: 1px solid #a8505b; border-radius: 16px; padding: 12px 16px; color: #fff; background: #8f3b48; font-weight: 850; }
.text-button, .icon-button, .link-button { border: 0; color: var(--text); background: transparent; font-weight: 750; }
.icon-button { width: 42px; height: 42px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); font-size: 1.3rem; }
.top-actions { display: flex; align-items: center; gap: 4px; }
.notice { margin: -8px 0 18px; border: 1px solid #78623e; border-radius: 14px; padding: 12px 14px; background: #342a1d; color: #ffe4ae; line-height: 1.5; }
.summary-strip { display: flex; justify-content: space-between; align-items: center; gap: 18px; margin: 22px 0; padding: 16px; border-radius: 14px; background: var(--surface-2); }
.summary-strip span { color: var(--muted); }
.hero-panel { padding: 10px 2px 24px; }
.hero-panel h2 { margin-bottom: 18px; }
.member-cloud { display: flex; flex-wrap: wrap; gap: 8px; }
.person-badge { display: inline-flex; align-items: center; min-width: 0; gap: 10px; }
.person-badge .participant-chip { flex: 0 0 auto; }
.person-badge > span:last-child { min-width: 0; display: flex; flex-direction: column; }
.person-badge strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .96rem; }
.person-badge small { color: var(--muted); font-size: .72rem; margin-top: 1px; }
.person-badge.compact .participant-chip { width: 34px; height: 34px; font-size: .78rem; }
.feature-grid { display: grid; gap: 12px; }
.feature-card { display: grid; grid-template-columns: 58px 1fr; gap: 14px; align-items: center; padding: 18px; border: 1px solid var(--line); border-radius: 20px; background: rgba(23, 28, 49, .93); }
.feature-card button { grid-column: 1 / -1; width: 100%; }
.feature-card h3 { margin: 3px 0 4px; font-size: 1.25rem; }
.feature-card p { margin: 0; color: var(--muted); font-size: .88rem; }
.feature-icon { display: grid; place-items: center; width: 56px; height: 56px; border-radius: 18px; background: #7b2d4a; color: #fff5eb; font-size: 1.65rem; font-weight: 900; }
.seat-icon { background: #385a6c; }
.bill-icon { background: #6d5936; }
.poker-feature { border-color: #5d3b4c; background: linear-gradient(135deg, rgba(49, 29, 50, .95), rgba(23, 28, 49, .95)); }
.manage-list { display: grid; gap: 12px; margin: 18px 0; }
.manage-person { display: grid; grid-template-columns: 1fr; gap: 10px; padding: 14px; border: 1px solid var(--line); border-radius: 16px; background: #11162a; }
.manage-person > input { min-height: 46px; border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; background: var(--surface); color: var(--text); }
.toggle-row { display: flex; gap: 9px; align-items: center; color: var(--muted); font-size: .9rem; }
.toggle-row input { width: 20px; height: 20px; accent-color: var(--accent); }
.helper { color: var(--muted); font-size: .85rem; line-height: 1.5; text-align: center; }
.game-header, .result-heading { margin: 10px 2px 22px; }
.game-header h2, .result-heading h2 { margin-bottom: 8px; }
.game-header p, .result-heading p { margin: 0; color: var(--muted); line-height: 1.6; }
.board-panel { padding: 18px 12px; border: 1px solid #4d4054; border-radius: 22px; background: linear-gradient(135deg, #47263a, #242039); box-shadow: inset 0 0 40px rgba(0,0,0,.18); }
.board-label { display: flex; justify-content: space-between; margin: 0 4px 12px; color: #e9d1da; font-size: .85rem; }
.board-cards, .card-pair { display: flex; justify-content: center; gap: 6px; }
.playing-card { display: inline-grid; grid-template-rows: auto 1fr; align-items: start; width: clamp(48px, 15vw, 74px); aspect-ratio: .69; padding: 7px; border-radius: 10px; background: #fbf9f2; color: #161a28; box-shadow: 0 6px 18px rgba(0,0,0,.23); font-weight: 900; }
.playing-card b { font-size: .9rem; }
.playing-card span { place-self: center; font-size: clamp(1rem, 5vw, 1.55rem); }
.red-card { color: #b72d3f; }
.hidden-card { display: grid; place-items: center; background: repeating-linear-gradient(45deg, #283452, #283452 5px, #344264 5px, #344264 10px); color: #9cabc9; border: 2px solid #7b88a6; }
.hands-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin: 14px 0 20px; }
.hand-card { display: grid; gap: 10px; padding: 12px; border: 1px solid var(--line); border-radius: 16px; background: var(--surface); }
.hand-card .person-badge { max-width: 100%; }
.current-hand-name { text-align: center; font-size: .9rem; color: var(--accent); font-weight: 750; }
.hand-card .playing-card { width: min(42%, 58px); }
.sticky-action { position: sticky; bottom: calc(80px + env(safe-area-inset-bottom)); z-index: 10; padding-top: 8px; }
.sticky-action .primary { box-shadow: 0 12px 36px rgba(0,0,0,.45); }
.ranking-list, .payment-list, .bill-list { display: grid; gap: 9px; margin: 0 0 18px; }
.ranking-row { display: grid; grid-template-columns: 52px minmax(0, 1fr); gap: 6px 10px; align-items: center; padding: 14px; border: 1px solid var(--line); border-radius: 17px; background: var(--surface); }
.ranking-row.rank-1 { border-color: #a97939; background: linear-gradient(90deg, rgba(113, 72, 26, .55), var(--surface)); }
.rank-number { grid-row: span 3; color: var(--accent); font-size: 1.6rem; text-align: center; }
.result-hand { grid-column: 2; display: flex; align-items: center; gap: 10px; margin: 4px 0; }
.result-hand-label { font-size: .75rem; color: var(--muted); }
.result-hand .playing-card { width: 42px; padding: 5px; border-radius: 7px; }
.result-hand .playing-card span { font-size: 1.15rem; }
.rank-number small { font-size: .7rem; margin-left: 1px; }
.hand-name { grid-column: 2; color: var(--muted); font-size: .88rem; }
.hand-name small { display: block; color: #e4b3bd; margin-top: 3px; }
.button-stack { display: grid; gap: 10px; }
.table-wrap { padding: 20px 8px; overflow-x: auto; }
.swipe-hint { margin: -10px 2px 2px; color: var(--muted); font-size: .78rem; }
.seat-row { display: flex; justify-content: space-around; gap: 8px; min-width: 540px; }
.seat-node { display: grid; justify-items: center; gap: 6px; width: 96px; min-height: 86px; padding: 8px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); text-align: center; }
.seat-node .person-badge { flex-direction: column; gap: 3px; }
.seat-node .person-badge > span:last-child { max-width: 78px; }
.seat-number { color: var(--accent); font-size: .78rem; font-weight: 850; }
.long-table { display: grid; place-items: center; min-width: 540px; height: 112px; margin: 10px 0; border: 2px solid #705237; border-radius: 56px; background: linear-gradient(90deg, #513721, #6c4c2f 50%, #513721); box-shadow: inset 0 0 0 7px rgba(255,255,255,.04), 0 14px 28px rgba(0,0,0,.3); }
.long-table span { color: rgba(255,255,255,.3); font-weight: 900; letter-spacing: .4em; }
.compact-card { margin-bottom: 12px; padding: 18px; box-shadow: none; }
.field-label { display: block; margin-bottom: 8px; color: var(--muted); font-size: .85rem; font-weight: 750; }
.money-input { display: grid; grid-template-columns: auto 1fr; align-items: center; gap: 8px; border-bottom: 2px solid var(--line); }
.money-input span { color: var(--accent); font-size: 1.5rem; font-weight: 900; }
.money-input input { min-width: 0; width: 100%; border: 0; background: transparent; color: var(--text); padding: 8px 0; font-size: clamp(1.8rem, 9vw, 3rem); font-weight: 900; }
.section-heading { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-bottom: 14px; }
.section-heading h3 { margin: 3px 0 0; }
.target-grid, .bulk-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.target-row, .bulk-person { min-width: 0; padding: 10px; border: 1px solid var(--line); border-radius: 14px; background: #11162a; }
.target-row input, .bulk-person input { position: absolute; opacity: 0; pointer-events: none; }
.target-row.selected, .bulk-person.selected { border-color: #b88a4e; background: #30291f; }
.segmented { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; margin: 16px 0 10px; padding: 4px; border-radius: 16px; background: #11162a; }
.segmented button { min-height: 48px; border: 0; border-radius: 12px; background: transparent; color: var(--muted); font-weight: 800; }
.segmented button.active { background: var(--surface-2); color: var(--text); box-shadow: 0 4px 14px rgba(0,0,0,.2); }
.bulk-trigger { margin-bottom: 10px; }
.bulk-panel { margin-bottom: 12px; padding: 16px; border: 1px solid #6d5a3c; border-radius: 18px; background: #28231f; }
.percent-slider { display: grid; grid-template-columns: minmax(0, 1fr); align-items: center; }
.percent-slider input { accent-color: var(--accent); width: 100%; min-width: 0; height: 44px; margin: 0; touch-action: pan-y; }
.percent-steps { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 16px; }
.percent-steps output { min-width: 4ch; text-align: center; font-size: 1.25rem; font-weight: 800; }
.percent-slider strong { min-width: 56px; font-size: 1.25rem; text-align: right; }
.bulk-preview { color: #d7c9b6; font-size: .84rem; line-height: 1.6; }
.bill-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 9px 12px; align-items: center; padding: 14px; border: 1px solid var(--line); border-radius: 16px; background: var(--surface); }
.percent-input { display: flex; align-items: center; justify-content: flex-end; gap: 3px; }
.percent-input input { width: 72px; min-height: 42px; border: 1px solid var(--line); border-radius: 11px; background: #11162a; color: var(--text); padding: 7px; text-align: right; font-weight: 800; }
.money { grid-column: 2; color: var(--accent); white-space: nowrap; }
.calculation-status { display: flex; justify-content: space-between; gap: 12px; margin: 12px 0; padding: 14px; border: 1px solid #556348; border-radius: 15px; background: #263023; }
.calculation-status span { color: var(--muted); }
.calculation-status.over { border-color: #77434b; background: #352127; }
.payment-row { display: flex; justify-content: space-between; align-items: center; gap: 14px; padding: 17px; border: 1px solid var(--line); border-radius: 16px; background: var(--surface); }
.payment-row > strong { color: var(--accent); font-size: 1.25rem; white-space: nowrap; }
.empty-state { padding: 30px 14px; color: var(--muted); text-align: center; border: 1px dashed var(--line); border-radius: 16px; }
.event-footer { padding: 32px 0 6px; text-align: center; }
.danger-link { color: var(--danger); }
.modal-backdrop { position: fixed; z-index: 80; inset: 0; display: grid; place-items: center; padding: 18px; background: rgba(4, 6, 14, .82); backdrop-filter: blur(8px); }
.modal { width: min(100%, 460px); padding: 24px; border: 1px solid #62424d; border-radius: 22px; background: #191728; box-shadow: 0 28px 90px rgba(0,0,0,.55); }
.ad-slot { position: fixed; z-index: 30; left: 50%; bottom: max(10px, env(safe-area-inset-bottom)); translate: -50% 0; width: min(calc(100% - 24px), 680px); height: 66px; border: 1px dashed #59617d; border-radius: 15px; background: rgba(11, 15, 29, .96); display: flex; align-items: center; justify-content: center; gap: 8px; color: #8991ab; backdrop-filter: blur(12px); }
.ad-slot span { font-size: .78rem; font-weight: 800; letter-spacing: .14em; }
.ad-slot small { font-size: .72rem; }
@media (min-width: 620px) {
  #app { padding-top: 38px; }
  .actions { grid-template-columns: 1fr 1fr; }
  .feature-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .feature-card:first-child { grid-column: 1 / -1; }
  .hands-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .manage-person { grid-template-columns: minmax(170px, .8fr) 1fr; align-items: center; }
  .manage-person .toggle-row { grid-column: 2; }
  .target-grid, .bulk-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .bill-row { grid-template-columns: minmax(0, 1fr) 110px 130px; }
  .money { grid-column: auto; text-align: right; }
}
@media (max-width: 400px) {
  .brand p { display: none; }
  .hands-grid { grid-template-columns: 1fr 1fr; }
  .hand-card { padding: 9px; }
  .playing-card { padding: 5px; }
  .target-grid, .bulk-grid { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: no-preference) {
  .card { animation: rise .35s ease-out both; }
  @keyframes rise { from { opacity: 0; transform: translateY(8px); } }
}

/* Display preferences never change automatically with participant count. */
.display-picker { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.poker-mini.hands-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.poker-mini .hand-card { padding: 6px; gap: 5px; border-radius: 10px; }
.poker-mini .person-badge { gap: 4px; }
.poker-mini .person-badge .participant-chip { width: 23px; height: 23px; font-size: .68rem; }
.poker-mini .person-badge strong { font-size: .75rem; }
.poker-mini .person-badge small { display: none; }
.poker-mini .playing-card { width: 30px; padding: 3px; border-radius: 5px; }
.poker-mini .playing-card b { font-size: .7rem; }
.poker-mini .playing-card span { font-size: .95rem; }
.poker-mini .current-hand-name { font-size: .72rem; overflow-wrap: anywhere; }
.poker-mini .ranking-row { grid-template-columns: minmax(30px, max-content) minmax(0, 1fr) auto; padding: 7px; gap: 4px; }
.poker-mini .rank-number { grid-row: span 2; font-size: 1.1rem; white-space: nowrap; }
.poker-mini .result-hand { grid-column: 3; grid-row: span 2; margin: 0; }
.poker-mini .result-hand-label { display: none; }
.poker-text.hands-grid { grid-template-columns: minmax(0, 1fr); gap: 4px; }
.poker-text .hand-card { grid-template-columns: minmax(0, 1fr) auto minmax(65px, .65fr); align-items: center; padding: 7px; gap: 6px; border-radius: 9px; }
.poker-text .person-badge { gap: 4px; }
.poker-text .person-badge .participant-chip { width: 24px; height: 24px; font-size: .7rem; }
.poker-text .person-badge strong { font-size: .78rem; }
.poker-text .person-badge small, .poker-text .result-hand-label { display: none; }
.poker-text .playing-card { display: inline-flex; align-items: center; width: auto; aspect-ratio: auto; padding: 0; border-radius: 0; background: none; color: var(--text); box-shadow: none; gap: 1px; }
.poker-text .playing-card.red-card { color: #ff9ca9; }
.poker-text .playing-card b, .poker-text .playing-card span { font-size: .8rem; }
.poker-text .current-hand-name, .poker-text .hand-name { font-size: .72rem; text-align: right; overflow-wrap: anywhere; }
.poker-text.ranking-list { gap: 4px; }
.poker-text .ranking-row { grid-template-columns: max-content minmax(0, 1fr) auto minmax(65px, .65fr); gap: 5px; padding: 4px 7px; border-radius: 9px; }
.poker-text .rank-number { grid-row: auto; min-width: 3ch; white-space: nowrap; font-size: .85rem; }
.poker-text .result-hand, .poker-text .hand-name { grid-column: auto; margin: 0; }
@media (max-width: 600px) and (orientation: portrait) {
  .swipe-hint { display: none; }
  .table-wrap { padding: 10px 0; overflow-x: visible; }
  .seat-row { display: grid; grid-template-columns: repeat(var(--seat-columns), minmax(0, 1fr)); min-width: 0; gap: 4px; }
  .seat-node { width: 100%; min-width: 0; min-height: 84px; padding: 6px 2px; gap: 4px; border-radius: 8px; }
  .seat-node .person-badge { width: 100%; }
  .seat-node .person-badge > span:last-child { max-width: 100%; }
  .seat-node .person-badge strong { white-space: normal; overflow-wrap: anywhere; font-size: .7rem; line-height: 1.35; }
  .seat-node .person-badge small { display: none; }
  .seat-node .person-badge .participant-chip { width: 26px; height: 26px; font-size: .7rem; }
  .seat-number { font-size: .7rem; }
  .bottom-seats .seat-number { order: 1; }
  .long-table { min-width: 0; height: 60px; margin: 7px 0; border-radius: 22px; box-shadow: none; }
  .board-cards .playing-card { width: min(15vw, 74px); min-width: 0; }
}

.result-board { padding: 12px; border-radius: 16px; }
.result-board .board-label { margin-bottom: 8px; }
.result-board .playing-card { width: 38px; padding: 4px; border-radius: 6px; }
.result-board .playing-card span { font-size: 1rem; }
.poker-normal.ranking-list { grid-template-columns: minmax(0, 1fr); }
.poker-normal .ranking-row { grid-template-columns: max-content 86px minmax(0, 1fr); gap: 8px; padding: 12px; }
.poker-normal .rank-number { grid-column: 1; grid-row: 1; white-space: nowrap; font-size: 1.15rem; }
.poker-normal .ranking-row > .person-badge { grid-column: 2 / -1; grid-row: 1; }
.poker-normal .result-hand { grid-column: 1 / 3; grid-row: 2; gap: 5px; margin: 0; }
.poker-normal .hand-name { grid-column: 3; grid-row: 2; min-width: 0; overflow-wrap: anywhere; }
.best-hand { grid-column: 1 / -1; grid-row: 3; min-width: 0; }
.best-cards { display: flex; flex-wrap: nowrap; gap: 5px; margin-top: 5px; }
.best-cards .playing-card { width: 32px; flex: 0 0 32px; padding: 3px; border-radius: 5px; }
.best-cards .playing-card b { font-size: .7rem; }
.best-cards .playing-card span { font-size: .95rem; }
.game-header { margin: 0 2px 10px; }
.game-header h2.eyebrow { font-size: .82rem; margin: 0; }
.board-label { align-items: center; gap: 8px; white-space: nowrap; }
.board-stage { font-size: .8rem; }
.poker-help { margin: -10px 0 14px; color: var(--muted); font-size: .85rem; }
.poker-help summary { display: flex; align-items: center; gap: 7px; width: fit-content; min-height: 44px; cursor: pointer; list-style: none; }
.poker-help summary::-webkit-details-marker { display: none; }
.poker-help summary::after { content: "＋"; }
.poker-help[open] summary::after { content: "−"; }
.poker-help summary:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 8px; }
.help-mark { display: grid; place-items: center; width: 24px; height: 24px; border: 1px solid var(--line); border-radius: 50%; color: var(--accent); font-weight: 800; }
.help-content { padding: 16px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); line-height: 1.7; overflow-wrap: anywhere; }
.help-content h3 { margin: 16px 0 6px; color: var(--text); font-size: 1rem; }
.help-content h3:first-child { margin-top: 0; }
.help-content p { margin: 8px 0; }
.hand-guide { padding-left: 1.7em; }
.hand-guide li { margin-bottom: 9px; }
.hand-guide strong { display: block; color: var(--text); }
