.toolbar-actions { flex: none; }
.icon-button, .language-wrap select { min-height: 44px; }
.icon-button { min-width: 44px; }
.world-button {
  display: flex; justify-content: center; gap: 6px; padding: 0 10px;
  background: var(--accent); color: var(--accent-ink); font-size: 13px; white-space: nowrap;
}
.world-button > :first-child { font-size: 18px; }
.overlay { padding: clamp(8px, 2vmin, 18px); }
.panel { overscroll-behavior-y: contain; }
.actions > button { flex: 1 1 8rem; overflow-wrap: anywhere; }
#ready-panel .secondary-button { color: var(--ink); }
#result-panel {
  display: flex; flex-direction: column; width: min(440px, 100%); min-width: 0;
  padding: 0; overflow: hidden;
}
.result-heading {
  flex: none; display: flex; justify-content: space-between; align-items: center;
  gap: 8px; padding: 12px 16px 8px; text-align: start;
}
.result-heading > div { min-width: 0; }
.result-heading h2 { overflow-wrap: anywhere; }
#result-body {
  flex: 1 1 auto; min-height: 0; padding: 0 16px 12px;
  overflow: auto; overscroll-behavior: contain;
}
.result-footer { flex: none; padding: 8px 14px 4px; border-top: 1px solid var(--line); }
.result-footer .actions { gap: 6px; margin-top: 6px; }
.result-footer .actions > button, #submit-button, #result-home { min-height: 44px; padding: 5px 8px; }
.result-footer .fine-print { margin-block: 3px; }
#score-form { text-align: start; font-size: .82rem; }
.submit-row { display: flex; gap: 6px; margin-top: 3px; }
#nickname {
  flex: 1 1 8ch; min-width: 0; min-height: 44px;
  padding: 5px 8px; border: 1px solid var(--line); border-radius: 12px;
  background: #18100b; color: var(--ink); font: inherit; font-size: 16px;
}
#nickname:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }

#world-dialog {
  width: min(450px, calc(100% - 16px));
  max-height: calc(var(--visible-height, 100dvh) - 16px);
  padding: 0; overflow: hidden; border: 1px solid var(--line); border-radius: 20px;
  background: #241a12; color: var(--ink); box-shadow: 0 16px 52px #1607038c;
}
#world-dialog[open] { display: flex; flex-direction: column; }
#world-dialog::backdrop { background: #160b06a6; }
.world-head {
  flex: none; display: flex; justify-content: space-between; align-items: center;
  gap: 10px; padding: 8px 12px; border-bottom: 1px solid var(--line);
}
.world-head h2 { margin: 0; font-size: clamp(18px, 4vw, 25px); }
#world-scroll { min-height: 0; overflow: auto; overscroll-behavior: contain; padding: 0 14px 12px; }
#world-scroll a { display: inline-flex; align-items: center; min-height: 44px; color: var(--accent); }
#world-scroll :is(p, #world-more):empty { display: none; }
#world-status, #world-me, #world-submit-status, #world-more { margin: 8px 0; font-size: .88rem; }
#world-more button { min-height: 44px; }
#world-list { list-style: none; margin: 0; padding: 0; }
#world-list li {
  display: grid; grid-template-columns: 32px minmax(0, 1fr) auto;
  align-items: center; gap: 8px; min-height: 40px; padding-block: 5px; border-bottom: 1px solid var(--line);
}
#world-list bdi { overflow-wrap: anywhere; }
#world-list strong { text-align: end; font-variant-numeric: tabular-nums; }
.world-elapsed { display: block; color: var(--muted); font-size: .75rem; font-weight: 600; white-space: nowrap; }
.world-position { display: grid; place-items: center; font-variant-numeric: tabular-nums; }
.featured .world-position { min-height: 28px; border-radius: 50%; background: #644822; color: #fff3d5; }
.is-me { background: #453019; }

@media (max-width: 640px) {
  .toolbar-actions { gap: 5px; }
  .world-button > :last-child { display: none; }
  .top-row .chip.step { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
  .result-heading { padding: 10px 12px 6px; }
  #result-body { padding-inline: 12px; }
}
@media (max-width: 360px) {
  .toolbar { gap: 5px; padding-inline: 8px; }
  .language-wrap select { width: min(38vw, 116px); min-width: 0; padding-inline: 6px; }
}
@media (max-height: 520px) {
  .result-heading { padding-block: 5px 3px; }
  #result-panel .result-heading h2 { font-size: clamp(15px, 4.4vw, 20px); }
  #result-panel .result-score strong { font-size: 34px; }
  #result-body { padding-block: 0 4px; }
  #result-panel .marks { margin-block: 3px; }
  .result-footer { padding-block: 4px 1px; }
  .result-footer .actions { margin-top: 3px; }
  .result-footer .actions > button { flex-basis: 7rem; }
}

/* Leave the result actions above Safari's toolbar on short landscape screens. */
@media (orientation: landscape) and (max-height: 390px) {
  .toolbar { gap: 8px; padding-inline: 10px; }
  .toolbar-rule, .toolbar h1, .toolbar .wide-tool, .brand span:last-child { display: none; }
  #result-panel.panel.result { width: min(520px, 100%); }
  #result-parts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .result-footer { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px; align-items: center; }
  .result-footer .actions { flex-wrap: nowrap; margin: 0; }
  .result-footer .actions > button { flex-basis: 0; }
  #result-home { text-align: start; }
}
