/* Shared ending-screen composition for every playable level. */
#successScreen,
#level02Success,
#level03Success,
#level04Success,
#level05Success,
#level06Success {
  background: #17383b;
}

.ending-panel {
  inset: 0;
  justify-content: flex-start;
  padding: clamp(120px, 25vh, 210px) 16px 24px;
  overflow-y: auto;
  scrollbar-width: none;
}

.ending-panel::-webkit-scrollbar { display: none; }

.ending-panel > small {
  color: #555653;
  font-size: 12px;
  line-height: 1;
  letter-spacing: .2em;
}

.ending-panel h2,
.l2-success-panel h2,
.l3-success-panel h2,
.l4-success-panel h2,
.l5-success-panel h2,
.l6-success-panel h2 {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  width: 100%;
  min-height: 2.1em;
  margin: 12px 0 28px;
  color: #fff7e8;
  font: 700 clamp(35px, 9vw, 43px)/1.05 Georgia, serif;
}

.ending-art,
.hand-moment.ending-art,
.l2-success-animation.ending-art,
.l3-success-animation.ending-art,
.l4-success-art.ending-art,
.l5-success-art.ending-art,
.l6-success-art.ending-art {
  position: relative;
  flex: 0 0 auto;
  align-self: center;
  width: 100%;
  height: auto;
  margin: 0 0 20px;
  border: 4px solid #17383b;
  box-shadow: 6px 6px 0 #d68576;
  overflow: hidden;
}

.hand-moment.ending-art,
.l2-success-animation.ending-art,
.l3-success-animation.ending-art {
  aspect-ratio: 3 / 2;
  max-height: none;
}

.l4-success-art.ending-art-portrait {
  width: min(100%, 300px);
  aspect-ratio: 3 / 4;
}

.ending-panel .complete {
  margin: 0 0 17px;
  color: #fff7e8;
  font-size: 13px;
  line-height: 1.2;
  letter-spacing: .17em;
}

.ending-panel .primary {
  flex: 0 0 auto;
  margin: 0 0 14px;
}

.ending-panel .secondary { flex: 0 0 auto; }

@media (max-height: 760px) {
  .ending-panel { padding-top: 96px; }
  .ending-panel h2,
  .l2-success-panel h2,
  .l3-success-panel h2,
  .l4-success-panel h2,
  .l5-success-panel h2 { margin-bottom: 18px; font-size: 34px; }
  .l4-success-art.ending-art-portrait { width: min(100%, 250px); }
}

/* Level 03 has three ending actions; use its upper blank space on phones. */
#level03Success .l3-success-panel {
  padding: clamp(48px, 10vh, 100px) 14px 18px;
}

#level03Success .l3-ending-link {
  min-height: 48px;
  margin: 0 0 9px;
  padding: 11px 14px;
  background: #d68576;
  color: #fff;
  border: 0;
}

#level03Success .return-level-select { margin: 0; }

/* Keep Level 05's final story and both actions within a short phone viewport. */
#level05Success .l5-success-panel {
  padding: clamp(40px, 8vh, 72px) 14px 18px;
}

/* Level 04's portrait story needs room for both actions on a phone. */
#level04Success .l4-success-panel {
  padding: clamp(24px, 8vh, 72px) 14px 18px;
}

#level04Success .l4-success-panel h2 {
  min-height: 0;
  margin: 8px 0 14px;
  font-size: clamp(29px, 9vw, 42px);
}

#level04Success .l4-success-art.ending-art-portrait {
  width: min(100%, 300px, calc(75dvh - 290px));
  margin-bottom: 14px;
}

#level04Success .l4-success-panel .complete { margin-bottom: 12px; }
#level04Success .l4-success-panel .primary { margin: 0 0 8px; padding: 14px 16px; }
#level04Success .l4-success-panel .secondary { margin: 0; padding: 10px 14px; }

/* Every failed mini game uses the full cream canvas from Level 06. */
#game .screen[id$="Fail"].active {
  display: flex;
  align-items: center;
  justify-content: center;
  overflow-y: auto;
  background: #fff7e8;
}

#game .screen[id$="Fail"] .success-panel {
  position: relative;
  inset: auto;
  flex: 0 0 auto;
  width: 100%;
  max-width: 480px;
  margin: auto;
  padding: 28px 29px;
  border: 0;
  background: transparent;
  box-shadow: none;
  color: #555653;
}

#game .screen[id$="Fail"] .success-panel > small,
#game .screen[id$="Fail"] .success-panel h2,
#game .screen[id$="Fail"] .success-panel p,
#game .screen[id$="Fail"] .success-panel .complete {
  color: #555653;
}

#game .screen[id$="Fail"] .success-panel h2 {
  margin: 9px 0 8px;
  font: 700 clamp(34px, 9.5vw, 45px)/1.08 Georgia, serif;
}

#game .screen[id$="Fail"] .success-panel p {
  margin: 10px 0 15px;
  font-size: 16px;
  line-height: 1.45;
}

#game .screen[id$="Fail"] .success-panel .complete {
  margin: 0 0 17px;
}

#game .screen[id$="Fail"] .success-panel .primary {
  flex: 0 0 auto;
  min-height: 52px;
  margin: 0 0 9px;
}

#game .screen[id$="Fail"] .success-panel .secondary {
  flex: 0 0 auto;
  min-height: 45px;
  margin: 9px 0 0;
  color: #555653;
  border-color: #555653;
}
