/* The rider name and the action row have independent sizing. Long names can
   truncate; they never set the width of Locker, Shop or Account. */
#title #rider-sec {
  width: 100%;
  max-width: 460px;
  min-width: 0;
  grid-template-columns: minmax(0,1fr);
  justify-items: start;
}
#title #rider-sec .sec-top {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 10px;
  width: 100%;
  max-width: 100%;
  min-width: 0;
}
#title #rider-sec #sec-rename.rider-name {
  flex: 0 1 auto;
  width: auto;
  max-width: 100%;
  min-width: 0;
  min-height: 44px;
  overflow: hidden;
  color: var(--ink);
}
#title #rider-sec #sec-rename.rider-name #sec-name {
  flex: 0 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: inherit;
}
#title #rider-sec #sec-rename.rider-name .ph { flex: 0 0 18px; }
#title #rider-sec #sec-powder {
  flex: 0 0 auto;
  min-width: 44px;
  min-height: 44px;
  margin-left: 0;
}
#title #rider-sec .acts {
  display: flex;
  flex-wrap: nowrap;
  align-items: stretch;
  justify-content: flex-start;
  gap: 8px;
  width: max-content;
  max-width: 100%;
  min-width: 0;
}
#title #rider-sec .acts > button {
  flex: 0 0 auto;
  width: auto;
  min-width: 44px;
  min-height: 44px;
  max-width: 150px;
  padding-inline: 14px;
}
#title #rider-sec #sec-acct .long {
  display: block;
  min-width: 0;
  max-width: 112px;
  white-space: normal;
  overflow-wrap: normal;
}
#title #rider-sec #sec-streak,
#title #rider-sec #sec-payout { max-width: 100%; }

@media (orientation:landscape) and (min-height:501px), (orientation:portrait) and (min-width:761px) {
  #title #rider-sec { max-width: none; }
  #title #rider-sec .acts { width: 100%; }
  #title #rider-sec .acts > button { flex: 1 1 0; min-width: 0; max-width: none; }
  html body #title :is(.title-top,.title-dock) {
    background: var(--paper);
    color: var(--ink);
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
  }
  html body.night #title #rider-sec #sec-rename.rider-name { color: var(--ink); }
  html body #title #rider-sec .acts > button:not(.new) { background: #e8edf2; }
  html body #title #rider-sec .acts > button:not(.new):hover { background: var(--lime); }
  html body #title #go:hover { background: #e8edf2; }
}

@media (max-height:500px) and (orientation:landscape) {
  /* Reserve the right-hand race controls explicitly rather than relying on the
     intrinsic width of either the rider name or the leaderboard leader. */
  #title { --home-go-width: clamp(168px,25vw,210px); }
  #title .go-stack {
    width: var(--home-go-width);
    min-width: 0;
    max-width: var(--home-go-width);
  }
  #title .go-stack .kings-chip { min-width: 0; overflow: hidden; }
  #title .go-stack #kings-lead {
    display: block;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  #title #rider-sec {
    width: calc(100% - max(34px,env(safe-area-inset-left)) - var(--pr) - 7px - var(--home-go-width) - 24px);
    max-width: 460px;
    right: auto;
  }
  #title #rider-sec #sec-rename.rider-name { font-size: 30px; }
  #title #rider-sec .acts > button { padding-inline: 14px; }
}
@media (max-height:350px) and (orientation:landscape) {
  #title #rider-sec #sec-rename.rider-name { font-size: 26px; }
}
@media (max-width:760px) and (orientation:portrait) {
  #title #rider-sec {
    width: calc(100% - var(--pl) - var(--pr) - 10px);
    max-width: none;
    right: auto;
  }
  #title #rider-sec .acts { width: 100%; gap: 6px; }
  #title #rider-sec .acts > button {
    flex: 1 1 0;
    min-width: 0;
    padding-inline: 12px;
    max-width: none;
    white-space: normal;
  }
  #title #rider-sec #sec-acct .long { max-width: 102px; }
}
@media (max-width:350px) and (orientation:portrait) {
  #title #rider-sec .acts > button { padding-inline: 9px; font-size: 15px; }
}
body.night #title #rider-sec #sec-rename.rider-name { color: var(--paper); }

/* Utility screens, results and the leaderboard share the gear area's solid
   paper surface. Keep the Home card as a layout wrapper over the live scene. */
html body :is(#account,#settings,#news,#rename,#howto,#paused,#finish,#dare) .card,
html body #board.board,
html body.night :is(#account,#settings,#news,#rename,#howto,#paused,#finish,#dare) .card,
html body.night #board.board {
  background: var(--paper);
  border-radius: 12px;
  color: var(--ink);
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}
html body #finish .card::before,
html body.night #finish .card::before {
  background: var(--paper);
  border-radius: inherit;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}
html body #finish .finish-bar,
html body.night #finish .finish-bar {
  background: var(--paper);
  border-radius: 12px 12px 0 0;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}
html body :is(#account,#settings,#news,#rename,#howto,#paused,#finish,#dare) .card .headline,
html body #board.board .board-head > b {
  color: var(--ink);
  -webkit-text-stroke: 0;
  text-shadow: none;
}
html body :is(#account,#settings,#news,#rename,#howto,#paused,#finish,#dare) .card .headline > span {
  color: var(--ink-soft);
  -webkit-text-stroke: 0;
}
html body #finish .card .headline #finish-eyebrow.newbest { color: var(--coral); }
html body :is(#account,#settings,#news,#rename,#howto,#paused,#finish,#dare) .card :is(.copy,.board-label),
html body #board.board :is(.board-label,.board-picks,.board-me) { color: var(--ink-soft); }
html body #board.board li:not(:is(.p1,.p2,.p3,.medal-row)) > button:not(.me) { background: #e8edf2; }
html body #board.board li.medal-row > button { background: #edf1f5; }
html body #board.board li:not(:is(.p1,.p2,.p3,.medal-row)) > button:not(.me):hover { background: #dde5ec; }

/* Solid surfaces need controls distinguishable from the panel itself. */
html body #finish .actions { gap:8px; }
html body #finish .actions :is(#share,#finish-locker,#finish-home) { flex:1 1 0; min-width:0; min-height:44px; height:auto; padding:8px; white-space:normal; text-align:center; }
@media (max-height:500px) and (orientation:landscape) {
  html body #finish .actions :is(#share,#finish-locker,#finish-home) { font-size:16px; }
}
html body :is(#account,#settings,#news,#rename,#howto,#paused,#finish,#dare) .card .ghost,
html body #board.board .board-tabs button:not(.on) { background: #e8edf2; }
html body :is(#account,#settings,#news,#rename,#howto,#paused,#finish,#dare) .card .ghost:hover { background: var(--lime); color: var(--ink); }
html body :is(#account,#settings,#news,#rename,#howto,#paused,#dare) .card :is(button,a,input:not([type=checkbox]),.tick) { min-height: 44px; }
html body :is(#account,#settings,#news,#rename,#howto,#paused,#dare) .card :is(.copy,.tick span) { color: var(--ink-soft); }

@media (orientation:landscape) and (min-height:501px), (orientation:portrait) and (min-width:761px) {
  html body #board.board,
  html body #finish .card { border-radius: 12px 12px 0 0; }
}
