/* mamuth.css — UI "Mamuth" (cards gialle a puntini blu, accenti viola/arancio) */

:root{
  /* palette */
  --bg: #eaf7ff;
  --panel: #ffffff;
  --text: #1c1f2e;
  --muted: #4b4f6a;

  --violet: #5c50d8;
  --orange: #ffb347;
  --orange2:#ffa53a;

  --blue: #1f4cff;          /* bordo carte / puntini */
  --blue-soft:#d7e3ff;

  --shadow: 0 16px 40px rgba(19, 28, 66, .12);

  --r-card: 22px;
  --r-pill: 14px;

  /* dimensioni: JS può sovrascrivere via inline, ma questi sono i default */
  --tile: 180px;
  --gap: 22px;

  /* pattern puntini */
  --dot-size: 6px;
  --dot-gap: 14px;
}

/* reset */
*{ box-sizing:border-box; }
html, body{ height:100%; }
body{
  margin:0;
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial;
  color: var(--text);
  background: var(--bg);
}

#mamuth-root{ min-height:100%; }

/* wrapper generale */
.mamuth-app{
  min-height:100%;
  padding: 26px 26px;
}

/* view wrapper: centra solo le schermate "card", ma non il game */
.view{ width:100%; }
.view[style*="display:none"]{ display:none !important; }

/* ==== CARD (login/home/rank/insights) ==== */
.card{
  width: min(520px, 92vw);
  margin: 0 auto;
  background: var(--panel);
  border-radius: 26px;
  box-shadow: var(--shadow);
  padding: 22px 22px;
}

.card h1{
  margin: 0 0 10px;
  font-size: 44px;
  letter-spacing: .2px;
  color: var(--violet);
}
.card h2{
  margin: 0 0 14px;
  font-size: 28px;
}
.card p{
  margin: 0 0 18px;
  color: var(--muted);
}

/* form */
label{
  display:block;
  margin: 12px 0 6px;
  font-weight: 700;
  color: #2c2f43;
  font-size: 14px;
}

input[type="text"], input[type="password"], input[type="email"]{
  width:100%;
  padding: 12px 12px;
  border-radius: 14px;
  border: 2px solid #e7ebf7;
  background: #fbfcff;
  outline: none;
  font-size: 15px;
}
input:focus{
  border-color: var(--blue-soft);
  box-shadow: 0 0 0 4px rgba(31, 76, 255, .10);
}

.checkbox{
  display:flex;
  align-items:center;
  gap:10px;
  margin-top:10px;
  color: var(--muted);
}
.checkbox input{ transform: scale(1.05); }

/* buttons */
button{
  border:0;
  cursor:pointer;
  font-weight: 800;
  letter-spacing: .2px;
  font-size: 16px;
}

.btn-primary{
  background: linear-gradient(180deg, var(--orange), var(--orange2));
  color: #fff;
  padding: 14px 18px;
  border-radius: 999px;
  box-shadow: 0 10px 22px rgba(255, 165, 58, .24);
}
.btn-primary:hover{ filter: brightness(1.02); }
.btn-primary:active{ transform: translateY(1px); }

.secondary{
  background: transparent;
  color: var(--violet);
  padding: 12px 14px;
  border-radius: 999px;
  border: 2px solid rgba(92, 80, 216, .25);
}
.secondary:hover{ background: rgba(92, 80, 216, .06); }

.btn-ghost{
  background: transparent;
  color: var(--violet);
  padding: 10px 12px;
  border-radius: 999px;
}

/* bottone "Esci" in-game: evidente e coerente */
.btn-danger{
  background: #ff4d5a;
  color: #fff;
  padding: 14px 18px;
  border-radius: 999px;
  box-shadow: 0 10px 22px rgba(255, 77, 90, .22);
}
.btn-danger:hover{ filter: brightness(1.02); }
.btn-danger:active{ transform: translateY(1px); }

.danger{
  background: #ffe7ea;
  color: #b8182e;
  padding: 12px 14px;
  border-radius: 999px;
  border: 2px solid rgba(184, 24, 46, .18);
}

.row{ display:flex; gap:12px; align-items:center; flex-wrap:wrap; }

.msg{
  margin: 10px 0 0;
  padding: 12px 14px;
  border-radius: 16px;
  border: 2px solid #eef1fb;
  background: #fbfcff;
}
.msg.ok{ border-color: rgba(12, 160, 108, .25); background: rgba(12, 160, 108, .08); color:#085a3d; }
.msg.error{ border-color: rgba(184, 24, 46, .20); background: rgba(184, 24, 46, .07); color:#8b0f20; }

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

/* home menu */
.home-menu{
  display:grid;
  grid-template-columns: 1fr;
  gap: 14px;
  margin-top: 18px;
}
@media (min-width:520px){
  .home-menu{ grid-template-columns: repeat(2, 1fr); }
}

/* livelli/autori: bottoni "piatti" */
.level, .author{
  background: #ffffff;
  border: 2px solid #eef1fb;
  color: #2c2f43;
  padding: 14px 14px;
  border-radius: 18px;
}
.level:hover, .author:hover{
  border-color: rgba(31,76,255,.18);
  box-shadow: 0 10px 24px rgba(19, 28, 66, .08);
}

.author.selected{
  border-color: rgba(31,76,255,.35);
  box-shadow: 0 12px 28px rgba(31,76,255,.10);
}


/* ==== GAME LAYOUT ==== */
.game-shell{
  width: 100%;
  display:grid;
  grid-template-columns: 1fr 420px;
  gap: 28px;
  align-items:start;
}

@media (max-width: 1100px){
  .game-shell{ grid-template-columns: 1fr; }
}

/* sinistra: board area */
.board-wrap{
  padding: 12px 12px 18px 12px;
}

/* griglia coordinate + board (evita sovrapposizioni e "celle" vuote) */
.board-grid{
  display:grid;
  grid-template-columns: 64px 1fr;
  grid-template-rows: 54px 1fr;
  gap: 14px;
  align-items:start;
}

.coord-corner{ width:64px; height:54px; }

/* coordinate pills */
.coord-top{
  display:grid;
  gap: var(--gap);
  align-content:start;
}
.coord-left{
  display:grid;
  gap: var(--gap);
  align-content:start;
}

/* le etichette di riga devono essere compatte (non grandi come le carte) */
.coord-left .coord.cell{
  width: 64px;
  font-size: 16px;
}

/* stessa classe usata dal JS: coord + cell */
.coord.cell{
  width: var(--tile);
  height: 42px;
  display:flex;
  align-items:center;
  justify-content:center;
  border-radius: var(--r-pill);
  background: #ffffff;
  border: 2px solid #eef1fb;
  color: #2c2f43;
  font-weight: 900;
  box-shadow: 0 10px 22px rgba(19, 28, 66, .06);
}

/* board: la griglia vera e propria */
.board{
  display:grid;
  gap: var(--gap);
  align-content:start;
}

/* ==== CARTE (front coperto / back rivelato) ==== */
.card3d{
  width: var(--tile);
  height: var(--tile);
  position:relative;
  border-radius: var(--r-card);
  transform-style: preserve-3d;
  transition: transform .45s ease;
  cursor: pointer;
}
.card3d.flip{ transform: rotateY(180deg); }

.face{
  position:absolute;
  inset:0;
  border-radius: var(--r-card);
  backface-visibility:hidden;
  overflow:hidden;
}

/* FRONT = carta coperta: gialla con puntini blu */
.face.front{
  background:
    radial-gradient(circle, var(--blue) 0 var(--dot-size), transparent calc(var(--dot-size) + 1px)) 0 0 / var(--dot-gap) var(--dot-gap),
    linear-gradient(180deg, #ffd36a, #ffc84f);
  border: 4px solid var(--blue);
  box-shadow: 0 12px 26px rgba(19, 28, 66, .08);
}

/* BACK = carta scoperta: bianca con immagine centrata (nota musicale) */
.face.back{
  transform: rotateY(180deg);
  background: #ffffff;
  border: 4px solid rgba(255, 179, 71, .9); /* leggermente arancio come highlight */
  display:flex;
  align-items:center;
  justify-content:center;
  padding: 18px;
  box-shadow: 0 12px 26px rgba(19, 28, 66, .08);
}

.face.back img{
  width: 64%;
  height: 64%;
  object-fit: contain;
  filter: saturate(1.05);
}

/* se il JS mette un'icona via testo (fallback) */
.face.back .icon{
  font-size: 64px;
  color: var(--violet);
  font-weight: 900;
}

/* matched: leggera enfasi */
.card3d.matched .face.back{
  border-color: rgba(92, 80, 216, .55);
  box-shadow: 0 18px 34px rgba(92, 80, 216, .16);
}

/* ==== SIDEBAR destra (pannello bianco) ==== */
.game-right{
  background: #ffffff;
  border-radius: 26px;
  box-shadow: var(--shadow);
  padding: 22px 22px;
}

.side-stats{
  display:grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-bottom: 18px;
}

.stat{
  text-align:center;
}
.stat-label{
  font-weight: 900;
  color: #2c2f43;
  font-size: 22px;
}
.stat-value{
  margin-top: 8px;
  font-size: 46px;
  font-weight: 900;
  color: var(--violet);
}

.side-title{
  font-size: 34px;
  font-weight: 900;
  margin: 10px 0 18px;
}

/* bottoni sidebar */
.game-actions{
  display:grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin: 10px 0 8px;
}
.game-actions button{ width:100%; }

/* log mosse/dettagli */
.moves-log{
  margin-top: 10px;
  max-height: 360px;
  overflow:auto;
  padding-right: 6px;
}
.move{
  background: #fbfcff;
  border: 2px solid #eef1fb;
  border-radius: 18px;
  padding: 12px 14px;
  margin-bottom: 10px;
}

/* ==== MODAL ==== */
.modal{
  position:fixed;
  inset:0;
  background: rgba(0,0,0,.25);
  display:flex;
  align-items:center;
  justify-content:center;
  padding: 18px;
  z-index: 9999;
}

.modal-body{
  width: min(640px, 96vw);
  background: #ffffff;
  border-radius: 22px;
  box-shadow: var(--shadow);
  overflow:hidden;
}

.modal-content{
  padding: 18px 18px;
}

.modal-title{
  font-size: 26px;
  font-weight: 900;
  margin: 2px 0 10px;
}

.modal-text{
  font-size: 18px;
  line-height: 1.45;
  color: #2c2f43;
}

/* contenuto "fine partita" */
.modal-hero{
  font-size: 40px;
  line-height: 1;
  margin-bottom: 6px;
}
.modal-sub{
  font-weight: 900;
  font-size: 20px;
  margin: 2px 0 10px;
}
.modal-stats{
  display:grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 12px 0 10px;
}
.mstat{
  background: #fbfcff;
  border: 2px solid #eef1fb;
  border-radius: 18px;
  padding: 10px 12px;
}
.mstat-k{
  color: var(--muted);
  font-weight: 800;
  font-size: 13px;
}
.mstat-v{
  font-weight: 900;
  font-size: 18px;
  margin-top: 2px;
}
.modal-hint{
  color: var(--muted);
  margin-top: 6px;
}

#modal_btns{
  display:flex;
  justify-content:flex-end;
  gap: 10px;
  margin-top: 14px;
}

/* ==== RANK / INSIGHTS (se usati) ==== */
.rank{
  width:100%;
  border-radius: 18px;
  overflow:hidden;
  border: 2px solid #eef1fb;
  background: #ffffff;
}
.rank-row{
  display:grid;
  grid-template-columns: 54px 1.1fr 80px 80px 80px 1.1fr;
  gap:10px;
  padding: 12px 14px;
  border-bottom: 2px solid #f2f4fd;
  align-items:center;
}
.rank-row.rank-head{
  background: #fbfcff;
  font-weight: 900;
  color: var(--muted);
}
.rank-row:last-child{ border-bottom:0; }

@media (max-width:740px){
  .rank-row{ grid-template-columns: 44px 1fr 70px 70px; }
  .rank-row span:nth-child(5),
  .rank-row span:nth-child(6){ display:none; }
}

.insights-list{
  display:flex;
  flex-direction:column;
  gap: 12px;
  margin-top: 10px;
}
.insight-row{
  background: #ffffff;
  border: 2px solid #eef1fb;
  border-radius: 18px;
  padding: 14px;
  box-shadow: 0 10px 22px rgba(19, 28, 66, .06);
}
.insight-title{
  font-weight: 900;
  margin-bottom: 10px;
}
.insight-controls{
  display:flex;
  gap: 10px;
  align-items:center;
  flex-wrap:wrap;
}
.insight-audio{ width: min(520px, 100%); }
