/* ===== MINESWEEPER ===== */

:root {
  --bg:        #08080F;
  --surface:   #0F0F1A;
  --border:    rgba(255,255,255,0.07);
  --text:      #E8E8F5;
  --muted:     rgba(232,232,245,0.45);

  --accent:       #00D4FF;
  --accent-dim:   rgba(0,212,255,0.10);
  --accent-glow:  0 0 12px #00D4FF, 0 0 28px rgba(0,212,255,0.3);

  --cell-covered: #1A1A2E;
  --cell-hover:   #242445;
  --cell-open:    #0D0D1A;
  --cell-mine:    #FF3B5C;

  --n1: #60A5FA;
  --n2: #34D399;
  --n3: #F87171;
  --n4: #818CF8;
  --n5: #FB923C;
  --n6: #22D3EE;
  --n7: #F472B6;
  --n8: #94A3B8;

  --t: 0.18s;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', sans-serif;
  font-weight: 300;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* ── BACK ── */
.back {
  position: fixed; top: 1.25rem; left: 1.5rem; z-index: 100;
  display: flex; align-items: center; gap: 0.4rem;
  font-size: 0.8rem; font-weight: 500;
  color: var(--muted); text-decoration: none;
  transition: color var(--t);
  letter-spacing: 0.02em;
}
.back:hover { color: var(--text); }
.back svg { opacity: 0.7; transition: opacity var(--t); }
.back:hover svg { opacity: 1; }

/* ── HERO ── */
.hero {
  min-height: 36vh;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  position: relative; overflow: hidden;
  padding: 6rem 1.5rem 2.5rem;
  text-align: center;
}

.hero-bg {
  position: absolute; inset: 0; pointer-events: none;
  background:
    radial-gradient(ellipse 70% 55% at 50% 60%, rgba(0,212,255,0.08) 0%, transparent 70%),
    radial-gradient(ellipse 40% 30% at 15% 80%, rgba(0,140,200,0.05) 0%, transparent 60%),
    radial-gradient(ellipse 35% 25% at 85% 20%, rgba(0,80,180,0.05) 0%, transparent 55%);
  animation: aurora 14s ease-in-out infinite alternate;
}

@keyframes aurora {
  0%   { opacity: 0.6; transform: scale(1); }
  100% { opacity: 1;   transform: scale(1.1); }
}

.badge {
  display: inline-flex; align-items: center; gap: 0.5rem;
  font-size: 0.72rem; font-weight: 500; letter-spacing: 0.14em;
  text-transform: uppercase; color: var(--accent);
  border: 1px solid rgba(0,212,255,0.22); border-radius: 50px;
  padding: 0.35rem 1rem; margin-bottom: 1.2rem;
  background: rgba(0,212,255,0.06);
  animation: fade-up 0.8s cubic-bezier(.16,1,.3,1) 0.3s both;
}
.badge-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--accent);
  animation: pulse-dot 2.2s ease-in-out infinite;
}
@keyframes pulse-dot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%       { opacity: 0.4; transform: scale(0.65); }
}

.hero h1 {
  font-family: 'Instrument Serif', serif;
  font-size: clamp(3rem, 10vw, 6.5rem);
  font-weight: 400; line-height: 1; letter-spacing: -0.02em;
  color: var(--text); margin-bottom: 1rem;
  animation: fade-up 0.9s cubic-bezier(.16,1,.3,1) 0.45s both;
}
.hero h1 .accent-text { font-style: italic; color: var(--accent); }

.hero-subtitle {
  font-size: clamp(0.85rem, 2vw, 0.95rem);
  color: var(--muted); max-width: 360px; line-height: 1.7;
  animation: fade-up 0.9s cubic-bezier(.16,1,.3,1) 0.6s both;
}

@keyframes fade-up {
  from { opacity: 0; transform: translateY(22px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── MAIN ── */
main {
  display: flex; flex-direction: column; align-items: center;
  padding-bottom: 5rem;
}

/* ── GAME WRAPPER ── */
.game-wrapper {
  display: flex; flex-direction: column; gap: 1rem;
  width: 100%; max-width: 620px;
  padding: 0 1rem;
  animation: fade-up 0.7s cubic-bezier(.16,1,.3,1) 0.15s both;
}

/* ── DIFFICULTY BAR ── */
.difficulty-bar {
  display: flex; gap: 0.5rem;
}

.diff-btn {
  flex: 1;
  padding: 0.6rem 0.75rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--muted);
  font-family: 'Inter', sans-serif;
  font-size: 0.85rem; font-weight: 500;
  cursor: pointer;
  transition: border-color var(--t), color var(--t), background var(--t);
}
.diff-btn:hover {
  border-color: rgba(0,212,255,0.3);
  color: var(--text);
}
.diff-btn.active {
  border-color: rgba(0,212,255,0.5);
  color: var(--accent);
  background: var(--accent-dim);
}

/* ── HUD BAR ── */
.hud-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 0.75rem 1.25rem;
}

.hud-item {
  display: flex; align-items: center; gap: 0.5rem;
  min-width: 80px;
}
.hud-item:last-child { justify-content: flex-end; }

.hud-icon { font-size: 1rem; }

.hud-value {
  font-family: 'JetBrains Mono', 'ui-monospace', monospace;
  font-size: 1.5rem; font-weight: 700;
  color: var(--accent);
  letter-spacing: 0.05em;
  min-width: 3ch;
}

.reset-btn {
  width: 42px; height: 42px;
  display: flex; align-items: center; justify-content: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--muted);
  cursor: pointer;
  transition: border-color var(--t), color var(--t), transform 0.1s;
}
.reset-btn:hover {
  border-color: rgba(0,212,255,0.35);
  color: var(--accent);
}
.reset-btn:active { transform: scale(0.9); }

/* ── BOARD CONTAINER ── */
.board-container {
  position: relative;
  border: 1px solid var(--border);
  border-radius: 16px;
  overflow: hidden;
  overflow-x: auto;
  box-shadow: 0 0 40px rgba(0,212,255,0.06);
  background: var(--bg);
  -webkit-overflow-scrolling: touch;
}

/* ── BOARD ── */
.board {
  display: grid;
  gap: 2px;
  padding: 12px;
  background: var(--bg);
}

/* ── CELLS ── */
.cell {
  background: var(--cell-covered);
  border-radius: 5px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-family: 'JetBrains Mono', 'ui-monospace', monospace;
  font-weight: 700;
  font-size: 0.8em;
  line-height: 1;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.07),
    inset 0 -1px 0 rgba(0,0,0,0.25);
  transition: background var(--t), box-shadow var(--t);
  position: relative;
  overflow: hidden;
}

.cell:hover:not([data-state="open"]) {
  background: var(--cell-hover);
}

.cell[data-state="open"] {
  background: var(--cell-open);
  box-shadow: none;
  cursor: default;
  animation: cell-open 0.15s ease-out;
}

.cell[data-state="flagged"] {
  background: var(--cell-covered);
  box-shadow:
    inset 0 0 0 1px rgba(0,212,255,0.45),
    inset 0 1px 0 rgba(255,255,255,0.07),
    inset 0 -1px 0 rgba(0,0,0,0.25);
}

.cell[data-state="mine-revealed"] {
  background: rgba(255,59,92,0.18);
  box-shadow: none;
  cursor: default;
}

.cell[data-state="mine-hit"] {
  background: rgba(255,59,92,0.35);
  box-shadow: 0 0 14px rgba(255,59,92,0.5);
  cursor: default;
  animation: explode 0.4s ease-out;
}

.cell[data-state="wrong-flag"] {
  background: var(--cell-open);
  box-shadow: none;
  cursor: default;
}

/* Szám színek */
.cell[data-num="1"] { color: var(--n1); }
.cell[data-num="2"] { color: var(--n2); }
.cell[data-num="3"] { color: var(--n3); }
.cell[data-num="4"] { color: var(--n4); }
.cell[data-num="5"] { color: var(--n5); }
.cell[data-num="6"] { color: var(--n6); }
.cell[data-num="7"] { color: var(--n7); }
.cell[data-num="8"] { color: var(--n8); }

/* Zászló ikon */
.cell-flag {
  font-size: 0.85em;
  animation: flag-in 0.2s cubic-bezier(.16,1,.3,1);
  display: block;
  line-height: 1;
}

/* Akna ikon */
.cell-mine {
  font-size: 0.85em;
  display: block;
  line-height: 1;
}

/* Rossz zászló X */
.cell-wrong {
  font-size: 0.8em;
  color: var(--cell-mine);
  display: block;
  line-height: 1;
  font-family: 'Inter', sans-serif;
  font-weight: 700;
}

@keyframes flag-in {
  from { transform: scale(0) rotate(-20deg); opacity: 0; }
  to   { transform: scale(1) rotate(0deg);  opacity: 1; }
}

@keyframes cell-open {
  from { transform: scale(0.88); opacity: 0.5; }
  to   { transform: scale(1);    opacity: 1;   }
}

@keyframes explode {
  0%   { transform: scale(1);    }
  35%  { transform: scale(1.18); }
  100% { transform: scale(1);    }
}

@keyframes mine-reveal {
  from { transform: scale(0); opacity: 0; }
  to   { transform: scale(1); opacity: 1; }
}

.mine-reveal-anim {
  animation: mine-reveal 0.2s cubic-bezier(.16,1,.3,1) both;
}

/* ── OVERLAYS ── */
.overlay {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 0.8rem;
  background: rgba(8,8,15,0.82);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  text-align: center;
  padding: 2rem;
  animation: fade-in 0.25s ease;
  border-radius: 16px;
}

/* Start overlay csak szöveget mutat, átengedi a kattintásokat a cellákra */
#startOverlay {
  pointer-events: none;
}
.overlay.hidden { display: none; }
.overlay--win  { background: rgba(0,20,30,0.85); }
.overlay--lose { background: rgba(20,5,8,0.85);  }

@keyframes fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.overlay-emoji { font-size: 2.8rem; line-height: 1; }

.overlay-title {
  font-family: 'Instrument Serif', serif;
  font-size: clamp(1.6rem, 5vw, 2.4rem);
  font-weight: 400; font-style: italic;
  color: var(--text);
}

.overlay-hint {
  font-size: 1rem; font-weight: 500; color: var(--text);
}
.overlay-sub  { font-size: 0.82rem; color: var(--muted); }
.overlay-time { font-size: 0.88rem; color: var(--accent); font-family: 'JetBrains Mono', monospace; }

/* ── BUTTONS ── */
.btn-primary {
  margin-top: 0.25rem;
  padding: 0.75rem 2.2rem;
  background: var(--accent);
  color: #000;
  border: none; border-radius: 12px;
  font-family: 'Inter', sans-serif;
  font-size: 0.9rem; font-weight: 600;
  cursor: pointer;
  transition: opacity var(--t), transform var(--t);
}
.btn-primary:hover  { opacity: 0.85; transform: scale(1.03); }
.btn-primary:active { transform: scale(0.97); }

/* ── BEST TIMES ── */
.best-times {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 0.85rem 1.25rem;
  display: flex;
  align-items: center;
  gap: 1rem;
}

.best-times-label {
  font-size: 0.65rem; font-weight: 500;
  text-transform: uppercase; letter-spacing: 0.1em;
  color: var(--muted);
  white-space: nowrap;
}

.best-times-grid {
  display: flex;
  flex: 1;
  gap: 0;
}

.best-item {
  flex: 1;
  display: flex; flex-direction: column; align-items: center; gap: 0.1rem;
  border-left: 1px solid var(--border);
  padding: 0 0.75rem;
}
.best-item:first-child { border-left: none; padding-left: 0; }

.best-label {
  font-size: 0.62rem; font-weight: 500;
  text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--muted);
}

.best-value {
  font-family: 'JetBrains Mono', 'ui-monospace', monospace;
  font-size: 1rem; font-weight: 700;
  color: var(--accent);
}

/* ── INFO SECTION ── */
.info-section {
  margin-top: 3rem;
  max-width: 620px;
  padding: 0 1rem;
  display: flex; flex-direction: column; gap: 0.75rem;
}
.info-section h2 {
  font-family: 'Instrument Serif', serif;
  font-size: 1.1rem; font-style: italic;
  color: var(--text); font-weight: 400;
}
.info-section p { font-size: 0.88rem; color: var(--muted); line-height: 1.7; }
.info-section ul { list-style: none; display: flex; flex-direction: column; gap: 0.35rem; }
.info-section li {
  font-size: 0.88rem; color: var(--muted); line-height: 1.6;
  padding-left: 1rem; position: relative;
}
.info-section li::before {
  content: '›'; position: absolute; left: 0; color: var(--accent);
}

/* ── FOOTER ── */
footer {
  text-align: center; padding: 2rem 1rem;
  font-size: 0.78rem; color: var(--muted);
  display: flex; justify-content: center; gap: 0.6rem;
}
footer a { color: var(--muted); text-decoration: none; }
footer a:hover { color: var(--text); }

/* ── MOBILE ── */
@media (max-width: 500px) {
  .difficulty-bar { gap: 0.3rem; }
  .diff-btn { font-size: 0.8rem; padding: 0.5rem 0.4rem; }
  .hud-value { font-size: 1.25rem; }
  .best-times { flex-direction: column; align-items: flex-start; gap: 0.6rem; }
  .best-item { border-left: none; padding-left: 0; }
  .best-times-grid { width: 100%; justify-content: space-between; }
}

/* ── REDUCED MOTION ── */
@media (prefers-reduced-motion: reduce) {
  .hero-bg { animation: none; }
  .badge-dot { animation: none; }
  .cell[data-state="open"]     { animation: none; }
  .cell[data-state="mine-hit"] { animation: none; }
  .cell-flag { animation: none; }
  .mine-reveal-anim { animation: none; }
}
