/* Adapt to available width, including folded and unfolded phone viewports. */
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body { min-width: 0; }
html { scrollbar-gutter: stable; }
.wallet-layout > .wallet-loading { grid-column: 1 / -1; min-height: 180px; }
.portal-content, .app-shell, .login-layout { width: 100%; }
.portal-content > *, .admin-body > *, .meeting-layout > *, .wallet-layout > *,
.timer-center, .setup-grid > *, .toolbar > *, .participant-actions { min-width: 0; }
.portal-header > *, .identity { min-width: 0; }
.identity { flex-wrap: wrap; justify-content: flex-end; }
.identity > span { overflow-wrap: anywhere; }
.portal-header nav, .admin-tabs { max-width: 100%; }
.portal-header nav button, .admin-tabs button { flex-shrink: 0; }
.table-scroll { max-width: 100%; overscroll-behavior-x: contain; -webkit-overflow-scrolling: touch; }
.table-scroll table { width: 100%; }
.meeting-list h3, .admin-list h3, .panel h2, .event-heading h1,
.wallet-hero > strong, .member-balance { overflow-wrap: anywhere; }
.action-group { max-width: 100%; }
.action-group button { white-space: normal; overflow-wrap: anywhere; }
.meeting-admin-actions { min-width: 0; }
.toolbar input, .toolbar select { max-width: 100%; }
.toolbar > label, .toolbar > input, .toolbar > select { min-width: 0; }
.toolbar .file-button { white-space: normal; text-align: center; }
.dialog { max-height: calc(100vh - 32px); max-height: calc(100dvh - 32px); overscroll-behavior: contain; overflow-y: auto; }
.dialog input, .dialog select { scroll-margin-block: 32px; }
.dialog .toolbar { flex-wrap: wrap; }
.nickname-dialog { max-width: calc(100vw - 32px); }
.timer-center { container-type: inline-size; }
.timer-center .blinds div { min-width: 0; }
.timer-center .blinds strong { overflow-wrap: anywhere; }
.timer-center .controls { flex-wrap: wrap; }
.tournament-stats dl > div { min-width: 0; }
.tournament-stats dt { font-weight: 700; line-height: 1.4; color: #4b5146; overflow-wrap: anywhere; }
.tournament-stats dd { font-weight: 700; line-height: 1.25; }
/* Layout containment disables row subgrid sizing. Keep it only on stacked layouts. */
@media (min-width: 1200px) {
  .timer-center { container-type: normal; }
}
@media (min-width: 1198px) and (max-width: 1440px) {
  .timer-center .clock-card { padding-inline: 16px; }
  .timer-center .blinds { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 16px 10px; }
  .timer-center .blind-divider { display: none; }
  .timer-center .blinds .ante { grid-column: auto; border-left: 1px solid var(--line); border-top: 0; padding: 0 0 0 10px; }
}
@container (max-width: 620px) {
  .timer-center .clock-card { padding-inline: 16px; }
  .timer-center .blinds { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 16px 10px; }
  .timer-center .blind-divider { display: none; }
  .timer-center .blinds .ante { grid-column: 1/-1; border-left: 0; border-top: 1px solid var(--line); padding: 14px 0 0; }
  .timer-center .controls .outline { min-width: 0; padding: 13px 10px; font-size: 13px; }
  .timer-center .controls .play { min-width: 130px; padding: 14px 12px; }
}
@media (max-width: 1024px) {
  .portal-header { padding-inline: max(16px,env(safe-area-inset-left)); }
  .portal-header nav { order: 3; width: 100%; flex-wrap: nowrap; overflow-x: auto; padding-bottom: 8px; }
  .admin-workspace { display: block; margin-top: 22px; }
  .admin-workspace > .admin-tabs { position: static; flex-direction: row; flex-wrap: nowrap; overflow-x: auto; gap: 4px; padding: 0 0 8px; margin: 0 0 20px; }
  .admin-workspace > .admin-tabs button { white-space: nowrap; border-left: 0; border-bottom: 2px solid transparent; border-radius: 0; padding: 12px; }
  .admin-workspace > .admin-tabs button.selected { border-bottom-color: #45543e; }
  .admin-workspace > .admin-tabs button:last-child { margin: 0 0 0 8px; }
  .setup .settings-fields { display: flex; flex-direction: column; }
  .setup .settings-fields > * { width: 100%; }
  .setup .setup-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); }
  .admin-body.settings-body { max-width: 760px; }
  .participant-actions { width: 100%; max-width: 100%; }
  .admin-body .admin-list article { flex-wrap: wrap; }
  .participant-actions .action-group { justify-content: flex-start; }
  .meeting-admin-actions { flex: 1 1 100%; }
  .meeting-admin-actions > button { flex: 1 1 120px; }
  .meeting-layout { grid-template-columns: minmax(240px,.8fr) minmax(0,1.6fr); }
  .meeting-list article > button { white-space: normal; }
}
@media (max-width: 800px) {
  .wallet-layout, .meeting-layout { display: flex; flex-direction: column; }
  .wallet-layout > *, .meeting-layout > * { width: 100%; }
  .timer-host .header { align-items: flex-start; }
  .timer-backup { width: 100%; flex-wrap: wrap; }
  .timer-backup > * { flex: 1 1 130px; text-align: center; }
  .meeting-participants, .history { min-width: 0; }
  .toolbar > button, .toolbar > .file-button { flex: 1 1 140px; }
}
@media (max-width: 599px) {
  .portal-content, .app-shell, .app-shell:has(.tournament-dashboard) { padding-left: max(12px,env(safe-area-inset-left)); padding-right: max(12px,env(safe-area-inset-right)); }
  .portal-content { margin-top: 24px; padding-bottom: env(safe-area-inset-bottom); }
  .portal-header { column-gap: 12px; }
  .portal-brand { font-size: 18px; }
  .portal-brand small { font-size: 8px; margin-left: 20px; }
  .identity { gap: 6px; max-width: 48%; font-size: 12px; }
  .identity .outline { padding: 9px 10px; }
  .panel { padding: 18px; }
  .wallet-layout > .wallet-hero { padding: 24px; }
  .wallet-hero > strong { font-size: clamp(34px,10vw,48px); }
  .login-layout { padding-inline: max(12px,env(safe-area-inset-left)); margin: 24px auto; }
  .login-brand-panel { padding: 24px; }
  .login-wordmark { font-size: 46px; padding: 20px 0; }
  .login-layout > .login-panel { padding: 28px 22px; }
  .login-layout .login-panel h1 { font-size: 26px; }
  .setup .setup-grid { grid-template-columns: minmax(0,1fr); }
  .setup .setup-grid > .panel { padding: 18px; }
  .setup .level-editor .table-scroll table { min-width: 600px; }
  .table-scroll th, .table-scroll td { padding: 12px 10px; }
  .points-table { min-width: 600px; }
  .level-settings, .quick-blind-fields { grid-template-columns: minmax(0,1fr) !important; }
  .toolbar > label, .toolbar > input, .toolbar > select { flex: 1 1 100%; width: 100%; }
  .toolbar input, .toolbar select, input, select { font-size: 16px; }
  .toolbar .file-button input { display: none; }
  .action-group { gap: 8px; width: 100%; justify-content: flex-start; }
  .action-group button { flex: 1 1 110px; min-height: 44px; padding: 10px 12px; }
  .meeting-admin-actions { width: 100%; gap: 8px !important; }
  .meeting-admin-actions > button { flex: 1 1 100px; white-space: normal; }
  .meeting-list article > button { flex: 1 1 110px; }
  .admin-list article, .meeting-list article { gap: 14px; }
  .add-row > button { flex: 1 1 100%; }
  .quick-blind-settings { flex: 1 1 100%; }
  .quick-blind-settings > button { width: 100%; }
  .quick-blind-toggle { min-height: 44px; margin-top: 6px; }
  .timer-center .controls { display: grid; grid-template-columns: minmax(0,1fr) minmax(0,1.2fr) minmax(0,1fr); gap: 6px; }
  .timer-center .controls .outline, .timer-center .controls .play { min-width: 0; width: 100%; padding: 13px 6px; font-size: 13px; }
  .timer-center .event-heading { flex-wrap: wrap; }
  .tournament-stats { padding: 18px; }
  .tournament-stats dl { gap: 0 14px; }
  .tournament-stats dl > div { padding: 14px 0; }
  .utility { display: flex; flex-wrap: wrap; }
  .utility button { min-height: 44px; }
  .modal-backdrop { padding: 12px; padding-bottom: max(12px,env(safe-area-inset-bottom)); }
  .dialog { max-height: calc(100dvh - 24px); padding: 22px 18px; }
  .dialog .toolbar > button { flex: 1 1 100px; }
  .pagination { gap: 12px; flex-wrap: wrap; }
}
@media (max-width: 359px) {
  .portal-header { flex-wrap: wrap; }
  .identity { max-width: 100%; }
  .portal-header .identity { flex: 1 1 100%; justify-content: flex-start; }
  .tournament-stats dl { grid-template-columns: minmax(0,1fr); }
  .timer-center .timer-digits { letter-spacing: -3px; }
  .panel { padding: 16px; }
}
@media (pointer: coarse) {
  button, a.primary, .file-button { min-height: 44px; }
  .row-actions button { width: 44px; height: 44px; min-width: 44px; }
  .row-actions { gap: 8px; }
  .setup .level-editor .table-scroll table { min-width: 700px; }
  .setup .level-editor th:last-child { width: 172px; }
  .player-alive-control .small { min-height: 44px; padding: 10px 12px; }
}
@media (max-height: 500px) and (orientation: landscape) {
  .dialog { max-height: calc(100dvh - 16px); }
  .login-layout { margin-block: 16px; }
  .portal-content { margin-top: 20px; }
}
/* Size text from each card, never apply containment to the desktop subgrid. */
.timer-center .clock-card { container: timer-card / inline-size; }
.tournament-stats { container: tournament-stats / inline-size; }
.timer-center .event-heading h1 { font-size: clamp(1.5rem, calc(1rem + 1.5vw), 2.5rem); line-height: 1.2; }
.timer-center .event-heading .eyebrow,
.timer-center .status { font-size: clamp(.75rem, calc(.65rem + .3vw), 1rem); }
.timer-center .timer-digits { font-size: clamp(3rem, 24cqi, 13.125rem); line-height: 1.1; letter-spacing: -.04em; white-space: nowrap; }
.timer-center .level-tag { font-size: clamp(.875rem, 3cqi, 1.375rem); }
.timer-center .clock-caption,
.timer-center .current-blind-label { font-size: clamp(.875rem, 2.6cqi, 1.25rem); }
.timer-center .break-label { font-size: clamp(1.25rem, 5cqi, 2.5rem); }
.timer-center .blinds div > span { font-size: clamp(.6875rem, 2cqi, 1rem); letter-spacing: .06em; }
.timer-center .blinds strong { font-size: clamp(1.75rem, 7.5cqi, 4.5rem); line-height: 1.2; }
.timer-center .next-blind-values strong { font-size: clamp(1.125rem, 4.455cqi, 2.43rem); }
.timer-center .next-blind-title h2 { font-size: clamp(.875rem, 2.6cqi, 1.25rem); }
.timer-center .next-blind-title > span,
.timer-center .next-blind-detail { font-size: clamp(.75rem, 2cqi, 1rem); }
.timer-center .next-blind-banner > strong { font-size: clamp(1.25rem, 4cqi, 2rem); }
.timer-center .controls .outline,
.timer-center .controls .play,
.timer-center .utility button { font-size: clamp(.8125rem, calc(.65rem + .4vw), 1.125rem); white-space: normal; }
.tournament-stats h2 { font-size: clamp(1.125rem, calc(.75rem + 3cqi), 1.5rem); }
/* Every layout sizes metric text from its own available cell width. */
.tournament-stats dl > div { container-type: inline-size; }
.tournament-stats dt { font-size: clamp(.875rem, calc(.75rem + 4cqi), 1.5rem); }
.tournament-stats dd { font-size: clamp(1.125rem, calc(.625rem + 10cqi), 2.5rem); }
.tournament-stats dl > div:first-child dd { font-size: clamp(1.25rem, calc(.75rem + 10cqi), 2.75rem); }
.tournament-stats .hint,
.tournament-stats .field-error { font-size: clamp(.75rem, calc(.625rem + 1cqi), 1rem); overflow-wrap: anywhere; }
.timer-center .blinds { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 16px 12px; }
.timer-center .blind-divider { display: none; }
.timer-center .blinds .ante { grid-column: auto; border-top: 0; border-left: 1px solid var(--line); padding: 0 0 0 12px; }
@container timer-card (max-width: 479.98px) {
  .timer-center .blinds { gap: 12px 6px; padding-inline: 0; }
  .timer-center .blinds .ante { padding-left: 6px; }
  .timer-center .blinds div > span { font-size: clamp(.625rem, 2.6cqi, .75rem); letter-spacing: 0; }
  .timer-center .blinds strong { font-size: clamp(1rem, 6cqi, 1.75rem); }
  .timer-center .next-blind-values strong { font-size: clamp(.759375rem, 4.05cqi, 1.215rem); }
  .timer-center .next-blind-banner { padding-inline: 10px; }
}
