/* Ranking, start, and result screens. */

.start-screen {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 28px;
  padding: 28px;
  background: rgba(0, 0, 0, 0.9);
  text-align: center;
  transition:
    opacity 160ms ease,
    visibility 160ms ease;
}

.start-screen.is-hidden {
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
}

.title-logo {
  display: block;
  width: min(92vw, 1440px);
  max-height: min(78vh, 890px);
  object-fit: contain;
}

.primary-start {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  min-width: 172px;
  min-height: 50px;
  border: 0;
  border-radius: 999px;
  background: #fff;
  color: #000;
  padding: 0 34px;
  font-size: 18px;
  font-weight: 900;
  letter-spacing: 0;
  cursor: pointer;
}

.primary-start.is-loading::after {
  content: '';
  width: 14px;
  height: 14px;
  border: 2px solid rgba(0, 0, 0, 0.22);
  border-top-color: #000;
  border-radius: 50%;
  animation: start-loading-spin 720ms linear infinite;
}

@keyframes start-loading-spin {
  to {
    transform: rotate(360deg);
  }
}

.primary-start:hover,
.primary-start:focus-visible {
  background: #e6e6e6;
}

.primary-start:disabled {
  cursor: default;
  opacity: 0.65;
}

.run-hud {
  position: absolute;
  top: 12px;
  left: 50%;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transform: translateX(-50%);
  pointer-events: none;
}

.run-hud-item {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  min-width: 74px;
  min-height: 28px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.52);
  color: #fff;
  padding: 0 8px;
  font-size: 14px;
  font-weight: 850;
  line-height: 1;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(5px);
}

.run-hud-item svg {
  width: 17px;
  height: 17px;
  flex: 0 0 auto;
  stroke: #fff;
  stroke-width: 2.25;
  stroke-linecap: round;
  stroke-linejoin: round;
  fill: none;
}

.run-hud-item svg .skull-eye {
  fill: #fff;
}

.encouragement-bubbles {
  position: absolute;
  inset: 0;
  z-index: 5;
  overflow: hidden;
  pointer-events: none;
}

.encouragement-bubbles[hidden] {
  display: none;
}

.encouragement-bubble {
  position: absolute;
  top: 0;
  left: 0;
  display: grid;
  gap: 6px;
  max-width: 270px;
  min-width: 144px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 20px;
  background: rgba(18, 18, 18, 0.62);
  color: rgba(255, 255, 255, 0.9);
  padding: 14px 17px;
  box-shadow: 0 20px 42px rgba(0, 0, 0, 0.3);
  font: inherit;
  text-align: left;
  cursor: grab;
  pointer-events: auto;
  touch-action: none;
  transition:
    opacity 160ms ease,
    filter 160ms ease;
  will-change: transform;
}

.encouragement-bubble::after {
  content: '';
  position: absolute;
  left: 27px;
  bottom: -10px;
  width: 19px;
  height: 19px;
  border-right: 1px solid rgba(255, 255, 255, 0.2);
  border-bottom: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(18, 18, 18, 0.62);
  transform: rotate(45deg);
}

.encouragement-bubble:hover,
.encouragement-bubble.is-paused {
  filter: brightness(1.18);
}

.encouragement-bubble.is-dragging {
  z-index: 2;
  cursor: grabbing;
  filter: brightness(1.2);
}

.encouragement-bubble span,
.encouragement-bubble small {
  position: relative;
  z-index: 1;
  overflow: hidden;
  white-space: nowrap;
}

.encouragement-bubble span {
  font-size: 19px;
  font-weight: 850;
}

.encouragement-bubble.is-message-long span {
  font-size: 15px;
}

.encouragement-bubble.is-message-very-long span {
  font-size: 11px;
}

.encouragement-bubble small {
  color: rgba(255, 255, 255, 0.64);
  font-size: 15px;
  font-weight: 700;
}

.difficulty-warning {
  position: absolute;
  top: 50%;
  left: 50%;
  z-index: 6;
  max-width: min(82vw, 760px);
  padding: 18px 34px;
  border: 1px solid rgba(255, 255, 255, 0.32);
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.72);
  color: #fff;
  font-size: clamp(34px, 5vw, 72px);
  font-weight: 950;
  letter-spacing: 0;
  text-align: center;
  text-shadow: 0 4px 22px rgba(0, 0, 0, 0.8);
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, -50%) scale(0.94);
}

.boss-heal-notice {
  position: absolute;
  top: 18%;
  left: 50%;
  z-index: 6;
  min-width: 112px;
  padding: 10px 22px;
  border: 1px solid rgba(255, 255, 255, 0.34);
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.68);
  color: #fff;
  font-size: clamp(24px, 3vw, 42px);
  font-weight: 950;
  letter-spacing: 0;
  text-align: center;
  text-shadow: 0 3px 16px rgba(0, 0, 0, 0.82);
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 12px) scale(0.96);
}

.boss-heal-notice.is-visible {
  animation: boss-heal-notice-pop 1.2s ease both;
}

.difficulty-warning.is-visible {
  animation: difficulty-warning-pop 2s ease both;
}

@keyframes boss-heal-notice-pop {
  0% {
    opacity: 0;
    transform: translate(-50%, 14px) scale(0.9);
  }

  22%,
  68% {
    opacity: 1;
    transform: translate(-50%, 0) scale(1);
  }

  100% {
    opacity: 0;
    transform: translate(-50%, -20px) scale(1.04);
  }
}

@keyframes difficulty-warning-pop {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.88);
  }

  16%,
  72% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
  }

  100% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(1.03);
  }
}

.result-screen {
  position: absolute;
  inset: 0;
  z-index: 4;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 6px;
  padding: 18px;
  background: rgba(0, 0, 0, 0.9);
  color: #fff;
  overflow: auto;
}

.result-title-top {
  display: block;
  width: min(30vw, 250px);
  max-height: 15vh;
  object-fit: contain;
}

.result-title-bottom {
  display: block;
  width: min(54vw, 420px);
  max-height: 14vh;
  object-fit: contain;
}

.result-version-button {
  position: fixed;
  right: max(12px, env(safe-area-inset-right));
  bottom: max(10px, env(safe-area-inset-bottom));
  z-index: 7;
  padding: 4px 6px;
  border: 0;
  background: transparent;
  color: rgba(255, 255, 255, 0.48);
  font-size: 10px;
  font-weight: 750;
  letter-spacing: 0.04em;
  cursor: pointer;
}

.result-version-button:hover,
.result-version-button:focus-visible {
  color: rgba(255, 255, 255, 0.9);
  text-decoration: underline;
}

.update-history-modal {
  position: fixed;
  z-index: 40;
  inset: 0;
  display: grid;
  padding: 20px;
  place-items: center;
  background: rgba(0, 0, 0, 0.72);
  backdrop-filter: blur(5px);
}

.update-history-dialog {
  width: min(520px, calc(100vw - 32px));
  max-height: min(76vh, 640px);
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 10px;
  background: rgba(14, 15, 20, 0.98);
  color: #fff;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.56);
}

.update-history-dialog > header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.16);
}

.update-history-dialog h2 {
  margin: 0;
  font-size: 19px;
}

.update-history-dialog > header button {
  display: grid;
  width: 32px;
  height: 32px;
  padding: 0;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
}

.update-history-list {
  display: grid;
  gap: 14px;
  max-height: calc(min(76vh, 640px) - 65px);
  overflow: auto;
  padding: 16px 18px 20px;
  color: rgba(255, 255, 255, 0.72);
  font-size: 14px;
}

.update-history-list article {
  padding: 14px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.05);
}

.update-history-list h3,
.update-history-list p {
  margin: 0;
}

.update-history-list h3 {
  display: flex;
  align-items: baseline;
  gap: 7px;
  color: #fff;
  font-size: 18px;
}

.update-history-list h3 small {
  color: rgba(255, 255, 255, 0.44);
  font-size: 11px;
  font-weight: 650;
}

.update-history-list p {
  margin-top: 4px;
  color: rgba(255, 255, 255, 0.86);
  font-weight: 750;
}

.update-history-list ul {
  display: grid;
  gap: 7px;
  margin: 12px 0 0;
  padding-left: 20px;
}

.result-panel {
  display: grid;
  grid-template-columns: minmax(250px, 0.95fr) minmax(280px, 1.15fr) 86px;
  gap: 12px;
  align-items: stretch;
  width: min(860px, calc(100vw - 36px));
  max-height: min(58vh, 540px);
  padding: 14px;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 6px;
  background: rgba(14, 14, 14, 0.96);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.5);
  overflow: hidden;
}

.ranking-board,
.score-register,
.result-actions {
  min-width: 0;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 6px;
  background: rgba(26, 26, 26, 0.92);
}

.ranking-board {
  overflow: hidden;
}

.ranking-board,
.score-register {
  padding: 12px;
}

.ranking-board h2 {
  margin: 0 0 8px;
  color: #fff;
  font-size: 18px;
}

.ranking-list {
  display: grid;
  gap: 4px;
  margin: 0;
  padding: 0;
  list-style-position: inside;
  font-size: 12px;
}

.ranking-list li {
  display: grid;
  grid-template-columns: 20px minmax(0, 1fr);
  gap: 2px;
  min-height: 34px;
  padding: 4px 6px;
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.07);
}

.ranking-list b {
  grid-row: 1 / 4;
  color: #fff;
  font-size: 13px;
}

.ranking-list div {
  display: flex;
  justify-content: space-between;
  gap: 8px;
}

.ranking-list strong,
.ranking-list span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ranking-list p,
.ranking-list small {
  margin: 0;
  color: #bcbcbc;
  font-size: 10px;
  line-height: 1.15;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ranking-empty {
  display: block;
  color: #bcbcbc;
}

.score-total,
.score-breakdown {
  display: grid;
  gap: 8px;
  margin: 0;
}

.score-total {
  margin-bottom: 8px;
}

.score-breakdown {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-bottom: 14px;
}

.score-total div,
.score-breakdown div {
  display: grid;
  gap: 4px;
  padding: 10px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.08);
}

.score-total dt,
.score-breakdown dt {
  color: #bcbcbc;
  font-size: 12px;
  text-align: center;
}

.score-total dd,
.score-breakdown dd {
  margin: 0;
  color: #fff;
  font-size: 20px;
  font-weight: 850;
  text-align: center;
}

.score-total dd {
  font-size: 40px;
  line-height: 1.1;
}

.ranking-form {
  display: grid;
  gap: 10px;
}

.ranking-form label {
  display: grid;
  gap: 5px;
  color: #d8d8d8;
  font-size: 13px;
}

.ranking-form input,
.ranking-form textarea {
  width: 100%;
  border: 1px solid #5a5a5a;
  border-radius: 5px;
  background: #0e0e0e;
  color: #fff;
  padding: 9px 10px;
  resize: none;
}

.ranking-form button {
  min-height: 40px;
  border: 0;
  border-radius: 999px;
  background: #fff;
  color: #000;
  font-weight: 850;
  cursor: pointer;
}

.ranking-form button:disabled {
  cursor: default;
  opacity: 0.58;
}

.result-actions {
  display: grid;
  align-content: center;
  gap: 10px;
  padding: 12px;
}

.icon-action {
  display: grid;
  place-items: center;
  min-width: 0;
  min-height: 64px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  text-decoration: none;
  cursor: pointer;
}

.icon-action svg {
  width: 32px;
  height: 32px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.icon-action img {
  width: 36px;
  height: 36px;
  border-radius: 6px;
}

.icon-action[href$='instagram.com/govy9807'] img,
.icon-action[href$='x.com/govy9807'] img {
  color: #fff;
  border-radius: 0;
  filter: grayscale(1);
}

.icon-action span {
  font-weight: 900;
}

.lezhin-action {
  padding: 0;
}

@media (max-width: 820px) {
  .start-screen {
    grid-template-columns: minmax(0, 1fr);
  }

  .start-screen picture {
    display: grid;
    width: 100%;
    place-items: center;
  }

  .start-screen .title-logo {
    justify-self: center;
    transform: translate(-10px, -3px);
  }

  .start-screen .primary-start {
    justify-self: center;
  }

  .encouragement-bubbles {
    display: none !important;
  }

  .result-panel {
    grid-template-columns: 1fr;
    max-height: 72vh;
    overflow: auto;
  }

  .score-register {
    order: 1;
  }

  .result-actions {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    order: 2;
  }

  .ranking-board {
    order: 3;
    overflow: visible;
  }
}

@media (max-width: 560px) {
  .start-screen {
    gap: 22px;
    padding: 22px;
  }

  .title-logo {
    width: min(96vw, 1120px);
    max-height: 72vh;
  }

  .primary-start {
    min-height: 44px;
    font-size: 16px;
  }

  .result-screen {
    gap: 4px;
    padding: 10px;
  }

  .result-title-top {
    width: min(46vw, 180px);
    max-height: 12vh;
  }

  .result-title-bottom {
    width: min(74vw, 320px);
    max-height: 10vh;
  }

  .encouragement-bubble {
    max-width: 220px;
    min-width: 124px;
    padding: 10px 12px;
    border-radius: 16px;
  }

  .encouragement-bubble span {
    font-size: 15px;
  }

  .encouragement-bubble.is-message-long span {
    font-size: 12px;
  }

  .encouragement-bubble.is-message-very-long span {
    font-size: 9px;
  }

  .encouragement-bubble small {
    font-size: 12px;
  }

  .result-panel {
    grid-template-columns: 1fr;
    gap: 10px;
    padding: 10px;
    max-height: 70vh;
    overflow: auto;
  }

  .ranking-board,
  .score-register {
    padding: 12px;
  }

  .ranking-list {
    font-size: 12px;
  }

  .result-actions {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    padding: 8px;
  }

  .icon-action {
    min-height: 54px;
  }
}
