:root {
  --bg-primary: #0a0a0f;
  --bg-secondary: #14141f;
  --bg-tertiary: #1e1e2e;
  --bg-card: #1C1E21;
  --text-primary: #ffffff;
  --text-secondary: #a0a0b0;
  --text-muted: #606070;
  --accent: #00d4ff;
  --accent-secondary: #00ff88;
  --danger: #ff4466;
  --focus-ring: #00d4ff;
  --focus-glow: rgba(0, 212, 255, 0.4);
  --radius-md: 12px;
  --radius-sm: 8px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  width: 600px;
  height: 600px;
  overflow: hidden;
  background: #000;
  color: var(--text-primary);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  -webkit-font-smoothing: antialiased;
}

#app { width: 100%; height: 100%; position: relative; }

.screen {
  width: 100%;
  height: 100%;
  position: absolute;
  top: 0;
  left: 0;
  display: flex;
  flex-direction: column;
}

.screen.hidden { display: none; }

.focusable {
  transition: box-shadow 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
  border: 2px solid transparent;
  cursor: pointer;
  outline: none;
}

.focusable:focus {
  border-color: var(--focus-ring);
  box-shadow: 0 0 20px var(--focus-glow);
}

.hidden { display: none !important; }

/* ---------- HOME ---------- */
.home-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  padding: 40px;
}

.logo-mark {
  position: relative;
  width: 80px;
  height: 56px;
  margin-bottom: 4px;
}

.logo-mark .mark {
  position: absolute;
  font-size: 44px;
  line-height: 1;
  top: 0;
}

.logo-mark .mark-a { left: 0; color: var(--accent); text-shadow: 0 0 18px rgba(0,212,255,0.6); }
.logo-mark .mark-b { right: 0; color: var(--accent-secondary); text-shadow: 0 0 18px rgba(0,255,136,0.5); }

.title {
  font-size: 52px;
  font-weight: 900;
  letter-spacing: 6px;
  text-align: center;
  line-height: 1.05;
  color: var(--text-primary);
}

.title-accent {
  background: linear-gradient(135deg, var(--accent), var(--accent-secondary));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
}

.subtitle {
  font-size: 16px;
  color: var(--text-secondary);
  letter-spacing: 1.5px;
  text-align: center;
}

.best-score {
  font-size: 15px;
  color: var(--accent);
  min-height: 22px;
  letter-spacing: 1px;
  padding: 4px 16px;
  background: var(--bg-primary);
  border-radius: 999px;
  margin-top: 4px;
}

.best-score.empty {
  color: var(--text-muted);
}

.btn {
  background: var(--bg-secondary);
  color: var(--text-primary);
  border-radius: var(--radius-md);
  padding: 0 40px;
  height: 88px;
  min-width: 280px;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 3px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: inherit;
}

.btn.primary {
  background: linear-gradient(135deg, rgba(0, 212, 255, 0.18), rgba(0, 255, 136, 0.12));
  color: var(--text-primary);
}

.hint {
  font-size: 12px;
  color: var(--text-muted);
  letter-spacing: 2px;
  margin-top: 12px;
}

/* ---------- GAME ---------- */
#game {
  padding: 14px;
  gap: 12px;
}

.hud {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--bg-primary);
  border-radius: var(--radius-md);
  padding: 10px 28px;
  height: 68px;
  border: 1px solid rgba(255,255,255,0.05);
}

.hud-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  min-width: 90px;
}

.hud-label {
  font-size: 11px;
  color: var(--text-muted);
  letter-spacing: 2.5px;
  font-weight: 600;
}

.hud-value {
  font-size: 26px;
  font-weight: 800;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
  letter-spacing: 1px;
}

.hud-mid .hud-value { color: var(--accent); }
.hud-sub { color: var(--text-muted); font-size: 18px; font-weight: 600; }

.grid {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  grid-template-rows: repeat(4, 1fr);
  gap: 10px;
}

.card {
  background: transparent;
  border-radius: var(--radius-md);
  position: relative;
  perspective: 800px;
  min-height: 44px;
}

.card-inner {
  position: relative;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
  transition: transform 0.35s ease;
}

.card.flipped .card-inner {
  transform: rotateY(180deg);
}

.card-face {
  position: absolute;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  overflow: hidden;
}

.card-front {
  background: var(--bg-card);
  color: var(--text-muted);
  font-size: 28px;
  font-weight: 800;
  letter-spacing: 1px;
  background-image:
    linear-gradient(135deg, rgba(0,212,255,0.04) 0%, rgba(0,212,255,0) 60%),
    linear-gradient(315deg, rgba(0,255,136,0.04) 0%, rgba(0,255,136,0) 60%);
}

.card-back {
  background: var(--bg-tertiary);
  font-size: 60px;
  transform: rotateY(180deg);
  font-weight: 700;
  line-height: 1;
}

.card-back .sym {
  text-shadow: 0 0 12px currentColor;
}

.card.matched .card-back {
  background: rgba(0, 255, 136, 0.12);
  box-shadow: inset 0 0 18px rgba(0, 255, 136, 0.25);
}

.card.mismatch .card-back {
  background: rgba(255, 68, 102, 0.18);
  box-shadow: inset 0 0 18px rgba(255, 68, 102, 0.3);
}

.card.locked { pointer-events: none; }

/* Focus on cards should override default; keep border outside the flip */
.card.focusable:focus {
  box-shadow: 0 0 20px var(--focus-glow);
}

/* ---------- WIN ---------- */
.win-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 40px;
}

.win-burst {
  font-size: 56px;
  color: var(--accent-secondary);
  text-shadow:
    0 0 24px rgba(0,255,136,0.7),
    0 0 8px rgba(0,255,136,0.9);
  line-height: 1;
  margin-bottom: 4px;
}

.win-title {
  font-size: 68px;
  font-weight: 900;
  letter-spacing: 10px;
  background: linear-gradient(135deg, var(--accent-secondary), var(--accent));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
  margin-bottom: 8px;
}

.win-stats {
  display: flex;
  align-items: center;
  gap: 36px;
  padding: 16px 28px;
  background: var(--bg-primary);
  border-radius: var(--radius-md);
  margin-bottom: 12px;
}

.stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  min-width: 100px;
}

.stat-divider {
  width: 1px;
  height: 40px;
  background: rgba(255,255,255,0.1);
}

.stat-label {
  font-size: 11px;
  color: var(--text-muted);
  letter-spacing: 2.5px;
  font-weight: 600;
}

.stat-value {
  font-size: 32px;
  font-weight: 800;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
}

.win-best {
  font-size: 15px;
  color: var(--accent);
  min-height: 22px;
  letter-spacing: 1.5px;
  margin-bottom: 8px;
}

.win-best.record {
  color: var(--accent-secondary);
  font-weight: 700;
  text-shadow: 0 0 12px rgba(0,255,136,0.5);
}
