:root {
  --red: #d8352a;
  --yellow: #f7cf3f;
  --cream: #fff1c9;
  --blue: #1f6f8b;
  --ink: #171717;
  --paper: #fff7df;
  --shadow: #0d0d0d;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: Montserrat, system-ui, sans-serif;
  background: var(--cream);
  overflow-x: hidden;
  overflow-wrap: break-word;
  word-break: break-word;
}

img, svg { max-width: 100%; height: auto; }

.halftone-bg {
  position: fixed;
  inset: 0;
  z-index: -2;
  background:
    radial-gradient(circle, rgba(23,23,23,.17) 2px, transparent 2px) 0 0 / 18px 18px,
    linear-gradient(135deg, #ffefb2 0%, #fbd147 44%, #e63a32 44%, #e63a32 58%, #1f6f8b 58%);
}

.halftone-bg::after {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(255, 247, 223, .55);
}

.app-shell {
  width: min(980px, 94vw);
  margin: 34px auto 18px;
  display: grid;
  gap: 24px;
}

.card {
  position: relative;
  background: var(--paper);
  border: 5px solid var(--ink);
  box-shadow: 12px 12px 0 var(--shadow);
  border-radius: 24px;
  padding: clamp(22px, 4vw, 42px);
}

.hero { text-align: center; overflow: hidden; }

.stamp {
  position: absolute;
  top: 18px;
  right: -44px;
  rotate: 12deg;
  background: var(--yellow);
  border: 4px solid var(--ink);
  padding: 10px 52px;
  font-weight: 900;
  letter-spacing: .03em;
}

h1, h2, .impact, .boom {
  font-family: Bangers, Luckiest Guy, cursive;
  letter-spacing: .04em;
  margin: 0;
  text-transform: uppercase;
}

h1 {
  font-size: clamp(86px, 18vw, 178px);
  line-height: .78;
  color: var(--red);
  text-shadow: 5px 5px 0 var(--ink), 10px 10px 0 var(--yellow);
}

h2 {
  font-size: clamp(35px, 6vw, 66px);
  color: var(--blue);
  text-shadow: 3px 3px 0 var(--yellow);
}

.tagline {
  font-size: clamp(18px, 3vw, 28px);
  font-weight: 900;
  max-width: 720px;
  margin: 22px auto;
}

.comic-scene {
  min-height: 235px;
  margin: 22px auto;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: clamp(12px, 4vw, 52px);
}

.person {
  width: 118px;
  height: 146px;
  position: relative;
}

.person::before {
  content: "";
  position: absolute;
  top: 0;
  left: 19px;
  width: 82px;
  height: 82px;
  background: #f7b889;
  border: 5px solid var(--ink);
  border-radius: 46% 54% 45% 55%;
  box-shadow: 5px 5px 0 rgba(0,0,0,.18);
}

.person span {
  position: absolute;
  bottom: 0;
  left: 10px;
  width: 98px;
  height: 78px;
  background: var(--blue);
  border: 5px solid var(--ink);
  border-radius: 44px 44px 15px 15px;
}

.person-right { transform: scaleX(-1); }
.person-left { animation: bumpLeft 1.1s infinite ease-in-out; }
.person-right { animation: bumpRight 1.1s infinite ease-in-out; }

.impact {
  font-size: clamp(56px, 11vw, 120px);
  color: var(--yellow);
  -webkit-text-stroke: 3px var(--ink);
  text-shadow: 7px 7px 0 var(--red);
  animation: pop .55s infinite alternate;
}

.primary, .secondary {
  border: 4px solid var(--ink);
  border-radius: 999px;
  padding: 16px 28px;
  font: 900 18px Montserrat, sans-serif;
  text-transform: uppercase;
  cursor: pointer;
  box-shadow: 6px 6px 0 var(--ink);
  transition: transform .15s, box-shadow .15s;
  text-decoration: none;
  display: inline-flex;
  justify-content: center;
  align-items: center;
  color: var(--ink);
  min-height: 48px;
  max-width: 100%;
}

.primary { background: var(--red); color: white; }
.secondary { background: var(--yellow); }
button:disabled { opacity: .45; cursor: not-allowed; }
.primary:not(:disabled):active, .secondary:active { transform: translate(4px, 4px); box-shadow: 2px 2px 0 var(--ink); }

.hidden { display: none; }
.panel-header { margin-bottom: 16px; }
.eyebrow { margin: 0 0 4px; font-weight: 900; color: var(--red); text-transform: uppercase; }
.small { margin: 6px 0 0; font-size: 13px; font-weight: 700; }

.levels {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(210px, 100%), 1fr));
  gap: 14px;
}

.inputs {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.comic-input {
  width: 100%;
  padding: 16px 20px;
  font: 900 18px Montserrat, sans-serif;
  border: 4px solid var(--ink);
  border-radius: 18px;
  background: white;
  box-shadow: 6px 6px 0 rgba(0,0,0,.9);
  outline: none;
  color: var(--ink);
  transition: box-shadow .15s, transform .15s;
}

.comic-input::placeholder {
  font-weight: 700;
  color: #aaa;
}

.comic-input:focus {
  background: var(--cream);
  box-shadow: 3px 3px 0 var(--ink);
  transform: translate(3px, 3px);
}

.option {
  background: white;
  border: 4px solid var(--ink);
  border-radius: 18px;
  padding: 16px;
  cursor: pointer;
  box-shadow: 6px 6px 0 rgba(0,0,0,.9);
}
.option.selected { background: var(--yellow); transform: translate(3px, 3px); box-shadow: 3px 3px 0 var(--ink); }
.option strong { display: block; font-size: 20px; margin-bottom: 6px; }
.option p { margin: 0; font-size: 14px; font-weight: 700; }
.contacts-title { margin-top: 28px; }
.send { width: 100%; margin-top: 22px; }

.result { text-align: center; }
.comic-gif {
  position: relative;
  height: 280px;
  border: 5px solid var(--ink);
  border-radius: 18px;
  overflow: hidden;
  background:
    radial-gradient(circle at 50% 45%, var(--yellow) 0 16%, transparent 17%),
    repeating-radial-gradient(circle at 50% 50%, #fff 0 8px, #f2d57a 8px 16px);
  margin-bottom: 24px;
}
.frame-lines {
  position: absolute;
  inset: -20px;
  background: repeating-conic-gradient(from 0deg, transparent 0 8deg, rgba(0,0,0,.13) 8deg 10deg);
  mix-blend-mode: multiply;
}
.mini-person {
  position: absolute;
  bottom: 46px;
  width: 84px;
  height: 112px;
  background: var(--blue);
  border: 5px solid var(--ink);
  border-radius: 50px 50px 16px 16px;
}
.mini-person::before {
  content: "";
  position: absolute;
  top: -60px;
  left: 9px;
  width: 58px;
  height: 58px;
  border-radius: 50%;
  background: #f7b889;
  border: 5px solid var(--ink);
}
.one { left: calc(50% - 155px); animation: hitOne .8s infinite; }
.two { right: calc(50% - 155px); animation: hitTwo .8s infinite; }

.person-label {
  position: absolute;
  bottom: -26px;
  left: 50%;
  transform: translateX(-50%);
  font-family: Bangers, cursive;
  font-size: 16px;
  letter-spacing: .06em;
  color: var(--ink);
  background: var(--yellow);
  border: 3px solid var(--ink);
  border-radius: 8px;
  padding: 1px 8px;
  white-space: nowrap;
  max-width: 90px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.result-message {
  background: white;
  border: 4px solid var(--ink);
  border-radius: 18px;
  padding: 22px 28px;
  margin-bottom: 24px;
  text-align: left;
  box-shadow: 6px 6px 0 rgba(0,0,0,.9);
}

.result-message .rm-intro {
  font-size: 13px;
  font-weight: 900;
  text-transform: uppercase;
  color: var(--blue);
  letter-spacing: .08em;
  margin: 0 0 6px;
}

.result-message .rm-name {
  font-family: Bangers, cursive;
  font-size: clamp(26px, 5vw, 40px);
  letter-spacing: .04em;
  color: var(--red);
  text-shadow: 2px 2px 0 var(--yellow);
  margin: 0 0 12px;
  line-height: 1;
}

.result-message .rm-motive {
  font-size: 15px;
  font-weight: 700;
  color: var(--ink);
  border-left: 4px solid var(--yellow);
  padding-left: 12px;
  margin: 0 0 10px;
}

.result-message .rm-line {
  font-size: 13px;
  font-weight: 700;
  color: #666;
  margin: 0;
  font-style: italic;
}
.boom {
  position: absolute;
  inset: 64px 0 auto;
  font-size: clamp(60px, 13vw, 130px);
  color: var(--red);
  -webkit-text-stroke: 3px var(--ink);
  text-shadow: 6px 6px 0 var(--yellow);
  animation: shake .25s infinite;
}
.stars { position: absolute; top: 32px; left: 0; right: 0; font-size: 42px; color: var(--blue); animation: spinny 1s infinite linear; }
.actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 14px; }
footer { text-align: center; font-size: 12px; font-weight: 800; padding: 0 10px 22px; }

/* ── Modal system ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal {
  background: var(--paper);
  border: 5px solid var(--ink);
  box-shadow: 14px 14px 0 var(--shadow);
  border-radius: 24px;
  padding: 28px 28px 24px;
  width: 100%;
  max-width: 540px;
  max-height: 90dvh;
  overflow-y: auto;
  position: relative;
  animation: modalIn .22s cubic-bezier(.22,.68,0,1.2);
  -webkit-overflow-scrolling: touch;
}

@keyframes modalIn {
  from { transform: scale(.92) translateY(16px); opacity: 0; }
  to   { transform: scale(1)   translateY(0);    opacity: 1; }
}

.modal-close {
  position: absolute;
  top: 16px;
  right: 16px;
  background: var(--ink);
  color: white;
  border: none;
  border-radius: 50%;
  width: 38px;
  height: 38px;
  font-size: 17px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  z-index: 1;
}
.modal-close:active { opacity: .7; }

.modal-back {
  background: none;
  border: none;
  font: 700 12px Montserrat, sans-serif;
  color: var(--blue);
  cursor: pointer;
  padding: 0;
  margin-bottom: 10px;
  text-transform: uppercase;
  letter-spacing: .07em;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.modal-back:active { opacity: .6; }

.modal-header {
  margin-bottom: 18px;
  padding-right: 44px;
}

.modal-result .comic-gif { height: 220px; margin-bottom: 18px; }
.modal-result .result-message { padding: 18px 20px; margin-bottom: 18px; }
.modal-result h2 { font-size: clamp(26px, 5vw, 46px); margin-bottom: 12px; text-align: center; }
.modal-result .actions { flex-direction: column; }
.modal-result .actions .primary,
.modal-result .actions .secondary { width: 100%; }

.selected-level-preview { margin-bottom: 18px; }
.level-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--yellow);
  border: 3px solid var(--ink);
  border-radius: 999px;
  padding: 8px 16px;
  font: 700 14px Montserrat, sans-serif;
  box-shadow: 4px 4px 0 var(--ink);
}
.punch-badge {
  font-family: Bangers, cursive;
  font-size: 18px;
  letter-spacing: .05em;
  color: var(--red);
}

.toast {
  position: fixed;
  bottom: 32px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--ink);
  color: white;
  font: 700 15px Montserrat, sans-serif;
  padding: 14px 24px;
  border-radius: 999px;
  border: 3px solid var(--yellow);
  box-shadow: 6px 6px 0 var(--shadow);
  z-index: 999;
  opacity: 0;
  transition: opacity .25s, transform .25s;
  white-space: nowrap;
  max-width: 90vw;
  text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ── Share card (off-screen, captured by html2canvas) ── */
#shareCard {
  position: fixed;
  left: -9999px;
  top: 0;
  width: 480px;
  padding: 0;
  z-index: -100;
}

.sc-bg {
  background: #fff7df;
  border: 6px solid #171717;
  border-radius: 24px;
  padding: 28px 28px 20px;
  font-family: Montserrat, sans-serif;
  box-shadow: 10px 10px 0 #0d0d0d;
  position: relative;
  overflow: hidden;
}

.sc-bg::before {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(circle, rgba(23,23,23,.12) 2px, transparent 2px) 0 0 / 16px 16px;
  z-index: 0;
}

.sc-bg > * { position: relative; z-index: 1; }

.sc-header {
  font-family: Bangers, cursive;
  font-size: 64px;
  color: #d8352a;
  text-shadow: 4px 4px 0 #171717, 8px 8px 0 #f7cf3f;
  letter-spacing: .05em;
  line-height: 1;
  text-align: center;
}

.sc-sub {
  text-align: center;
  font-size: 13px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: #1f6f8b;
  margin-bottom: 4px;
}

.sc-level-name {
  font-family: Bangers, cursive;
  font-size: 30px;
  letter-spacing: .04em;
  color: #171717;
  text-align: center;
  margin-bottom: 16px;
}

.sc-scene {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 12px;
  height: 140px;
  margin-bottom: 16px;
}

.sc-person {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  position: relative;
}

.sc-body {
  width: 70px;
  height: 88px;
  background: #1f6f8b;
  border: 4px solid #171717;
  border-radius: 36px 36px 12px 12px;
  display: block;
  position: relative;
}

.sc-body::before {
  content: "";
  position: absolute;
  top: -48px;
  left: 8px;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: #f7b889;
  border: 4px solid #171717;
}

.sc-right { transform: scaleX(-1); }
.sc-right .sc-label { transform: scaleX(-1); }

.sc-label {
  font-family: Bangers, cursive;
  font-size: 15px;
  letter-spacing: .06em;
  background: #f7cf3f;
  border: 3px solid #171717;
  border-radius: 8px;
  padding: 1px 8px;
  color: #171717;
  white-space: nowrap;
  max-width: 100px;
  overflow: hidden;
  text-overflow: ellipsis;
  display: block;
}

.sc-boom {
  font-family: Bangers, cursive;
  font-size: 54px;
  color: #f7cf3f;
  -webkit-text-stroke: 3px #171717;
  text-shadow: 5px 5px 0 #d8352a;
  letter-spacing: .03em;
  align-self: center;
  line-height: 1;
}

.sc-box {
  background: white;
  border: 4px solid #171717;
  border-radius: 14px;
  padding: 14px 18px;
  font-size: 14px;
  font-weight: 700;
  line-height: 1.6;
  color: #171717;
  margin-bottom: 14px;
}

.sc-footer {
  text-align: center;
  font-size: 11px;
  font-weight: 800;
  color: #999;
  text-transform: uppercase;
  letter-spacing: .06em;
}


@keyframes bumpLeft { 0%,100%{transform:translateX(0)} 50%{transform:translateX(24px) rotate(3deg)} }
@keyframes bumpRight { 0%,100%{transform:scaleX(-1) translateX(0)} 50%{transform:scaleX(-1) translateX(24px) rotate(3deg)} }
@keyframes pop { from{transform:scale(.92) rotate(-2deg)} to{transform:scale(1.06) rotate(2deg)} }
@keyframes hitOne { 0%,100%{transform:translateX(0) rotate(-4deg)} 50%{transform:translateX(55px) rotate(8deg)} }
@keyframes hitTwo { 0%,100%{transform:translateX(0) rotate(4deg)} 50%{transform:translateX(-55px) rotate(-8deg)} }
@keyframes shake { 0%,100%{transform:translate(0)} 50%{transform:translate(4px,-3px) rotate(-1deg)} }
@keyframes spinny { to { transform: rotate(360deg); } }

@media (max-width: 768px) {
  .app-shell { width: min(980px, 96vw); margin: 20px auto 14px; gap: 16px; }
  .card { padding: clamp(16px, 5vw, 26px); border-width: 4px; box-shadow: 8px 8px 0 var(--shadow); border-radius: 18px; }
  .levels { grid-template-columns: 1fr; }
  .inputs, .actions { width: 100%; }
  .actions { flex-direction: column; align-items: stretch; }
  .primary, .secondary { width: 100%; padding: 18px 20px; font-size: 17px; min-height: 54px; }
  .comic-input { padding: 16px 18px; font-size: 16px; }
  .comic-gif { height: 220px; }
  .mini-person { width: 68px; height: 92px; }
  .mini-person::before { width: 46px; height: 46px; top: -48px; }
  .one { left: calc(50% - 90px); }
  .two { right: calc(50% - 90px); }
  .boom { font-size: clamp(46px, 16vw, 90px); inset: 48px 0 auto; }
  .stars { font-size: 30px; }
  .result-message { padding: 18px 20px; }

  /* Modal su tablet/mobile */
  .modal-overlay { padding: 10px; }
  .modal {
    padding: 22px 18px 20px;
    border-radius: 20px;
    border-width: 4px;
    max-height: 93dvh;
  }
  .modal .levels { grid-template-columns: 1fr; }
  .modal .inputs, .modal .actions { width: 100%; }
  .modal .primary, .modal .secondary { width: 100%; min-height: 54px; padding: 18px 16px; font-size: 16px; }
  .modal .send { margin-top: 18px; }
  .modal-result .comic-gif { height: 190px; }
  .modal-result .actions { flex-direction: column; align-items: stretch; }
}

@media (max-width: 620px) {
  .stamp { position: static; display: inline-block; margin-bottom: 18px; rotate: -3deg; padding: 8px 20px; }
  .comic-scene { min-height: 180px; gap: 5px; }
  .person { width: 82px; height: 108px; }
  .person::before { width: 58px; height: 58px; left: 12px; }
  .person span { width: 70px; height: 56px; }
  .card { box-shadow: 7px 7px 0 var(--shadow); }

  /* Modal su schermi piccoli */
  .modal-overlay { padding: 6px; align-items: flex-end; }
  .modal {
    border-radius: 20px 20px 16px 16px;
    max-height: 95dvh;
    padding: 20px 16px 18px;
  }
  .modal-result .comic-gif { height: 170px; }
  .one { left: calc(50% - 76px); }
  .two { right: calc(50% - 76px); }
  .mini-person { width: 58px; height: 78px; }
  .mini-person::before { width: 40px; height: 40px; top: -42px; left: 5px; }
}
