html,
body {
  margin: 0;
  padding: 0;
  overflow-x: hidden;
  width: 100%;
}

html {
  background-color: #120000;
  background-image: url("/assets/img/sfondo.webp");
  background-repeat: no-repeat;
  background-position: center top;
  background-size: cover;
}

:root {
  --red-1: #ff1a1a;
  --red-2: #ff3b1f;
  --gold: #ffd54a;
  --text: #ffffff;
  color-scheme: dark;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

[hidden] {
  display: none !important;
}

button {
  font-family: inherit;
  font-size: inherit;
  font-weight: inherit;
  line-height: inherit;
  letter-spacing: inherit;
  color: inherit;
  text-transform: none;
  margin: 0;
  -webkit-appearance: none;
  appearance: none;
}

body {
  min-height: 100vh;
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  background-image:
    radial-gradient(circle at top center, rgba(255,120,0,0.10), transparent 28%),
    linear-gradient(to bottom, rgba(0,0,0,0.08), rgba(0,0,0,0.55)),
    url("/assets/img/sfondo.webp");
  background-repeat: no-repeat;
  background-position: center top;
  background-size: cover;
  background-color: #120000;
  color: var(--text);
  text-align: center;
  overflow-x: hidden;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(circle at 15% 18%, rgba(255,130,0,0.12), transparent 12%),
    radial-gradient(circle at 85% 30%, rgba(255,60,0,0.10), transparent 10%),
    radial-gradient(circle at 12% 76%, rgba(255,120,0,0.08), transparent 9%),
    radial-gradient(circle at 88% 82%, rgba(255,90,0,0.08), transparent 10%);
  mix-blend-mode: screen;
  opacity: .9;
}

#mobileContent {
  position: relative;
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  padding: 130px 6px calc(20px + env(safe-area-inset-bottom, 0px));
}

#mobileContent::before {
  content: "";
  position: absolute;
  top: 143px;
  left: 50%;
  transform: translateX(-50%);
  width: calc(100% - 2px);
  max-width: none;
  bottom: 30px;
  border-radius: 26px;
  background: linear-gradient(180deg, rgba(0,0,0,0.15), rgba(0,0,0,0.25));
  box-shadow:
    0 12px 30px rgba(0,0,0,0.25),
    inset 0 1px 0 rgba(255,255,255,0.04);
  z-index: 0;
}

#mobileContent.offline::before {
  display: none;
}

#dynamicTop,
#linkContainer {
  position: relative;
  z-index: 1;
}

#verificaContainer {
  width: 100%;
  max-width: 400px;
  margin: 0 auto 22px auto;
}

#verificaInput {
  width: 100%;
  padding: 15px 18px;
  border-radius: 18px;
  border: 2px solid rgba(255, 55, 35, 0.95);
  font-size: 19px;
  font-weight: 700;
  margin-bottom: 2px;
  background: linear-gradient(180deg, rgba(45, 0, 0, 0.88), rgba(20, 0, 0, 0.84));
  color: #fff;
  outline: none;
  box-shadow:
    0 0 0 1px rgba(255,255,255,0.05) inset,
    0 0 12px rgba(255,0,0,0.25),
    0 6px 18px rgba(0,0,0,0.22);
  transition: .25s ease;
  text-align: center;
  touch-action: manipulation;
}

#verificaInput::placeholder {
  color: rgba(255,255,255,0.72);
  font-weight: 600;
}

#verificaInput:focus {
  border-color: #ff6a4f;
  box-shadow:
    0 0 0 1px rgba(255,255,255,0.08) inset,
    0 0 22px rgba(255,40,0,0.42),
    0 8px 20px rgba(0,0,0,0.24);
  transform: translateY(-1px);
}

.button {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 18px;
  width: 100%;
  max-width: 400px;
  margin: 16px auto;
  padding: 17px 18px;
  background: linear-gradient(135deg, rgba(25,25,25,0.93), rgba(65,8,8,0.88) 58%, rgba(95,15,15,0.78));
  border: 2px solid var(--red-1);
  border-radius: 20px;
  cursor: pointer;
  font-size: 18px;
  font-weight: 800;
  transition: transform .22s ease, box-shadow .22s ease, background .22s ease, border-color .22s ease, opacity .22s ease;
  box-shadow:
    0 0 10px rgba(255, 20, 0, 0.40),
    0 0 24px rgba(255, 60, 0, 0.12),
    inset 0 1px 0 rgba(255,255,255,0.08),
    inset 0 -1px 0 rgba(0,0,0,0.25);
  animation: glowPulse 3.2s infinite alternate ease-in-out;
  overflow: hidden;
  touch-action: manipulation;
}

.button::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(120deg, transparent 0%, rgba(255,255,255,0.09) 18%, transparent 36%);
  transform: translateX(-130%);
  transition: transform .65s ease;
  pointer-events: none;
}

.button::after {
  content: "";
  position: absolute;
  inset: 1px;
  border-radius: 18px;
  pointer-events: none;
  background: linear-gradient(180deg, rgba(255,255,255,0.03), transparent 24%, transparent 76%, rgba(0,0,0,0.10));
}

@media (hover: hover) {
  .button:hover::before {
    transform: translateX(130%);
  }

  .button:hover {
    background: linear-gradient(135deg, rgba(42,10,10,0.98), rgba(90,8,8,0.92) 58%, rgba(120,15,15,0.84));
    transform: translateY(-2px) scale(1.008);
    box-shadow:
      0 0 18px rgba(255, 30, 0, 0.62),
      0 0 34px rgba(255, 80, 0, 0.18),
      inset 0 1px 0 rgba(255,255,255,0.10),
      inset 0 -1px 0 rgba(0,0,0,0.25);
    border-color: #ff5a3a;
    animation-play-state: paused;
  }

  .button.convocato:hover {
    border-color: #69ff9a;
    animation-play-state: paused;
  }

  .nolink-close:hover {
    transform: scale(1.06);
    box-shadow: 0 0 26px rgba(255,60,0,0.65);
  }
}

.button:active {
  transform: scale(0.985);
}

.button:focus-visible,
.nolink-close:focus-visible {
  outline: 3px solid var(--gold);
  outline-offset: 3px;
}

.button[aria-busy="true"] {
  opacity: .75;
  pointer-events: none;
}

.button[aria-busy="true"]::before {
  animation: scorrimento 1.1s ease-in-out infinite;
}

@keyframes scorrimento {
  from { transform: translateX(-130%); }
  to { transform: translateX(130%); }
}

.button.convocato {
  border-color: #00e676;
  animation: greenPulse 1.8s infinite alternate ease-in-out;
}

@keyframes greenPulse {
  0% {
    box-shadow:
      0 0 8px rgba(0, 230, 118, 0.55),
      0 0 18px rgba(0, 200, 90, 0.15),
      inset 0 1px 0 rgba(255,255,255,0.08),
      inset 0 -1px 0 rgba(0,0,0,0.25);
  }
  50% {
    box-shadow:
      0 0 22px rgba(0, 230, 118, 0.90),
      0 0 40px rgba(0, 255, 120, 0.28),
      inset 0 1px 0 rgba(255,255,255,0.10),
      inset 0 -1px 0 rgba(0,0,0,0.25);
  }
  100% {
    box-shadow:
      0 0 8px rgba(0, 230, 118, 0.55),
      0 0 18px rgba(0, 200, 90, 0.15),
      inset 0 1px 0 rgba(255,255,255,0.08),
      inset 0 -1px 0 rgba(0,0,0,0.25);
  }
}

.button-label {
  font-size: 20px;
  flex-grow: 1;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  letter-spacing: 0.2px;
  text-shadow: 0 2px 5px rgba(0,0,0,0.45);
  position: relative;
  z-index: 1;
}

.clan-logo {
  width: 75px;
  height: 75px;
  object-fit: contain;
  flex-shrink: 0;
  filter: drop-shadow(0 0 6px rgba(255,0,0,0.4));
}

.trophy-box {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 5px;
  min-width: 70px;
  margin-left: auto;
  position: relative;
  z-index: 1;
  flex-shrink: 0;
}

.trophy-icon {
  width: 20px !important;
  height: 20px !important;
  object-fit: contain;
  opacity: 0.95;
  flex-shrink: 0;
  filter: none !important;
}

.trophy-value {
  font-size: 18px;
  font-weight: 800;
  color: var(--gold);
  text-shadow: 0 1px 3px rgba(0,0,0,0.6);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

#verificaBtn {
  justify-content: center;
  text-align: center;
  min-height: 58px;
}

#verificaBtn .button-label {
  text-align: center;
}

#verificaRisultato {
  display: none;
  margin-top: 14px;
  font-size: 17px;
  color: #ffffff;
  text-align: center;
  line-height: 1.8;
  font-weight: 500;
  word-break: break-word;
  overflow-wrap: anywhere;
  padding: 14px 18px;
  background: rgba(0, 0, 0, 0.50);
  border: 1px solid rgba(255, 60, 0, 0.40);
  border-radius: 16px;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  box-shadow: 0 4px 18px rgba(0,0,0,0.30);
}

#verificaRisultato.visibile {
  display: block;
  animation: fadeUp .35s ease backwards;
}

#verificaRisultato.trovato {
  border-color: rgba(0, 200, 90, 0.50);
}

#verificaRisultato.non-trovato {
  border-color: rgba(255, 40, 40, 0.45);
  color: #ff8a8a;
}

.nota-parziale {
  display: block;
  margin-top: 6px;
  font-size: 14px;
  color: rgba(255,255,255,0.72);
}

#linkContainer {
  width: 100%;
  max-width: 400px;
  margin: 0 auto;
}

#linkContainer.comparsa {
  animation: fadeUp .45s ease backwards;
}

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.offline-box {
  width: 100%;
  max-width: 400px;
  margin: 52px auto 0;
  padding: 20px 18px;
  border-radius: 20px;
  background: rgba(0, 0, 0, 0.50);
  border: 1px solid rgba(255, 60, 0, 0.40);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  box-shadow:
    0 4px 18px rgba(0,0,0,0.30),
    inset 0 1px 0 rgba(255,255,255,0.04);
  color: #ffffff;
  text-align: center;
  line-height: 1.6;
  animation: fadeUp .45s ease backwards;
}

.offline-title {
  font-size: 22px;
  font-weight: 800;
  margin-bottom: 8px;
  text-shadow: 0 2px 5px rgba(0,0,0,0.45);
}

.offline-text {
  font-size: 17px;
  color: rgba(255,255,255,0.88);
}

.offline-text a {
  color: var(--gold);
  font-weight: 700;
}

.offline-box .button {
  justify-content: center;
  margin: 16px auto 0;
  min-height: 52px;
}

@keyframes glowPulse {
  0% {
    box-shadow:
      0 0 8px rgba(255, 0, 0, 0.45),
      0 0 18px rgba(255, 70, 0, 0.10),
      inset 0 1px 0 rgba(255,255,255,0.08),
      inset 0 -1px 0 rgba(0,0,0,0.25);
  }
  50% {
    box-shadow:
      0 0 20px rgba(255, 60, 0, 0.80),
      0 0 38px rgba(255, 110, 0, 0.20),
      inset 0 1px 0 rgba(255,255,255,0.10),
      inset 0 -1px 0 rgba(0,0,0,0.25);
  }
  100% {
    box-shadow:
      0 0 8px rgba(255, 0, 0, 0.45),
      0 0 18px rgba(255, 70, 0, 0.10),
      inset 0 1px 0 rgba(255,255,255,0.08),
      inset 0 -1px 0 rgba(0,0,0,0.25);
  }
}

#noLinkOverlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: rgba(0,0,0,0.72);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  align-items: center;
  justify-content: center;
}

#noLinkOverlay.visible {
  display: flex;
  animation: dissolvenza .2s ease-out;
}

@keyframes dissolvenza {
  from { opacity: 0; }
  to { opacity: 1; }
}

.nolink-card {
  background: linear-gradient(160deg, rgba(30,0,0,0.97), rgba(60,10,10,0.95));
  border: 2px solid rgba(255,60,0,0.55);
  border-radius: 26px;
  padding: 34px 28px 28px;
  max-width: 320px;
  width: 90%;
  text-align: center;
  box-shadow: 0 0 40px rgba(255,30,0,0.25), 0 8px 32px rgba(0,0,0,0.5);
  animation: popIn .3s cubic-bezier(.34,1.56,.64,1) both;
}

@keyframes popIn {
  from { transform: scale(0.7); opacity: 0; }
  to   { transform: scale(1);   opacity: 1; }
}

.nolink-emoji {
  font-size: 58px;
  line-height: 1;
  margin-bottom: 12px;
  display: block;
  animation: wobble 1.2s ease infinite;
}

@keyframes wobble {
  0%,100% { transform: rotate(-6deg); }
  50%      { transform: rotate(6deg);  }
}

.nolink-title {
  font-size: 22px;
  font-weight: 900;
  color: #fff;
  margin: 0 0 8px;
  text-shadow: 0 2px 8px rgba(255,60,0,0.5);
  white-space: pre-line;
}

.nolink-text {
  font-size: 16px;
  line-height: 1.5;
  color: rgba(255,255,255,0.85);
  margin: 0 0 18px;
}

.nolink-close {
  display: inline-block;
  padding: 12px 32px;
  background: linear-gradient(135deg, #ff1a1a, #ff5500);
  border: none;
  border-radius: 14px;
  font-size: 16px;
  font-weight: 800;
  color: #fff;
  cursor: pointer;
  box-shadow: 0 0 16px rgba(255,40,0,0.45);
  transition: transform .18s, box-shadow .18s;
  touch-action: manipulation;
}

.nolink-close:active {
  transform: scale(0.96);
}

.desktop-block {
  font-size: 22px;
  line-height: 1.5;
  padding: 20px;
  box-sizing: border-box;
  color: white;
  background: black;
  white-space: pre-line;
}

@media (max-width: 420px) {
  #mobileContent {
    padding: 180px 12px calc(16px + env(safe-area-inset-bottom, 0px));
  }
  #mobileContent::before {
    width: calc(100% - 18px);
  }
  .button {
    gap: 14px;
    padding: 15px 16px;
    border-radius: 18px;
  }
  .button::after {
    border-radius: 16px;
  }
  .button-label {
    font-size: 18px;
  }
  .clan-logo {
    width: 68px !important;
    height: 68px !important;
  }
  .trophy-box {
    min-width: 64px;
    gap: 4px;
  }
  .trophy-icon {
    width: 18px !important;
    height: 18px !important;
  }
  .trophy-value {
    font-size: 14px;
  }
  #verificaInput {
    font-size: 17px;
    padding: 14px 16px;
  }
  #verificaRisultato {
    font-size: 16px;
  }
  .offline-box {
    margin: 46px auto 0;
    padding: 18px 16px;
    border-radius: 18px;
  }
  .offline-title {
    font-size: 20px;
  }
  .offline-text {
    font-size: 16px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .button,
  .button.convocato,
  .button[aria-busy="true"]::before,
  .nolink-emoji,
  .nolink-card,
  #noLinkOverlay.visible,
  #linkContainer.comparsa,
  #verificaRisultato.visibile,
  .offline-box {
    animation: none;
  }
  .button::before,
  .button,
  #verificaInput {
    transition: none;
  }
}
