/* Aligned with song-select-screen: #120820, 64px grid, HUD, info-bar panels */

.root {
  --endgame-accent: #d946ef;
  --endgame-highlight: #f0abfc;

  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  /* Fill the viewport like SongSelectScreen; avoid negative margins that cause overflow */
  height: 100vh;
  height: 100dvh;
  margin: 0;
  padding: 0.75rem clamp(1rem, 3vw, 2.5rem) 1rem;
  background-color: #120820;
  color: #ffffff;
  overflow: hidden;
  box-sizing: border-box;
}

.root::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(to right, rgba(255, 255, 255, 0.06) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(255, 255, 255, 0.06) 1px, transparent 1px);
  background-size: 64px 64px;
  pointer-events: none;
  z-index: 0;
}

.hud {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
}

.hudCorner {
  position: absolute;
  width: 40px;
  height: 40px;
  border-color: var(--endgame-highlight);
  border-style: solid;
  border-width: 0;
  opacity: 0.65;
}

.hudCornerTl {
  top: 16px;
  left: 16px;
  border-top-width: 2px;
  border-left-width: 2px;
}

.hudCornerTr {
  top: 16px;
  right: 16px;
  border-top-width: 2px;
  border-right-width: 2px;
}

.hudCornerBl {
  bottom: 16px;
  left: 16px;
  border-bottom-width: 2px;
  border-left-width: 2px;
}

.hudCornerBr {
  bottom: 16px;
  right: 16px;
  border-bottom-width: 2px;
  border-right-width: 2px;
}

.hudCounter {
  position: absolute;
  top: 20px;
  right: 44px;
  font-size: 14px;
  letter-spacing: 0.22em;
  opacity: 0.9;
}

.hudMeta {
  position: absolute;
  bottom: 16px;
  font-size: 13px;
  letter-spacing: 0.2em;
  opacity: 0.85;
}

.hudMetaLeft {
  composes: hudMeta;
  left: 22px;
}

.hudMetaRight {
  composes: hudMeta;
  right: 22px;
}

.inner {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  width: min(980px, 100%);
  gap: clamp(0.5rem, 1.5vw, 1rem);
}

.screenTitle {
  margin: 0;
  text-align: center;
  letter-spacing: 0.32em;
  font-size: var(--font-size-title);
  color: #ffffff;
  text-shadow: 0 0 24px rgb(255 255 255 / 0.25);
}

/* —— Hero score (arcade attract / final tally) —— */
.scoreHero {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  padding: 0;
}

.scoreHeroLabel {
  color: rgb(255 255 255 / 0.55);
  letter-spacing: 0.28em;
}

.scoreHeroValue {
  margin: 0;
  font-size: clamp(3rem, 10vw, 5.5rem);
  line-height: 0.95;
  letter-spacing: 0.02em;
  font-variant-numeric: tabular-nums;
  color: #ffffff;
  text-shadow:
    0 0 20px var(--endgame-highlight),
    0 0 48px rgb(240 171 252 / 0.55),
    0 0 96px rgb(217 70 239 / 0.35),
    0 0 140px rgb(217 70 239 / 0.2);
  filter: drop-shadow(0 0 28px rgb(217 70 239 / 0.45));
}

/* —— Song-info-bar style summary —— */
.summaryBar {
  display: grid;
  grid-template-columns: auto 1fr;
  grid-template-rows: auto auto;
  gap: 12px 28px;
  align-items: center;
  width: 100%;
  padding: 16px 18px;
  border: 1px solid;
  box-sizing: border-box;
}

.summaryGradeCol {
  grid-row: 1 / -1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding-right: 8px;
  border-right: 1px solid rgb(255 255 255 / 0.15);
}

.summaryStatLabel {
  font-size: 11px;
  letter-spacing: 0.2em;
  color: rgb(255 255 255 / 0.65);
}

.summaryGradeBadge {
  display: flex;
  align-items: center;
  justify-content: center;
  width: clamp(4.25rem, 10vw, 5.5rem);
  height: clamp(4.25rem, 10vw, 5.5rem);
  border-radius: 0.5rem;
  font-size: clamp(2rem, 4.5vw, 2.85rem);
  line-height: 1;
  font-family: var(--font-family-display);
  font-weight: var(--font-weight-black);
  border: 2px solid currentColor;
}

.summaryStats {
  display: flex;
  flex-wrap: wrap;
  gap: 24px 36px;
  align-items: flex-end;
}

.summaryStat {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 4.5rem;
}

.summaryStatNum {
  font-size: clamp(1.65rem, 3.2vw, 2.15rem);
  line-height: 1;
  font-variant-numeric: tabular-nums;
  transition:
    transform 0.2s ease,
    filter 0.2s ease,
    text-shadow 0.2s ease;
}

.summaryStatLead {
  transform: scale(1.1);
}

.summaryNotes {
  grid-column: 2;
  margin: 0;
  letter-spacing: 0.18em;
  color: rgb(255 255 255 / 0.4);
}

.judgmentPerfect {
  color: #ffd700;
  text-shadow: 0 0 12px rgb(255 215 0 / 0.5);
}

.judgmentGood {
  color: #86efac;
  text-shadow: 0 0 12px rgb(134 239 172 / 0.45);
}

.judgmentMiss {
  color: #fb7185;
  text-shadow: 0 0 12px rgb(251 113 133 / 0.5);
}

.summaryStatLead.judgmentPerfect {
  filter: drop-shadow(0 0 8px rgb(255 215 0 / 0.55));
}

.summaryStatLead.judgmentGood {
  filter: drop-shadow(0 0 8px rgb(134 239 172 / 0.5));
}

.summaryStatLead.judgmentMiss {
  filter: drop-shadow(0 0 8px rgb(251 113 133 / 0.55));
}

@keyframes gradeSlam {
  0% {
    transform: translateY(-200%) rotate(-5deg) scale(1.15);
    filter: brightness(1.25);
  }
  48% {
    transform: translateY(10%) rotate(2deg) scale(0.92, 1.1);
    filter: brightness(1.45);
  }
  62% {
    transform: translateY(-5%) scale(1.04, 0.96);
  }
  100% {
    transform: translateY(0) rotate(0) scale(1);
    filter: brightness(1);
  }
}

.gradeSlam {
  animation: gradeSlam 0.52s cubic-bezier(0.22, 1, 0.25, 1) both;
}

@media (prefers-reduced-motion: reduce) {
  .gradeSlam {
    animation: none;
  }
}

.summaryGradeBadge[data-grade='S'] {
  color: #ffd700;
  background: rgb(255 215 0 / 0.12);
  box-shadow: 0 0 18px rgb(255 215 0 / 0.45);
}

.summaryGradeBadge[data-grade='A'] {
  color: #86efac;
  background: rgb(134 239 172 / 0.1);
  box-shadow: 0 0 16px rgb(134 239 172 / 0.4);
}

.summaryGradeBadge[data-grade='B'] {
  color: #e9d5ff;
  background: rgb(233 213 255 / 0.12);
  box-shadow: 0 0 16px rgb(233 213 255 / 0.35);
}

.summaryGradeBadge[data-grade='C'] {
  color: #fde047;
  background: rgb(253 224 71 / 0.1);
  box-shadow: 0 0 14px rgb(253 224 71 / 0.35);
}

.summaryGradeBadge[data-grade='D'] {
  color: #fb923c;
  background: rgb(251 146 60 / 0.1);
  box-shadow: 0 0 14px rgb(251 146 60 / 0.35);
}

.summaryGradeBadge[data-grade='F'] {
  color: #fb7185;
  background: rgb(251 113 133 / 0.1);
  box-shadow: 0 0 14px rgb(251 113 133 / 0.35);
}

.summaryGradeBadge[data-grade='other'] {
  color: #d4d4d8;
  background: rgb(212 212 216 / 0.1);
}

/* —— Form + arcade name entry —— */
.form {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  width: 100%;
  gap: 14px;
  margin-top: 0.25rem;
}

.nameBar {
  padding: 16px 18px;
  border: 1px solid;
  box-sizing: border-box;
}

.nameBarHeader {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
}

.nameBarTitle {
  margin: 0;
  font-size: var(--font-size-display-lg);
  line-height: 1.05;
  letter-spacing: 0.06em;
  color: #ffffff;
}

.nameBarSub {
  letter-spacing: 0.2em;
  color: rgb(255 255 255 / 0.5);
}

.nameInputHidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
  opacity: 0;
}

.nameSlots {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 8px;
  justify-content: center;
  padding: 12px 10px;
  background: rgb(0 0 0 / 0.35);
  border: 2px solid rgb(255 255 255 / 0.22);
  cursor: text;
  outline: none;
}

.nameSlots:focus-within {
  border-color: var(--endgame-highlight);
  box-shadow: 0 0 0 1px var(--endgame-highlight), 0 0 22px rgb(240 171 252 / 0.25);
}

.nameSlot {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  position: relative;
  min-width: 2.15rem;
  height: 2.65rem;
  padding: 0 0.35rem;
  font-size: 1.55rem;
  font-weight: var(--font-weight-black);
  line-height: 1;
  color: #ffffff;
  background: rgb(0 0 0 / 0.55);
  border: 2px solid rgb(255 255 255 / 0.35);
  box-shadow:
    inset 0 2px 0 rgb(255 255 255 / 0.08),
    0 2px 0 rgb(0 0 0 / 0.4);
  font-variant-numeric: tabular-nums;
}

.nameSlotActive {
  border-color: var(--endgame-highlight);
  background: rgb(217 70 239 / 0.12);
  box-shadow:
    inset 0 0 12px rgb(240 171 252 / 0.15),
    0 0 14px rgb(217 70 239 / 0.35);
}

@keyframes caretBlink {
  0%,
  45% {
    opacity: 1;
  }
  50%,
  100% {
    opacity: 0;
  }
}

.nameCaret {
  position: absolute;
  bottom: 6px;
  left: 50%;
  width: 70%;
  height: 3px;
  margin-left: -35%;
  background: var(--endgame-highlight);
  animation: caretBlink 0.85s step-end infinite;
}

@media (prefers-reduced-motion: reduce) {
  .nameCaret {
    animation: none;
    opacity: 1;
  }
}

.arcadeConfirm {
  border: 0;
  padding: 14px 28px;
  font-size: 20px;
  font-weight: 800;
  letter-spacing: 0.14em;
  cursor: pointer;
  text-transform: uppercase;
  align-self: center;
  min-width: min(100%, 320px);
  transition:
    transform 0.12s ease,
    filter 0.2s ease;
}

.arcadeConfirm:hover:not(:disabled) {
  filter: brightness(1.08);
}

.arcadeConfirm:active:not(:disabled) {
  transform: scale(0.99);
}

.arcadeConfirm:disabled {
  cursor: wait;
  opacity: 0.75;
}

.error {
  margin: 0;
  font-size: var(--font-size-caption);
  color: #fda4af;
  text-align: center;
  letter-spacing: 0.06em;
}

.bottomActions {
  display: flex;
  gap: 1.5rem;
  justify-content: center;
  align-self: center;
  margin-top: 0;
}

.skip {
  background: none;
  border: none;
  padding: 0.4rem;
  letter-spacing: 0.22em;
  color: rgb(255 255 255 / 0.38);
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 4px;
}

.skip:hover {
  color: rgb(255 255 255 / 0.65);
}

@media (max-width: 720px) {
  .summaryBar {
    grid-template-columns: 1fr;
    grid-template-rows: auto;
  }

  .summaryGradeCol {
    grid-row: auto;
    flex-direction: row;
    justify-content: center;
    padding-right: 0;
    padding-bottom: 12px;
    border-right: none;
    border-bottom: 1px solid rgb(255 255 255 / 0.12);
  }

  .summaryNotes {
    grid-column: 1;
    text-align: center;
  }

  .summaryStats {
    justify-content: space-around;
    width: 100%;
  }

  .hudCounter,
  .hudMetaLeft,
  .hudMetaRight {
    font-size: 11px;
  }

  .nameSlot {
    min-width: 1.85rem;
    height: 2.35rem;
    font-size: 1.3rem;
  }
}
