@font-face {
  font-family: 'Horta';
  src: url('../font/horta.eot');
  src: url('../font/horta.eot?#iefix') format('embedded-opentype'),
       url('../font/horta.woff2') format('woff2'),
       url('../font/horta.woff') format('woff'),
       url('../font/horta.ttf') format('truetype'),
       url('../font/horta.svg#Horta') format('svg');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'AvenirLTStd-Book';
  src: url('../font/AvenirLTStd-Book.eot');
  src: url('../font/AvenirLTStd-Book.eot?#iefix') format('embedded-opentype'),
       url('../font/AvenirLTStd-Book.woff2') format('woff2'),
       url('../font/AvenirLTStd-Book.woff') format('woff'),
       url('../font/AvenirLTStd-Book.ttf') format('truetype'),
       url('../font/AvenirLTStd-Book.svg#AvenirLTStd-Book') format('svg');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'Monument';
  src: url('../font/MonumentExtended-Regular.eot');
  src: url('../font/MonumentExtended-Regular.eot?#iefix') format('embedded-opentype'),
       url('../font/Monument-Extended.woff2') format('woff2'),
       url('../font/MonumentExtended-Regular.woff') format('woff'),
       url('../font/MonumentExtended-Regular.ttf') format('truetype'),
       url('../font/MonumentExtended-Regular.svg#Monument') format('svg');
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}

:root {
  --app-height: 100vh;
}

@supports (height: 100dvh) {
  :root {
    --app-height: 100dvh;
  }
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  min-height: var(--app-height);
  overflow-x: hidden;
  overflow-y: auto;
  font-family: 'AvenirLTStd-Book', 'Horta', sans-serif;
  letter-spacing: 0.5px;
  background: #f3f3f3;
  color: #1a1a1a;
}

#game-container {
  position: relative;
  width: min(100vw, 560px);
  height: var(--app-height);
  min-height: var(--app-height);
  margin: 0 auto;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  color: inherit;
  overflow: hidden;
}

#game-container::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image: var(--level-background);
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  /*filter: blur(15px);
  transform: scale(1.5);*/
  transition: background-image 0.3s ease, opacity 0.3s ease;
  z-index: 0;
}

#game-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
  touch-action: none;
}

.preload-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.92);
  z-index: 120;
  transition: opacity 0.3s ease;
}

.preload-overlay--done {
  opacity: 0;
  pointer-events: none;
}

.preload-panel {
  width: min(320px, 80%);
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: center;
  text-align: center;
  color: #ffffff;
  font-family: 'Monument', sans-serif;
  text-transform: uppercase;
}

.preload-label {
  margin: 0;
  font-size: 14px;
  letter-spacing: 2px;
}

.preload-bar {
  width: 100%;
  height: 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  overflow: hidden;
}

.preload-bar__fill {
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, #fe0606, #ff6a6a);
  border-radius: inherit;
  transition: width 0.25s ease;
}

.preload-percentage {
  margin: 0;
  font-size: 18px;
  letter-spacing: 1px;
}

.hidden { display: none !important; }

#hud {
  position: absolute;
  top: 16px;
  left: 16px;
  right: 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  z-index: 20;
  gap: 8px;
}

#level-label {
  padding: 8px 14px;
  background: rgba(0, 0, 0, 0.6);
  border-radius: 6px;
  font-size: 12px;
}

.hud-button {
  margin-left: auto;
  padding: 8px 16px;
  font-size: 18px;
  background: #fe0606;
   display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  color: #fff;
  cursor: pointer;
  border-radius: 6px;
  transition: transform 0.2s ease, background 0.2s ease;
  font-family: 'Monument', sans-serif;
  font-weight: 500;
  text-transform: uppercase;
}

.hud-button:hover { transform: scale(1.05); }

#btn-pause {
  width: 30px;
  height: 30px;
  padding: 0;
  min-width: 30px;
}

.hud-button__icon {
    width: 16px;
    height: 16px;
    background-image: url('../images/pause.png');
    background-repeat: no-repeat;
    background-position: center;
    background-size: 16px 16px;
    filter: brightness(0) saturate(100%) invert(89%) sepia(1%) saturate(5060%) hue-rotate(283deg) brightness(119%) contrast(110%);
}
.btn-exit-menu {
    background: transparent;
    box-shadow: none;
    text-decoration: underline;
    color: inherit;
}

.screen,
.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 0;
  text-align: center;
  background: transparent;
  z-index: 40;
  overflow-y: auto;
}

.overlay-2 {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0 !important;
  text-align: center;
  background: transparent;
  z-index: 40;
  overflow-y: auto;
  font-family: 'AvenirLTStd-Book', 'Horta', sans-serif;
}

.gameover-overlay {
  justify-content: flex-start;
  padding: 32px 24px calc(32px + env(safe-area-inset-bottom));
}

.gameover-panel {
  /* background: rgba(0, 0, 0, 0.65); */
  position: relative;
  padding: 24px;
  width: 100%;
  height: 100%;
  /* inset: 0; */
  display: block;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.45);
  color: #ffffff;
  font-family: 'AvenirLTStd-Book', 'Horta', sans-serif;
}

.gameover-panel h2 {
  position: relative;
  z-index: 99;
  width: 100%;
  text-align: center;
  font-family: 'Horta', sans-serif;
  font-size: 60px;
}

.gameover-panel-overlay-background {
  position: absolute;
  top: 0;
  left: 0;
  background: rgba(0, 0, 0, 0.65);
  width: 100%;
  height: 100%;
}

#character-select-overlay {
	justify-content: flex-start;
}

#character-select-overlay.screen .panel {
	justify-content: flex-start;
}

#level-clear-overlay,
#end-overlay {
  background: transparent;
}

/* Overlay scuro anche nello step finale */
#end-overlay {
  position: absolute;
  inset: 0;
}

#end-overlay::before {
  content: "";
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  z-index: 0;
}

/*#level-clear-overlay .panel,
#end-overlay .panel {
  background: rgba(0, 0, 0, 0.65);
}*/

#pause-overlay,
#countdown-overlay {
  background: transparent;
  padding: 0;
}

#pause-overlay .panel,
#countdown-overlay .panel {
  width: 100%;
  height: 100%;
  background: rgb(0 0 0 / 85%);
  justify-content: center;
}

#countdown-overlay .panel {
  padding: 32px;
}

#pause-overlay .panel {
  padding: 32px;
}
.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 0;
  text-align: center;
  background: transparent;
  z-index: 40;
  overflow-y: auto;
}

.screen .panel,
.overlay .panel {
  background: rgba(0, 0, 0, 0.65);
  padding: 24px;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  gap: 16px;
  justify-content: center;
  align-items: center;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.45);
  color: #ffffff;
  font-family: 'AvenirLTStd-Book', 'Horta', sans-serif;
}

.screen .panel {
  height: auto !important;
}

.gradient-background,
.panel.gradient-background {
  background: linear-gradient(300deg, #ffffff, #fe0606);
  background-size: 120% 120%;
  animation: gradient-animation 8s ease infinite;
}

@keyframes gradient-animation {
  0% {
    background-position: 0% 50%;
  }
  50% {
    background-position: 100% 50%;
  }
  100% {
    background-position: 0% 50%;
  }
}

.title {
  font-family: 'Horta', cursive;
  font-size: clamp(38px, 6vw, 64px);
  margin: 0;
  text-shadow: none;
}

.panel h2 {
  font-family: 'Horta', cursive;
  font-size: 38px;
  margin: 0;
}

.panel p {
  margin: 0;
  font-size: 18px;
  line-height: 1.4;
}

.actions {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
  z-index: 99;
}

.primary,
.secondary,
#character-select-list .character-option {
  width: 100%;
  padding: 14px;
  font-size: 16px;
  border-radius: 18px;
  box-shadow: rgba(0, 0, 0, 0.10) 0px 3px 6px, rgba(0, 0, 0, 0.10) 0px 3px 6px;
  border: none;
  color: #fff;
  cursor: pointer;
  transition: transform 0.2s ease, background 0.2s ease;
  font-family: 'Monument', sans-serif;
  font-weight: 500;
  text-transform: uppercase;
}

.primary:disabled,
#btn-start-game:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  filter: grayscale(40%);
  transform: none;
}

.primary {
  background: #fe0606;
}

.secondary {
  background: rgba(40, 40, 40, 0.65);
  font-size: 14px;
}

.secondary.btn-exit-menu {
  background: transparent;
  box-shadow: none;
  text-decoration: underline;
  color: inherit;
}

.primary:hover,
.secondary:hover,
#character-select-list .character-option:hover {
  transform: translateY(-2px);
}

#countdown-text {
  font-family: 'Monument', sans-serif;
  font-size: clamp(52px, 10vw, 88px);
  margin: 0;
}

#level-postcard {
  width: 100%;
	max-width: 200px;
  max-height: 300px;
  object-fit: cover;
  display: block;
  border: none;
  box-shadow: none;
  background: transparent;
  cursor: pointer;
}

.level-clear-panel {
  position: relative;
}

.level-clear-back-button {
  position: absolute;
  top: 16px;
  left: 16px;
  width: 40px;
  height: 40px;
  border-radius: 999px;
  border: none;
  background: rgba(0, 0, 0, 0.65);
  color: #fff;
  font-size: 20px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.25);
}

.level-clear-back-button:hover {
  background: rgba(0, 0, 0, 0.78);
}

.level-clear-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  width: 100%;
}

.level-postcard-title {
  font-family: 'Monument', sans-serif;
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin: 0;
  display: none;
}

.level-clear-story-text {
  font-size: 18px;
  line-height: 1.5;
  margin: 0;
}

.overlay-message {
  font-size: 18px;
  text-align: center;
  margin: 12px 0;
  opacity: 0.85;
  z-index: 99;
}

.level-list {
  display: grid;
  grid-template-columns: 1fr 1fr; 
  grid-template-rows: 1fr 1fr;
  gap: 12px;
  width: 100%;
  margin: 16px 0;
}

#character-select-list .character-option {
  background: rgba(0, 0, 0, 0.55);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 12px;
  text-align: center;
  /*aspect-ratio: 1 / 1;*/
  padding: 18px;
}

#character-select-list .character-option.active {
  background: linear-gradient(180deg, #ff6a6a, #fe0606);
  color: #fff;
}

.character-option-thumb {
  width: min(75%, 160px);
  height: auto;
}

.character-option-label {
  font-size: 18px;
}

.postcard-strip {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
  width: 100%;
  margin-top: 12px;
  z-index: 99;
}

.postcard-thumb {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-start;
  width: 170px;
  aspect-ratio: 2 / 3;
  border-width: 10px;
  border-color: #fff;
  border-style: solid;
  border-radius: 0;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.35);
  background: #ffffff;
  cursor: pointer;
  transition: transform 0.2s ease;
  overflow: hidden;
}

/*.postcard-thumb:focus-visible {
  outline: 3px solid #fe0606;
  outline-offset: 2px;
}*/

.postcard-thumb-image {
  flex: 1 1 auto;
  width: 100%;
  height: auto;
  min-height: 0;
  object-fit: cover;
  display: block;
}

/* .postcard-thumb::after {
  content: '';
  position: absolute;
  inset: 0;
  opacity: 1;
  pointer-events: none;
  background: linear-gradient(180deg, rgba(0, 0, 0, 0) 80%, rgba(0, 0, 0, 0.6) 100%);
  z-index: 1;
  transition: opacity 0.2s ease;
} */

.postcard-thumb-icon {
  position: absolute;
  bottom: 45px;
  right: 5px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.92);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.25);
  z-index: 2;
  pointer-events: none;
  transition: transform 0.2s ease, opacity 0.2s ease;
}

.postcard-thumb:hover {
  transform: scale(1.03);
}

.postcard-thumb:hover .postcard-thumb-icon {
  transform: translateY(-2px);
}

.postcard-thumb--locked {
  border-style: dashed;
  border-color: rgba(255, 255, 255, 0.8);
  border-width: 2px;
  box-shadow: none;
  background: rgba(255, 255, 255, 0.12);
  cursor: default;
  pointer-events: none;
}

.postcard-thumb--locked::after {
  content: none;
}

.postcard-thumb-locked-label {
  font-size: 14px;
  font-family: 'Monument', sans-serif;
  color: rgba(255, 255, 255, 0.9);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  text-align: center;
  padding: 0 10px;
}

.postcard-thumb-label,
.postcard-card-label {
  position: relative;
  inset: auto;
  left: auto;
  bottom: auto;
  width: 100%;
  padding: 10px 0;
  white-space: normal;
  overflow: hidden;
  text-overflow: clip;
  word-break: break-word;
  overflow-wrap: anywhere;
  line-height: 1.2;
  text-align: left;
  color: #000;
  background: #fff; 
}

.postcard-card-label {
  left: 0;
  padding: 10px 0;
  width: 100%;
  text-align: left;
}

.postcard-empty {
  font-size: 16px;
  opacity: 0.8;
  grid-column-start: 1;
  grid-column-end: 3;
}

.postcard-card {
  position: relative;
  display: flex;
  justify-content: center;
  flex-direction: column;
  align-items: center;
  width: auto;
  border-radius: 0;
  border-style: solid;
  border-width: 10px;
  border-color: #fff;
  margin-bottom: 20px;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.35);
  background: #ffffff;
  transition: transform 0.2s ease;
}

.postcard-card--zoomable {
  cursor: pointer;
}

/* .postcard-card::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(0, 0, 0, 0) 80%, rgba(0, 0, 0, 0.6) 100%);
  pointer-events: none;
  z-index: 1;
} */

.postcard-card-icon {
  position: absolute;
  bottom: 45px;
  right: 5px;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.92);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.25);
 pointer-events: none;
  z-index: 2;
}

.postcard-zoom-icon {
  width: 18px;
  height: 18px;
  display: block;
  stroke: #001e3c;
  stroke-width: 2.2;
  fill: none;
}

.postcard-info-icon {
  width: 20px;
  height: 20px;
  display: block;
  object-fit: contain;
}

.postcard-card:hover {
  transform: scale(1.03);
}

.postcard-card--static {
  transition: none;
}

.postcard-card--static:hover {
  transform: none;
}

.postcard-zoom-overlay {
  background: rgba(0, 0, 0, 0.85);
  z-index: 85;
  padding: 24px 16px calc(24px + env(safe-area-inset-bottom)) 16px;
}

.postcard-zoom-panel {
  background: transparent;
  box-shadow: none;
  width: min(92vw, 760px);
  height: auto;
  max-height: 90vh;
  padding: 20px;
  gap: 20px;
}

.postcard-zoom-image {
  width: 100%;
  max-height: 75vh;
  object-fit: contain;
  border-radius: 14px;
  box-shadow: 0 16px 32px rgba(0, 0, 0, 0.35);
}

/*.postcard-card--focus {
  outline: 3px solid #fe0606;
  outline-offset: 2px;
}*/

#gameover-postcards {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 16px;
  width: 100%;
}

#gameover-postcards-unlocked {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  width: 100%;
}

#gameover-postcards-locked {
  display: flex;
  gap: 8px;
  width: 100%;
  flex-direction: row;
  flex-wrap: wrap;
  justify-content: center;
  padding-bottom: 50px;
}

#gameover-postcards-unlocked .postcard-thumb {
  width: 100%;
}

#gameover-postcards-unlocked .postcard-thumb:only-child,
#gameover-postcards-unlocked .postcard-thumb:last-child:nth-child(odd) {
  grid-column: auto;
  justify-self: center;
  width: 100%;
}

#gameover-postcards-locked .postcard-thumb--locked {
  width: 72px;
  border-width: 2px;
  background: rgba(255, 255, 255, 0.08);
  justify-content: center;
  align-self: start;
}

#gameover-postcards-locked .postcard-thumb--locked .postcard-thumb-locked-label {
  font-size: 7px;
  padding: 0 4px;
  letter-spacing: 0.08em;
}

#gameover-postcards .postcard-thumb--locked .postcard-thumb-locked-label {
  font-size: 7px;
  padding: 0 4px;
  letter-spacing: 0.08em;
}

#confirm-overlay {
  z-index: 60;
}

@media (max-width: 480px) {
  #hud {
    align-items: flex-start;
    gap: 12px;
  }

  .hud-button {
    align-self: flex-end;
  }

  .start-screen-guide {
    padding: 12px;
    gap: 6px;
  }

  .start-guide-title {
    font-size: 14px;
  }

  .start-guide-list {
    font-size: 13px;
  }

}

#hud {
  color: #ffffff;
}

#start-screen {
  background: #f3f3f3;
  color: #1a1a1a;
  padding: 16px;
  gap: 20px;
  justify-content: flex-start;
  align-items: center;
}

#start-screen .title {
  margin-top: 0;
}

.start-screen-hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  width: 100%;
  max-width: 420px;
}

.start-screen-intro {
  font-size: 16px;
  line-height: 1.5;
  margin: 0;
  max-width: 420px;
}

.start-screen-guide {
  width: 100%;
  max-width: 420px;
  margin: 20px 0 0;
  padding: 16px;
  border-radius: 16px;
  border: 1px solid rgba(0, 0, 0, 0.1);
  background: rgba(255, 255, 255, 0.8);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.start-guide-title {
  margin: 0;
  font-family: 'Monument', sans-serif;
  font-size: 16px;
  letter-spacing: 1px;
  text-transform: uppercase;
}

.start-guide-list {
  margin: 0;
  padding-left: 18px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 14px;
  line-height: 1.5;
  text-align: left;
}

.start-screen-media {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  width: 100%;
}

.start-screen-header {
  display: flex;
  flex-direction: row;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  gap: 16px;
  padding: 0 10px;
}

.start-screen-home-link {
  background-color: #FFFFFF00;
  font-family: "Monument Extended", "Monument", sans-serif;
  font-size: 14px;
  font-weight: 500;
  text-transform: uppercase;
  fill: var(--e-global-color-text, currentColor);
  color: var(--e-global-color-text, #1a1a1a);
  border-style: solid;
  border-width: 0 0 1px 0;
  border-radius: 0;
  padding: 0;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  line-height: 1.2;
}

.start-screen-home-link:hover,
.start-screen-home-link:focus-visible {
  color: var(--e-global-color-text, #1a1a1a);
  border-color: currentColor;
}

.start-screen-actions {
  max-width: 360px;
  width: 100%;
  align-self: center;
  align-items: stretch;
  margin-top: 20px;
}

.start-screen-actions .primary,
.start-screen-actions .secondary {
  width: 100%;
}

.start-screen-logo {
  max-width: 30px !important;
  width: 100%;
  height: auto;
}

.story-overlay {
  background: rgba(0, 0, 0, 0.85);
  z-index: 80;
}

.story-overlay .panel {
  background: #ffffff;
  color: #001e3c;
  max-width: 480px;
  width: calc(100% - 48px);
  max-height: min(80vh, 520px);
  border-radius: 16px;
  padding: 32px;
  align-items: flex-start;
  justify-content: flex-start;
  text-align: left;
  position: relative;
  overflow-y: auto;
  gap: 18px;
  transform: translateY(24px);
  opacity: 0;
  transition: transform 0.35s ease, opacity 0.35s ease;
}

.story-overlay.story-overlay--open .panel {
  transform: translateY(0);
  opacity: 1;
}

.story-overlay.story-overlay--closing .panel {
  transform: translateY(32px);
  opacity: 0;
}

.postcard-story-close {
  position: absolute;
  top: 16px;
  right: 16px;
  background: transparent;
  border: none;
  color: #1f1f1f;
  font-size: 20px;
  cursor: pointer;
  font-family: 'Monument', sans-serif;
  line-height: 1;
}

.postcard-story-close:hover {
  color: #fe0606;
}

.postcard-story-title {
  font-family: 'Horta', cursive;
  font-size: 34px;
  margin: 0;
  color: #fe0606;
}

.postcard-story-text {
  white-space: pre-wrap;
  font-size: 16px;
  line-height: 1.5;
  margin: 0;
}

.postcard-story-image {
  width: 100%;
  border-radius: 12px !important;
  box-shadow: 0 12px 24px rgba(0, 0, 0, 0.18) !important;
}

.story-overlay {
  background: rgba(0, 0, 0, 0.85);
  z-index: 80;
  padding: 24px 16px calc(24px + env(safe-area-inset-bottom)) 16px;
}

#end-overlay .panel {
  justify-content: flex-start;
  align-items: stretch;
  gap: 20px;
  padding: 28px 24px;
  /*overflow: hidden;*/
  text-align: center;
  height: 100%;
  position: relative;
  z-index: 1;
  background: none;
  box-shadow: none;
}

#end-postcards {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
  width: 100%;
  /*max-height: calc(100% - 220px);
  overflow-y: auto;
  padding: 8px 4px;*/
  flex: 1;
}

#end-postcards .postcard-thumb {
  width: 100%;
}

#end-postcards .postcard-thumb:only-child {
  grid-column: 1 / -1;
  justify-self: center;
  width: 100%;
  max-width: calc((100% - 16px) / 2);
}

#end-postcards .postcard-thumb:last-child:nth-child(odd) {
  grid-column: 1 / -1;
  justify-self: center;
  width: 100%;
  max-width: calc((100% - 16px) / 2);
}

/* =========================
   LEVEL CLEAR: background foto + overlay scuro + contenuto sopra
   ========================= */
#level-clear-overlay {
  position: absolute;
  inset: 0;
  background: transparent !important;
}

/* Foto sbloccata come sfondo */
#level-clear-overlay::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image: var(--level-clear-bg, none);
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  z-index: 0;
}

/* Overlay scuro per leggibilità */
#level-clear-overlay::after {
  display: none;
}

/* Il pannello non deve avere il suo background: deve “galleggiare” sopra */
#level-clear-overlay .panel {
  position: relative;
  z-index: 2;
  background: transparent !important;
  box-shadow: none !important;
}

/* Se vuoi mantenere un minimo di contrasto sui testi */
#level-clear-overlay .panel h2,
#level-clear-overlay .panel p,
#level-clear-overlay .panel .actions {
  position: relative;
  z-index: 2;
}

/* =========================
   GAME OVER: overlay sempre presente anche con scroll
   ========================= */
#gameover-overlay {
  position: absolute;
  inset: 0;
}

/* Overlay scuro sempre a copertura viewport, anche scrollando */
#gameover-overlay::before {
  content: "";
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  z-index: 0;
}

/* Pannello sopra l'overlay */
#gameover-overlay .gameover-panel {
  position: relative;
  z-index: 1;
}

/* Disattiva il vecchio overlay interno (evita tagli) */
.gameover-panel-overlay-background {
  display: none !important;
}

/* Level clear: se esistesse ancora il wrapper postcard-card, nascondo label e lente */
#level-clear-overlay .postcard-card-icon,
#level-clear-overlay .postcard-card-label {
  display: none !important;
}

#level-clear-overlay .postcard-card {
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
  margin: 0 !important;
  padding: 0 !important;
}

/* =========================
   Level Clear: overlay extra dietro testi (intro + story)
   ========================= */

#level-clear-step-intro,
#level-clear-step-story {
  position: relative;
  padding: 20px;
  border-radius: 16px;
}

#level-clear-step-intro {
  width: min(100%, 360px);
  padding: 12px 16px;
  gap: 10px;
}

#level-clear-step-story {
  width: min(100%, 360px);
  padding: 12px 16px;
  gap: 10px;
}

/* Overlay scuro solo sui box "Complimenti" e "Storia" (testi + bottoni). */
#level-clear-step-intro::before {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  border-radius: 16px;
  z-index: 0;
}

#level-clear-step-story::before {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  border-radius: 16px;
  z-index: 0;
}

/* Porta sopra i contenuti rispetto al ::before */
#level-clear-step-intro > *,
#level-clear-step-story > * {
  position: relative;
  z-index: 1;
}

#level-clear-step-intro h2 {
  font-size: 30px;
}

#level-clear-step-intro .overlay-message {
  font-size: 16px;
}

#level-clear-step-story h2 {
  font-size: 30px;
}

#level-clear-step-story .level-clear-story-text {
  font-size: 16px;
}

/* Extra: un pelo più leggibili i testi nello step storia */
#level-clear-step-story .level-clear-story-text,
#level-clear-step-intro .overlay-message {
  text-shadow: 0 2px 12px rgba(0, 0, 0, 0.35);
}

/* =========================
   Level clear: posizione freccia back fuori dal box testi
   ========================= */

#level-clear-step-story {
  position: relative;
}

/* Spostiamo il bottone fuori dal box */
#btn-level-back {
  position: absolute;
  top: -45px;
  left: 0;
  z-index: 3;
}

/* Se vuoi che sembri più "flottante" */
#btn-level-back {
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(4px);
}

/* =========================
   Level clear: contenuto allineato in basso
   ========================= */

/* Il panel deve spingere i contenuti verso il basso */
#level-clear-overlay .panel {
  justify-content: flex-end !important;
  height: 100%;
}

/* Margine dal fondo della pagina */
#level-clear-step-intro,
#level-clear-step-story {
  margin-bottom: 24px;
}

/* =========================
   Gameover unlocked grid: se dispari, ultima centrata ma stessa dimensione
   ========================= */

#gameover-postcards-unlocked {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

/* Base: tutte le thumb occupano la cella */
#gameover-postcards-unlocked .postcard-thumb {
  width: 100%;
}

/* Caso: una sola foto sbloccata */
#gameover-postcards-unlocked .postcard-thumb:only-child {
  grid-column: 1 / -1;            /* prende entrambe le colonne */
  justify-self: center;           /* centra la card */
  width: 100%;
  max-width: calc((100% - 12px) / 2); /* ma resta larga come una colonna */
}

/* Caso: numero dispari, ultima foto sbloccata rimasta sola */
#gameover-postcards-unlocked .postcard-thumb:last-child:nth-child(odd) {
  grid-column: 1 / -1;
  justify-self: center;
  width: 100%;
  max-width: calc((100% - 12px) / 2);
}

#gameover-overlay .gameover-panel {
  box-shadow: none !important;
}
