/* Results, leaderboard and achievements screens. */

/* ---------- end screens (#win, #grave): drawing next to the run summary ---------- */
#grave,
#win {
  display: block;
  padding: 0;
  text-align: left;
  -webkit-overflow-scrolling: touch;
}
#grave.hidden,
#win.hidden {
  display: none;
}
.endWrap {
  box-sizing: border-box;
  min-height: 100%;
  max-width: 1040px;
  margin: 0 auto;
  padding: max(16px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(20px, env(safe-area-inset-bottom))
    max(16px, env(safe-area-inset-left));
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 14px;
}
#grave .endWrap h3,
#win .endWrap h3 {
  max-width: none;
  text-align: center;
  font-size: clamp(26px, 5vw, 50px);
}
.endCols {
  display: flex;
  gap: 22px;
  align-items: flex-start;
  justify-content: center;
}
#win .endCols canvas {
  width: min(400px, 38vw);
  flex: none;
}
#grave .endCols canvas {
  width: min(250px, 26vw);
  flex: none;
}
.endSum {
  flex: 1 1 0;
  min-width: 0;
  max-width: 560px;
  color: #e9ecf5;
  font: 400 14px/1.4 Inter, system-ui, sans-serif;
}
.endSum h4,
.recPanel h3 {
  font: 400 19px 'Bebas Neue', Impact, sans-serif;
  letter-spacing: 1.5px;
  color: #ffd23f;
  margin: 14px 0 6px;
}
.rhead {
  display: flex;
  gap: 8px;
}
.rbig {
  flex: 1 1 0;
  min-width: 0;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  padding: 7px 10px 5px;
}
.rbig span {
  display: block;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: #9aa3ba;
}
.rbig b {
  display: block;
  font: 400 clamp(22px, 3.4vw, 34px) / 1.1 'Bebas Neue', Impact, sans-serif;
  letter-spacing: 1px;
  color: #ffd23f;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.rbig.bad b {
  color: #ff6b6b;
}
.rpb {
  min-height: 20px;
  margin: 9px 0 2px;
  color: #c6ccdc;
}
.rpb.gold {
  color: #111;
  background: #ffd23f;
  border-radius: 6px;
  padding: 5px 10px;
  box-shadow: 3px 3px 0 #000;
}
.rnick {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 9px;
  font-size: 13px;
  color: #9aa3ba;
}
.rnick input {
  flex: 1 1 120px;
  min-width: 0;
  max-width: 240px;
  font: 600 16px Inter, system-ui, sans-serif;
  color: #fff;
  background: rgba(0, 0, 0, 0.45);
  border: 2px solid #4a5270;
  border-radius: 6px;
  padding: 7px 10px;
}
.rnick input:focus {
  outline: none;
  border-color: #ffd23f;
}
.rnone {
  margin: 14px 0 0;
  color: #9aa3ba;
  font-style: italic;
}
.rbars {
  display: grid;
  gap: 4px;
}
.rbar {
  display: grid;
  grid-template-columns: minmax(96px, 34%) 1fr auto;
  align-items: center;
  gap: 8px;
  font-size: 13px;
}
.rbar .l {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.rbar .t {
  height: 10px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 3px;
  overflow: hidden;
}
.rbar .t i {
  display: block;
  height: 100%;
  background: #ffd23f;
  border-radius: 3px;
}
.rbars.red .t i {
  background: #e63946;
}
.rbar .v {
  min-width: 76px;
  text-align: right;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.rchips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 14px;
}
.rchip {
  background: rgba(255, 255, 255, 0.07);
  border-radius: 99px;
  padding: 3px 10px;
  font-size: 12.5px;
  color: #c6ccdc;
  white-space: nowrap;
}
.rchip b {
  color: #fff;
}
.endBar {
  position: sticky;
  bottom: 0;
  margin: 0 -16px -20px;
  padding: 18px 16px max(10px, env(safe-area-inset-bottom));
  background: linear-gradient(180deg, rgba(5, 6, 11, 0), rgba(5, 6, 11, 0.96) 26%);
}
#win .btns,
#grave .btns {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
}
#graveGo,
.endBtn {
  box-shadow: 3px 3px 0 #000;
  min-height: 44px;
}
.endBtn.alt {
  background: #1b2135;
  color: #ffd23f;
  border: 2px solid #ffd23f;
  font-size: 22px;
  padding: 8px 18px;
}
.endBtn.alt:hover {
  background: #ffd23f;
  color: #111;
}
#graveGo:focus-visible,
.endBtn:focus-visible,
#records button:focus-visible,
.recPanel:focus-visible {
  outline: 3px solid #fff;
  outline-offset: 2px;
}
.endNote {
  min-height: 18px;
  margin-top: 6px;
  text-align: center;
  font: 400 13px Inter, system-ui, sans-serif;
  color: #9aa3ba;
}
.endNote.bad {
  color: #ff8a80;
  user-select: text;
}

/* ---------- records screen ---------- */
#records {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(4, 6, 12, 0.86);
  padding: max(10px, env(safe-area-inset-top)) max(10px, env(safe-area-inset-right)) max(10px, env(safe-area-inset-bottom))
    max(10px, env(safe-area-inset-left));
  font: 400 14px/1.4 Inter, system-ui, sans-serif;
  color: #e9ecf5;
}
#records.hidden {
  display: none;
}
.recBox {
  box-sizing: border-box;
  width: min(900px, 100%);
  height: min(680px, 100%);
  display: flex;
  flex-direction: column;
  background: linear-gradient(180deg, #161c2e, #0b0e18);
  border: 3px solid #ffd23f;
  border-radius: 10px;
  box-shadow:
    0 0 0 4px #000,
    0 18px 50px rgba(0, 0, 0, 0.8);
  overflow: hidden;
}
.recTop {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 14px 0;
  flex-wrap: wrap;
}
.recTop h2 {
  margin: 0;
  font: 400 38px/1 'Bebas Neue', Impact, sans-serif;
  letter-spacing: 3px;
  color: #ffd23f;
  text-shadow: 3px 3px 0 #000;
}
.recTabs {
  display: flex;
  gap: 4px;
  flex: 1 1 auto;
}
#records button {
  font: 400 22px/1 'Bebas Neue', Impact, sans-serif;
  letter-spacing: 1.5px;
  cursor: pointer;
  border: 0;
  min-height: 44px;
  padding: 8px 16px;
  border-radius: 6px 6px 0 0;
  background: transparent;
  color: #aab2c8;
}
#records [role='tab']:hover {
  color: #fff;
}
#records [role='tab'][aria-selected='true'] {
  background: #ffd23f;
  color: #111;
}
#records .recClose {
  border-radius: 6px;
  border: 2px solid #4a5270;
  color: #e9ecf5;
  font-size: 18px;
  margin-bottom: 6px;
}
#records .recClose:hover {
  border-color: #ffd23f;
  color: #ffd23f;
}
.recClose kbd {
  font: 600 11px Inter, sans-serif;
  background: #2a3148;
  border-radius: 3px;
  padding: 1px 5px;
  margin-left: 4px;
  color: #c6ccdc;
}
.recPanel {
  flex: 1 1 0;
  min-height: 0;
  overflow: auto;
  border-top: 3px solid #ffd23f;
  padding: 14px;
  -webkit-overflow-scrolling: touch;
}
.recNote {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 12px;
  color: #c6ccdc;
}
.recTag {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 1px;
  text-transform: uppercase;
  background: #2a3148;
  color: #ffd23f;
  border: 1px solid #ffd23f;
  border-radius: 99px;
  padding: 2px 10px;
  white-space: nowrap;
}
.recTag.on {
  background: #2bd96b;
  border-color: #2bd96b;
  color: #06210f;
}
.recProg {
  flex: 1 1 120px;
  height: 10px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 5px;
  overflow: hidden;
}
.recProg i {
  display: block;
  height: 100%;
  background: #ffd23f;
}
.recWait,
.recEmpty {
  text-align: center;
  color: #9aa3ba;
  padding: 40px 10px;
}
.recEmpty {
  font: 400 26px/1.25 'Bebas Neue', Impact, sans-serif;
  letter-spacing: 1.5px;
}
.recTable {
  width: 100%;
  border-collapse: collapse;
  font-variant-numeric: tabular-nums;
}
.recTable th {
  text-align: left;
  font-size: 11px;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: #9aa3ba;
  padding: 4px 8px;
  border-bottom: 1px solid #2a3148;
  position: sticky;
  top: -14px;
  background: #121727;
}
.recTable td {
  padding: 7px 8px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  white-space: nowrap;
}
.recTable td:nth-child(2) {
  white-space: normal;
  overflow-wrap: anywhere;
  font-weight: 600;
}
.recTable td:first-child {
  color: #9aa3ba;
  width: 1%;
}
.recTable tr.w td b {
  font: 400 21px/1 'Bebas Neue', Impact, sans-serif;
  letter-spacing: 1px;
  color: #ffd23f;
}
.recTable tr.w:first-child td:first-child {
  color: #ffd23f;
  font-weight: 800;
}
.recTable .x {
  color: #ff8a80;
}
.recTable tr.l td {
  color: #aab2c8;
}
.recTable tr.cur td {
  background: rgba(255, 210, 63, 0.13);
}
.recTable tr.mine td:nth-child(2) {
  color: #ffd23f;
}
.recTable em {
  font-style: normal;
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  background: #ffd23f;
  color: #111;
  border-radius: 3px;
  padding: 1px 5px;
  margin-left: 4px;
}
.achGrid {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 8px;
}
.ach {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  padding: 9px 10px;
  color: #8d95ab;
}
.ach .ic {
  font-size: 22px;
  line-height: 1.1;
  filter: grayscale(1);
  opacity: 0.6;
}
.ach b {
  display: block;
  font: 400 19px/1.1 'Bebas Neue', Impact, sans-serif;
  letter-spacing: 1px;
  color: #aab2c8;
}
.ach p {
  margin: 2px 0 3px;
  font-size: 12.5px;
}
.ach small {
  font-size: 11px;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}
.ach.on {
  background: rgba(255, 210, 63, 0.1);
  border-color: #ffd23f;
  color: #e9ecf5;
}
.ach.on .ic {
  filter: none;
  opacity: 1;
}
.ach.on b,
.ach.on small {
  color: #ffd23f;
}
.recTiles {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(132px, 1fr));
  gap: 8px;
}
.recTile {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  padding: 8px 10px 7px;
}
.recTile b {
  display: block;
  font: 400 28px/1.1 'Bebas Neue', Impact, sans-serif;
  letter-spacing: 1px;
  color: #ffd23f;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.recTile span {
  font-size: 12px;
  color: #aab2c8;
}
.recFoot {
  margin: 16px 0 0;
  font-size: 12px;
  color: #7f879d;
}

/* ---------- small screens ---------- */
@media (max-width: 700px) and (orientation: portrait) {
  .endCols {
    flex-direction: column;
    align-items: center;
  }
  #win .endCols canvas {
    width: min(360px, 88vw);
  }
  #grave .endCols canvas {
    width: min(200px, 52vw);
  }
  .endSum {
    width: 100%;
    max-width: 520px;
    flex: none;
  }
  .endWrap {
    justify-content: flex-start;
  }
}
@media (max-width: 560px) {
  .recTop h2 {
    font-size: 28px;
    flex: 1 1 auto;
  }
  .recTabs {
    order: 3;
    flex: 1 1 100%;
  }
  #records [role='tab'] {
    flex: 1 1 0;
    padding: 8px 4px;
    font-size: 20px;
  }
  .hideS {
    display: none;
  }
  .recPanel {
    padding: 10px;
  }
  .recTable th {
    top: -10px;
  }
}
@media (max-height: 460px) {
  .endWrap {
    gap: 8px;
    justify-content: flex-start;
  }
  #grave .endWrap h3,
  #win .endWrap h3 {
    font-size: clamp(22px, 4.2vw, 32px);
  }
  #win .endCols canvas {
    width: min(300px, 32vw);
  }
  #grave .endCols canvas {
    width: min(170px, 20vw);
  }
  .endBtn,
  #graveGo {
    font-size: 22px;
    padding: 8px 18px;
  }
  .endBtn.alt {
    font-size: 19px;
    padding: 6px 14px;
  }
  .recTop {
    padding-top: 6px;
    gap: 8px;
  }
  .recTop h2 {
    font-size: 26px;
  }
  #records button {
    min-height: 40px;
    font-size: 19px;
    padding: 6px 12px;
  }
  #records .recClose {
    margin-bottom: 4px;
  }
  .recPanel {
    padding: 10px;
  }
}
@media (prefers-reduced-motion: no-preference) {
  .rbar .t i,
  .recProg i {
    animation: recGrow 0.5s ease-out;
    transform-origin: left;
  }
  @keyframes recGrow {
    from {
      transform: scaleX(0);
    }
  }
}

/* medium-height windows: keep the whole summary above the button bar */
@media (max-height: 800px) {
  .endWrap {
    gap: 8px;
    justify-content: flex-start;
  }
  #grave .endWrap h3,
  #win .endWrap h3 {
    font-size: clamp(24px, 5vh, 40px);
  }
}
