:root{
  --bg: #0b0e14;
  --panel: #121827;
  --cardBack: #1b2540;
  --cardFront: #0e1426;
  --text: #e9eefc;
  --muted: #a9b3cc;
  --primary: #6aa6ff;
  --danger: #ff5b6e;
  --ok: #49d17d;
  --shadow: rgba(0,0,0,.35);
  --radius: 16px;
}

*{ box-sizing:border-box; }
html,body{ height:100%; }
body{
  margin:0;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  background: radial-gradient(1000px 600px at 15% 10%, #182142 0%, var(--bg) 55%) fixed;
  color: var(--text);
}

.topbar{
  display:flex;
  gap:16px;
  align-items:center;
  justify-content:space-between;
  padding:16px 18px;
  border-bottom: 1px solid rgba(255,255,255,.08);
  background: rgba(10, 14, 20, .7);
  backdrop-filter: blur(8px);
  position: sticky;
  top: 0;
  z-index: 10;
}
.topbar h1{
  margin:0;
  font-size:18px;
  letter-spacing:.2px;
}
.meta{
  display:flex;
  flex-wrap:wrap;
  gap:8px;
  margin-top:8px;
}

.pill{
  display:inline-flex;
  align-items:center;
  gap:8px;
  padding:6px 10px;
  border-radius: 999px;
  background: rgba(255,255,255,.06);
  border: 1px solid rgba(255,255,255,.08);
  color: var(--text);
  font-size:12px;
}
.pill--danger{
  border-color: rgba(255,91,110,.35);
  background: rgba(255,91,110,.12);
}

.wrap{
  max-width: 1200px;
  margin: 18px auto 40px;
  padding: 0 14px;
}

.panel{
  background: rgba(255,255,255,.04);
  border: 1px solid rgba(255,255,255,.08);
  border-radius: var(--radius);
  padding: 14px 14px 12px;
  box-shadow: 0 12px 30px var(--shadow);
}
.panel__row{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
}
.panel__info .title{
  font-weight: 700;
  font-size: 13px;
  margin-bottom: 4px;
}
.panel__info .text{
  font-size: 13px;
  color: var(--muted);
  line-height: 1.35;
  max-width: 820px;
}
.progress{
  margin-top: 10px;
  height: 10px;
  border-radius: 999px;
  background: rgba(255,255,255,.06);
  border: 1px solid rgba(255,255,255,.08);
  overflow:hidden;
}
.progress__bar{
  height: 100%;
  background: linear-gradient(90deg, rgba(106,166,255,.9), rgba(73,209,125,.9));
  width: 0%;
  transition: width .25s ease;
}

.btn{
  appearance:none;
  border: 1px solid rgba(255,255,255,.14);
  background: rgba(255,255,255,.06);
  color: var(--text);
  padding: 10px 12px;
  border-radius: 12px;
  cursor:pointer;
  font-weight: 700;
  font-size: 13px;
  text-decoration:none;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  gap:8px;
  user-select:none;
}
.btn:hover{ background: rgba(255,255,255,.10); }
.btn:disabled{ opacity:.55; cursor:not-allowed; }

.btn--primary{
  background: rgba(106,166,255,.18);
  border-color: rgba(106,166,255,.35);
}
.btn--primary:hover{ background: rgba(106,166,255,.26); }

.btn--danger{
  background: rgba(255,91,110,.16);
  border-color: rgba(255,91,110,.35);
}
.btn--danger:hover{ background: rgba(255,91,110,.24); }

.btn--ghost{
  background: transparent;
}

.board{
  margin-top: 16px;
  display:grid;
  gap: 10px;
  grid-template-columns: repeat(6, minmax(0, 1fr));
}

@media (max-width: 1100px){
  .board{ grid-template-columns: repeat(5, minmax(0, 1fr)); }
}
@media (max-width: 900px){
  .board{ grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
@media (max-width: 650px){
  .board{ grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 420px){
  .board{ grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

.card{
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1.12;
  perspective: 1000px;
}

.card__inner{
  position:absolute;
  inset:0;
  transform-style: preserve-3d;
  transition: transform .18s ease;
  border-radius: 14px;
}
.card.is-flipped .card__inner{ transform: rotateY(180deg); }
.card.is-matched{ pointer-events:none; }

.face{
  position:absolute;
  inset:0;
  border-radius: 14px;
  backface-visibility: hidden;
  border: 1px solid rgba(255,255,255,.10);
  overflow:hidden;
}

.back{
  background: linear-gradient(180deg, rgba(255,255,255,.06), rgba(255,255,255,.02));
  box-shadow: 0 10px 22px rgba(0,0,0,.32);
  display:flex;
  align-items:center;
  justify-content:center;
}

.back__badge{
  width: 56%;
  height: 56%;
  border-radius: 18px;
  background: rgba(255,255,255,.06);
  border: 1px solid rgba(255,255,255,.10);
  position: relative;
  overflow:hidden;
}
.back__badge::before{
  content:"";
  position:absolute;
  inset:-30%;
  background: radial-gradient(circle at 30% 30%, rgba(106,166,255,.35), transparent 50%),
              radial-gradient(circle at 70% 70%, rgba(73,209,125,.25), transparent 55%);
  transform: rotate(20deg);
}
.back__text{
  position:absolute;
  inset:0;
  display:flex;
  align-items:center;
  justify-content:center;
  font-weight: 900;
  letter-spacing:.8px;
  color: rgba(233,238,252,.85);
  text-transform: uppercase;
  font-size: 12px;
}

.back__icon{
  width: 70%;
  height: 70%;
  object-fit: contain;
  display:block;
  filter: drop-shadow(0 6px 10px rgba(0,0,0,.35));
}

.front{
  background: linear-gradient(180deg, rgba(14,20,38,.9), rgba(14,20,38,.65));
  transform: rotateY(180deg);
  display:flex;
  align-items:center;
  justify-content:center;
  padding: 10px;
}
.front img{
  width: 88%;
  height: 88%;
  object-fit: contain;
  image-rendering: auto;
  filter: var(--imgFilter, none);
}

.card.is-matched .front{
  outline: 2px solid rgba(73,209,125,.7);
  box-shadow: 0 0 0 4px rgba(73,209,125,.12);
}

.modal{
  position: fixed;
  inset:0;
  display:none;
  align-items:center;
  justify-content:center;
  background: rgba(0,0,0,.55);
  z-index: 50;
}
.modal.is-open{ display:flex; }
.modal__card{
  width: min(520px, calc(100% - 26px));
  background: rgba(18,24,39,.92);
  border: 1px solid rgba(255,255,255,.10);
  border-radius: 18px;
  box-shadow: 0 30px 80px rgba(0,0,0,.55);
  padding: 16px 16px 14px;
}
.modal__card h2{
  margin: 0 0 8px 0;
  font-size: 18px;
}
.modal__card p{
  margin: 0 0 14px 0;
  color: var(--muted);
  line-height: 1.35;
}
.modal__actions{
  display:flex;
  gap:10px;
  justify-content:flex-end;
  flex-wrap:wrap;
}
