/* Screens ------------------------------------------------------------------ */

.screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: calc(16px + var(--safe-top)) calc(16px + var(--safe-right)) calc(16px + var(--safe-bottom)) calc(16px + var(--safe-left));
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.25s ease, visibility 0s linear 0.25s;
}

.screen.visible {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transition: opacity 0.25s ease;
}

.screen-title,
.screen-menu {
  background: radial-gradient(ellipse at center, rgba(0, 0, 0, 0) 35%, rgba(0, 0, 0, 0.55) 100%);
}

.screen-title {
  cursor: pointer;
}

.screen-panel {
  background: rgba(0, 0, 0, 0.45);
}

.version {
  position: absolute;
  left: calc(10px + var(--safe-left));
  bottom: calc(8px + var(--safe-bottom));
  font-size: 16px;
  color: #dddddd;
  text-shadow: 2px 2px 0 var(--text-shadow);
}

/* Logo ------------------------------------------------------------------------ */

.logo {
  position: relative;
  text-align: center;
  line-height: 1;
}

.logo-main {
  display: block;
  width: min(760px, 86vw);
  height: auto;
  margin: 0 auto;
  image-rendering: pixelated;
  filter: drop-shadow(0 12px 18px rgba(0, 0, 0, 0.45));
}

.logo-sub {
  margin-top: 18px;
  font: 400 clamp(18px, 3.2vw, 30px) var(--font);
  color: #ffd84a;
  text-shadow: 3px 3px 0 #5a3f00;
}

.logo-small .logo-main {
  width: min(560px, 70vw);
}

.logo-small .logo-sub {
  font-size: clamp(16px, 2.6vw, 24px);
  margin-top: 12px;
}

.splash {
  position: absolute;
  right: -4%;
  bottom: 28%;
  font: 400 clamp(18px, 3vw, 30px) var(--font);
  color: var(--yellow);
  text-shadow: 3px 3px 0 #3f3f00;
  rotate: -16deg;
  animation: splash-pulse 0.55s ease-in-out infinite alternate;
  white-space: nowrap;
}

@keyframes splash-pulse {
  from { scale: 1; }
  to { scale: 1.09; }
}

.title-prompt {
  margin-top: 6vh;
  padding: 6px 16px;
  background: rgba(0, 0, 0, 0.45);
  font-size: clamp(18px, 2.6vw, 26px);
  color: #ffffff;
  text-shadow: 2px 2px 0 var(--text-shadow);
}

.blink {
  animation: blink 1.2s steps(2, jump-none) infinite;
}

@keyframes blink {
  50% { opacity: 0.55; }
}

/* Buttons --------------------------------------------------------------------- */

.mc-button {
  appearance: none;
  font: 400 clamp(18px, 2.4vw, 22px) var(--font);
  color: #ffffff;
  text-shadow: 2px 2px 0 var(--text-shadow);
  min-width: 180px;
  height: 48px;
  padding: 0 22px;
  border: 2px solid #000;
  background: linear-gradient(#8b8b8b, #6c6c6c);
  box-shadow: inset 2px 2px 0 rgba(255, 255, 255, 0.35), inset -2px -3px 0 rgba(0, 0, 0, 0.35);
  cursor: pointer;
  white-space: nowrap;
  touch-action: manipulation;
}

.mc-button:hover,
.mc-button:focus-visible {
  outline: none;
  color: #ffffa0;
  background: linear-gradient(#94a1dc, #6a76b6);
}

.mc-button:active {
  transform: translateY(1px);
  box-shadow: inset -2px -2px 0 rgba(255, 255, 255, 0.2), inset 2px 3px 0 rgba(0, 0, 0, 0.4);
}

.mc-button-wide {
  width: min(400px, 82vw);
}

.mc-button-primary {
  background: linear-gradient(#6fbf4a, #3f8a2a);
}

.mc-button-primary:hover,
.mc-button-primary:focus-visible {
  background: linear-gradient(#85d65e, #4c9e33);
}

.mc-button-danger {
  background: linear-gradient(#c65a4a, #8f3326);
}

.mc-button-danger:hover,
.mc-button-danger:focus-visible {
  background: linear-gradient(#d86b5a, #a33f30);
}

.menu-buttons {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 5vh;
}

.menu-hint {
  max-width: 420px;
  text-align: center;
  font-size: 16px;
  color: var(--yellow);
  text-shadow: 2px 2px 0 #3f3f00;
}

/* Slider --------------------------------------------------------------------------- */

.mc-slider {
  position: relative;
  height: 48px;
  min-width: 240px;
  border: 2px solid #000;
  background: #2f2f2f;
  box-shadow: inset 0 0 0 2px #1c1c1c;
  cursor: pointer;
  touch-action: none;
}

.mc-slider:focus-visible {
  outline: 2px solid #ffffa0;
}

.mc-slider-handle {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 16px;
  background: linear-gradient(#9a9a9a, #6c6c6c);
  border-left: 2px solid #000;
  border-right: 2px solid #000;
  box-shadow: inset 2px 2px 0 rgba(255, 255, 255, 0.35);
}

.mc-slider-text {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font: 400 clamp(16px, 2.2vw, 20px) var(--font);
  text-shadow: 2px 2px 0 var(--text-shadow);
  pointer-events: none;
}

/* Panels ------------------------------------------------------------------------------- */

.panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  max-width: 94vw;
  max-height: calc(100dvh - 32px - var(--safe-top) - var(--safe-bottom));
  overflow-y: auto;
  padding: 22px 26px;
  background: var(--panel);
  border: 3px solid #000;
  box-shadow: inset 0 0 0 3px rgba(255, 255, 255, 0.1);
  animation: panel-in 0.25s ease-out;
}

.panel-wide {
  width: min(860px, 94vw);
}

@keyframes panel-in {
  from { transform: translateY(12px) scale(0.98); opacity: 0; }
}

.panel h2 {
  margin: 0 0 8px;
  font-weight: 400;
  font-size: clamp(24px, 3.4vw, 34px);
  text-shadow: 3px 3px 0 var(--text-shadow);
}

.panel-text {
  margin: 0 0 8px;
  max-width: 460px;
  text-align: center;
  font-size: 18px;
  line-height: 1.5;
  white-space: pre-line;
  text-shadow: 2px 2px 0 var(--text-shadow);
}

.settings-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  width: 100%;
}

.settings-grid > * {
  width: 100%;
  min-width: 0;
}

.settings-footer {
  display: flex;
  gap: 10px;
  margin-top: 8px;
  flex-wrap: wrap;
  justify-content: center;
}

@media (max-width: 640px) {
  .settings-grid {
    grid-template-columns: 1fr;
  }
}

.credits-authors {
  margin: 0;
  font-size: 22px;
}

.credits-outro {
  margin: 0 0 10px;
  font-size: 24px;
  color: var(--yellow);
  text-shadow: 3px 3px 0 #3f3f00;
  animation: splash-pulse 0.55s ease-in-out infinite alternate;
}

.credits-link {
  margin: -4px 0 8px;
  padding: 6px 12px;
  font-size: 20px;
  color: var(--yellow);
  text-shadow: 2px 2px 0 #3f3f00;
  text-decoration: underline;
  text-underline-offset: 4px;
  pointer-events: auto;
  touch-action: manipulation;
}

.credits-link:hover,
.credits-link:focus-visible {
  outline: none;
  color: #ffffff;
}

/* Results ---------------------------------------------------------------------------- */

.panel-results {
  width: min(560px, 94vw);
}

.results-level {
  margin-top: -6px;
  color: #ffd84a;
  font-size: 20px;
  text-shadow: 2px 2px 0 #5a3f00;
}

.result-stars {
  display: flex;
  gap: clamp(10px, 3vw, 28px);
  margin: 6px 0 8px;
}

.result-star {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 110px;
}

.star-icon {
  width: clamp(56px, 9vw, 80px);
  height: clamp(56px, 9vw, 80px);
  image-rendering: pixelated;
}

.star-full {
  position: absolute;
  top: 0;
  scale: 0;
}

.result-star.earned .star-full {
  animation: star-pop 0.45s cubic-bezier(0.2, 1.8, 0.4, 1) forwards;
}

@keyframes star-pop {
  from { scale: 0; rotate: -40deg; }
  to { scale: 1; rotate: 0deg; }
}

.result-star-label {
  margin-top: 6px;
  font-size: 14px;
  text-align: center;
  color: #d8d8d8;
  text-shadow: 1px 1px 0 var(--text-shadow);
}

.result-rows {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.result-row {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 12px;
  align-items: center;
  padding: 6px 10px;
  background: rgba(255, 255, 255, 0.06);
  font-size: 20px;
  text-shadow: 2px 2px 0 var(--text-shadow);
}

.result-label {
  display: flex;
  gap: 8px;
  align-items: center;
}

.result-value {
  color: #ffffff;
}

.result-note {
  text-align: right;
  color: var(--yellow);
  font-size: 16px;
}

.results-target {
  font-size: 15px;
  color: #cfcfcf;
}

.results-buttons {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
  margin-top: 6px;
}

/* Loading, rotate, message -------------------------------------------------------- */

.loading-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  text-align: center;
}

.loading-title {
  font-size: clamp(22px, 3vw, 30px);
  text-shadow: 2px 2px 0 var(--text-shadow);
}

.loading-level {
  font-size: clamp(26px, 4vw, 40px);
  color: #ffd84a;
  text-shadow: 3px 3px 0 #5a3f00;
}

.loading-bar {
  width: min(420px, 70vw);
  height: 16px;
  border: 2px solid #000;
  background: #3a3a3a;
  box-shadow: inset 0 0 0 2px #1a1a1a;
}

.loading-bar-fill {
  height: 100%;
  width: 0;
  background: #7ed957;
  animation: loading-fill 0.5s steps(10) forwards;
}

@keyframes loading-fill {
  to { width: 100%; }
}

.loading-tip {
  max-width: 520px;
  color: #cfcfcf;
  font-size: 17px;
}

.screen-rotate,
.screen-message {
  z-index: 40;
  text-align: center;
}

.screen-rotate h2,
.screen-message h2 {
  margin: 0;
  font-weight: 400;
  font-size: 30px;
  text-shadow: 3px 3px 0 var(--text-shadow);
}

.screen-rotate p,
.screen-message p {
  margin: 0;
  font-size: 18px;
  color: #dddddd;
}

.rotate-icon svg {
  width: 96px;
  height: 96px;
  animation: rotate-phone 1.6s ease-in-out infinite;
}

@keyframes rotate-phone {
  0%, 20% { rotate: 0deg; }
  60%, 100% { rotate: -90deg; }
}

.debug-overlay {
  position: absolute;
  top: calc(60px + var(--safe-top));
  left: calc(8px + var(--safe-left));
  margin: 0;
  padding: 6px 8px;
  background: rgba(0, 0, 0, 0.5);
  font: 14px ui-monospace, monospace;
  color: #ffffff;
  pointer-events: none;
}
