/*
 * Stile della Mini App.
 *
 * I colori vengono dal tema di Telegram (var(--tg-theme-*)), con fallback per
 * quando la pagina e' aperta fuori da Telegram. Non fissare colori propri:
 * l'utente puo' stare in tema chiaro o scuro, e una Mini App che ignora il
 * tema si vede subito.
 */

:root {
  --bg:        var(--tg-theme-secondary-bg-color, #f4f4f5);
  --card:      var(--tg-theme-bg-color, #ffffff);
  --text:      var(--tg-theme-text-color, #000000);
  --hint:      var(--tg-theme-hint-color, #707579);
  --link:      var(--tg-theme-link-color, #2481cc);
  --btn-bg:    var(--tg-theme-button-color, #2481cc);
  --btn-text:  var(--tg-theme-button-text-color, #ffffff);
  --section:   var(--tg-theme-secondary-bg-color, #f4f4f5);
  --danger:    var(--tg-theme-destructive-text-color, #e53935);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

#app {
  /* safe-area-inset: su iPhone il bordo inferiore finisce sotto la tacca.
     Il padding-bottom e' generoso perche' il MainButton nativo copre
     la parte bassa della finestra. */
  padding: 16px 16px calc(24px + env(safe-area-inset-bottom, 0px));
  max-width: 640px;
  margin: 0 auto;
}

h1 {
  font-size: 20px;
  font-weight: 600;
  margin: 0 0 8px;
}

.muted { color: var(--hint); }

/* ------------------------------------------------------- regolamento */

.rules {
  background: var(--card);
  border-radius: 14px;
  padding: 16px 18px;
  margin: 0 0 18px;
  overflow-wrap: anywhere;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
}

/* Il testo arriva dal bot con a capo singoli: servono paragrafi compatti. */
.rules p { margin: 0 0 10px; }
.rules p:last-child { margin-bottom: 0; }
.rules b, .rules strong { font-weight: 600; }
.rules a { color: var(--link); }

.rules h2 {
  font-size: 16px;
  font-weight: 600;
  margin: 18px 0 8px;
}
.rules h2:first-child { margin-top: 0; }

/* --------------------------------------------------------- azioni */

.decline-row {
  text-align: center;
  margin: 4px 0 0;
}

/* Il rifiuto e' un link, non un bottone: l'azione primaria e' il
   MainButton nativo, e due bottoni pieni competerebbero tra loro. */
.linklike {
  display: inline-block;
  background: none;
  border: 1px solid var(--hint);
  border-radius: 10px;
  padding: 12px 24px;
  font: inherit;
  font-size: 15px;
  font-weight: 500;
  color: var(--text);
  text-decoration: none;
  cursor: pointer;
}

.linklike:disabled { opacity: 0.5; cursor: default; }

.btn {
  width: 100%;
  padding: 14px 16px;
  border: none;
  border-radius: 10px;
  font-size: 16px;
  font-family: inherit;
  cursor: pointer;
  user-select: none;
  margin-bottom: 8px;
}

.btn:disabled { opacity: 0.6; cursor: default; }

.btn-primary {
  background: var(--btn-bg);
  color: var(--btn-text);
  font-weight: 600;
}

.btn-ghost {
  background: transparent;
  color: var(--link);
}

/* ------------------------------------------------- schermate di esito */

.center {
  text-align: center;
  padding: 48px 8px 24px;
}

.icon {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  margin: 0 auto 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  font-weight: 700;
  background: var(--card);
  color: var(--hint);
}

.icon-ok     { background: var(--btn-bg); color: var(--btn-text); }
.icon-warn   { background: var(--section); color: var(--danger); }

.spinner {
  width: 28px;
  height: 28px;
  margin: 0 auto 14px;
  border: 3px solid var(--card);
  border-top-color: var(--hint);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

@media (prefers-reduced-motion: reduce) {
  .spinner { animation-duration: 3s; }
}

[hidden] { display: none !important; }
