html.desktop-app, html.desktop-app body { min-width: 320px; }
.desktop-app .app-shell, .desktop-app .app-shell * { min-width: 0; }
.desktop-app .app-shell h1 { flex-wrap: wrap; white-space: normal; gap: 4px 8px; }
.desktop-app .app-shell h1 span { margin-left: 0; }
.desktop-app .app-shell .header-actions .desktop-mode-switch { flex-shrink: 0; }
.desktop-app .app-shell .hand { flex-wrap: wrap; height: auto; padding: 12px 4px 6px; overflow: visible; }
.desktop-app .app-shell .hand .pro-tile { width: 48px; height: 66px; flex-shrink: 0; }
.desktop-app .app-shell .river { justify-content: flex-start; }
.desktop-app .app-shell .rules-action strong { font-size: inherit; }
.desktop-app .app-shell .hand-area { scroll-margin-block: 12px; }
.desktop-app .app-shell .discard-guide, .desktop-app .app-shell .pro-actions { flex-wrap: wrap; }
.desktop-app .app-shell .pro-indicators { width: 100%; flex-wrap: wrap; }
.desktop-app .app-shell .pro-indicators > span { white-space: normal; }
.desktop-app .scrim, .desktop-app .pro-scrim {
  position: fixed; inset: 0; padding: 12px; max-height: 100dvh;
  display: flex; align-items: center; justify-content: center; overflow: auto;
}
.desktop-app .dialog, .desktop-app .pro-dialog, .desktop-app .pro-guide-dialog {
  width: min(960px, 100%); min-width: 0; max-width: calc(100vw - 24px);
  max-height: calc(100dvh - 24px); margin: auto; padding: 18px;
  overflow: auto; overflow-wrap: anywhere; box-sizing: border-box;
}
.desktop-app .reaction-dialog, .desktop-app .pro-reaction-dialog { width: min(460px,100%); }
.desktop-app .dictionary-dialog, .desktop-app .pro-guide-dialog {
  display: flex; flex-direction: column; height: min(760px,calc(100dvh - 24px)); overflow: hidden;
}
.desktop-app .dictionary-frame, .desktop-app .pro-guide-frame { flex: 1; min-height: 0; width: 100%; height: auto; }
.desktop-app .tile-catalog-header, .desktop-app .pro-guide-dialog-header {
  flex: none; flex-wrap: wrap; gap: 8px; align-items: center;
}
.desktop-app .tile-catalog-header h2, .desktop-app .pro-guide-dialog-header h2 { font-size: clamp(18px,3vw,28px); }
.desktop-app .tile-catalog-header button, .desktop-app .pro-guide-dialog-header button { flex-shrink: 0; }
.desktop-app .dialog .primary, .desktop-app .pro-dialog .primary { min-height: 38px; }
.desktop-app .result .settlement, .desktop-app .pro-settlement { flex-wrap: wrap; }
.desktop-app .yaku-catalog, .desktop-app .tile-catalog { max-width: calc(100vw - 24px); }
.desktop-app button:focus-visible { outline: 2px solid #f5dc91; outline-offset: 3px; }
.desktop-app .pro-river { --river-w: 35px; --river-h: 48px; align-items: flex-end; }
.desktop-app .pro-river .pro-tile.small { width: var(--river-w); height: var(--river-h); }
.desktop-app .desktop-riichi-discard {
  position: relative; display: inline-block; flex: none;
  width: var(--river-h); height: var(--river-w);
}
.desktop-app .desktop-riichi-discard .pro-tile.small {
  position: absolute; left: calc((var(--river-h) - var(--river-w)) / 2);
  top: calc((var(--river-w) - var(--river-h)) / 2); transform: rotate(90deg);
}
.desktop-app .pro-river .desktop-riichi-claimed {
  width: var(--river-h); height: var(--river-w); flex: none;
  border: 1px dashed #dfc17a; border-radius: 4px;
}
@media (max-width:680px) {
  .desktop-app .pro-river { --river-w: 23px; --river-h: 33px; }
  .desktop-app .pro-river .pro-tile.small span { font-size: 19px; }
  .desktop-app .pro-river .pro-tile.small.honor span { font-size: 15px; }
}
@media (max-width: 900px) {
  .desktop-app .app-shell > header { grid-template-columns: 1fr; gap: 8px; }
  .desktop-app .header-actions { justify-content: flex-start; }
  .desktop-app .app-shell .table { grid-template-columns: minmax(160px,.7fr) minmax(0,1.7fr); }
  .desktop-app .app-shell .rules-card { padding: 10px; }
  .desktop-app .app-shell .score-value { font-size: 15px; }
  .desktop-app .app-shell .seat-info { flex-wrap: wrap; white-space: normal; gap: 3px 6px; }
}
@media (max-width: 680px) {
  html.desktop-app body { padding: 6px; }
  .desktop-app .app-shell { padding: 0 10px 10px; border-radius: 14px; }
  .desktop-app .app-shell .table {
    grid-template-columns: 1fr; grid-template-areas: "opponents" "player" "rules"; padding: 8px; gap: 8px;
  }
  .desktop-app .app-shell .rules-card { max-height: 100px; }
  .desktop-app .app-shell .opponents { gap: 8px; }
  .desktop-app .app-shell .opponent, .desktop-app .app-shell .opponent:first-child,
  .desktop-app .app-shell .player-river { min-height: 80px; padding: 8px; gap: 4px; }
  .desktop-app .app-shell .hand-area { padding: 10px 6px; }
  .desktop-app .app-shell .hand { gap: 4px; }
  .desktop-app .app-shell .hand .tile, .desktop-app .app-shell .hand .pro-tile {
    width: clamp(28px,6.7vw,40px); height: clamp(42px,9.5vw,58px); margin-left: 0;
  }
  .desktop-app .app-shell .hand .tile-glyph { font-size: 30px; }
  .desktop-app .app-shell .hand .honor-tile .tile-glyph { font-size: 25px; }
  .desktop-app .app-shell .hand .pro-tile { font-size: 30px; }
  .desktop-app .app-shell .hand .pro-tile.honor { font-size: 25px; }
  .desktop-app .app-shell .status-bar { gap: 6px 14px; }
  .desktop-app .app-shell .status-bar > p { flex-basis: 100%; text-align: left; }
  .desktop-app .app-shell .match-start-actions button { padding: 8px 12px; }
  .desktop-app .dialog, .desktop-app .pro-dialog { padding: 12px; }
  .desktop-app .pro-win-results, .desktop-app .tile-catalog-groups { grid-template-columns: 1fr; }
}
@media (min-width:681px) and (max-height:740px) {
  html.desktop-app body { padding: 8px; }
  .desktop-app .app-shell { gap: 6px; }
  .desktop-app .app-shell > header { min-height: 60px; padding: 8px 0; }
  .desktop-app .app-shell .table { padding: 8px; gap: 8px; }
  .desktop-app .app-shell .rules-card { max-height: 185px; }
  .desktop-app .app-shell .opponent, .desktop-app .app-shell .opponent:first-child,
  .desktop-app .app-shell .player-river { min-height: 80px; padding: 8px; }
  .desktop-app .app-shell .hand-area { padding: 8px 12px; gap: 5px; }
  .desktop-app .app-shell .hand .tile,
  .desktop-app .app-shell .hand .pro-tile { min-height: 54px; height: 54px; }
}

/* Shared Windows geometry: both modes use the same frame and spacing. */
.desktop-app .app-shell { width: 100%; max-width: none; }
.desktop-app .app-shell .header-title { display: flex; align-items: center; width: auto; }
.desktop-app .app-shell .pro-kicker { display: none; }
.desktop-app .app-shell h1 { margin: 0; font-size: 25px; line-height: 1.25; }
.desktop-app .app-shell h1 span { font-size: 20px; line-height: 1.25; letter-spacing: .04em; }
.desktop-app .app-shell .status-bar { display: grid; grid-template-columns: 90px 240px 160px minmax(0,1fr); }
.desktop-app .app-shell .status-bar > p { grid-column: 4; }
.desktop-app .app-shell .status-bar > div { min-height: 32px; }
.desktop-app .app-shell .table {
  --seat-height: 130px;
  grid-template-columns: minmax(250px,.85fr) minmax(0,2fr);
  grid-template-rows: repeat(2,minmax(var(--seat-height),auto));
}
.desktop-app .app-shell .rules-card { height: calc(var(--seat-height) * 2 + 12px); max-height: none; }
.desktop-app .app-shell .opponent,
.desktop-app .app-shell .opponent:first-child,
.desktop-app .app-shell .player-river { grid-template-rows: 34px minmax(38px,1fr); }
.desktop-app .app-shell .opponent.has-melds { grid-template-rows: 34px auto minmax(38px,1fr); }
.desktop-app .app-shell .hand-heading { padding: 0; margin: 0; min-height: 24px; }
.desktop-app .app-shell .hand { gap: 7px; padding: 12px 4px 6px; }
.desktop-app .app-shell .hand > .tile,
.desktop-app .app-shell .hand > .pro-tile { margin-left: 0; }
.desktop-app .app-shell .discard-guide,
.desktop-app .app-shell .pro-actions {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: min(720px,100%); min-height: 56px; height: auto;
  align-self: center; margin: 0; padding: 6px 10px; box-sizing: border-box;
}
.desktop-app .app-shell .pro-actions:empty:after { min-height: 42px; border: 0; background: transparent; }
@media (min-width:1400px) and (min-height:800px) {
  .desktop-app .app-shell .table { --seat-height: clamp(150px,19vh,250px); grid-template-columns: minmax(300px,.7fr) minmax(0,2.3fr); }
  .desktop-app .app-shell .rules-card p,
  .desktop-app .app-shell .rules-card .rules-list dt,
  .desktop-app .app-shell .rules-card .rules-list dd { font-size: clamp(14px,.85vw,18px); }
  .desktop-app .app-shell .rules-card .rules-list > div { grid-template-columns: 54px minmax(0,1fr); }
  .desktop-app .app-shell .hand .tile,
  .desktop-app .app-shell .hand .pro-tile { width: clamp(54px,3.8vw,84px); height: clamp(74px,5.2vw,116px); }
  .desktop-app .app-shell .hand .tile-glyph,
  .desktop-app .app-shell .hand .pro-tile { font-size: clamp(38px,2.7vw,58px); }
  .desktop-app .app-shell .hand .honor-tile .tile-glyph,
  .desktop-app .app-shell .hand .pro-tile.honor { font-size: clamp(32px,2.3vw,50px); }
  .desktop-app .app-shell .score-value { font-size: clamp(20px,1.3vw,28px); }
}
@media (max-width:1050px) {
  .desktop-app .app-shell .status-bar { grid-template-columns: 70px minmax(180px,1fr) 150px; }
  .desktop-app .app-shell .status-bar > p { grid-column: 1 / -1; text-align: left; min-height: 20px; }
}
@media (max-width:900px) {
  .desktop-app .app-shell .table { grid-template-columns: minmax(160px,.7fr) minmax(0,1.7fr); }
}
@media (max-width:680px) {
  .desktop-app .app-shell h1 { flex-direction: column; align-items: flex-start; font-size: 22px; gap: 4px; }
  .desktop-app .app-shell h1 span { font-size: 18px; }
  .desktop-app .app-shell .status-bar { grid-template-columns: 60px minmax(0,1fr); }
  .desktop-app .app-shell .status-bar > div:nth-child(3) { grid-column: 1 / -1; grid-row: 2; }
  .desktop-app .app-shell:not(.pro-app) .status-bar:after { content: ''; grid-column: 1 / -1; grid-row: 2; min-height: 32px; }
  .desktop-app .app-shell .status-bar > p { grid-row: 3; }
  .desktop-app .app-shell .table { grid-template-columns: 1fr; grid-template-rows: auto auto 100px; }
  .desktop-app .app-shell .rules-card { height: 100px; max-height: 100px; }
  .desktop-app .app-shell .hand { gap: 4px; }
}
@media (min-width:681px) and (max-height:740px) {
  .desktop-app .app-shell .table { --seat-height: 100px; }
  .desktop-app .app-shell .rules-card { height: calc(var(--seat-height) * 2 + 8px); }
}
@media (min-width:901px) and (min-height:741px) {
  .desktop-app .app-shell { min-height: calc(100dvh - 36px); }
  .desktop-app .app-shell .table { flex: 1; grid-template-rows: repeat(2,minmax(var(--seat-height),1fr)); }
  .desktop-app .app-shell .rules-card { height: 0; min-height: 100%; }
}
html.desktop-app body { display: block; }
html.desktop-app #root { width: 100%; }
.desktop-app .app-shell .status-bar { grid-template-rows: auto; }
.desktop-app .app-shell .status-bar .mode { white-space: nowrap; }
.desktop-app .app-shell .river { min-height: 46px; padding: 0; }
@media (max-width:680px) {
  .desktop-app .app-shell .pro-indicators { min-height: 79px; }
  .desktop-app .app-shell .pro-indicators > span { flex-basis: 100%; }
}
.desktop-app .app-shell .river { margin: 0; }
.desktop-app .app-shell .hand-heading strong,
.desktop-app .app-shell .hand-heading small,
.desktop-app .app-shell .hand-heading > span { font-size: 16px; line-height: 1.2; }
.desktop-app .app-shell .opponent:not(.active) { border: 1px solid #dcbf7633; }
@media (max-width:680px) {
  .desktop-app .app-shell .hand-heading { min-height: 48px; align-content: flex-start; }
}
/* Four Japanese characters fit in either mode's shared action-label column. */
.desktop-app .app-shell .rules-card .rules-list > div { grid-template-columns: 4em minmax(0,1fr); }
@media (min-width:1400px) and (min-height:800px) {
  .desktop-app .app-shell .rules-card .rules-list > div { font-size: clamp(14px,.85vw,18px); }
}
