/* Memory Match — layout and UI chrome.
 * Colors/fonts come from config.js via CSS variables set in src/main.js. */

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: var(--font, system-ui, sans-serif);
  background: var(--bg, #141c2e);
  color: var(--text, #fff);
  min-height: 100dvh;
  -webkit-tap-highlight-color: transparent;
}

.screen { display: none; min-height: 100dvh; flex-direction: column; align-items: center; padding: 16px; }
.screen.active { display: flex; }

h1 { font-size: clamp(24px, 6vw, 36px); margin: 8px 0 4px; text-align: center; }
#subtitle { opacity: 0.75; margin-bottom: 18px; text-align: center; }

#difficulties { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; margin-bottom: 16px; }
.diff {
  font: inherit; font-size: 14px; font-weight: 600;
  background: var(--panel); color: var(--text);
  border: 2px solid transparent; border-radius: 10px; padding: 10px 16px; cursor: pointer;
}
.diff.selected { border-color: var(--primary); }

#best-score { min-height: 20px; font-size: 14px; opacity: 0.85; margin-bottom: 14px; }

.big-btn {
  font-family: inherit; font-size: 17px; font-weight: 800; letter-spacing: 1px;
  border: 0; border-radius: 12px; padding: 14px 34px;
  background: var(--primary); color: #10131c; cursor: pointer; transition: transform 0.1s;
}
.big-btn:active { transform: scale(0.96); }

/* game screen */
#hud {
  width: min(96vw, 620px);
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  margin-bottom: 12px; font-size: 15px;
}
#hud button {
  font: inherit; font-size: 13px; font-weight: 600;
  background: var(--panel); color: var(--text);
  border: 1px solid rgba(255,255,255,0.18); border-radius: 8px; padding: 7px 12px; cursor: pointer;
}

#board {
  width: min(96vw, 620px);
  display: grid;
  grid-template-columns: repeat(var(--cols, 4), 1fr);
  gap: min(2.2vw, 12px);
}

.card {
  aspect-ratio: 3 / 4;
  border: 0; background: none; padding: 0; cursor: pointer;
  perspective: 600px;
  -webkit-tap-highlight-color: transparent;
}
.card .inner {
  position: relative; display: block; width: 100%; height: 100%;
  transition: transform 0.35s; transform-style: preserve-3d;
}
.card.flipped .inner { transform: rotateY(180deg); }
.card .back, .card .face {
  position: absolute; inset: 0; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  backface-visibility: hidden; -webkit-backface-visibility: hidden;
  font-size: clamp(20px, 6vw, 40px);
}
.card .back {
  background: var(--card-back);
  box-shadow: inset 0 0 0 2px rgba(255,255,255,0.15);
}
.card .back::after { content: "?"; color: rgba(255,255,255,0.55); font-weight: 800; }
.card .face {
  background: var(--card-face); color: var(--card-text);
  transform: rotateY(180deg);
  box-shadow: inset 0 0 0 2px rgba(0,0,0,0.08);
}
.card.matched .inner { transform: rotateY(180deg); }
.card.matched .face { box-shadow: inset 0 0 0 3px var(--primary); }
.card.matched { cursor: default; }

/* win overlay */
#win-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.6);
  display: flex; align-items: center; justify-content: center; padding: 20px; z-index: 10;
  opacity: 0; visibility: hidden; pointer-events: none; transition: opacity 0.25s, visibility 0.25s;
}
#win-overlay.open { opacity: 1; visibility: visible; pointer-events: auto; }
.win-card {
  background: var(--panel); border: 1px solid rgba(255,255,255,0.14); border-radius: 16px;
  padding: 28px 24px; width: min(92vw, 340px); text-align: center;
  transform: scale(0.85); transition: transform 0.25s; box-shadow: 0 12px 40px rgba(0,0,0,0.5);
}
#win-overlay.open .win-card { transform: scale(1); }
#win-title { font-size: 24px; margin-bottom: 10px; }
#win-moves { font-size: 17px; margin-bottom: 4px; }
#win-time { font-size: 15px; opacity: 0.85; margin-bottom: 8px; }
#win-best { min-height: 20px; font-size: 14px; color: var(--primary); font-weight: 700; margin-bottom: 16px; }

#mute-btn {
  position: fixed; right: 14px; top: 14px; width: 42px; height: 42px; border-radius: 50%; border: 0;
  background: rgba(255,255,255,0.12); font-size: 20px; cursor: pointer; z-index: 5;
}

/* embed mode */
body.embed .screen { padding: 8px; }
body.embed h1, body.embed #subtitle { display: none; }
body.embed #mute-btn { right: 6px; top: 6px; width: 34px; height: 34px; font-size: 16px; }
