:root {
  color-scheme: dark;
  --felt-1: #0b5b45;
  --felt-2: #063c31;
  --felt-surface:
    radial-gradient(circle at 50% 45%, rgba(62, 158, 117, 0.42), transparent 52%),
    radial-gradient(circle at 50% 45%, rgba(40, 139, 101, 0.58), transparent 45%),
    linear-gradient(145deg, var(--felt-1), var(--felt-2));
  --ink: #f7f2df;
  --muted: #b9cec5;
  --gold: #f2ce75;
  --call-target-frame: 0 0 0 2px var(--gold);
  --red: #e95c55;
  --tile-w: clamp(31px, 5.15vw, 45px);
  --tile-h: calc(var(--tile-w) * 1.333);
  --open-tile-w: 30px;
  --open-half-tile-w: 15px;
  --open-tile-h: 40px;
  --side-river-meld-gap: 12px;
  --side-riichi-stick-lane: 6px;
  --sideways-tile-shift: 10px;
  --sideways-tile-offset: 5px;
  --seat-layout-clearance: calc(var(--open-tile-w) + var(--sideways-tile-shift));
  --opponent-score-top: 6px;
  --side-river-inset: 15%;
  --action-panel-w: clamp(126px, 18vw, 166px);
  --human-hand-row-h: 74px;
  --human-river-shift: clamp(14px, 2vw, 18px);
  --app-visible-height: 100dvh;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  width: 100%;
  min-height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--felt-surface);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Hiragino Sans", sans-serif;
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
}

html.character-swap-touch-lock,
html.character-swap-touch-lock body {
  overflow: hidden;
  overscroll-behavior: none;
  touch-action: none;
}

html.character-swap-touch-lock body {
  position: fixed;
  inset: 0;
  -webkit-overflow-scrolling: auto;
}

button {
  color: inherit;
  font: inherit;
}

.app-shell {
  display: grid;
  width: 100vw;
  height: 100dvh;
  min-height: 0;
  place-items: center;
  overflow: hidden;
  background: var(--felt-surface);
}

.topbar {
  position: relative;
  z-index: 20;
  display: grid;
  grid-template-columns: auto auto minmax(72px, 1fr) auto auto auto auto auto;
  align-items: center;
  gap: 8px;
  height: calc(44px + env(safe-area-inset-top));
  padding: env(safe-area-inset-top) max(10px, env(safe-area-inset-right)) 0 max(10px, env(safe-area-inset-left));
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(3, 19, 15, 0.88);
  box-shadow: 0 5px 18px rgba(0, 0, 0, 0.18);
  backdrop-filter: blur(14px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
  white-space: nowrap;
}

.brand-mark {
  display: grid;
  width: 28px;
  height: 28px;
  place-items: center;
  border: 1px solid rgba(242, 206, 117, 0.7);
  border-radius: 8px;
  background: linear-gradient(145deg, #234c3f, #102c24);
  color: var(--gold);
  font-family: Georgia, serif;
  font-size: 13px;
}

.round-pill {
  padding: 5px 9px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
  color: var(--gold);
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.top-status {
  overflow: hidden;
  color: var(--muted);
  font-size: 11px;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.icon-button {
  display: grid;
  min-width: 42px;
  height: 30px;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.07);
  color: inherit;
  font-size: 11px;
  font-weight: 750;
  text-decoration: none;
}

.voice-library-link {
  border-color: rgba(242, 206, 117, 0.36);
  color: var(--gold);
}

.stats-link {
  border-color: rgba(115, 185, 255, 0.38);
  color: #a9d7ff;
}

.bgm-control {
  position: relative;
}

.bgm-button[aria-pressed="true"] {
  border-color: rgba(127, 224, 163, 0.48);
  background: rgba(44, 137, 87, 0.22);
  color: #a6f0c1;
}

.bgm-button[aria-pressed="false"] {
  color: #81978e;
}

.bgm-panel {
  position: absolute;
  top: 36px;
  right: -48px;
  z-index: 90;
  width: min(240px, calc(100vw - 20px));
  padding: 12px;
  border: 1px solid rgba(242, 206, 117, 0.38);
  border-radius: 12px;
  background: rgba(3, 24, 19, 0.97);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.42);
}

.bgm-panel[hidden] {
  display: none;
}

.bgm-panel-row,
.bgm-volume-label > span {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.bgm-panel-row {
  font-size: 13px;
}

.bgm-track-name {
  display: inline-block;
  margin-left: 4px;
  color: var(--gold);
  font-size: 10px;
  letter-spacing: 0.08em;
}

.bgm-current-scene {
  margin-top: 5px;
  color: #9bd9b2;
  font-size: 9px;
  line-height: 1.35;
}

.bgm-settings-link {
  display: block;
  margin-top: 9px;
  padding: 7px 9px;
  border: 1px solid rgba(242, 206, 117, 0.28);
  border-radius: 8px;
  background: rgba(242, 206, 117, 0.07);
  color: var(--gold);
  font-size: 10px;
  font-weight: 800;
  text-align: center;
  text-decoration: none;
}

#settingsBgmLink[hidden],
#accountSetupLink[hidden],
#newGameButton[hidden] {
  display: none !important;
}

.bgm-toggle {
  min-width: 52px;
  padding: 5px 10px;
  border: 1px solid rgba(151, 195, 183, 0.38);
  border-radius: 999px;
  background: linear-gradient(145deg, rgba(45, 82, 72, 0.72), rgba(8, 39, 31, 0.9));
  box-shadow: inset 0 1px rgba(255, 255, 255, 0.08), 0 4px 10px rgba(0, 0, 0, 0.18);
  color: #e8f2ed;
  font-size: 12px;
  font-weight: 850;
}

.bgm-volume-label {
  display: grid;
  gap: 5px;
  margin-top: 10px;
  color: var(--muted);
  font-size: 11px;
}

.bgm-volume-label output {
  color: var(--gold);
  font-variant-numeric: tabular-nums;
}

.bgm-volume-label input {
  width: 100%;
  accent-color: #7fe0a3;
}

.bgm-panel small {
  display: block;
  margin-top: 7px;
  color: #8da59b;
  font-size: 9px;
  line-height: 1.4;
}

.settings-sheet,
.settings-page-sheet,
.account-sheet,
.confirm-sheet,
.exit-sheet,
.meddling-uncle-sheet {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: max(10px, env(safe-area-inset-top)) max(14px, env(safe-area-inset-right)) max(10px, env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left));
  background: rgba(0, 12, 9, 0.84);
  backdrop-filter: blur(14px) saturate(0.9);
}

.settings-sheet {
  z-index: 110;
}

.settings-page-sheet {
  z-index: 140;
  bottom: auto;
  grid-template-rows: auto minmax(0, 1fr);
  place-items: stretch;
  width: 100%;
  height: 100vh;
  height: 100svh;
  padding: 0;
  background: #03130f;
  backdrop-filter: none;
}

.settings-page-toolbar {
  position: relative;
  z-index: 2;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  min-height: calc(58px + env(safe-area-inset-top));
  padding: env(safe-area-inset-top) max(14px, env(safe-area-inset-right)) 0 max(14px, env(safe-area-inset-left));
  border-bottom: 1px solid rgba(242, 206, 117, 0.34);
  background: linear-gradient(180deg, rgba(5, 35, 27, 0.99), rgba(3, 24, 19, 0.98));
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.24);
}

.settings-page-heading {
  display: grid;
  gap: 1px;
  text-align: center;
}

.settings-page-heading span {
  color: var(--gold);
  font-family: Georgia, serif;
  font-size: 8px;
  font-weight: 850;
  letter-spacing: 0.18em;
}

.settings-page-heading strong {
  color: #f7f2df;
  font-size: 17px;
}

.settings-page-back {
  justify-self: start;
  min-width: 74px;
  min-height: 42px;
  padding: 8px 15px;
  border: 1px solid rgba(242, 206, 117, 0.52);
  border-radius: 11px;
  background: linear-gradient(145deg, rgba(55, 100, 76, 0.58), rgba(13, 55, 42, 0.82));
  color: var(--gold);
  font-size: 15px;
  font-weight: 850;
}

.settings-page-back:active {
  transform: scale(0.97);
}

.settings-page-action {
  display: flex;
  min-width: 74px;
  min-height: 42px;
  justify-self: end;
  align-items: center;
  justify-content: flex-end;
  color: #abc3b9;
  font-size: 11px;
  font-weight: 750;
  text-align: right;
}

.settings-page-action:empty {
  visibility: hidden;
}

.settings-page-action button {
  min-height: 40px;
  padding: 7px 13px;
  border: 1px solid rgba(242, 206, 117, 0.34);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.065);
  color: #f7f2df;
  font-size: 13px;
  font-weight: 800;
}

.settings-page-action .collection-count {
  display: flex;
  align-items: baseline;
  gap: 3px;
  color: #abc3b9;
}

.settings-page-action .collection-count strong {
  color: var(--gold);
  font-size: 18px;
}

.settings-page-action .collection-count > span {
  font-size: 9px;
}

.settings-page-frame {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
  background: #03130f;
}

.account-sheet {
  z-index: 126;
}

.confirm-sheet {
  z-index: 120;
}

.meddling-uncle-sheet {
  z-index: 125;
  background:
    radial-gradient(circle at 50% 42%, rgba(242, 206, 117, 0.18), transparent 46%),
    rgba(0, 12, 9, 0.88);
}

.exit-sheet {
  z-index: 130;
  background:
    radial-gradient(circle at 50% 45%, rgba(29, 112, 82, 0.32), transparent 48%),
    #03130f;
}

.settings-sheet[hidden],
.settings-page-sheet[hidden],
.account-sheet[hidden],
.confirm-sheet[hidden],
.exit-sheet[hidden],
.meddling-uncle-sheet[hidden] {
  display: none;
}

.settings-dialog {
  width: min(780px, 100%);
  max-height: calc(100dvh - 20px);
  overflow: auto;
  border: 1px solid rgba(242, 206, 117, 0.52);
  border-radius: 19px;
  background: linear-gradient(145deg, rgba(10, 48, 38, 0.99), rgba(3, 24, 19, 0.99));
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.58);
}

.settings-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 58px;
  padding: 9px 12px 8px 18px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.settings-header span,
.exit-dialog > span {
  color: var(--gold);
  font-family: Georgia, serif;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.16em;
}

.settings-header h1 {
  margin: 1px 0 0;
  font-size: 24px;
  line-height: 1;
}

.settings-version {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-left: auto;
  color: #d8e8df;
  white-space: nowrap;
}

.settings-version strong {
  color: var(--gold);
  font-size: 19px;
  font-weight: 900;
  letter-spacing: 0.05em;
}

.settings-close {
  display: grid;
  flex: 0 0 auto;
  width: 44px;
  height: 44px;
  margin-left: 14px;
  padding: 0;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.07);
  font-size: 28px;
  line-height: 1;
}

.settings-body {
  display: grid;
  grid-template-columns: minmax(260px, 1.1fr) minmax(210px, 0.9fr);
  gap: 14px;
  padding: 14px;
}

.settings-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 9px;
}

.settings-menu-button {
  display: grid;
  min-height: 52px;
  margin: 0;
  padding: 8px 12px;
  place-items: center;
  border: 1px solid rgba(151, 195, 183, 0.32);
  border-radius: 11px;
  background: linear-gradient(145deg, rgba(45, 82, 72, 0.68), rgba(8, 39, 31, 0.9));
  box-shadow:
    inset 0 1px rgba(255, 255, 255, 0.075),
    inset 0 -1px rgba(0, 0, 0, 0.22),
    0 5px 13px rgba(0, 0, 0, 0.16);
  color: #e8f2ed;
  font-size: 15px;
  font-weight: 820;
  line-height: 1.2;
  text-align: center;
  text-decoration: none;
}

.settings-menu-button:active,
.settings-close:active,
.table-settings-button:active,
.confirm-button:active {
  transform: scale(0.97);
}

#soundButton[aria-pressed="false"],
.settings-menu-button.meddling-uncle-toggle[aria-pressed="false"],
.bgm-toggle[aria-pressed="false"],
#accountSignupButton:disabled {
  border-color: rgba(151, 195, 183, 0.14);
  background: linear-gradient(145deg, rgba(18, 45, 37, 0.72), rgba(2, 18, 15, 0.96));
  color: #83968f;
  box-shadow: none;
}

#accountSignupButton:disabled {
  cursor: default;
  opacity: 1;
  -webkit-text-fill-color: #83968f;
}

.settings-menu-button.danger {
  border-color: rgba(207, 111, 103, 0.44);
  background: linear-gradient(145deg, rgba(75, 61, 56, 0.7), rgba(37, 35, 31, 0.9));
  color: #e9c6c1;
}

.settings-side-stack {
  display: grid;
  min-width: 0;
  align-content: start;
  gap: 10px;
}

.settings-account-card {
  min-width: 0;
  padding: 13px 14px;
  border: 1px solid rgba(151, 195, 183, 0.3);
  border-radius: 13px;
  background: linear-gradient(145deg, rgba(19, 55, 46, 0.84), rgba(1, 22, 17, 0.78));
}

.settings-account-card[data-state="signed-in"] {
  border-color: rgba(151, 195, 183, 0.38);
  background: linear-gradient(145deg, rgba(23, 65, 53, 0.82), rgba(1, 22, 17, 0.78));
}

.settings-account-heading {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 10px;
}

.settings-account-heading > div {
  display: grid;
  min-width: 0;
  gap: 2px;
}

.settings-account-heading > div > span {
  color: #a9c8bf;
  font-family: Georgia, serif;
  font-size: 8px;
  font-weight: 800;
  letter-spacing: 0.13em;
}

.settings-account-heading strong {
  overflow: hidden;
  font-size: 16px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.account-state-badge {
  flex: 0 0 auto;
  padding: 4px 7px;
  border: 1px solid rgba(151, 195, 183, 0.3);
  border-radius: 999px;
  color: #c2d8d1;
  font-size: 9px;
  font-weight: 850;
}

.settings-account-card[data-state="signed-in"] .account-state-badge {
  border-color: rgba(151, 195, 183, 0.4);
  color: #d5e5df;
}

.settings-account-card p {
  margin: 8px 0 10px;
  color: #a9c1b7;
  font-size: 10px;
  line-height: 1.55;
}

.settings-account-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 7px;
}

.settings-account-actions button,
.settings-account-actions a {
  display: grid;
  min-height: 35px;
  margin: 0;
  padding: 6px 8px;
  place-items: center;
  border: 1px solid rgba(151, 195, 183, 0.3);
  border-radius: 9px;
  background: linear-gradient(145deg, rgba(45, 82, 72, 0.64), rgba(8, 39, 31, 0.88));
  box-shadow: inset 0 1px rgba(255, 255, 255, 0.065), 0 4px 10px rgba(0, 0, 0, 0.14);
  color: #dceae5;
  font-size: 11px;
  font-weight: 850;
  text-align: center;
  text-decoration: none;
}

.settings-account-actions a {
  border-color: rgba(151, 195, 183, 0.3);
  background: linear-gradient(145deg, rgba(45, 82, 72, 0.64), rgba(8, 39, 31, 0.88));
  color: #dceae5;
}

.account-dialog {
  width: min(520px, 100%);
  max-height: calc(100dvh - 20px);
  overflow: auto;
  border: 1px solid rgba(242, 206, 117, 0.56);
  border-radius: 19px;
  background: linear-gradient(145deg, rgba(10, 48, 38, 0.995), rgba(3, 24, 19, 0.995));
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.62);
}

.account-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 64px;
  padding: 10px 12px 9px 18px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.account-header > div {
  display: grid;
  gap: 1px;
}

.account-header span {
  color: var(--gold);
  font-family: Georgia, serif;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.16em;
}

.account-header h1 {
  margin: 0;
  font-size: 23px;
}

.account-close {
  display: grid;
  width: 42px;
  height: 42px;
  padding: 0;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.07);
  font-size: 27px;
}

.account-body {
  display: grid;
  gap: 12px;
  padding: 15px;
}

.account-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  padding: 4px;
  border-radius: 11px;
  background: rgba(0, 13, 10, 0.55);
}

.account-tabs[hidden],
.account-form[hidden],
.account-signed-in[hidden] {
  display: none;
}

.account-tabs button {
  min-height: 38px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: #94aaa1;
  font-size: 13px;
  font-weight: 850;
}

.account-tabs button[aria-selected="true"] {
  border-color: rgba(242, 206, 117, 0.46);
  background: rgba(146, 104, 36, 0.22);
  color: #fff0b3;
}

.account-form {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.account-form label {
  display: grid;
  gap: 5px;
}

.account-form label:first-child,
.account-form .account-submit {
  grid-column: 1 / -1;
}

.account-form label span {
  color: #b9cec5;
  font-size: 10px;
  font-weight: 780;
}

.account-form input {
  width: 100%;
  min-height: 43px;
  padding: 9px 11px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 9px;
  outline: 0;
  background: rgba(0, 13, 10, 0.68);
  color: #f7f2df;
  font: inherit;
  font-size: 14px;
  -webkit-user-select: text;
  user-select: text;
}

.account-form input:focus {
  border-color: rgba(127, 224, 163, 0.72);
  box-shadow: 0 0 0 2px rgba(127, 224, 163, 0.12);
}

.account-form output {
  float: right;
  color: #91ada2;
  font-size: 9px;
}

.account-name-rules,
.account-display-name-form small {
  color: #89a198;
  font-size: 9px;
  line-height: 1.5;
}

.account-display-name-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 7px 9px;
  padding: 12px;
  border: 1px solid rgba(242, 206, 117, 0.3);
  border-radius: 12px;
  background: rgba(2, 24, 18, 0.58);
}

.account-display-name-form[hidden] {
  display: none;
}

.account-display-name-form label {
  display: flex;
  grid-column: 1 / -1;
  justify-content: space-between;
  color: #d8c68e;
  font-size: 10px;
  font-weight: 850;
}

.account-display-name-form input {
  min-width: 0;
  min-height: 41px;
  padding: 8px 10px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 9px;
  outline: 0;
  background: rgba(0, 13, 10, 0.68);
  color: #f7f2df;
  font: inherit;
  -webkit-user-select: text;
  user-select: text;
}

.account-display-name-form input:focus {
  border-color: rgba(127, 224, 163, 0.72);
  box-shadow: 0 0 0 2px rgba(127, 224, 163, 0.12);
}

.account-display-name-form > small,
.account-display-name-form > p {
  grid-column: 1 / -1;
  margin: 0;
}

.account-display-name-form button {
  min-width: 112px;
  min-height: 41px;
  border: 1px solid rgba(127, 224, 163, 0.5);
  border-radius: 9px;
  background: rgba(44, 137, 87, 0.23);
  color: #d7f7e2;
  font-size: 11px;
  font-weight: 850;
}

.account-display-name-form p {
  min-height: 1.5em;
  color: #a9c1b7;
  font-size: 10px;
  line-height: 1.5;
}

.account-display-name-form p[data-tone="success"] {
  color: #c5f3d5;
}

.account-display-name-form p[data-tone="error"] {
  color: #ffc3be;
}
.account-verification {
  grid-template-columns: minmax(0, 1fr);
}

.account-verification-copy {
  margin: 0;
  color: #b9cec5;
  font-size: 11px;
  line-height: 1.65;
}

.account-verification-copy strong {
  color: #fff0b3;
}

.account-verification label,
.account-verification-actions {
  grid-column: 1;
}

.account-verification input {
  font-size: 21px;
  font-weight: 850;
  letter-spacing: 0.18em;
  text-align: center;
}

.account-verification-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.account-verification-actions .account-submit {
  grid-column: 1 / -1;
}

.account-verification-actions button:not(.account-submit) {
  min-height: 38px;
  border: 1px solid rgba(115, 185, 255, 0.32);
  border-radius: 9px;
  background: rgba(35, 89, 125, 0.13);
  color: #c9e5ff;
  font-size: 10px;
  font-weight: 850;
}

.account-submit {
  min-height: 44px;
  border: 1px solid rgba(127, 224, 163, 0.56);
  border-radius: 10px;
  background: linear-gradient(145deg, rgba(45, 148, 95, 0.56), rgba(24, 91, 63, 0.72));
  color: #e7fff0;
  font-size: 14px;
  font-weight: 900;
}

.account-signed-in {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 5px 10px;
  padding: 14px;
  border: 1px solid rgba(127, 224, 163, 0.38);
  border-radius: 12px;
  background: rgba(44, 137, 87, 0.12);
}

.account-signed-in > span,
.account-signed-in > strong,
.account-signed-in > small {
  grid-column: 1;
}

.account-signed-in > span {
  color: #9ddcb5;
  font-size: 9px;
  font-weight: 850;
}

.account-signed-in > strong {
  font-size: 20px;
}

.account-signed-in > small {
  color: #a8bbb3;
}

.account-signed-in a,
.account-signed-in button {
  grid-column: 2;
  min-width: 120px;
  padding: 8px;
  border: 1px solid rgba(127, 224, 163, 0.38);
  border-radius: 8px;
  background: rgba(44, 137, 87, 0.18);
  color: #c8f7d8;
  font-size: 11px;
  font-weight: 850;
  text-align: center;
  text-decoration: none;
}

.account-signed-in button {
  border-color: rgba(233, 92, 85, 0.45);
  background: rgba(151, 45, 41, 0.18);
  color: #ffc3be;
}

.account-signed-in button.account-start-ranking[hidden] {
  display: none;
}

.account-signed-in button.account-start-ranking {
  border-color: rgba(127, 224, 163, 0.5);
  background: linear-gradient(145deg, rgba(45, 148, 95, 0.42), rgba(24, 91, 63, 0.58));
  color: #e7fff0;
}

.account-message,
.account-privacy {
  margin: 0;
  color: #a9c1b7;
  font-size: 11px;
  line-height: 1.55;
}

.account-setup-link {
  justify-self: center;
  color: #a9d7ff;
  font-size: 11px;
  font-weight: 850;
}

.account-message {
  padding: 9px 11px;
  border: 1px solid rgba(115, 185, 255, 0.25);
  border-radius: 9px;
  background: rgba(35, 89, 125, 0.12);
}

.account-message[data-tone="success"] {
  border-color: rgba(127, 224, 163, 0.34);
  color: #c5f3d5;
}

.account-message[data-tone="error"] {
  border-color: rgba(233, 92, 85, 0.5);
  color: #ffc3be;
}

.account-privacy {
  color: #7f978e;
  font-size: 9px;
  text-align: center;
}

.settings-bgm-card {
  min-width: 0;
  padding: 13px 14px;
  border: 1px solid rgba(127, 224, 163, 0.3);
  border-radius: 13px;
  background: rgba(1, 22, 17, 0.68);
}

.settings-bgm-card .bgm-panel-row {
  font-size: 15px;
}

.settings-bgm-card .bgm-track-name {
  font-size: 12px;
}

.settings-bgm-card .bgm-current-scene {
  margin-top: 7px;
  font-size: 13px;
}

.settings-bgm-card .bgm-set-label {
  display: grid;
  grid-template-columns: auto minmax(150px, 1fr);
  gap: 12px;
  align-items: center;
  margin-top: 11px;
  color: #c8d8d1;
  font-size: 13px;
  font-weight: 800;
}

.settings-bgm-card .bgm-set-label select {
  width: 100%;
  min-height: 36px;
  padding: 6px 30px 6px 10px;
  border: 1px solid rgba(242, 206, 117, 0.42);
  border-radius: 9px;
  background: #092d24;
  color: #f6dfa2;
  font: inherit;
}

.settings-bgm-card .bgm-volume-label {
  font-size: 14px;
}

.settings-bgm-card .bgm-volume-label input {
  min-height: 28px;
}

.settings-bgm-card small {
  display: block;
  margin-top: 7px;
  color: #a9bdb4;
  font-size: 11px;
  line-height: 1.4;
}

.settings-offline-card {
  min-width: 0;
  padding: 12px 14px;
  border: 1px solid rgba(115, 185, 255, 0.28);
  border-radius: 13px;
  background: linear-gradient(145deg, rgba(18, 57, 54, 0.76), rgba(1, 22, 17, 0.78));
}

.settings-offline-heading {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 10px;
}

.settings-offline-heading > div {
  display: grid;
  gap: 2px;
}

.settings-offline-heading > div > span {
  color: #a9c8bf;
  font-family: Georgia, serif;
  font-size: 8px;
  font-weight: 800;
  letter-spacing: 0.13em;
}

.settings-offline-heading strong {
  font-size: 15px;
}

.offline-media-policy {
  padding: 3px 7px;
  border: 1px solid rgba(115, 185, 255, 0.28);
  border-radius: 999px;
  color: #b8d8f4;
  font-size: 9px;
  font-weight: 850;
}

.settings-offline-card p {
  margin: 7px 0 5px;
  color: #adc5bc;
  font-size: 10px;
  line-height: 1.45;
}

.settings-offline-card p[data-state="complete"] {
  color: #b9edca;
}

.settings-offline-card p[data-state="partial"],
.settings-offline-card p[data-state="unavailable"] {
  color: #f0c1ba;
}

.settings-offline-card progress {
  display: block;
  width: 100%;
  height: 7px;
  margin: 6px 0;
  overflow: hidden;
  border: 0;
  border-radius: 999px;
  accent-color: #7fe0a3;
  background: rgba(0, 0, 0, 0.36);
}

.settings-offline-card progress[hidden] {
  display: none;
}

.settings-offline-card > small {
  display: block;
  min-height: 14px;
  color: #8da99f;
  font-size: 9px;
  line-height: 1.35;
}

.offline-media-actions {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr);
  gap: 7px;
  margin-top: 7px;
}

.offline-media-actions button {
  min-height: 34px;
  margin: 0;
  padding: 5px 7px;
  border: 1px solid rgba(151, 195, 183, 0.32);
  border-radius: 9px;
  background: rgba(17, 65, 51, 0.76);
  color: #e5f0eb;
  font-size: 10px;
  font-weight: 850;
  line-height: 1.2;
}

.offline-media-actions button:last-child {
  border-color: rgba(207, 111, 103, 0.32);
  background: rgba(64, 43, 39, 0.66);
  color: #e8c9c4;
}

.offline-media-actions button:disabled {
  cursor: default;
  opacity: 0.48;
}

.meddling-uncle-dialog {
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr);
  gap: 16px;
  width: min(620px, 100%);
  max-height: calc(100dvh - 20px);
  padding: 20px;
  overflow: auto;
  border: 1px solid rgba(242, 206, 117, 0.68);
  border-radius: 20px;
  background:
    linear-gradient(135deg, rgba(255, 243, 188, 0.07), transparent 35%),
    linear-gradient(145deg, #164a38, #071f19);
  box-shadow: 0 28px 76px rgba(0, 0, 0, 0.7), 0 0 38px rgba(242, 206, 117, 0.1);
}

.meddling-uncle-icon {
  display: grid;
  width: 86px;
  height: 86px;
  place-items: center;
  border: 2px solid rgba(242, 206, 117, 0.72);
  border-radius: 50%;
  background: #fff8dc;
  box-shadow: 0 7px 22px rgba(0, 0, 0, 0.48);
  font-size: 50px;
  line-height: 1;
}

.meddling-uncle-content {
  min-width: 0;
}

.meddling-uncle-kicker {
  color: var(--gold);
  font-family: Georgia, serif;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.18em;
}

.meddling-uncle-content h1 {
  margin: 2px 0 8px;
  color: #fff5ca;
  font-size: 25px;
  line-height: 1.1;
}

.meddling-uncle-comment {
  margin: 0 0 8px;
  color: #fff;
  font-size: 18px;
  font-weight: 720;
  line-height: 1.65;
}

.meddling-uncle-comment-text {
  white-space: pre-wrap;
}

.meddling-uncle-rule-name {
  white-space: nowrap;
}

.meddling-uncle-inline-tile {
  display: inline-block;
  width: 36px;
  height: 48px;
  margin: 0 4px;
  vertical-align: -17px;
  object-fit: fill;
}

.meddling-uncle-reason {
  margin: 0 0 9px;
  color: #ffe18a;
  font-size: 13px;
  font-weight: 800;
}

.meddling-uncle-comparison {
  display: grid;
  grid-template-columns: auto minmax(60px, 1fr) auto minmax(60px, 1fr) auto minmax(60px, 1fr);
  gap: 5px 8px;
  align-items: center;
  padding: 8px 10px;
  border-radius: 10px;
  background: rgba(0, 12, 9, 0.5);
  font-size: 12px;
}

.meddling-uncle-comparison span {
  color: #9fb8ae;
}

.meddling-uncle-comparison strong {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #fff5ca;
  font-size: 14px;
}

.meddling-uncle-choice-tile {
  display: block;
  flex: 0 0 auto;
  width: 43px;
  height: 57px;
  object-fit: fill;
}

.meddling-uncle-choice-ev {
  color: #fff5ca;
  font-size: 14px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.meddling-uncle-no-redo {
  margin: 9px 0 10px;
  color: #c8d5cf;
  font-size: 12px;
  line-height: 1.4;
}

.meddling-uncle-reason[hidden],
.meddling-uncle-comparison[hidden],
.meddling-uncle-no-redo[hidden] {
  display: none;
}

.meddling-uncle-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.meddling-uncle-view,
.meddling-uncle-close {
  display: block;
  width: 100%;
  min-height: 43px;
  border: 1px solid rgba(242, 206, 117, 0.72);
  border-radius: 12px;
  color: #fff8dc;
  font-size: 16px;
  font-weight: 850;
}

.meddling-uncle-view {
  background: linear-gradient(#715b28, #403216);
}

.meddling-uncle-close {
  background: linear-gradient(#2d8a68, #175c46);
}

.table-review-return {
  position: fixed;
  z-index: 126;
  top: max(8px, env(safe-area-inset-top));
  right: max(8px, env(safe-area-inset-right));
  display: flex;
  align-items: center;
  padding: 5px;
  border: 1px solid rgba(242, 206, 117, 0.68);
  border-radius: 12px;
  background: rgba(3, 31, 24, 0.94);
  box-shadow: 0 7px 20px rgba(0, 0, 0, 0.42);
}

.table-review-return[hidden] {
  display: none;
}

.table-review-back {
  min-width: 72px;
  min-height: 38px;
  border: 1px solid rgba(242, 206, 117, 0.72);
  border-radius: 9px;
  background: linear-gradient(#2d8a68, #175c46);
  color: #fff8dc;
  font-size: 15px;
  font-weight: 900;
}

.confirm-dialog,
.exit-dialog {
  width: min(460px, 100%);
  padding: 24px;
  border: 1px solid rgba(242, 206, 117, 0.52);
  border-radius: 18px;
  background: linear-gradient(145deg, #0c4033, #061f19);
  box-shadow: 0 26px 72px rgba(0, 0, 0, 0.62);
  text-align: center;
}

.confirm-eyebrow {
  color: var(--gold);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.18em;
}

.confirm-dialog h1,
.exit-dialog h1 {
  margin: 7px 0 8px;
  font-size: 24px;
  line-height: 1.25;
}

.confirm-dialog p,
.exit-dialog p {
  margin: 0;
  color: #d0e2da;
  font-size: 15px;
  line-height: 1.55;
}

.confirm-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(120px, 1fr));
  gap: 12px;
  margin-top: 20px;
}

.confirm-button {
  min-height: 50px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 11px;
  background: rgba(255, 255, 255, 0.08);
  font-size: 17px;
  font-weight: 850;
}

.confirm-button.yes {
  border-color: rgba(242, 206, 117, 0.65);
  background: linear-gradient(#b68131, #80561d);
}

.exit-dialog small {
  display: block;
  margin-top: 16px;
  color: #93aaa0;
  font-size: 12px;
}

.table {
  position: relative;
  width: min(100vw, 250dvh);
  height: min(100dvh, 40vw);
  min-height: 0;
  aspect-ratio: 5 / 2;
  overflow: hidden;
  background: transparent;
}

.opponent {
  position: absolute;
  z-index: 4;
  display: flex;
  align-items: center;
  gap: 7px;
}

.opponent-top {
  top: var(--opponent-score-top);
  left: calc(50% + var(--open-tile-w) * 3 + 10px + var(--seat-layout-clearance));
  flex-direction: row;
  transform: none;
}

.opponent-left {
  top: 38%;
  left: max(7px, env(safe-area-inset-left));
  transform: translateY(-50%);
}

.opponent-right {
  top: 38%;
  right: max(7px, env(safe-area-inset-right));
  flex-direction: row-reverse;
  transform: translateY(-50%);
}

.player-card {
  position: relative;
  appearance: none;
  display: grid;
  grid-template-columns: 19px auto;
  grid-template-rows: 12px 12px;
  align-items: center;
  column-gap: 4px;
  row-gap: 0;
  min-width: 0;
  padding: 3px 5px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  background: rgba(2, 25, 20, 0.72);
  font-size: 9px;
  line-height: 1;
  white-space: nowrap;
  backdrop-filter: blur(8px);
}

.agari-houki-badge {
  position: absolute;
  z-index: 5;
  left: 50%;
  bottom: -17px;
  min-width: 58px;
  padding: 3px 6px;
  transform: translateX(-50%);
  border: 1px solid rgba(255, 139, 122, 0.82);
  border-radius: 999px;
  background: rgba(92, 18, 15, 0.96);
  box-shadow: 0 2px 8px rgba(22, 0, 0, 0.35);
  color: #ffe6df;
  font-size: 9px;
  font-weight: 900;
  line-height: 1.15;
  text-align: center;
  pointer-events: none;
}

.agari-houki-badge[hidden] {
  display: none;
}

.player-card.has-agari-houki {
  border-color: rgba(255, 139, 122, 0.66);
  background: rgba(62, 12, 10, 0.88);
}

.profile-trigger {
  cursor: pointer;
  transition: border-color 150ms ease, background 150ms ease, box-shadow 150ms ease, transform 150ms ease;
}

.profile-trigger::after {
  display: none;
}

.profile-trigger:active {
  transform: scale(0.96);
}

.profile-trigger:focus-visible {
  border-color: rgba(242, 206, 117, 0.88);
  box-shadow: 0 0 0 2px rgba(242, 206, 117, 0.24);
  outline: none;
}

.player-card .name {
  grid-column: 2;
  grid-row: 1;
  align-self: end;
  font-size: 9px;
  font-weight: 800;
}

.player-card .score {
  grid-column: 2;
  grid-row: 2;
  align-self: start;
  color: var(--gold);
  font-size: 9px;
  font-variant-numeric: tabular-nums;
}

.wind {
  grid-column: 1;
  grid-row: 1 / 3;
  display: inline-grid;
  width: 19px;
  height: 19px;
  place-items: center;
  border-radius: 50%;
  background: #f5ecda;
  color: #173b2f;
  font-family: "Hiragino Mincho ProN", serif;
  font-size: 11px;
  font-weight: 900;
}

.river {
  position: absolute;
  z-index: 6;
  display: grid;
  grid-template-columns: repeat(6, var(--open-tile-w));
  grid-template-rows: repeat(3, var(--open-tile-h));
  grid-auto-columns: var(--open-tile-w);
  grid-auto-rows: var(--open-tile-h);
  gap: 0;
  width: calc(var(--open-tile-w) * 6);
  height: calc(var(--open-tile-h) * 3);
  padding: 0;
  overflow: visible;
  background: transparent;
}

.river img {
  display: block;
  width: var(--open-tile-w);
  height: var(--open-tile-h);
  border-radius: 0;
  box-shadow: none;
}

.river.has-riichi-stick::before {
  content: "";
  position: absolute;
  z-index: 8;
  top: -4px;
  left: 50%;
  width: clamp(38px, calc(var(--open-tile-w) * 1.6), 52px);
  height: 4px;
  box-sizing: border-box;
  transform: translateX(-50%);
  border: 1px solid #b7ad93;
  border-radius: 999px;
  background:
    radial-gradient(circle at center, #cf302d 0 1.5px, transparent 1.9px),
    linear-gradient(#fffdf3, #e8dfca);
  pointer-events: none;
}

.river img.riichi-discard {
  position: relative;
  z-index: 7;
  transform: translate(var(--sideways-tile-offset), calc(0px - var(--sideways-tile-offset))) rotate(90deg);
  transform-origin: center;
}

.river img.after-riichi-discard {
  transform: translateX(var(--sideways-tile-shift));
}

.river-top {
  top: 0;
  left: calc(50% + var(--seat-layout-clearance));
  transform: translateX(-50%) rotate(180deg);
}

.river-bottom {
  bottom: calc(74px + max(5px, env(safe-area-inset-bottom)));
  left: calc(50% - var(--human-river-shift));
  transform: translateX(-50%);
}

.river-left {
  top: calc(var(--open-tile-w) * 3 + 2px);
  left: calc(var(--side-river-inset) + 5% - var(--open-tile-w) - var(--side-river-meld-gap));
  transform: translateY(-50%) rotate(90deg);
}

.river-right {
  top: 38%;
  right: auto;
  left: calc(50% + var(--open-tile-w) * 3 + 10px - var(--open-half-tile-w) + var(--side-riichi-stick-lane));
  transform: translateY(-50%) rotate(-90deg);
}

.river-right.wanpai-kan-pair-1 {
  left: calc(50% + var(--open-tile-w) * 4 + 10px - var(--open-half-tile-w) + var(--side-riichi-stick-lane));
}

.river-right.wanpai-kan-pair-2 {
  left: calc(50% + var(--open-tile-w) * 5 + 10px - var(--open-half-tile-w) + var(--side-riichi-stick-lane));
}

.meld-zone {
  z-index: 7;
  display: flex;
  align-items: flex-end;
  gap: 0;
}

.meld-zone:empty {
  display: none;
}

.meld-zone-top,
.meld-zone-left,
.meld-zone-right {
  position: absolute;
}

.meld-zone-top {
  top: var(--opponent-score-top);
  right: calc(50% + 94px);
  flex-direction: column-reverse;
  align-items: flex-end;
  transform: rotate(180deg);
}

.meld-zone-left {
  top: calc(38% + 18px);
  left: max(8px, env(safe-area-inset-left));
  flex-direction: row;
  align-items: flex-end;
  gap: 0;
}

.meld-zone-right {
  top: var(--opponent-score-top);
  right: max(8px, env(safe-area-inset-right));
  flex-direction: row-reverse;
  align-items: flex-start;
  gap: 0;
}

.meld-stack-item {
  position: relative;
  flex: 0 0 auto;
  width: var(--open-tile-h);
}

.meld-stack-3 {
  height: calc(
    var(--open-tile-w) + var(--open-tile-w) + var(--open-tile-w)
  );
}

.meld-stack-4 {
  height: calc(
    var(--open-tile-w) + var(--open-tile-w) + var(--open-tile-w) +
    var(--open-tile-w)
  );
}

.meld-stack-item.meld-stack-called {
  height: calc(
    var(--open-tile-w) + var(--open-tile-w) + var(--open-tile-w) +
    var(--sideways-tile-shift)
  );
}

.meld-stack-4.meld-stack-called {
  height: calc(
    var(--open-tile-w) + var(--open-tile-w) + var(--open-tile-w) +
    var(--open-tile-w) + var(--sideways-tile-shift)
  );
}

.meld-stack-item .meld-group {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}

.meld-zone-left .meld-stack-item .meld-group {
  transform: translate(-50%, -50%) rotate(90deg);
}

.meld-zone-right .meld-stack-item .meld-group {
  transform: translate(-50%, -50%) rotate(-90deg);
}

.meld-group {
  display: flex;
  align-items: flex-end;
  gap: 0;
  padding: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

.meld-group img {
  display: block;
  width: var(--open-tile-w);
  height: var(--open-tile-h);
  border-radius: 0;
}

.meld-group img.called {
  margin: 0 var(--sideways-tile-offset);
  transform: translateY(var(--sideways-tile-offset)) rotate(90deg);
}

.meld-group.kakan > img.added-kan {
  margin: 0;
  transform: none;
}

.meld-zone-human {
  position: absolute;
  right: 0;
  bottom: var(--human-hand-row-h);
  flex-direction: column-reverse;
  align-items: flex-end;
  gap: 0;
  max-width: none;
  overflow: visible;
}

.meld-zone-human .meld-group img {
  width: var(--open-tile-w);
  height: var(--open-tile-h);
}

.call-tray {
  position: absolute;
  right: auto;
  bottom: 108px;
  left: 50%;
  z-index: 15;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 7px;
  width: max-content;
  max-width: min(560px, calc(100% - 16px));
  min-height: 50px;
  padding: 6px 8px;
  border: 1px solid rgba(242, 206, 117, 0.42);
  border-radius: 11px;
  background: rgba(3, 28, 22, 0.68);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.3);
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
  transform: translateX(-50%);
}

.call-source {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 7px;
  padding-right: 10px;
  border-right: 1px solid rgba(242, 206, 117, 0.35);
}

.call-source > img {
  width: 34px;
  height: 46px;
  border-radius: 3px;
  box-shadow: var(--call-target-frame);
}

.call-source-copy {
  display: flex;
  flex-direction: column;
  min-width: 72px;
}

.call-source-copy span {
  color: var(--muted);
  font-size: 9px;
  white-space: nowrap;
}

.call-source-copy strong {
  color: #fff6d0;
  font-size: 13px;
  white-space: nowrap;
}

.call-options {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 7px;
}

.call-tray[hidden] {
  display: none;
}

.call-choice {
  display: inline-flex;
  min-width: 88px;
  min-height: 39px;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid rgba(242, 206, 117, 0.45);
  border-radius: 8px;
  padding: 4px 7px;
  background: linear-gradient(#2c7359, #164e3b);
  font-size: 11px;
  font-weight: 850;
}

.call-choice-name {
  flex: 0 0 auto;
  white-space: nowrap;
}

.call-choice-tiles {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: flex-end;
  gap: 0;
}

.call-choice-tile {
  position: relative;
  display: block;
  width: 22px;
  height: 29px;
  flex: 0 0 auto;
}

.call-choice-tile.called {
  width: 29px;
}

.call-choice-tile img {
  position: absolute;
  top: 0;
  left: 50%;
  display: block;
  width: 22px;
  height: 29px;
  border-radius: 2px;
  transform: translateX(-50%);
}

.call-choice-tile.called img {
  top: 3.5px;
  transform: translateX(-50%) rotate(90deg);
}

.call-choice.ankan,
.call-choice.daiminkan,
.call-choice.kakan {
  background: linear-gradient(#a0712e, #704916);
}

.call-choice.pon {
  background: linear-gradient(#8d4a45, #612d2a);
}

.river img.call-target {
  position: relative;
  z-index: 8;
  outline: none;
  box-shadow: var(--call-target-frame);
  filter: none;
}

.center-console {
  --wanpai-right-shift: 0px;
  --wanpai-wide-correction: 0px;
  position: absolute;
  z-index: 8;
  top: calc(36.5% + 14px);
  left: calc(50% + 10px);
  display: block;
  transform: translate(calc(-50% + var(--wanpai-right-shift) - var(--wanpai-wide-correction)), -50%);
}

.center-console.wanpai-eight-columns {
  --wanpai-wide-correction: var(--open-half-tile-w);
}

.center-console.wanpai-kan-pair-1 {
  --wanpai-right-shift: var(--open-tile-w);
}

.center-console.wanpai-kan-pair-2 {
  --wanpai-right-shift: calc(var(--open-tile-w) * 2);
}

.corner-table-status {
  position: absolute;
  z-index: 9;
  top: max(10px, env(safe-area-inset-top));
  left: max(14px, env(safe-area-inset-left));
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.round-status-lines,
.corner-remaining {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 58px;
  padding: 6px 9px;
  border-radius: 9px;
  background: rgba(2, 25, 20, 0.68);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.16);
  backdrop-filter: blur(7px);
}

.round-status-lines {
  min-width: 72px;
  gap: 2px;
}

.round-status-lines strong {
  color: var(--gold);
  font-family: "Hiragino Mincho ProN", serif;
  font-size: 17px;
  line-height: 1;
}

.round-status-lines span {
  color: #e2eee8;
  font-size: 11px;
  font-weight: 750;
  line-height: 1.05;
  white-space: nowrap;
}

.corner-remaining {
  box-sizing: border-box;
  width: 100%;
  min-width: 0;
  padding-right: 7px;
  padding-left: 7px;
}

.wanpai-display {
  --wanpai-tile-w: var(--open-tile-w);
  --wanpai-tile-h: var(--open-tile-h);
  --wanpai-stack-offset: calc(var(--open-tile-h) * 0.2);
  display: grid;
  justify-items: center;
  min-width: 0;
}

.wanpai-display[hidden] {
  display: none;
}

.wanpai-rack {
  display: flex;
  align-items: flex-start;
  gap: 0;
}

.wanpai-stack {
  position: relative;
  flex: 0 0 var(--wanpai-tile-w);
  width: var(--wanpai-tile-w);
  height: calc(var(--wanpai-tile-h) + var(--wanpai-stack-offset));
}

.wanpai-stack img {
  position: absolute;
  left: 0;
  display: block;
  width: var(--wanpai-tile-w);
  height: var(--wanpai-tile-h);
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

.wanpai-bottom {
  z-index: 1;
  top: var(--wanpai-stack-offset);
}

.wanpai-top {
  z-index: 2;
  top: 0;
}

.wanpai-stack.revealed-pair {
  height: calc(var(--wanpai-tile-h) * 2);
}

.wanpai-stack.revealed-pair .wanpai-bottom {
  top: var(--wanpai-tile-h);
}

.table-wanpai {
  min-height: calc(var(--open-tile-h) * 1.2);
}

.table-settings-button {
  position: absolute;
  z-index: 15;
  top: max(8px, env(safe-area-inset-top));
  right: max(14px, env(safe-area-inset-right));
  display: grid;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  color: #ffe39a;
}

.table-settings-button span {
  font-size: 30px;
  line-height: 1;
  opacity: 0.6;
}

.remaining span {
  color: var(--muted);
  font-size: 10px;
}

.remaining strong {
  margin-top: 1px;
  font-size: 21px;
  font-variant-numeric: tabular-nums;
}

.human-area {
  position: absolute;
  z-index: 10;
  right: max(8px, env(safe-area-inset-right));
  bottom: max(5px, env(safe-area-inset-bottom));
  left: max(8px, env(safe-area-inset-left));
  height: 104px;
}

.human-meta {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  height: 28px;
  margin-bottom: 2px;
}

.human-id {
  position: absolute;
  top: 0;
  right: calc(50% + var(--human-river-shift) + var(--open-tile-w) * 3 + 10px);
  z-index: 2;
  display: grid;
  font-size: 11px;
  font-weight: 750;
}

.human-id .score {
  color: var(--gold);
  font-size: 9px;
}

.turn-message {
  margin-left: auto;
  margin-right: calc(var(--action-panel-w) + 8px);
  max-width: 54%;
  overflow: hidden;
  padding: 5px 10px;
  border-radius: 999px;
  background: rgba(2, 28, 22, 0.68);
  color: #e5f5ed;
  font-size: 10px;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.hand-and-actions {
  position: relative;
  display: flex;
  align-items: flex-end;
  gap: 8px;
  height: var(--human-hand-row-h);
}

.hand {
  display: flex;
  flex: 1 1 auto;
  align-items: flex-end;
  justify-content: center;
  gap: 0;
  min-width: 0;
  height: var(--human-hand-row-h);
  padding: 9px calc(var(--action-panel-w) + 14px) 2px 6px;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

/*
 * Keep one invisible draw position in the flex track while the human has the
 * normal post-discard tile count.  Without this slot, justify-content:center
 * recentres the whole hand by half a tile as the fourteenth tile is appended.
 */
.hand.reserves-draw-slot::after {
  content: "";
  display: block;
  flex: 0 1 var(--tile-w);
  width: var(--tile-w);
  min-width: 24px;
  height: var(--tile-h);
  margin: 0;
  visibility: hidden;
  pointer-events: none;
}

.tile-button {
  position: relative;
  flex: 0 1 var(--tile-w);
  width: var(--tile-w);
  min-width: 24px;
  height: var(--tile-h);
  margin: 0;
  border: 0;
  border-radius: 0;
  padding: 0;
  background: transparent;
  box-shadow: none;
  transform: translateY(0);
  transition: transform 100ms ease, filter 100ms ease, box-shadow 100ms ease;
}

.tile-button img {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: inherit;
  object-fit: fill;
  pointer-events: none;
}

.river img,
.meld-group img,
.dora-wrap img,
.tile-button img,
.result-hand img,
.result-bonus-tiles img {
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

.tile-button.drawn {
  margin-left: 0;
}

.tile-button.selected {
  z-index: 3;
  box-shadow: 0 0 0 3px var(--gold);
  transform: translateY(-10px);
}

.tile-button.disabled-choice {
  filter: brightness(0.48) saturate(0.4);
}

.action-panel {
  position: absolute;
  right: 0;
  bottom: 0;
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 5px;
  width: var(--action-panel-w);
}

.action-button {
  flex: 0 1 calc((100% - 5px) / 2);
  min-width: 58px;
  min-height: 32px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  background: rgba(13, 57, 45, 0.95);
  font-size: 12px;
  font-weight: 850;
}

.action-button:disabled {
  opacity: 0.36;
  cursor: default;
  filter: saturate(0.45);
}

.action-button.secondary:disabled {
  opacity: 0.24;
}

.action-button.discard {
  border-color: rgba(242, 206, 117, 0.74);
  background: linear-gradient(#d59c38, #a86e1d);
}

.action-button.riichi {
  border-color: rgba(238, 99, 91, 0.62);
  background: linear-gradient(#a94c48, #75302e);
}

.action-button.win {
  background: linear-gradient(#277e5e, #14533d);
  color: #fff8c7;
}

.half-start-sheet {
  position: fixed;
  z-index: 100;
  inset: 0;
  display: grid;
  place-items: center;
  padding: max(8px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) max(8px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
  overflow: hidden;
  background:
    radial-gradient(circle at 50% 48%, rgba(35, 147, 108, 0.35), transparent 38%),
    radial-gradient(circle at 50% 48%, transparent 0 24%, rgba(242, 206, 117, 0.08) 24.4% 24.8%, transparent 25.2%),
    linear-gradient(145deg, rgba(1, 19, 15, 0.97), rgba(0, 9, 8, 0.99));
  backdrop-filter: blur(10px) saturate(0.86);
}

.half-start-sheet[hidden] {
  display: none;
}

.half-start-dialog {
  position: relative;
  isolation: isolate;
  width: min(1120px, 100%);
  height: min(600px, calc(100dvh - max(16px, env(safe-area-inset-top)) - max(16px, env(safe-area-inset-bottom))));
  max-height: 100%;
  overflow: hidden;
  border: 1px solid rgba(242, 206, 117, 0.56);
  border-radius: 24px;
  background:
    linear-gradient(rgba(255, 255, 255, 0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.025) 1px, transparent 1px),
    radial-gradient(circle at 50% 48%, rgba(37, 132, 99, 0.28), transparent 34%),
    linear-gradient(145deg, rgba(8, 45, 35, 0.99), rgba(2, 21, 17, 0.99));
  background-size: 34px 34px, 34px 34px, auto, auto;
  box-shadow: 0 28px 90px rgba(0, 0, 0, 0.68), inset 0 0 55px rgba(0, 0, 0, 0.28);
  animation: half-start-reveal 420ms cubic-bezier(0.17, 0.84, 0.22, 1) both;
}

.half-start-dialog::before,
.half-start-dialog::after {
  position: absolute;
  z-index: -1;
  content: "";
  pointer-events: none;
}

.half-start-dialog::before {
  inset: 0;
  background:
    linear-gradient(90deg, transparent, rgba(242, 206, 117, 0.88), transparent) top / 100% 2px no-repeat,
    linear-gradient(90deg, transparent, rgba(242, 206, 117, 0.32), transparent) bottom / 100% 1px no-repeat;
}

.half-start-dialog::after {
  top: 50%;
  left: 50%;
  width: min(42vw, 430px);
  aspect-ratio: 1;
  border: 1px solid rgba(242, 206, 117, 0.075);
  transform: translate(-50%, -50%) rotate(45deg);
}

.half-start-header {
  position: absolute;
  z-index: 6;
  top: 18px;
  left: 22px;
  width: min(350px, 34%);
  padding: 0;
  text-align: left;
}

.half-start-header span {
  display: block;
  color: rgba(242, 206, 117, 0.78);
  font-family: Georgia, serif;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.28em;
}

.half-start-header h1 {
  margin: 4px 0 0;
  color: #fff3c3;
  font-family: Georgia, "Yu Mincho", serif;
  font-size: clamp(32px, 3.4vw, 46px);
  font-weight: 800;
  line-height: 1;
  letter-spacing: 0.12em;
  text-shadow: 0 0 24px rgba(242, 206, 117, 0.25);
}

.half-start-header p {
  margin: 7px 0 0;
  color: #a8cbbd;
  font-size: 12px;
  line-height: 1.45;
  font-weight: 700;
  letter-spacing: 0.14em;
}

.half-start-arena {
  position: absolute;
  inset: 0;
  margin: 0;
}

.half-start-seat {
  --seat-accent: #f2ce75;
  appearance: none;
  position: absolute;
  z-index: 3;
  display: block;
  width: clamp(156px, 43dvh, 210px);
  height: auto;
  aspect-ratio: 1;
  overflow: hidden;
  padding: 0;
  border: 1px solid color-mix(in srgb, var(--seat-accent) 62%, transparent);
  border-radius: 18px;
  background: #071b16;
  color: inherit;
  cursor: pointer;
  font: inherit;
  text-align: left;
  box-shadow: 0 16px 38px rgba(0, 0, 0, 0.52), 0 0 32px color-mix(in srgb, var(--seat-accent) 12%, transparent), inset 0 0 0 1px rgba(255, 255, 255, 0.035);
  transition: border-color 150ms ease, box-shadow 150ms ease, filter 150ms ease;
  animation: half-start-seat-in 480ms cubic-bezier(0.17, 0.84, 0.22, 1) both;
}

.half-start-seat:active {
  filter: brightness(1.12);
}

.half-start-seat:focus-visible {
  border-color: color-mix(in srgb, var(--seat-accent) 90%, white 10%);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--seat-accent) 28%, transparent), 0 16px 38px rgba(0, 0, 0, 0.52);
  outline: none;
}

.half-start-seat[data-tone="human"] { --seat-accent: #f2ce75; }
.half-start-seat[data-tone="balance"] { --seat-accent: #d9a3ff; }
.half-start-seat[data-tone="speed"] { --seat-accent: #ff786f; }
.half-start-seat[data-tone="strategy"] { --seat-accent: #75baff; }

.half-start-seat-top {
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
}

.half-start-seat-bottom {
  bottom: 10px;
  left: 50%;
  transform: translateX(-50%);
}

.half-start-seat-left {
  top: 50%;
  left: 14px;
  transform: translateY(-50%);
}

.half-start-seat-right {
  top: 50%;
  right: 14px;
  transform: translateY(-50%);
}

.half-start-portrait {
  position: absolute;
  inset: 0;
  overflow: hidden;
  background: #071b16;
}

.half-start-portrait::after {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(180deg, rgba(1, 13, 11, 0.02) 32%, rgba(2, 17, 14, 0.36) 58%, rgba(2, 14, 12, 0.96) 100%),
    linear-gradient(90deg, rgba(3, 20, 17, 0.08), transparent 58%);
  content: "";
  pointer-events: none;
}

.half-start-portrait img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 16%;
  filter: saturate(0.96) contrast(1.06) brightness(0.97);
  transform: scale(1.02);
}

.half-start-portrait strong {
  position: absolute;
  z-index: 2;
  top: 10px;
  left: 10px;
  display: grid;
  width: 40px;
  height: 40px;
  place-items: center;
  border: 1px solid color-mix(in srgb, var(--seat-accent) 82%, white 18%);
  border-radius: 50%;
  background: rgba(2, 20, 17, 0.84);
  color: #fff8d8;
  font-family: "Yu Mincho", serif;
  font-size: 25px;
  line-height: 1;
  box-shadow: 0 3px 12px rgba(0, 0, 0, 0.48);
}

.half-start-copy {
  position: absolute;
  z-index: 2;
  right: 0;
  bottom: 0;
  left: 0;
  display: grid;
  min-width: 0;
  grid-template-columns: auto minmax(0, 1fr);
  padding: 28px 13px 11px;
  column-gap: 9px;
  align-items: end;
  background: linear-gradient(180deg, transparent, rgba(1, 15, 12, 0.2));
  border-bottom: 3px solid color-mix(in srgb, var(--seat-accent) 72%, transparent);
  text-shadow: 0 2px 7px rgba(0, 0, 0, 0.92);
}

.half-start-copy span {
  grid-row: 1 / span 2;
  align-self: center;
  color: var(--seat-accent);
  font-size: 11px;
  font-weight: 850;
  letter-spacing: 0.18em;
}

.half-start-copy b {
  overflow: hidden;
  margin: 0;
  color: #fffbea;
  font-size: clamp(19px, 2.1vw, 27px);
  line-height: 1.05;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.half-start-copy small {
  display: -webkit-box;
  overflow: hidden;
  margin-top: 2px;
  color: #d7e5df;
  font-size: 10px;
  font-weight: 700;
  line-height: 1.25;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 1;
}

.half-start-core {
  appearance: none;
  position: absolute;
  z-index: 6;
  top: 18px;
  right: 22px;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  grid-template-rows: auto auto;
  width: min(300px, 32%);
  min-height: 68px;
  align-items: center;
  padding: 9px 16px;
  column-gap: 12px;
  border: 1px solid rgba(242, 206, 117, 0.64);
  border-radius: 14px;
  background:
    linear-gradient(115deg, rgba(30, 110, 83, 0.94), rgba(3, 25, 20, 0.98) 72%);
  box-shadow: 0 0 0 5px rgba(242, 206, 117, 0.045), 0 0 30px rgba(32, 159, 112, 0.2);
  color: inherit;
  cursor: pointer;
  font: inherit;
  text-align: left;
}

.half-start-core:active {
  filter: brightness(1.1);
  transform: translateY(1px);
}

.half-start-core:focus-visible {
  border-color: rgba(255, 238, 216, 0.92);
  box-shadow: 0 0 0 3px rgba(242, 206, 117, 0.22), 0 0 30px rgba(32, 159, 112, 0.2);
  outline: none;
}

.half-start-core span {
  grid-column: 1 / -1;
  grid-row: 1;
  color: #91c9b4;
  font-family: Georgia, serif;
  font-size: 8px;
  font-weight: 800;
  letter-spacing: 0.22em;
}

.half-start-core strong {
  grid-column: 1;
  grid-row: 2;
  margin: 1px 0 0;
  color: #fff0ae;
  font-family: "Yu Mincho", serif;
  font-size: clamp(20px, 2.6vw, 28px);
  line-height: 1;
}

.half-start-core small {
  grid-column: 2;
  grid-row: 2;
  max-width: 100%;
  margin: 1px 0 0;
  padding-left: 12px;
  overflow: hidden;
  border-left: 1px solid rgba(242, 206, 117, 0.28);
  color: #edf6ee;
  font-size: 10px;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.half-start-button {
  position: absolute;
  z-index: 7;
  right: 18px;
  bottom: 16px;
  display: grid;
  width: min(286px, 29%);
  min-width: 230px;
  min-height: 58px;
  margin: 0;
  padding: 5px 22px 6px;
  place-items: center;
  border: 1px solid rgba(255, 226, 142, 0.86);
  border-radius: 15px;
  background: linear-gradient(135deg, #47a47d, #176047 58%, #0d3c2f);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.5), 0 0 28px rgba(58, 170, 124, 0.15), inset 0 1px rgba(255, 255, 255, 0.2);
  color: #fff9df;
  cursor: pointer;
}

.half-start-button::after {
  position: absolute;
  right: 18px;
  color: var(--gold);
  font-size: 20px;
  content: "›";
}

.half-start-button span {
  color: #a9d8c5;
  font-family: Georgia, serif;
  font-size: 8px;
  font-weight: 800;
  letter-spacing: 0.24em;
}

.half-start-button strong {
  font-size: 19px;
  line-height: 1.05;
  letter-spacing: 0.14em;
}

.half-start-button:active {
  transform: translateY(1px);
  filter: brightness(1.08);
}

@keyframes half-start-reveal {
  from { opacity: 0; transform: scale(0.975); }
  to { opacity: 1; transform: scale(1); }
}

@keyframes half-start-seat-in {
  from { opacity: 0; filter: brightness(1.35); }
  to { opacity: 1; filter: brightness(1); }
}

.profile-sheet {
  position: fixed;
  z-index: 105;
  inset: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  place-items: center;
  padding: max(10px, env(safe-area-inset-top)) max(14px, env(safe-area-inset-right)) max(10px, env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left));
  background:
    radial-gradient(circle at 28% 50%, rgba(28, 115, 84, 0.25), transparent 42%),
    rgba(0, 10, 8, 0.86);
  backdrop-filter: blur(15px) saturate(0.86);
}

.profile-sheet[hidden] {
  display: none;
}

.profile-dialog {
  --profile-accent: #f2ce75;
  position: relative;
  isolation: isolate;
  display: grid;
  grid-template-columns: minmax(250px, 43%) minmax(0, 57%);
  width: 100%;
  max-width: 980px;
  min-width: 0;
  height: min(86dvh, 540px);
  max-height: 540px;
  overflow: hidden;
  border: 1px solid color-mix(in srgb, var(--profile-accent) 52%, transparent);
  border-radius: 22px;
  background: linear-gradient(145deg, rgba(12, 46, 37, 0.99), rgba(3, 20, 17, 0.99));
  box-shadow: 0 28px 80px rgba(0, 0, 0, 0.62), 0 0 45px color-mix(in srgb, var(--profile-accent) 10%, transparent);
  animation: profile-reveal 260ms cubic-bezier(0.2, 0.85, 0.24, 1) both;
}

.profile-dialog::before {
  position: absolute;
  z-index: 2;
  top: 0;
  right: 0;
  left: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--profile-accent), transparent);
  content: "";
}

.profile-dialog[data-tone="human"] { --profile-accent: #f2ce75; }
.profile-dialog[data-tone="balance"] { --profile-accent: #d9a3ff; }
.profile-dialog[data-tone="speed"] { --profile-accent: #ff786f; }
.profile-dialog[data-tone="strategy"] { --profile-accent: #75baff; }

@keyframes profile-reveal {
  from { opacity: 0; transform: translateY(12px) scale(0.975); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.profile-close {
  position: absolute;
  z-index: 5;
  top: 12px;
  right: 12px;
  display: grid;
  width: 38px;
  height: 38px;
  padding: 0;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 50%;
  background: rgba(1, 13, 11, 0.72);
  color: #fff8df;
  font-size: 24px;
  font-weight: 300;
  line-height: 1;
  cursor: pointer;
  backdrop-filter: blur(8px);
}

.profile-portrait {
  position: relative;
  min-width: 0;
  overflow: hidden;
  background: #08271f;
}

.profile-portrait::after {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(90deg, transparent 68%, rgba(3, 20, 17, 0.78)),
    linear-gradient(0deg, rgba(2, 16, 13, 0.92), transparent 42%);
  content: "";
  pointer-events: none;
}

.profile-portrait > img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 22%;
  filter: saturate(0.92) contrast(1.04);
}

.profile-number {
  position: absolute;
  z-index: 2;
  top: 12px;
  left: 15px;
  color: rgba(255, 255, 255, 0.18);
  font-family: Georgia, serif;
  font-size: clamp(42px, 6vw, 78px);
  font-weight: 800;
  line-height: 1;
}

.profile-portrait-caption {
  position: absolute;
  z-index: 2;
  right: 22px;
  bottom: 138px;
  left: 22px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.profile-image-picker {
  position: absolute;
  z-index: 3;
  right: 16px;
  bottom: 58px;
  left: 16px;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
}

.profile-image-option {
  position: relative;
  min-width: 0;
  height: 68px;
  overflow: hidden;
  padding: 0;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-radius: 9px;
  background: #061d18;
  box-shadow: 0 3px 12px rgba(0, 0, 0, 0.46);
  opacity: 0.78;
  cursor: pointer;
}

.profile-image-option img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 20%;
}

.profile-image-option span {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  padding: 2px 0 3px;
  background: rgba(0, 12, 10, 0.78);
  color: #fffbe8;
  font-size: 12px;
  font-weight: 900;
  line-height: 1;
  text-align: center;
  letter-spacing: 0.08em;
}

.profile-image-option.selected {
  border-color: var(--profile-accent);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--profile-accent) 28%, transparent), 0 4px 15px rgba(0, 0, 0, 0.52);
  opacity: 1;
}

.profile-image-option:focus-visible {
  outline: 3px solid #fff7cd;
  outline-offset: 2px;
}

.profile-portrait-caption span {
  color: var(--profile-accent);
  font-size: 9px;
  font-weight: 900;
  letter-spacing: 0.2em;
}

.profile-portrait-caption strong {
  font-size: clamp(20px, 3vw, 34px);
  letter-spacing: 0.04em;
  text-shadow: 0 3px 16px rgba(0, 0, 0, 0.7);
}

.profile-copy {
  position: relative;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  overflow-x: hidden;
  overflow-y: auto;
  padding: clamp(24px, 4vw, 46px) clamp(26px, 4.2vw, 52px) 24px;
  background:
    linear-gradient(135deg, color-mix(in srgb, var(--profile-accent) 7%, transparent), transparent 42%),
    repeating-linear-gradient(135deg, rgba(255, 255, 255, 0.018) 0, rgba(255, 255, 255, 0.018) 1px, transparent 1px, transparent 13px);
}
.profile-dialog .profile-overline,
.profile-dialog .profile-traits,
.profile-dialog .profile-intro,
.profile-dialog .profile-specs {
  display: none;
}

.profile-dialog .profile-copy blockquote {
  margin: 14px 0 0;
}

.profile-overline {
  margin-bottom: 8px;
  color: var(--profile-accent);
  font-size: 9px;
  font-weight: 900;
  letter-spacing: 0.25em;
}

.profile-copy h1 {
  margin: 0;
  font-size: clamp(27px, 4vw, 44px);
  line-height: 1;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.profile-copy h2 {
  margin: 7px 0 10px;
  color: var(--profile-accent);
  font-family: "Hiragino Mincho ProN", "Yu Mincho", serif;
  font-size: clamp(15px, 2.1vw, 22px);
  font-weight: 750;
  letter-spacing: 0.04em;
}

.profile-traits {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-bottom: 12px;
}

.profile-traits span {
  border: 1px solid color-mix(in srgb, var(--profile-accent) 46%, transparent);
  border-radius: 999px;
  padding: 3px 8px;
  background: color-mix(in srgb, var(--profile-accent) 9%, transparent);
  color: #edf8f3;
  font-size: 9px;
  font-weight: 800;
}

.profile-intro {
  margin: 0;
  color: #dceae4;
  font-size: clamp(11px, 1.4vw, 14px);
  font-weight: 560;
  line-height: 1.75;
}

.profile-copy blockquote {
  margin: 14px 0;
  border-left: 2px solid var(--profile-accent);
  padding: 3px 0 3px 12px;
  color: #fff4c9;
  font-family: "Hiragino Mincho ProN", "Yu Mincho", serif;
  font-size: clamp(11px, 1.5vw, 14px);
  font-weight: 750;
}

.profile-specs {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
  margin-top: auto;
}

.profile-specs > div {
  min-width: 0;
  border-top: 1px solid rgba(255, 255, 255, 0.14);
  padding-top: 8px;
}

.profile-specs span,
.profile-specs strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.profile-specs span {
  margin-bottom: 3px;
  color: #819b90;
  font-size: 7px;
  font-weight: 850;
  letter-spacing: 0.1em;
}

.profile-specs strong {
  color: var(--profile-accent);
  font-size: clamp(8px, 1.1vw, 11px);
}

.profile-voice-picker-wrap {
  position: absolute;
  z-index: 3;
  right: 16px;
  bottom: 14px;
  left: 16px;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 7px;
}

.profile-voice-picker-wrap > span {
  color: #fff4c4;
  font-size: 9px;
  font-weight: 900;
  letter-spacing: 0.06em;
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.9);
  white-space: nowrap;
}

.profile-voice-picker {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 5px;
}

.profile-voice-option {
  display: grid;
  place-items: center;
  min-height: 34px;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 9px;
  background: rgba(0, 16, 12, 0.52);
  color: #d7e9e1;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.08em;
  line-height: 1;
  text-align: center;
  cursor: pointer;
}

.profile-voice-option.selected {
  border-color: var(--profile-accent);
  background: color-mix(in srgb, var(--profile-accent) 20%, rgba(0, 16, 12, 0.78));
  color: #fff6cf;
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--profile-accent) 20%, transparent);
}

.profile-voice-option:focus-visible {
  outline: 3px solid #fff7cd;
  outline-offset: 2px;
}


.character-swap-card {
  touch-action: none;
  overscroll-behavior: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-user-drag: none;
  -webkit-touch-callout: none;
}

.character-swap-card img {
  pointer-events: none;
  -webkit-user-drag: none;
}


.character-swap-card.character-swap-available {
  border-style: dashed;
  border-color: rgba(121, 239, 188, 0.86);
  box-shadow: 0 0 0 3px rgba(75, 226, 159, 0.16), 0 14px 38px rgba(0, 0, 0, 0.56);
}

.character-swap-card.character-swap-source {
  opacity: 0.36;
  filter: saturate(0.55) brightness(0.86);
}

.character-swap-card.character-swap-target {
  translate: 0 -12px;
  scale: 0.96;
  border-style: solid;
  border-color: #fff3ad;
  box-shadow: 0 0 0 5px rgba(255, 229, 117, 0.24), 0 22px 44px rgba(0, 0, 0, 0.68);
  filter: brightness(1.16);
}


.character-swap-ghost {
  position: fixed;
  z-index: 120;
  width: 92px;
  height: 92px;
  overflow: hidden;
  border: 3px solid #fff0a9;
  border-radius: 18px;
  background: #052219;
  box-shadow: 0 18px 42px rgba(0, 0, 0, 0.68);
  translate: -50% -58%;
  rotate: -3deg;
  pointer-events: none;
}

.character-swap-ghost[hidden] {
  display: none;
}

.character-swap-ghost img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}


@media (prefers-reduced-motion: reduce) {
  .character-swap-card.character-swap-target {
    translate: 0 -6px;
  }
}

.result-sheet {
  position: fixed;
  z-index: 50;
  inset: 0;
  display: grid;
  place-items: center;
  padding: max(12px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(12px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  background: rgba(0, 11, 8, 0.78);
  backdrop-filter: blur(12px);
}

.result-sheet[hidden] {
  display: none;
}

.table-character-layer {
  position: absolute;
  z-index: 14;
  inset: 0;
  background: rgba(0, 11, 8, 0.72);
  backdrop-filter: blur(10px);
  overscroll-behavior: none;
}

.table-character-layer[hidden] {
  display: none;
}

.table-character-layer .result-character-popup {
  z-index: 1;
}

.result-character-popup {
  position: absolute;
  z-index: 9;
  isolation: isolate;
  display: block;
  width: min(46vw, calc(var(--app-visible-height) * 0.42), 340px);
  aspect-ratio: 1;
  overflow: hidden;
  padding: 0;
  border: 2px solid rgba(242, 206, 117, 0.86);
  border-radius: 20px;
  background: rgba(3, 28, 22, 0.94);
  box-shadow: 0 16px 42px rgba(0, 0, 0, 0.62), 0 0 0 3px rgba(242, 206, 117, 0.12);
  cursor: pointer;
  transition: opacity 160ms ease, transform 160ms ease, visibility 160ms ease;
}

.result-character-popup[hidden] {
  display: none;
}

.result-character-popup img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 20%;
}

.result-character-standing {
  position: absolute;
  z-index: 2;
  right: 0;
  bottom: 0;
  left: 0;
  display: flex;
  height: 33.333%;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  padding: 5px 7px 6px;
  background: linear-gradient(180deg, rgba(1, 13, 11, 0.22), rgba(1, 13, 11, 0.94) 34%);
  color: #fff9e5;
  line-height: 1.12;
  text-align: center;
  text-shadow: 0 2px 5px rgba(0, 0, 0, 0.9);
  pointer-events: none;
}

.result-character-standing strong,
.result-character-standing span {
  display: block;
  white-space: nowrap;
}

.result-character-standing strong {
  color: #f7d77f;
  font-size: clamp(13px, 2vw, 20px);
  font-weight: 950;
}

.result-character-standing span {
  font-size: clamp(11px, 1.7vw, 17px);
  font-weight: 900;
}

.result-character-popup-top {
  top: max(4px, env(safe-area-inset-top));
  left: 50%;
  transform: translateX(-50%);
}

.result-character-popup-bottom {
  bottom: max(4px, env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
}

.result-character-popup-left {
  top: 50%;
  left: max(4px, env(safe-area-inset-left));
  transform: translateY(-50%);
}

.result-character-popup-right {
  top: 50%;
  right: max(4px, env(safe-area-inset-right));
  transform: translateY(-50%);
}

@media (orientation: landscape) {
  .result-character-popup {
    width: min(46vw, calc((var(--app-visible-height) - 16px) * 0.46), 360px);
  }

  .table-character-layer .result-character-popup {
    width: auto;
    height: min(calc(50% - max(16px, env(safe-area-inset-top), env(safe-area-inset-bottom))), 360px);
  }

  .result-character-standing {
    padding-right: 4px;
    padding-left: 4px;
  }

  .result-character-standing strong {
    max-width: 100%;
    font-size: clamp(12px, 1.55vw, 18px);
  }

  .result-character-standing span {
    width: 100%;
    max-width: 100%;
    overflow: hidden;
    font-size: clamp(9px, 1.15vw, 14px);
    letter-spacing: -0.035em;
    text-overflow: clip;
  }
}

.result-sheet.character-popups-hidden .result-character-popup:not([hidden]) {
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
}

.result-seat-delta {
  position: absolute;
  z-index: 3;
  min-width: 96px;
  max-width: 104px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 8px;
  padding: 5px 6px;
  background: rgba(3, 28, 22, 0.94);
  box-shadow: 0 5px 14px rgba(0, 0, 0, 0.38);
  font-size: 9px;
  font-weight: 900;
  line-height: 1.2;
  text-align: center;
  white-space: nowrap;
}

.result-seat-delta.positive {
  border-color: rgba(145, 229, 156, 0.7);
  color: #bff7c5;
}

.result-seat-delta.negative {
  border-color: rgba(246, 126, 119, 0.72);
  color: #ffb8b3;
}

.result-seat-delta.zero {
  color: var(--muted);
}

.result-seat-delta-top {
  top: max(6px, env(safe-area-inset-top));
  left: 50%;
  transform: translateX(-50%);
}

.result-seat-delta-bottom {
  bottom: max(6px, env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
}

.result-seat-delta-left {
  top: 50%;
  left: max(6px, env(safe-area-inset-left));
  transform: translateY(-50%);
}

.result-seat-delta-right {
  top: 50%;
  right: max(6px, env(safe-area-inset-right));
  transform: translateY(-50%);
}

.result-center-stack {
  display: contents;
}

.result-card {
  position: relative;
  z-index: 1;
  width: min(680px, calc(100vw - 220px - env(safe-area-inset-left) - env(safe-area-inset-right)));
  max-height: calc(100dvh - 84px);
  overflow: auto;
  border: 1px solid rgba(242, 206, 117, 0.48);
  border-radius: 20px;
  padding: 20px 26px;
  background: linear-gradient(145deg, #123d31, #071d18);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.5);
  text-align: center;
}

.result-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
  gap: 12px;
  min-height: 0;
}

.result-heading {
  align-self: center;
  min-width: 0;
}

.result-eyebrow {
  display: block;
  color: var(--muted);
  font-size: clamp(15px, 1.4vw, 17px);
  font-weight: 900;
  line-height: 1.3;
  letter-spacing: 0.08em;
}

.result-card h1 {
  margin: 1px 0 8px;
  color: var(--gold);
  font-family: "Hiragino Mincho ProN", serif;
  font-size: 30px;
  line-height: 1.15;
}

.result-wanpai {
  justify-self: end;
  min-height: calc(var(--open-tile-h) * 1.2);
  margin: 0;
}

.result-wanpai.has-ura {
  min-height: calc(var(--open-tile-h) * 2);
}

.result-hand {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  min-height: 47px;
}

.result-hand[hidden] {
  display: none;
}

.result-hand img {
  width: 28px;
  height: 38px;
  border-radius: 0;
}

.result-tenpai-hands {
  display: grid;
  gap: 2px;
  margin: 3px auto 2px;
}

.result-tenpai-hands[hidden] {
  display: none;
}

.result-tenpai-heading {
  color: #fff1bc;
  font-size: 9px;
}

.result-tenpai-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-height: 26px;
}

.result-tenpai-name {
  flex: 0 0 42px;
  color: #dcebe4;
  font-size: 8px;
  text-align: right;
  white-space: nowrap;
}

.result-tenpai-tiles {
  --open-tile-w: 18px;
  --open-tile-h: 24px;
  --sideways-tile-offset: 3px;
  --sideways-tile-shift: 6px;
  display: flex;
  align-items: flex-end;
  justify-content: flex-start;
  gap: 0;
  min-width: 252px;
}

.result-tenpai-tiles > img,
.result-tenpai-tiles .meld-group img {
  display: block;
  width: var(--open-tile-w);
  height: var(--open-tile-h);
  border: 0;
  border-radius: 0;
  box-shadow: none;
}

.result-winning-tile {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  margin-left: 0;
  padding: 0;
  border: 2px solid var(--gold);
  border-radius: 6px;
  background: rgba(242, 206, 117, 0.12);
  box-shadow: 0 0 12px rgba(242, 206, 117, 0.28);
}

.result-winning-tile img {
  display: block;
}

.result-yaku {
  margin: 9px 0 4px;
  color: #e3eee8;
  font-size: clamp(15px, 1.45vw, 17px);
  font-weight: 800;
  line-height: 1.4;
  white-space: pre-line;
}

.result-penalties {
  width: fit-content;
  max-width: 92%;
  margin: 5px auto 4px;
  padding: 5px 10px;
  border: 1px solid rgba(255, 139, 122, 0.72);
  border-radius: 7px;
  background: rgba(92, 18, 15, 0.72);
  color: #ffe1d8;
  font-size: 11px;
  font-weight: 900;
  line-height: 1.35;
  white-space: pre-line;
}

.result-penalties[hidden] {
  display: none;
}

.result-bonus {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 4px;
  margin: 5px auto 4px;
}

.result-bonus[hidden],
.result-kan[hidden] {
  display: none;
}

.result-bonus-row,
.result-red-dora {
  display: flex;
  align-items: center;
  gap: 4px;
  min-height: 29px;
  border: 1px solid rgba(242, 206, 117, 0.28);
  border-radius: 6px;
  padding: 2px 5px;
  background: rgba(2, 24, 19, 0.58);
}

.result-bonus-row strong,
.result-red-dora {
  color: #fff1bc;
  font-size: 9px;
  font-weight: 850;
  white-space: nowrap;
}

.result-bonus-tiles {
  display: flex;
  align-items: center;
  gap: 0;
}

.result-bonus-tiles img {
  display: block;
  width: 18px;
  height: 24px;
  border-radius: 0;
}

.result-kan {
  margin: 2px 0 4px;
  color: #cfe9dd;
  font-size: 9px;
  font-weight: 750;
}

.result-score {
  color: var(--gold);
  font-size: 20px;
  font-weight: 900;
  line-height: 1.3;
  overflow-wrap: anywhere;
}

.result-ranking-status {
  margin: 2px 0 0;
  color: #cfe9dd;
  font-size: 9px;
  font-weight: 750;
  line-height: 1.35;
}

.result-ranking-status[data-tone="warning"] {
  color: #f0d28d;
}

.result-ranking-status[data-tone="success"] {
  color: #8fe0b4;
}

.point-chart {
  position: relative;
  width: 100%;
  margin: 5px auto 0;
  overflow: hidden;
  border: 1px solid rgba(242, 206, 117, 0.24);
  border-radius: 8px;
  background: rgba(1, 18, 14, 0.72);
}

.point-chart-title {
  position: absolute;
  z-index: 1;
  top: 2px;
  left: 5px;
  color: #e8d18b;
  font-size: 7px;
  font-weight: 900;
  letter-spacing: 0.08em;
  pointer-events: none;
}

.point-chart svg {
  display: block;
  width: 100%;
  height: auto;
}

.point-chart-grid {
  stroke: rgba(212, 232, 222, 0.13);
  stroke-width: 0.65;
}

.point-chart-major-grid {
  stroke: rgba(242, 206, 117, 0.15);
}

.point-chart-renchan-grid {
  stroke: rgba(242, 206, 117, 0.38);
  stroke-width: 0.7;
  stroke-dasharray: 2 2;
}

.point-chart-line {
  stroke-width: 1.8;
  stroke-linejoin: round;
  stroke-linecap: round;
}

.point-chart-point {
  stroke: rgba(4, 20, 16, 0.9);
  stroke-width: 0.75;
}

.point-chart-y-label,
.point-chart-x-label,
.point-chart-renchan-label,
.point-chart-legend {
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", sans-serif;
}

.point-chart-y-label {
  fill: #b9cfc5;
  font-size: 6px;
}

.point-chart-x-label {
  fill: #c9dacf;
  font-size: 5.7px;
  font-weight: 750;
}

.point-chart-renchan-label {
  fill: #f2ce75;
  font-size: 5.2px;
  font-weight: 800;
}

.point-chart-legend {
  font-size: 6.2px;
  font-weight: 850;
}

.point-chart-legend-line {
  stroke-width: 2.2;
  stroke-linecap: round;
}

.result-actions {
  display: flex;
  align-items: stretch;
  justify-content: center;
  gap: 10px;
  margin-top: 12px;
}

.result-stats-button,
.result-exit-button,
.result-table-view-button,
.next-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 1 180px;
  min-width: 0;
  min-height: 38px;
  border: 1px solid rgba(242, 206, 117, 0.6);
  border-radius: 10px;
  background: linear-gradient(#2b8061, #16513d);
  color: var(--ink);
  font-weight: 850;
  line-height: 1;
  text-decoration: none;
}

.result-stats-button {
  background: linear-gradient(#715b28, #403216);
}

.result-table-view-button {
  background: linear-gradient(#715b28, #403216);
}

.result-exit-button {
  background: linear-gradient(#91473f, #572722);
}

.result-stats-button[hidden],
.result-exit-button[hidden],
.result-table-view-button[hidden] {
  display: none;
}

.rotate-notice {
  position: fixed;
  z-index: 100;
  inset: 0;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 9px;
  padding: 24px;
  background: #071d18;
  text-align: center;
}

.rotate-notice span {
  color: var(--muted);
  font-size: 12px;
}

.phone-icon {
  display: grid;
  width: 58px;
  height: 88px;
  place-items: center;
  border: 3px solid var(--gold);
  border-radius: 11px;
  color: var(--gold);
  font-size: 27px;
  transform: rotate(90deg);
}

@media (orientation: portrait) and (max-width: 700px) {
  .rotate-notice {
    display: none;
  }

  .half-start-sheet {
    z-index: 101;
    padding: max(8px, env(safe-area-inset-top)) max(8px, env(safe-area-inset-right)) max(8px, env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left));
  }

  .half-start-dialog {
    width: 100%;
    height: 100%;
    max-height: none;
    border-radius: 20px;
  }

  .half-start-header {
    top: 14px;
    left: 16px;
    width: auto;
  }

  .half-start-header h1 {
    margin: 0;
    font-size: clamp(27px, 8vw, 38px);
    line-height: 1;
    white-space: nowrap;
  }

  .half-start-core {
    top: 9px;
    right: 12px;
    width: 148px;
    min-height: 42px;
    padding: 5px 9px;
    column-gap: 6px;
    border-radius: 10px;
  }

  .half-start-core span {
    display: none;
  }

  .half-start-core strong {
    font-size: 16px;
  }

  .half-start-core small {
    padding-left: 6px;
    font-size: 8px;
  }
  .half-start-arena {
    inset: 58px 10px 80px;
  }

  .half-start-seat {
    width: min(43vw, 25dvh, 210px);
    height: auto;
    aspect-ratio: 1;
    border-radius: 14px;
  }

  .half-start-seat-top {
    top: 0;
    left: 50%;
    transform: translateX(-50%);
  }

  .half-start-seat-bottom {
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
  }

  .half-start-seat-left {
    top: 50%;
    left: 0;
    transform: translateY(-50%);
  }

  .half-start-seat-right {
    top: 50%;
    right: 0;
    transform: translateY(-50%);
  }

  .half-start-portrait strong {
    top: 7px;
    left: 7px;
    width: 34px;
    height: 34px;
    font-size: 21px;
  }

  .half-start-copy {
    padding: 22px 9px 8px;
    column-gap: 6px;
  }

  .half-start-copy span {
    font-size: 9px;
  }

  .half-start-copy b {
    font-size: clamp(16px, 5vw, 21px);
  }

  .half-start-copy small {
    font-size: 8px;
  }

  .half-start-button {
    right: 12px;
    bottom: 10px;
    width: min(250px, 64vw);
    min-width: 0;
    min-height: 56px;
  }
}

@media (orientation: landscape) and (max-width: 700px) {
  .result-card {
    padding: 10px 14px;
    border-radius: 14px;
  }

  .result-hand img {
    width: 25px;
    height: 34px;
  }

  .result-seat-delta {
    padding: 4px;
    font-size: 8px;
  }
}

@media (orientation: landscape) and (max-height: 500px) {
  .result-card {
    max-height: calc(100dvh - 72px);
    padding: 5px 12px 6px;
    border-radius: 14px;
  }

  .result-eyebrow {
    font-size: 13px;
    line-height: 1.2;
  }

  .result-card h1 {
    margin: 0 0 2px;
    font-size: 24px;
    line-height: 1.05;
  }

  .result-header {
    gap: 8px;
  }

  .result-wanpai {
    min-height: calc(var(--open-tile-h) * 1.2);
    margin: 0;
  }

  .result-wanpai.has-ura {
    min-height: calc(var(--open-tile-h) * 2);
  }

  .result-hand {
    min-height: 33px;
  }

  .result-hand img {
    width: 23px;
    height: 31px;
  }

  .result-tenpai-hands {
    gap: 1px;
    margin: 1px auto;
  }

  .result-tenpai-row {
    min-height: 23px;
  }

  .result-tenpai-tiles {
    --open-tile-w: 16px;
    --open-tile-h: 22px;
    --sideways-tile-offset: 3px;
    --sideways-tile-shift: 6px;
    min-width: 224px;
  }

  .result-yaku {
    margin: 2px 0 1px;
    font-size: 14px;
    font-weight: 800;
    line-height: 1.3;
  }

  .result-bonus {
    margin: 2px auto;
  }

  .result-bonus-row,
  .result-red-dora {
    min-height: 22px;
    padding: 1px 4px;
  }

  .result-bonus-tiles img {
    width: 14px;
    height: 19px;
  }

  .result-kan {
    margin: 1px 0;
    font-size: 7px;
  }

  .result-score {
    font-size: 18px;
    line-height: 1.2;
  }

  .point-chart {
    margin-top: 3px;
  }

  .point-chart svg {
    height: 98px;
  }

  .result-actions {
    gap: 6px;
    margin-top: 3px;
  }

  .result-stats-button,
  .result-exit-button,
  .result-table-view-button,
  .next-button {
    min-height: 28px;
    flex-basis: 150px;
  }
}

/* CPU通信は弱い代替判断へ切り替えず、同じ局面を保持して再接続する。 */
.network-status-layer {
  position: fixed;
  z-index: 138;
  inset: 0;
  width: 100vw;
  height: var(--app-visible-height, 100dvh);
  overflow: hidden;
  pointer-events: none;
}

.network-status-layer[hidden],
.network-status-panel[hidden],
.network-ranking-notice[hidden] {
  display: none;
}

.network-status-layer[data-network-state="stopped"],
.network-status-layer[data-network-state="fatal"] {
  background: rgba(0, 12, 9, 0.66);
  backdrop-filter: blur(5px) saturate(0.82);
  pointer-events: auto;
  touch-action: none;
}

.network-status-panel {
  position: absolute;
  z-index: 3;
  left: 50%;
  bottom: max(98px, calc(env(safe-area-inset-bottom) + 94px));
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  width: min(520px, calc(100vw - env(safe-area-inset-left) - env(safe-area-inset-right) - 22px));
  padding: 12px 13px;
  transform: translateX(-50%);
  border: 1px solid #d0a64f;
  border-radius: 14px;
  background: rgba(5, 34, 26, 0.97);
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.42);
  color: #f4ecd5;
  pointer-events: none;
}

.network-status-panel h2 {
  margin: 0;
  color: #f2d47d;
  font-size: 16px;
  line-height: 1.25;
}

.network-status-panel p {
  margin: 3px 0 0;
  font-size: 13px;
  line-height: 1.4;
}

.network-status-panel small {
  display: block;
  margin-top: 3px;
  color: #abc1b7;
  font-size: 10px;
  line-height: 1.4;
}

#networkRankingResumeStatus {
  grid-column: 1 / -1;
  margin: 3px 0 0;
  color: #ffdca1;
  font-size: 11px;
  text-align: center;
}

#networkRankingResumeWidget {
  grid-column: 1 / -1;
  justify-self: center;
  max-width: 100%;
}

.network-status-icon {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: 50%;
  background: rgba(210, 167, 79, 0.14);
  color: #f2d47d;
  font-size: 21px;
  font-weight: 850;
}

.network-stopped-panel,
.network-fatal-panel {
  top: 50%;
  bottom: auto;
  transform: translate(-50%, -50%);
  pointer-events: auto;
  touch-action: manipulation;
}

.network-status-actions {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 7px;
}

.network-status-actions button {
  min-height: 44px;
  padding: 8px 10px;
  border: 1px solid rgba(220, 188, 105, 0.55);
  border-radius: 11px;
  background: rgba(4, 43, 32, 0.98);
  color: #f4ecd5;
  font: inherit;
  font-size: 13px;
  font-weight: 800;
}

.network-status-actions .network-retry-button {
  background: linear-gradient(180deg, #edd07e, #bd9445);
  color: #142219;
}

.network-status-actions button:disabled {
  opacity: 0.55;
  cursor: wait;
}

.network-restored-panel {
  border-color: #72c596;
}

.network-restored-panel h2,
.network-restored-panel .network-status-icon {
  color: #9ae4b7;
}

.network-fatal-panel {
  border-color: #d07964;
}

.network-fatal-panel h2,
.network-fatal-panel .network-status-icon {
  color: #efb0a2;
}

.network-ranking-notice {
  position: fixed;
  z-index: 18;
  top: max(58px, calc(env(safe-area-inset-top) + 50px));
  left: 50%;
  width: min(430px, calc(100vw - env(safe-area-inset-left) - env(safe-area-inset-right) - 24px));
  margin: 0;
  padding: 5px 10px;
  transform: translateX(-50%);
  border: 1px solid rgba(208, 166, 79, 0.58);
  border-radius: 999px;
  background: rgba(2, 33, 25, 0.94);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.34);
  color: #f2d47d;
  font-size: 10px;
  font-weight: 800;
  line-height: 1.35;
  text-align: center;
  pointer-events: none;
}

@media (orientation: portrait) and (max-width: 700px) {
  .network-status-panel:not(.network-stopped-panel):not(.network-fatal-panel) {
    bottom: calc(var(--portrait-human-area-h) + max(12px, env(safe-area-inset-bottom)));
    width: min(520px, calc(100vw - 18px));
  }

  body:has(.call-tray:not([hidden])) .network-status-panel:not(.network-stopped-panel):not(.network-fatal-panel) {
    bottom: calc(var(--portrait-human-area-h) + min(224px, 26dvh));
  }

  .network-ranking-notice {
    top: max(58px, calc(env(safe-area-inset-top) + 50px));
  }
}

@media (orientation: landscape) and (max-height: 540px) {
  .network-status-panel {
    bottom: calc(92px + max(4px, env(safe-area-inset-bottom)));
    width: min(500px, calc(100vw - env(safe-area-inset-left) - env(safe-area-inset-right) - 110px));
    padding: 9px 12px;
  }

  .network-stopped-panel,
  .network-fatal-panel {
    top: 50%;
    bottom: auto;
    width: min(520px, calc(100vw - env(safe-area-inset-left) - env(safe-area-inset-right) - 110px));
  }

  .network-status-panel h2 {
    font-size: 15px;
  }

  .network-status-panel p {
    font-size: 12px;
  }

  .network-status-actions button {
    min-height: 40px;
  }

  body:has(.call-tray:not([hidden])) .network-status-panel:not(.network-stopped-panel):not(.network-fatal-panel) {
    bottom: calc(168px + max(4px, env(safe-area-inset-bottom)));
  }

  .network-ranking-notice {
    top: max(8px, env(safe-area-inset-top));
    width: min(390px, 45vw);
  }
}

@media (max-width: 370px) {
  .network-status-actions {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (prefers-reduced-motion: no-preference) {
  .network-slow-panel .network-status-icon {
    animation: network-wait-pulse 1.4s ease-in-out infinite;
  }

  @keyframes network-wait-pulse {
    50% {
      opacity: 0.45;
      transform: scale(0.88);
    }
  }
}

@media (max-height: 420px) {
  :root {
    --open-tile-w: 28px;
    --open-half-tile-w: 14px;
    --open-tile-h: 37px;
    --sideways-tile-shift: 9px;
    --sideways-tile-offset: 4.5px;
  }

  .river-bottom {
    bottom: calc(74px + max(5px, env(safe-area-inset-bottom)));
  }

  .center-console {
    top: calc(36.5% + 14px);
  }

  .table-wanpai {
    min-height: calc(var(--open-tile-h) * 1.2);
  }

}

@media (max-height: 350px), (max-aspect-ratio: 11/5) {
  :root {
    --tile-w: clamp(28px, 4.7vw, 39px);
    --open-tile-w: 26px;
    --open-half-tile-w: 13px;
    --open-tile-h: 35px;
    --sideways-tile-shift: 8px;
    --sideways-tile-offset: 4px;
    --human-hand-row-h: 63px;
  }

  .table {
    width: min(100vw, 250dvh);
    height: min(100dvh, 40vw);
    min-height: 0;
  }

  .human-area {
    height: 90px;
  }

  .human-meta {
    height: 24px;
  }

  .human-id {
    right: calc(50% + var(--human-river-shift) + var(--open-tile-w) * 3 + 8px);
  }

  .meld-zone-left,
  .meld-zone-right {
    gap: 0;
  }

  .river-bottom {
    bottom: calc(58px + max(5px, env(safe-area-inset-bottom)));
  }

  .river-top {
    top: 0;
  }

  .river-right {
    left: calc(50% + var(--open-tile-w) * 3 + 20px - var(--open-half-tile-w) + var(--side-riichi-stick-lane));
  }

  .river-right.wanpai-kan-pair-1 {
    left: calc(50% + var(--open-tile-w) * 4 + 20px - var(--open-half-tile-w) + var(--side-riichi-stick-lane));
  }

  .river-right.wanpai-kan-pair-2 {
    left: calc(50% + var(--open-tile-w) * 5 + 20px - var(--open-half-tile-w) + var(--side-riichi-stick-lane));
  }

  .river-top.has-riichi-stick::before {
    top: -4.5px;
  }

  .opponent-top {
    left: calc(50% + var(--open-tile-w) * 3 + 8px + var(--seat-layout-clearance));
  }

  .meld-zone-top {
    right: calc(50% + 74px);
  }

  .center-console {
    top: calc(36.5% + 8px);
    left: calc(50% + 20px);
  }

  .table-wanpai {
    min-height: calc(var(--open-tile-h) * 1.2);
  }

  .table-settings-button {
    top: max(4px, env(safe-area-inset-top));
    right: max(8px, env(safe-area-inset-right));
    width: 44px;
    height: 44px;
  }

  .table-settings-button span {
    font-size: 28px;
  }

  .corner-table-status {
    top: max(6px, env(safe-area-inset-top));
    left: max(8px, env(safe-area-inset-left));
    gap: 5px;
  }

  .round-status-lines,
  .corner-remaining {
    min-height: 52px;
    padding: 5px 7px;
  }

  .round-status-lines {
    min-width: 66px;
  }

  .round-status-lines strong {
    font-size: 15px;
  }

  .round-status-lines span {
    font-size: 10px;
  }

  .corner-remaining {
    min-width: 0;
  }

  .call-tray {
    bottom: 96px;
  }

  .result-card {
    padding: 10px 14px;
    border-radius: 14px;
  }

  .result-card h1 {
    margin-bottom: 4px;
    font-size: 24px;
  }

  .result-hand {
    min-height: 37px;
  }

  .result-hand img {
    width: 25px;
    height: 34px;
  }

  .result-yaku {
    margin-top: 4px;
    font-size: 14px;
    font-weight: 800;
    line-height: 1.3;
  }

  .result-bonus {
    margin: 3px auto;
  }

  .result-bonus-row,
  .result-red-dora {
    min-height: 25px;
    padding: 1px 4px;
  }

  .result-bonus-tiles img {
    width: 16px;
    height: 21px;
  }

  .result-score {
    font-size: 18px;
    line-height: 1.2;
    overflow-wrap: anywhere;
  }

  .result-actions {
    margin-top: 6px;
  }

  .result-stats-button,
  .result-exit-button,
  .result-table-view-button,
  .next-button {
    min-height: 32px;
  }

  .result-seat-delta {
    padding: 4px;
    font-size: 8px;
  }
}

@media (orientation: landscape) and (max-height: 500px) {
  .meddling-uncle-dialog {
    gap: 14px;
    padding: 12px 16px;
  }

  .half-start-sheet {
    padding-top: max(6px, env(safe-area-inset-top));
    padding-right: max(42px, env(safe-area-inset-right));
    padding-bottom: max(6px, env(safe-area-inset-bottom));
    padding-left: max(8px, env(safe-area-inset-left));
  }

  .half-start-dialog {
    width: 100%;
    height: 100%;
    border-radius: 18px;
  }

  .half-start-header {
    top: 10px;
    left: 14px;
    width: min(260px, 30%);
    padding: 0;
  }

  .half-start-header span {
    font-size: 7px;
  }

  .half-start-header h1 {
    font-size: clamp(26px, 7dvh, 32px);
  }

  .half-start-header p {
    margin-top: 4px;
    font-size: 9px;
    line-height: 1.35;
  }

  .half-start-arena {
    margin: 0;
  }

  .half-start-seat {
    width: clamp(156px, 43dvh, 180px);
    height: auto;
    aspect-ratio: 1;
    border-radius: 14px;
  }

  .half-start-seat-top {
    top: 7px;
  }

  .half-start-seat-bottom {
    bottom: 7px;
  }

  .half-start-seat-left {
    left: 8px;
  }

  .half-start-seat-right {
    right: 8px;
  }

  .half-start-portrait strong {
    top: 7px;
    left: 7px;
    width: 34px;
    height: 34px;
    font-size: 21px;
  }

  .half-start-copy {
    padding: 24px 10px 8px;
  }

  .half-start-copy b {
    font-size: clamp(16px, 3.8dvh, 20px);
  }

  .half-start-copy small {
    margin-top: 3px;
    font-size: 8.5px;
  }

  .half-start-core {
    top: 8px;
    right: 10px;
    width: clamp(180px, 26vw, 230px);
    min-height: 54px;
    padding: 6px 11px;
    column-gap: 8px;
    border-radius: 11px;
  }

  .half-start-core strong {
    font-size: clamp(18px, 4.8dvh, 22px);
  }

  .half-start-core small {
    margin-top: 1px;
    padding-left: 8px;
    font-size: 8.5px;
  }

  .half-start-button {
    right: 10px;
    bottom: 8px;
    width: min(244px, 29%);
    min-width: 210px;
    min-height: 48px;
    margin: 0;
    padding: 3px 18px 4px;
  }

  .half-start-button strong {
    font-size: 17px;
  }

  .settings-sheet,
  .account-sheet,
  .confirm-sheet,
  .exit-sheet {
    padding-top: max(6px, env(safe-area-inset-top));
    padding-right: max(46px, env(safe-area-inset-right));
    padding-bottom: max(6px, env(safe-area-inset-bottom));
    padding-left: max(8px, env(safe-area-inset-left));
  }

  .settings-dialog {
    width: 100%;
    max-width: 820px;
    max-height: calc(100dvh - 12px);
  }

  .settings-header {
    min-height: 52px;
    padding-top: 6px;
    padding-bottom: 6px;
  }

  .settings-header h1 {
    font-size: 22px;
  }

  .settings-body {
    gap: 10px;
    padding: 10px;
  }

  .settings-actions {
    gap: 7px;
  }

  .settings-menu-button {
    min-height: 48px;
    font-size: 15px;
  }

  .settings-bgm-card,
  .settings-offline-card {
    padding: 10px 12px;
  }

  .settings-account-card {
    padding: 10px 12px;
  }

  .account-dialog {
    width: min(680px, 100%);
    max-height: calc(100dvh - 12px);
  }

  .account-header {
    min-height: 54px;
    padding-top: 6px;
    padding-bottom: 6px;
  }

  .account-body {
    padding: 10px 14px 12px;
  }

  .confirm-dialog,
  .exit-dialog {
    padding: 19px 22px;
  }

  .profile-sheet {
    padding-top: max(6px, env(safe-area-inset-top));
    padding-right: max(46px, env(safe-area-inset-right));
    padding-bottom: max(6px, env(safe-area-inset-bottom));
    padding-left: max(8px, env(safe-area-inset-left));
  }

  .profile-dialog {
    grid-template-columns: minmax(205px, 37%) minmax(0, 63%);
    width: 100%;
    max-width: 900px;
    min-width: 0;
    height: 100%;
    max-height: 410px;
    border-radius: 17px;
  }

  .profile-copy {
    padding: 14px 26px 12px 22px;
  }

  .profile-copy h1 {
    font-size: clamp(32px, 4.6vw, 39px);
  }

  .profile-copy h2 {
    margin: 5px 0 8px;
    font-size: clamp(18px, 2.5vw, 22px);
  }

  .profile-overline {
    margin-bottom: 4px;
    font-size: 11px;
  }

  .profile-traits {
    gap: 6px;
    margin-bottom: 9px;
  }

  .profile-traits span {
    padding: 4px 9px;
    font-size: 14px;
  }

  .profile-intro {
    font-size: 17px;
    line-height: 1.45;
  }

  .profile-copy blockquote {
    margin: 9px 0;
    padding-left: 11px;
    font-size: 16px;
    line-height: 1.45;
  }

  .profile-specs > div {
    padding-top: 6px;
  }

  .profile-specs {
    grid-template-columns: 0.8fr 1.4fr 0.8fr;
  }

  .profile-specs span {
    font-size: 11px;
  }

  .profile-specs strong {
    font-size: 14px;
  }

  .profile-portrait-caption span {
    font-size: 12px;
  }

  .profile-portrait-caption strong {
    font-size: clamp(27px, 3.6vw, 32px);
  }

  .profile-portrait-caption {
    right: 16px;
    bottom: 112px;
    left: 16px;
  }

  .profile-image-picker {
    right: 12px;
    bottom: 46px;
    left: 12px;
    gap: 5px;
  }

  .profile-voice-picker-wrap {
    right: 12px;
    bottom: 8px;
    left: 12px;
  }

  .profile-image-option {
    height: 56px;
    border-radius: 8px;
  }

  .profile-image-option span {
    font-size: 12px;
  }

  .profile-close {
    top: 8px;
    right: 8px;
    width: 38px;
    height: 38px;
    font-size: 24px;
  }
}

@media (orientation: landscape) and (max-height: 350px) {
  .half-start-header {
    top: 7px;
    left: 10px;
    width: 27%;
    padding: 0;
  }

  .half-start-header span,
  .half-start-header p {
    display: none;
  }

  .half-start-header h1 {
    font-size: 26px;
  }

  .half-start-seat {
    width: clamp(140px, 43dvh, 156px);
    height: auto;
    aspect-ratio: 1;
  }

  .half-start-seat-top {
    top: 5px;
  }

  .half-start-seat-bottom {
    bottom: 5px;
  }

  .half-start-seat-left {
    left: 7px;
  }

  .half-start-seat-right {
    right: 7px;
  }

  .half-start-portrait strong {
    width: 27px;
    height: 27px;
    font-size: 17px;
  }

  .half-start-copy b {
    font-size: 16px;
  }

  .half-start-copy {
    padding: 20px 8px 6px;
  }

  .half-start-copy small {
    font-size: 8px;
    -webkit-line-clamp: 1;
  }

  .half-start-core {
    top: 6px;
    right: 8px;
    width: 180px;
    min-height: 48px;
    padding: 5px 10px;
    border-radius: 10px;
  }

  .half-start-core span {
    display: none;
  }

  .half-start-core strong {
    font-size: 18px;
  }

  .half-start-core small {
    max-width: 100%;
    font-size: 8px;
  }

  .half-start-button {
    right: 8px;
    bottom: 6px;
    width: 210px;
    min-width: 190px;
    min-height: 42px;
    margin: 0;
  }

  .half-start-button span {
    display: none;
  }

  .half-start-button strong {
    font-size: 16px;
  }
}

@media (orientation: landscape) and (max-width: 720px) {
  .half-start-button {
    width: 190px;
    min-width: 180px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .half-start-dialog,
  .half-start-seat,
  .profile-dialog,
  .profile-trigger {
    animation: none;
    transition: none;
  }
}

@media (min-width: 1000px) {
  :root {
    --tile-w: 48px;
  }
}

/*
 * Portrait play keeps the same physical tile scale as the compact iPhone landscape
 * table.  Only the human hand changes to a seven-column, two-row rack; the
 * river and meld tile dimensions remain the shared --open-tile-* values.
 */
@media (orientation: portrait) and (max-width: 700px) {
  :root {
    --tile-w: 39px;
    --tile-h: calc(var(--tile-w) * 1.333);
    --human-hand-row-h: calc(var(--tile-h) * 2 + 4px);
    --portrait-human-area-h: calc(var(--human-hand-row-h) + 102px);
    --action-panel-w: 166px;
    --human-river-shift: 35px;
    --opponent-score-top: max(8px, env(safe-area-inset-top));
  }

  .profile-dialog {
    grid-template-columns: minmax(0, 62%) minmax(0, 38%);
  }

  .profile-copy {
    padding: 22px 16px;
  }

  .profile-copy h1 {
    font-size: clamp(27px, 8vw, 34px);
  }

  .profile-copy h2 {
    font-size: 16px;
    line-height: 1.45;
  }

  .profile-dialog .profile-copy blockquote {
    margin-top: 18px;
    padding-left: 10px;
    font-size: 15px;
    line-height: 1.65;
  }

  .app-shell {
    width: 100vw;
    height: var(--app-visible-height);
    place-items: stretch;
  }

  .table {
    width: 100vw;
    height: var(--app-visible-height);
    aspect-ratio: auto;
  }

  .opponent-top {
    top: var(--opponent-score-top);
    left: 50%;
    transform: translateX(-50%);
  }

  .opponent-left {
    top: calc(32% - 30px);
    left: 0;
  }

  .opponent-right {
    top: calc(32% - 22px);
    right: auto;
    left: calc(100% - 105px);
  }

  .river-top {
    top: calc(12dvh + 89px);
    left: 50%;
  }

  .river-bottom {
    top: calc(89.4dvh - 201px);
    bottom: auto;
    left: calc(50% - 2px);
  }

  .river-left {
    top: calc(32% + 68px);
    left: calc(0px - var(--open-tile-w));
  }

  .river-right,
  .river-right.wanpai-kan-pair-1,
  .river-right.wanpai-kan-pair-2 {
    top: calc(32% + 76px);
    right: calc(0px - var(--open-tile-w));
    left: auto;
  }

  .center-console {
    top: calc(33.8dvh + 131px);
    left: 50%;
  }

  .meld-zone-top {
    top: var(--opponent-score-top);
    right: auto;
    left: max(8px, env(safe-area-inset-left));
  }

  .meld-zone-left {
    top: 56%;
    left: 0;
  }

  .meld-zone-right {
    top: var(--opponent-score-top);
    right: max(8px, env(safe-area-inset-right));
  }

  .corner-table-status {
    --portrait-status-right-shift: 0px;
    --portrait-status-wide-correction: 0px;
    top: calc(28dvh + 94px);
    left: 50%;
    flex-direction: row;
    align-items: stretch;
    gap: 6px;
    transform: translateX(calc(-50% + var(--portrait-status-right-shift) - var(--portrait-status-wide-correction)));
  }

  .table:has(.center-console.wanpai-eight-columns) .corner-table-status {
    --portrait-status-wide-correction: var(--open-half-tile-w);
  }

  .table:has(.center-console.wanpai-kan-pair-1) .corner-table-status {
    --portrait-status-right-shift: var(--open-tile-w);
  }

  .table:has(.center-console.wanpai-kan-pair-2) .corner-table-status {
    --portrait-status-right-shift: calc(var(--open-tile-w) * 2);
  }

  .round-status-lines,
  .corner-remaining {
    min-height: 48px;
    padding: 3px 7px;
  }

  .round-status-lines {
    min-width: 66px;
  }

  .corner-remaining {
    width: auto;
    min-width: 66px;
  }

  .human-area {
    right: max(4px, env(safe-area-inset-right));
    bottom: max(4px, env(safe-area-inset-bottom));
    left: max(4px, env(safe-area-inset-left));
    height: var(--portrait-human-area-h);
  }

  .human-meta {
    height: 28px;
    margin-bottom: 2px;
  }

  .human-id {
    top: 62px;
    right: auto;
    left: calc(50% - var(--tile-w) * 3.5);
    width: 70px;
  }

  .turn-message {
    position: absolute;
    top: 62px;
    right: auto;
    left: calc(50% - var(--tile-w) * 3.5 + 74px);
    display: flex;
    align-items: center;
    justify-content: center;
    width: 70px;
    max-width: 70px;
    height: 32px;
    overflow: hidden;
    margin: 0;
    padding: 4px 6px;
    border-radius: 9px;
    line-height: 1.08;
    text-align: center;
    text-overflow: clip;
    white-space: normal;
  }

  .hand-and-actions {
    height: calc(var(--human-hand-row-h) + 72px);
  }

  .hand {
    position: absolute;
    bottom: 0;
    left: 50%;
    display: grid;
    grid-template-columns: repeat(7, var(--tile-w));
    grid-template-rows: repeat(2, var(--tile-h));
    flex: none;
    align-items: end;
    justify-content: center;
    width: calc(var(--tile-w) * 7);
    height: var(--human-hand-row-h);
    padding: 4px 0 0;
    transform: translateX(-50%);
  }

  .hand.reserves-draw-slot::after,
  .tile-button {
    min-width: 0;
  }

  .tile-button {
    flex: none;
  }

  .tile-button.selected {
    transform: translateY(-8px);
  }

  .action-panel {
    top: auto;
    right: calc(var(--open-tile-w) * 4 + var(--sideways-tile-offset) * 2 + 8px);
    bottom: calc(var(--human-hand-row-h) + 8px);
    left: calc(50% - var(--tile-w) * 3.5 + 148px);
    display: flex;
    flex-direction: column;
    flex-wrap: nowrap;
    justify-content: flex-end;
    gap: 2px;
    width: auto;
    transform: none;
  }

  .action-panel .action-button {
    flex: 0 0 22px;
    width: 100%;
    min-width: 0;
    min-height: 22px;
    padding: 0 4px;
    font-size: 10px;
  }

  .meld-zone-human {
    right: 0;
    bottom: calc(var(--human-hand-row-h) + 8px);
  }

  .call-tray {
    bottom: calc(var(--portrait-human-area-h) + 8px);
    width: calc(100% - 12px);
    max-width: none;
    max-height: 210px;
    overflow-y: auto;
  }

  .meddling-uncle-dialog {
    grid-template-columns: 74px minmax(0, 1fr);
    gap: 12px;
    padding: 14px;
    overflow-x: hidden;
  }

  .meddling-uncle-icon {
    width: 70px;
    height: 70px;
    font-size: 41px;
  }

  .meddling-uncle-content h1 {
    font-size: 23px;
  }

  .meddling-uncle-comment {
    font-size: 17px;
  }

  .meddling-uncle-comparison {
    grid-template-columns: auto minmax(0, 1fr);
  }

  .meddling-uncle-actions {
    gap: 7px;
  }

  .settings-body {
    grid-template-columns: minmax(0, 1fr);
  }

  .account-sheet {
    padding: max(8px, env(safe-area-inset-top)) max(8px, env(safe-area-inset-right)) max(8px, env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left));
    place-items: start center;
    overflow-y: auto;
    overscroll-behavior: contain;
    touch-action: manipulation;
  }

  .account-dialog {
    width: min(520px, 100%);
    max-height: none;
  }

  .account-form {
    grid-template-columns: minmax(0, 1fr);
  }

  .account-form label,
  .account-form label:first-child,
  .account-form .account-submit {
    grid-column: 1;
  }

  .account-signed-in {
    grid-template-columns: minmax(0, 1fr);
  }

  .account-display-name-form {
    grid-template-columns: minmax(0, 1fr);
  }

  .account-display-name-form input,
  .account-display-name-form button {
    grid-column: 1;
    width: 100%;
  }

  .account-signed-in > span,
  .account-signed-in > strong,
  .account-signed-in > small,
  .account-signed-in a,
  .account-signed-in button {
    grid-column: 1;
  }

  .result-sheet {
    padding-right: max(8px, env(safe-area-inset-right));
    padding-left: max(8px, env(safe-area-inset-left));
  }

  .result-center-stack {
    position: relative;
    display: block;
    width: calc(100vw - max(8px, env(safe-area-inset-left)) - max(8px, env(safe-area-inset-right)));
  }

  .result-center-stack .result-seat-delta-left,
  .result-center-stack .result-seat-delta-right {
    top: 0;
    bottom: auto;
    transform: translateY(calc(-100% - 6px));
  }

  .result-center-stack .result-seat-delta-left {
    right: auto;
    left: 0;
  }

  .result-center-stack .result-seat-delta-right {
    right: 0;
    left: auto;
  }

  .result-card {
    width: 100%;
    max-height: calc(var(--app-visible-height) - 64px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
    padding: 16px 12px;
  }

  .result-eyebrow {
    font-size: clamp(15px, 4vw, 17px);
    line-height: 1.35;
  }

  .result-card h1 {
    font-size: clamp(28px, 7.5vw, 34px);
  }

  .result-yaku {
    font-size: clamp(15px, 4vw, 17px);
    font-weight: 800;
    line-height: 1.45;
  }

  .result-score {
    font-size: clamp(18px, 5vw, 22px);
    line-height: 1.3;
    overflow-wrap: anywhere;
  }
}

@media (orientation: portrait) and (max-width: 380px) {
  .human-id {
    width: 64px;
  }

  .turn-message {
    left: calc(50% - var(--tile-w) * 3.5 + 67px);
    width: 54px;
    max-width: 54px;
    padding-inline: 3px;
    font-size: 9px;
  }

  .action-panel {
    left: calc(50% - var(--tile-w) * 3.5 + 124px);
  }
}

.turnstile-area,
.half-start-ranking {
  display: grid;
  gap: 7px;
  justify-items: center;
}

.turnstile-area[hidden],
.half-start-ranking[hidden],
.turnstile-widget[hidden] {
  display: none;
}

.turnstile-area {
  padding: 9px;
  border: 1px solid rgba(242, 206, 117, 0.25);
  border-radius: 11px;
  background: rgba(0, 16, 13, 0.72);
}

.turnstile-widget {
  width: min(100%, 300px);
  min-height: 1px;
}

.turnstile-area p,
.half-start-ranking p {
  margin: 0;
  color: #b9d1c8;
  font-size: 10px;
  font-weight: 700;
  line-height: 1.45;
  text-align: center;
}

.turnstile-area p[data-tone="error"],
.half-start-ranking p[data-tone="warning"] {
  color: #ffd7a3;
}

.half-start-ranking {
  position: absolute;
  z-index: 9;
  top: 50%;
  left: 50%;
  width: min(330px, 44%);
  padding: 10px;
  border: 1px solid rgba(242, 206, 117, 0.55);
  border-radius: 13px;
  background: rgba(2, 26, 21, 0.96);
  box-shadow: 0 12px 34px rgba(0, 0, 0, 0.58);
  transform: translate(-50%, -50%);
}

#halfStartWithoutRankingButton {
  min-height: 34px;
  padding: 6px 13px;
  border: 1px solid rgba(242, 206, 117, 0.6);
  border-radius: 9px;
  background: rgba(86, 54, 12, 0.72);
  color: #fff2c7;
  font: inherit;
  font-size: 11px;
  font-weight: 800;
}

.half-start-button:disabled {
  cursor: wait;
  filter: saturate(0.55) brightness(0.72);
}

@media (orientation: portrait) and (max-width: 700px) {
  .half-start-ranking {
    top: 50%;
    width: min(310px, 76vw);
    padding: 8px;
  }
}

@media (orientation: landscape) and (max-height: 500px) {
  .half-start-ranking {
    width: min(300px, 39%);
    padding: 7px;
  }

  .half-start-ranking p {
    font-size: 9px;
  }
}
