.attempt-page {
  max-width: 1420px;
  min-height: calc(100vh - 158px);
  margin: auto;
  padding: 48px clamp(20px, 6vw, 92px) 78px;
  background: var(--ui-filter-bg, #edf3f6);
  color: var(--ui-text, #172f42);
  font-family: var(--type-font-ui, var(--sans, system-ui, sans-serif));
}

.attempt-page a {
  color: inherit;
}

.attempt-page .attempt-top {
  display: flex;
  gap: 20px;
  align-items: flex-end;
  justify-content: space-between;
  margin-bottom: 30px;
}

.attempt-page .attempt-top h1 {
  margin: 8px 0 0;
  color: var(--ui-text, #172f42);
  font: 700 clamp(37px, 4.6vw, 63px) / 1 var(--serif);
  letter-spacing: 0;
}

.attempt-page .attempt-actions {
  display: flex;
  gap: var(--ui-space-2, 8px);
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
}

.attempt-page .mode-pill {
  display: inline-flex;
  align-items: center;
  box-sizing: border-box;
  min-height: var(--ui-control-height, 40px);
  padding: 0 var(--ui-button-padding-x, 12px);
  border: 1px solid var(--ui-border-color, #bfd0da);
  border-radius: var(--ui-control-radius, 3px);
  background: var(--ui-surface, #fffdf7);
  color: var(--ui-text, #173044);
  font-size: var(--type-button-size, var(--ui-control-font-size, 12px));
  font-weight: var(--type-button-weight, 800);
  line-height: 1.2;
}

.attempt-page .mode-pill:hover,
.attempt-page .mode-pill:focus-visible {
  border-color: var(--ui-accent, #1676a8);
  color: var(--ui-accent, #1676a8);
}

.attempt-page .mode-pill:not(button):not(a) {
  cursor: default;
}

.attempt-page .mode-switch {
  cursor: pointer;
  font-family: inherit;
}

.attempt-page .attempt-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 290px;
  gap: 25px;
  align-items: start;
  min-width: 0;
}

.attempt-page .attempt-panel {
  min-width: 0;
  padding: 25px;
  border: 1px solid var(--ui-border-color, #bfd0da);
  border-radius: var(--ui-panel-radius, 6px);
  background: var(--ui-surface, #fffdf7);
  color: var(--ui-text, #173044);
  box-shadow: var(--ui-shadow-soft, 0 12px 30px rgba(23, 47, 66, .12));
}

.attempt-page .attempt-layout > aside.attempt-panel {
  position: sticky;
  top: 18px;
  max-height: calc(100dvh - 36px);
  overflow: auto;
}

.attempt-page .attempt-tabs {
  display: flex;
  gap: var(--ui-space-2, 8px);
  flex-wrap: wrap;
  margin-bottom: 18px;
  border-color: var(--ui-border-color, #bfd0da);
}

.attempt-page .attempt-tab {
  min-height: 36px;
  padding: 0 var(--ui-button-padding-x, 12px);
  border: 1px solid var(--ui-border-color, #bfd0da);
  border-radius: var(--ui-control-radius, 3px);
  background: var(--ui-surface, #fffdf7);
  color: var(--ui-text, #173044);
  cursor: pointer;
  font-size: var(--type-button-size, var(--ui-control-font-size, 12px));
  font-weight: var(--type-button-weight, 800);
}

.attempt-page .attempt-tab:hover,
.attempt-page .attempt-tab:focus-visible {
  border-color: var(--ui-accent, #1676a8);
  color: var(--ui-accent, #1676a8);
}

.attempt-page .attempt-tab.active {
  border-color: var(--ui-accent, #1676a8);
  background: var(--ui-accent, #1676a8);
  color: var(--ui-inverse-text, #fff);
}

.attempt-page .attempt-image {
  position: relative;
  display: block;
  width: 100%;
  max-width: 100%;
  overflow: hidden;
  border: 1px solid var(--ui-border-color, #bfd0da);
  border-radius: var(--ui-panel-radius, 6px);
  background: var(--ui-input-bg, #fff);
  line-height: 0;
}

.attempt-page .attempt-image img {
  display: block;
  width: 100%;
  height: auto !important;
  max-width: 100%;
  max-height: none;
  object-fit: contain;
  visibility: hidden;
}

.attempt-page .attempt-image.is-ready img {
  visibility: visible;
}

.attempt-page .play-hotspot {
  position: absolute;
  width: auto !important;
  height: auto !important;
  min-width: 0;
  min-height: 0;
  overflow: visible;
  padding: 0;
  border: 0 !important;
  border-radius: 0;
  background: transparent !important;
  color: var(--ui-accent, #1676a8);
  box-shadow: none !important;
  cursor: pointer;
  font-size: 25px;
  transform: translate(-50%, -50%);
}

.attempt-page .play-hotspot:disabled {
  opacity: .45;
  cursor: not-allowed;
}

.attempt-page .play-hotspot .ico {
  font-size: 14px;
  line-height: 1;
}

.attempt-page .play-hotspot .hot-label {
  position: absolute;
  bottom: 100%;
  left: 50%;
  padding: 1px 3px;
  background: var(--ui-surface, #fffdf7);
  color: var(--ui-text, #172f42);
  box-shadow: var(--ui-shadow-tiny, 0 1px 3px rgba(23, 47, 66, .20));
  font-size: var(--type-small-font-size, 11px);
  line-height: 1.2;
  transform: translateX(-50%);
  white-space: nowrap;
}

.attempt-page .play-hotspot .hot-count {
  position: absolute;
  top: 50%;
  left: 100%;
  padding: 2px 4px;
  background: var(--ui-text, #172f42);
  color: var(--ui-inverse-text, #fff);
  font-size: var(--type-badge-size, 10px);
  line-height: 1.2;
  transform: translate(5px, -50%);
  white-space: nowrap;
}

.attempt-page .attempt-description {
  margin: 0 0 18px;
  color: var(--ui-muted, #607884);
  line-height: 1.75;
  white-space: pre-line;
}

.attempt-page .attempt-stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0 14px;
}

.attempt-page .stat {
  min-width: 0;
  padding: 14px 0;
  border-bottom: 1px solid var(--ui-row-divider-color, var(--ui-border-color, #bfd0da));
  font: 14px ui-monospace, SFMono-Regular, Menlo, monospace;
}

.attempt-page .stat b {
  color: var(--ui-accent, #1676a8);
  font: 700 10px var(--sans);
  letter-spacing: 0;
}

.attempt-page .stat.mode-stat {
  grid-column: 1 / -1;
}

.attempt-page .attempt-stats .stat:first-child b {
  font-size: clamp(9px, 2.7vw, 10px);
  letter-spacing: 0;
  white-space: nowrap;
}

.attempt-page .attempt-stats .stat:first-child span {
  display: inline-block;
  font-size: clamp(11px, 3.6vw, 14px);
  letter-spacing: 0;
  white-space: nowrap;
}

.attempt-page .finish-box {
  margin-top: 22px;
  padding-top: 3px;
}

.attempt-page .finish-box h3 {
  margin: 0 0 8px;
  color: var(--ui-text, #173044);
  font: 700 22px var(--serif);
}

.attempt-page .finish-box p {
  color: var(--ui-muted, #607884);
  font-size: var(--type-helper-font-size, 12px);
  line-height: 1.6;
}

.attempt-page .finish-box button {
  min-height: var(--ui-control-height, 40px);
  margin-top: 7px;
  padding: 0 var(--ui-button-padding-x, 12px);
  border: 1px solid var(--ui-accent, #1676a8);
  border-radius: var(--ui-control-radius, 3px);
  background: var(--ui-accent, #1676a8);
  color: var(--ui-inverse-text, #fff);
  cursor: pointer;
  font-size: var(--type-button-size, var(--ui-control-font-size, 12px));
  font-weight: var(--type-button-weight, 800);
}

.attempt-page .finish-box button:disabled {
  opacity: var(--ui-button-disabled-opacity, .52);
  cursor: not-allowed;
}

.attempt-page .notice {
  margin-top: 17px;
}

.attempt-page .notice.error {
  border-left-color: var(--ui-danger, #b35243);
  background: var(--ui-danger-bg, #fff1ed);
}

.attempt-page .after {
  margin-top: 20px;
  padding: var(--ui-alert-padding, 12px 14px);
  border: 1px solid var(--ui-accent, #1676a8);
  border-left-width: 4px;
  border-radius: var(--ui-panel-radius, 6px);
  background: var(--ui-info-bg, #edf6f8);
  color: var(--ui-text, #173044);
  font-size: 13px;
  line-height: 1.7;
  white-space: pre-line;
}

.attempt-page .attempt-path {
  display: flex;
  gap: 0;
  flex-wrap: wrap;
  margin: 0 0 9px;
  color: var(--ui-muted, #607884);
  font-size: var(--type-small-font-size, 11px);
  line-height: 1.6;
}

.attempt-page .attempt-path a {
  text-decoration: underline;
  text-underline-offset: 3px;
}

.attempt-page .attempt-path span + span::before {
  content: "/";
  margin: 0 5px;
  color: var(--ui-muted, #607884);
}

.attempt-page .attempt-siblings {
  position: relative;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
}

.attempt-page .attempt-siblings p {
  display: none;
}

.attempt-page .attempt-sibling-menu {
  position: relative;
  display: block;
}

.attempt-page .attempt-sibling-menu summary {
  display: inline-flex;
  align-items: center;
  box-sizing: border-box;
  min-height: var(--ui-control-height, 40px);
  padding: 0 var(--ui-space-3, 12px);
  border: 1px solid var(--ui-border-color, #bfd0da);
  border-radius: var(--ui-control-radius, 3px);
  background: var(--ui-surface, #fffdf7);
  color: var(--ui-text, #173044);
  cursor: pointer;
  font-size: var(--type-helper-font-size, 12px);
  line-height: 1.2;
  list-style: none;
  white-space: nowrap;
}

.attempt-page .attempt-sibling-menu summary::-webkit-details-marker {
  display: none;
}

.attempt-page .attempt-sibling-menu summary::after {
  content: "⌄";
  margin-left: var(--ui-space-2, 8px);
  color: var(--ui-accent, #1676a8);
}

.attempt-page .attempt-sibling-menu > div {
  position: absolute;
  z-index: var(--ui-z-dropdown, 12000);
  right: 0;
  min-width: 220px;
  max-height: 250px;
  overflow: auto;
  border: 1px solid var(--ui-border-strong, #9eb9c5);
  border-top: 0;
  border-radius: 0 0 var(--ui-panel-radius, 6px) var(--ui-panel-radius, 6px);
  background: var(--ui-input-bg, #fff);
  box-shadow: var(--ui-shadow-dropdown, 0 10px 22px rgba(23, 47, 66, .14));
}

.attempt-page .attempt-sibling-menu a {
  display: block;
  padding: var(--ui-field-gap, 10px);
  border-top: 1px solid var(--ui-border-color, #bfd0da);
  color: var(--ui-text, #173044);
  font-size: var(--type-small-font-size, 11px);
}

.attempt-page .attempt-sibling-menu a[aria-current="page"] {
  background: var(--ui-info-bg, #edf6f8);
  color: var(--ui-accent, #1676a8);
  font-weight: 800;
}

.attempt-page .attempt-history-link {
  margin-left: auto;
}

.attempt-page .back-to-top {
  position: fixed !important;
  z-index: 20000 !important;
  right: calc(18px + env(safe-area-inset-right)) !important;
  bottom: calc(18px + var(--back-to-top-footer-offset, 0px) + env(safe-area-inset-bottom)) !important;
  width: 42px;
  height: 42px;
  border: 1px solid var(--ui-border-color, #bfd0da) !important;
  border-radius: 50%;
  background: var(--ui-surface, #fffdf7) !important;
  color: var(--ui-accent, #1676a8) !important;
  box-shadow: var(--ui-shadow-soft, 0 12px 30px rgba(23, 47, 66, .18)) !important;
  cursor: pointer;
  font-size: 20px;
}

.attempt-page .back-to-top[hidden] {
  display: none;
}

.attempt-page .time-progress {
  position: fixed;
  z-index: 30;
  right: 0;
  bottom: 0;
  left: 0;
  height: 10px;
  background: var(--ui-border-color, #bfd0da);
}

.attempt-page .time-progress[hidden] {
  display: none;
}

.attempt-page .time-progress i {
  display: block;
  width: 100%;
  height: 100%;
  transition: width .35s, background .35s;
}

.attempt-page .time-progress.green i {
  background: var(--ui-success, #287048);
}

.attempt-page .time-progress.yellow i {
  background: var(--ui-warning, #c99945);
}

.attempt-page .time-progress.red i {
  background: var(--ui-danger, #b35243);
}

@media (max-width: 850px) {
  .attempt-page {
    padding: 35px 20px 55px;
  }

  .attempt-page .attempt-layout {
    grid-template-columns: 1fr;
  }

  .attempt-page .attempt-layout > aside.attempt-panel {
    position: static;
    max-height: none;
    overflow: visible;
  }

  .attempt-page .attempt-top {
    align-items: flex-start;
    flex-direction: column;
  }
}

@media (max-width: 850px) and (min-width: 600px) and (orientation: landscape) {
  .attempt-page {
    padding: 28px 20px 55px;
  }

  .attempt-page .attempt-layout {
    grid-template-columns: minmax(0, 1fr) 255px;
  }

  .attempt-page .attempt-layout > aside.attempt-panel {
    position: sticky;
    top: 12px;
    max-height: calc(100dvh - 24px);
    overflow: auto;
  }
}

@media (max-width: 820px) {
  .attempt-page .attempt-actions {
    justify-content: flex-start;
    width: 100%;
  }

  .attempt-page .attempt-sibling-menu > div {
    right: auto;
    left: 0;
    min-width: min(290px, calc(100vw - 40px));
  }
}

@media (max-width: 900px) and (orientation: portrait) {
  .attempt-page {
    overflow-x: clip;
    padding-bottom: calc(var(--attempt-dock-height, 166px) + 22px) !important;
  }

  .attempt-page .attempt-layout {
    grid-template-columns: 1fr !important;
  }

  .attempt-page .attempt-top {
    align-items: flex-start;
    flex-direction: column;
  }

  .attempt-page .attempt-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: 100%;
    gap: var(--ui-space-2, 8px);
  }

  .attempt-page .attempt-actions > .mode-pill,
  .attempt-page .attempt-actions > .mode-switch,
  .attempt-page .attempt-actions > .attempt-siblings {
    width: 100%;
    justify-content: center;
    margin-left: 0;
  }

  .attempt-page .attempt-actions > .attempt-siblings .attempt-sibling-menu summary {
    width: 100%;
    justify-content: center;
  }

  .attempt-page .attempt-actions > .attempt-history-link {
    grid-column: 2;
  }

  .attempt-page .attempt-layout > aside.attempt-panel {
    position: fixed !important;
    z-index: 28;
    right: 10px !important;
    bottom: calc(10px + env(safe-area-inset-bottom)) !important;
    left: 10px !important;
    width: auto !important;
    height: auto !important;
    min-height: 0 !important;
    max-height: calc(100dvh - 112px) !important;
    margin: 0 !important;
    padding: 10px 13px !important;
    overflow: auto !important;
    overscroll-behavior: contain;
    box-shadow: var(--ui-shadow-dock, 0 8px 24px rgba(23, 47, 66, .25)) !important;
  }

  .attempt-page .attempt-layout > aside .attempt-stats {
    gap: 0 10px;
  }

  .attempt-page .attempt-layout > aside .stat {
    padding: 6px 0;
    font-size: 12px;
  }

  .attempt-page .attempt-layout > aside .stat.mode-stat,
  .attempt-page .attempt-layout > aside .finish-box h3,
  .attempt-page .attempt-layout > aside .finish-box p {
    display: block !important;
  }

  .attempt-page .attempt-layout > aside .after {
    display: none;
  }

  .attempt-page .attempt-layout > aside .finish-box {
    margin: 7px 0 0;
    padding: 0;
  }

  .attempt-page .attempt-layout > aside .finish-box h3 {
    margin: 0 0 4px;
    font-size: 17px;
  }

  .attempt-page .attempt-layout > aside .finish-box p {
    margin: 0 0 6px;
    font-size: 10px;
  }

  .attempt-page .attempt-layout > aside .finish-box button {
    width: 100%;
    margin: 0;
  }

  .attempt-page .attempt-layout > aside .notice {
    margin: 0 0 6px;
  }

  .attempt-page .back-to-top {
    right: calc(18px + env(safe-area-inset-right)) !important;
    bottom: calc(18px + var(--back-to-top-footer-offset, 0px) + env(safe-area-inset-bottom)) !important;
  }
}
