/* Memory dei Segnali — stili specifici (il grosso e' in /app-shared/app-common.css) */
:root {
  --card-size: clamp(72px, 21vw, 130px);
  --card-gap: clamp(6px, 2vw, 14px);
  --pc-blue: #003366;
  --pc-blue-light: #cfe2ff;
}

.game-container {
  max-width: 800px;
  margin: 0 auto;
  text-align: center;
}

.intro-box {
  background: #fff;
  border-radius: 16px;
  padding: 1.5rem 1.2rem;
  box-shadow: 0 4px 16px rgba(0, 0, 0, .08);
  text-align: left;
}
.intro-box h2 {
  color: var(--pc-blue);
  font-size: 1.2rem;
  margin: 0 0 .6rem;
}
.intro-box p {
  margin: 0 0 .8rem;
  font-size: .98rem;
  line-height: 1.55;
}
.livelli-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 1rem;
  margin-top: 1rem;
}
.btn-livello {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: .35rem;
  padding: 1.5rem 1rem;
  border: 3px solid var(--pc-blue);
  background: linear-gradient(180deg, #ffffff 0%, #e7f1ff 100%);
  color: var(--pc-blue);
  border-radius: 16px;
  cursor: pointer;
  transition: transform .15s, background .2s, color .2s, box-shadow .2s;
  font-weight: 600;
  font-family: inherit;
  width: 100%;
  min-height: 140px;
  box-shadow: 0 4px 0 var(--pc-blue), 0 6px 12px rgba(0,51,102,.15);
  position: relative;
}
.btn-livello:hover {
  background: linear-gradient(180deg, var(--pc-blue) 0%, #002244 100%);
  color: #fff;
  transform: translateY(-3px);
  box-shadow: 0 7px 0 #001a33, 0 10px 16px rgba(0,51,102,.3);
}
.btn-livello:focus-visible {
  outline: 4px solid #ffbe2e;
  outline-offset: 3px;
}
.btn-livello:active {
  transform: translateY(1px);
  box-shadow: 0 2px 0 var(--pc-blue), 0 3px 6px rgba(0,51,102,.15);
}
.btn-livello[data-livello="medio"]   { border-color: #b45309; box-shadow: 0 4px 0 #b45309, 0 6px 12px rgba(180,83,9,.15); color: #b45309; }
.btn-livello[data-livello="medio"]:hover  { background: linear-gradient(180deg, #b45309 0%, #7c3a0c 100%); color: #fff; box-shadow: 0 7px 0 #7c3a0c, 0 10px 16px rgba(180,83,9,.3); }
.btn-livello[data-livello="esperto"] { border-color: #7f1d1d; box-shadow: 0 4px 0 #7f1d1d, 0 6px 12px rgba(127,29,29,.15); color: #7f1d1d; }
.btn-livello[data-livello="esperto"]:hover { background: linear-gradient(180deg, #7f1d1d 0%, #5a0f0f 100%); color: #fff; box-shadow: 0 7px 0 #5a0f0f, 0 10px 16px rgba(127,29,29,.3); }

.livello-num {
  font-size: 2.4rem;
  font-weight: 700;
  line-height: 1;
  background: currentColor;
  color: #fff;
  width: 2.6rem;
  height: 2.6rem;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: .35rem;
}
.btn-livello:hover .livello-num,
.btn-livello[data-livello="medio"]:hover .livello-num,
.btn-livello[data-livello="esperto"]:hover .livello-num {
  background: #fff;
  color: var(--pc-blue);
}
.btn-livello[data-livello="medio"]:hover .livello-num   { color: #b45309; }
.btn-livello[data-livello="esperto"]:hover .livello-num { color: #7f1d1d; }
.livello-nome {
  font-size: 1.3rem;
  font-weight: 700;
  margin-top: .15rem;
  letter-spacing: .02em;
}
.livello-info {
  font-size: .88rem;
  opacity: .85;
  margin-top: .15rem;
}
.livello-cta {
  display: inline-flex;
  align-items: center;
  gap: .25rem;
  font-size: .82rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  margin-top: .35rem;
}
@media (prefers-reduced-motion: reduce) {
  .btn-livello { transition: none; }
  .btn-livello:hover, .btn-livello:active { transform: none; }
}

.hud-row {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
  justify-content: center;
  align-items: center;
  margin-bottom: 1rem;
}
.hud-pill {
  background: #fff;
  border: 2px solid var(--pc-blue);
  border-radius: 20px;
  padding: .25rem .8rem;
  font-size: .9rem;
  color: var(--pc-blue);
  display: inline-flex;
  align-items: center;
  gap: .35rem;
}

.memory-grid {
  display: grid;
  grid-template-columns: repeat(var(--mappa-cols, 4), var(--card-size));
  gap: var(--card-gap);
  justify-content: center;
  perspective: 1000px;
  margin-bottom: 1rem;
}

.card {
  width: var(--card-size);
  height: var(--card-size);
  position: relative;
  transform-style: preserve-3d;
  transition: transform 0.6s;
  cursor: pointer;
  background: transparent;
  border: 0;
  padding: 0;
}
.card:focus-visible {
  outline: 3px solid #ffbe2e;
  outline-offset: 3px;
  border-radius: 10px;
}
.card.flipped,
.card.matched {
  transform: rotateY(180deg);
  cursor: default;
}
.card.matched {
  animation: matchPulse 0.5s ease;
}
.card.matched .card-back {
  border: 3px solid #2e7d32;
  box-shadow: 0 0 12px rgba(46, 125, 50, 0.5);
}
.card.matched .card-back::after {
  content: '\2713';
  position: absolute;
  bottom: 2px;
  right: 6px;
  background: #2e7d32;
  color: white;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  font-size: 14px;
  font-weight: 700;
  display: flex;
  justify-content: center;
  align-items: center;
  line-height: 1;
}
@keyframes matchPulse {
  0%   { transform: rotateY(180deg) scale(1); }
  50%  { transform: rotateY(180deg) scale(1.08); }
  100% { transform: rotateY(180deg) scale(1); }
}
@media (prefers-reduced-motion: reduce) {
  .card { transition: none; }
  .card.matched { animation: none; }
}

.card-face {
  position: absolute;
  inset: 0;
  border-radius: 10px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
  display: flex;
  justify-content: center;
  align-items: center;
}
.card-front {
  background: linear-gradient(135deg, #004d99 0%, #003366 100%);
  color: white;
}
.card-front::after {
  content: '?';
  font-size: 2.5rem;
  font-weight: 700;
}
.card-back {
  background-color: white;
  transform: rotateY(180deg);
  padding: .4rem;
  border: 2px solid #e0e0e0;
}
.card-sign img {
  max-width: 88%;
  max-height: 88%;
}
.card-action {
  background: #e7f3ff;
}
.card-action-text {
  font-size: clamp(.78rem, 2.4vw, .95rem);
  line-height: 1.2;
  font-weight: 600;
  color: var(--pc-blue);
  text-align: center;
  padding: .25rem;
  hyphens: auto;
  word-break: break-word;
}

.explain-box {
  background: #d1e7dd;
  border: 1px solid #badbcc;
  border-radius: 10px;
  padding: .8rem 1rem;
  margin-top: 1rem;
  text-align: left;
  animation: slideUp .35s ease;
}
.explain-box h3 {
  margin: 0 0 .35rem;
  color: #0f5132;
  font-size: 1rem;
}
.explain-box p {
  margin: 0;
  color: #0f5132;
  font-size: .95rem;
  line-height: 1.5;
}
@keyframes slideUp {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}
@media (prefers-reduced-motion: reduce) {
  .explain-box { animation: none; }
}

.win-screen-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.7);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 100;
}
.win-box {
  background-color: white;
  padding: 2rem 1.5rem;
  border-radius: 16px;
  text-align: center;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
  max-width: 90%;
}
.win-stats {
  font-size: .95rem;
  color: var(--pc-blue);
  font-weight: 600;
  margin: .5rem 0 1rem;
}

.hide { display: none !important; }

.match-toast {
  position: fixed;
  transform: translateX(-50%);
  background: #2e7d32;
  color: white;
  padding: 6px 16px;
  border-radius: 20px;
  font-size: 1.1rem;
  font-weight: 700;
  pointer-events: none;
  z-index: 50;
  animation: toastUp 0.9s ease forwards;
}
@keyframes toastUp {
  0%   { opacity: 1; transform: translateX(-50%) translateY(0); }
  100% { opacity: 0; transform: translateX(-50%) translateY(-40px); }
}
