/* Room UI uses the existing modal and needs no animation loop. */
#partyModal [hidden] { display: none !important; }
#partyModal { padding: max(12px, env(safe-area-inset-top, 0px)) 12px max(12px, env(safe-area-inset-bottom, 0px)); }
#partyModal .party-panel { width: 100%; max-width: 560px; max-height: calc(100vh - 48px); max-height: calc(100dvh - 48px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px)); margin: 12px auto; padding: 0; overflow-y: auto; overscroll-behavior: contain; animation: none; transform: none; transition: none; }
#partyModal .modal-header { position: sticky; top: 0; z-index: 2; gap: 16px; margin: 0; padding: 16px 20px; border-radius: 18px 18px 0 0; }
#partyModal .modal-header h2 { font-size: 21px; line-height: 1.4; }
#party-close { flex: 0 0 44px; width: 44px; height: 44px; padding: 0; background: #21373b; line-height: 1; }
.party-content { padding: 20px; }
.party-intro, .party-hint { color: #afc3bd; font-size: 13px; line-height: 1.7; overflow-wrap: anywhere; }
.party-intro { margin: 0 0 22px; }
.party-hint { margin: 10px 0 0; font-size: 12px; }
.party-field { margin-bottom: 18px; }
.party-field label, .party-link-label { display: block; margin: 0 0 8px; color: #e1ecdf; font-size: 13px; font-weight: 600; }
#partyModal input, #partyModal select { display: block; width: 100%; min-width: 0; min-height: 48px; padding: 12px; color: #f0f3e9; background: #11262d; border: 1px solid #4a6264; border-radius: 9px; font: inherit; font-size: 16px; box-shadow: none; }
#partyModal input:focus-visible, #partyModal select:focus-visible { border-color: #d5ef96; outline: 2px solid #d5ef96; outline-offset: 2px; }
#party-code { text-transform: uppercase; letter-spacing: .14em; font-variant-numeric: tabular-nums; }
.party-join-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: end; gap: 10px; margin-top: 24px; padding-top: 22px; border-top: 1px solid #3d5559; }
.party-join-row .party-field { margin: 0; }
#partyModal button { min-height: 44px; white-space: normal; word-break: normal; }
#partyModal .btn-primary, #partyModal .btn-secondary { padding: 12px 16px; font-size: 14px; }
#partyModal button:disabled { opacity: .45; }
#party-create { width: 100%; }
.party-notice, #party-error { border: 1px solid #526462; border-radius: 10px; padding: 12px 14px; color: #d6e2d4; background: #213a3e; font-size: 13px; line-height: 1.7; }
.party-notice { margin: 0 0 20px; }
#party-error { margin: 18px 0 0; border-color: #a58468; color: #ffdcbd; background: #372f29; }
#party-error:empty { display: none; }
.party-room-top { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.party-room-label { color: #a8bfb4; font-size: 11px; font-weight: 600; letter-spacing: .04em; }
#party-room-code { display: block; color: #d5ef96; font: 700 clamp(22px, 6vw, 30px)/1.35 ui-monospace, SFMono-Regular, Consolas, monospace; letter-spacing: .15em; }
#party-copy { max-width: 45%; font-size: 12px !important; }
#party-link { margin-top: 10px; font-size: 13px !important; }
.party-room-status { margin: 20px 0 0; padding: 16px; border: 1px solid #3f595b; border-radius: 12px; background: #20383e; }
#party-round-label { color: #b3c89e; font-size: 11px; font-weight: 600; }
#party-status { margin: 6px 0 0; color: #f0f3e9; font-size: 17px; font-weight: 700; line-height: 1.5; }
#party-connection { min-height: 1.7em; margin: 8px 0 0; color: #a5bbb5; font-size: 11px; line-height: 1.7; }
.party-section-heading { margin: 23px 0 11px; color: #dbe7d6; font-size: 13px; }
#party-players, #party-results { display: grid; gap: 7px; margin: 0; padding: 0; list-style: none; }
#party-players { max-height: 216px; overflow-y: auto; overscroll-behavior: contain; }
.party-player, .party-result { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-width: 0; padding: 11px 12px; border: 1px solid #3d5457; border-radius: 9px; background: #162c33; }
.party-player.is-self { border-color: #829c77; }
.party-player-info { flex: 1; min-width: 0; }
.party-player-meta { color: #b3c4bc; font-size: 11px; line-height: 1.6; }
.party-badge { flex-shrink: 0; max-width: 40%; }
.party-player-name { min-width: 0; flex: 1; color: #e7eddf; font-size: 14px; overflow-wrap: anywhere; }
.party-player-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 5px; margin-top: 4px; }
.party-badge { display: inline-block; padding: 2px 6px; border-radius: 4px; background: #30494c; color: #bdcfbf; font-size: 10px; font-weight: 600; line-height: 1.6; }
.party-badge.is-ready { background: #354d39; color: #d5ef96; }
.party-player-state { flex-shrink: 0; max-width: 40%; color: #b3c4bc; font-size: 11px; line-height: 1.6; text-align: right; }
.party-player-state.is-ready { color: #d5ef96; }
.party-dice-area { margin-top: 22px; text-align: center; }
#party-dice { display: flex; flex-wrap: wrap; justify-content: center; gap: 12px; max-width: 344px; margin: 0 auto; padding: 12px 0; }
#party-dice > span { display: grid; place-items: center; flex: 0 0 76px; width: 76px; height: 76px; border-radius: 17px; background: #ecf0dd; color: #243d32; border: 1px solid #f7f8eb; box-shadow: 0 5px 0 #688477; font: 700 34px/1 ui-monospace, SFMono-Regular, Consolas, monospace; }
#party-dice.is-rolling > span { animation: party-dice-roll .45s ease-in-out 2; }
#party-dice.is-rolling > span:nth-child(2) { animation-delay: .06s; }
#party-dice.is-rolling > span:nth-child(3) { animation-delay: .12s; }
#party-dice.is-rolling > span:nth-child(4) { animation-delay: .18s; }
.party-result { padding: 12px; }
.party-result.is-winner { background: #2b4135; border-color: #a6c17f; }
.party-result-rank { flex: 0 0 42px; color: #b8ccaa; font-size: 12px; font-weight: 600; }
.party-result-score { flex-shrink: 0; max-width: 38%; overflow-wrap: anywhere; text-align: right; color: #d5ef96; font-size: 16px; font-weight: 700; font-variant-numeric: tabular-nums; }
.party-actions { display: grid; gap: 8px; margin-top: 22px; }
.party-actions > button { width: 100%; }
#party-ready[aria-pressed="true"] { color: #d5ef96; border-color: #abc786; background: #2a4236; }
.party-footer { border-top: 1px solid #3c5357; margin-top: 20px; padding-top: 16px; }
#party-leave { width: 100%; border-color: #48605e; color: #b3c7bd; font-size: 12px; }
@keyframes party-dice-roll { 0%, 100% { transform: rotate(0) translateY(0); } 25% { transform: rotate(-9deg) translateY(-5px); } 75% { transform: rotate(9deg) translateY(-3px); } }
@media (max-width: 380px) { .party-content { padding: 16px; } #partyModal .modal-header { padding: 14px 16px; } .party-join-row { grid-template-columns: 1fr; } #party-join { width: 100%; } .party-room-top { align-items: flex-start; } #party-room-code { letter-spacing: .08em; } }
@media (prefers-reduced-motion: reduce) { #party-dice.is-rolling > span { animation: none; } }

/* The confirmed rule stays visible while the host edits the next choice. */
.party-rules { margin-top: 18px; padding: 14px; border: 1px solid #3f595b; border-radius: 12px; background: #182f35; }
#party-rules-summary { margin: 0; color: #d5ef96; font-size: 14px; font-weight: 700; line-height: 1.5; overflow-wrap: anywhere; }
#party-rule-description { margin-top: 7px; }
#party-rule-controls { min-width: 0; margin: 15px 0 0; padding: 14px 0 0; border: 0; border-top: 1px solid #3d5559; }
#party-rule-controls legend { padding: 0 8px 0 0; color: #dbe7d6; font-size: 12px; font-weight: 600; }
.party-rule-fields { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 2fr); gap: 12px; }
.party-rule-fields .party-field { min-width: 0; margin-bottom: 0; }
#partyModal .party-rule-fields select { min-height: 46px; padding: 10px 8px; cursor: pointer; color-scheme: dark; }
#partyModal .party-rule-fields select:disabled { opacity: .6; cursor: default; }
#party-apply-rules { width: 100%; margin-top: 12px; }
#party-rules-notice { min-height: 1.7em; }
@media (max-width: 410px) {
  .party-rule-fields { grid-template-columns: 1fr; gap: 14px; }
  #party-dice { max-width: 164px; }
  .party-result { gap: 8px; padding: 11px 9px; }
  .party-result-rank { flex-basis: 36px; }
  .party-result-score { font-size: 14px; }
}
