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

:root {
  --bg: #1a1008;
  --card-bg: #2b1d0e;
  --card-border: #5c3d1e;
  --gold: #d4a24c;
  --gold-light: #f0c97a;
  --green: #2d6a4f;
  --green-glow: #52b788;
  --text: #f5e6c8;
  --text-muted: #a07840;
  --radius: 8px;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Lora', Georgia, serif;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 2rem 1rem 4rem;
  background-image:
    radial-gradient(ellipse at 20% 10%, #3a2010 0%, transparent 50%),
    radial-gradient(ellipse at 80% 90%, #2a1a08 0%, transparent 50%);
}

header {
  text-align: center;
  margin-bottom: 2rem;
}

header h1 {
  font-family: 'Playfair Display', serif;
  font-size: clamp(2.5rem, 6vw, 4.5rem);
  font-weight: 900;
  letter-spacing: 0.12em;
  color: var(--text);
  text-shadow: 0 0 40px rgba(212, 162, 76, 0.4);
  line-height: 1;
}

header p {
  color: var(--text);
  font-style: italic;
  margin-top: 0.5rem;
  font-size: 1rem;
}

#board {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 10px;
  width: 100%;
  max-width: 820px;
}

.cell {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 12px 8px;
  min-height: 110px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  font-size: clamp(0.6rem, 1.3vw, 0.78rem);
  font-family: 'Lora', serif;
  color: var(--text);
  cursor: pointer;
  user-select: none;
  line-height: 1.4;
  transition: background 0.35s ease, border-color 0.35s ease, transform 0.15s ease, box-shadow 0.35s ease;
  position: relative;
  overflow: hidden;
}

.cell::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(212,162,76,0.06), transparent);
  pointer-events: none;
}

.cell:hover:not(.marked) {
  border-color: var(--gold);
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(212, 162, 76, 0.15);
}

.cell.marked {
  background: var(--green);
  border-color: var(--green-glow);
  color: #d0ffe8;
  cursor: default;
  box-shadow: 0 0 16px rgba(82, 183, 136, 0.35);
  animation: pop 0.3s ease;
}

@keyframes pop {
  0%   { transform: scale(0.9); }
  60%  { transform: scale(1.07); }
  100% { transform: scale(1); }
}

.cell.marked::after {
  content: '✓';
  position: absolute;
  top: 6px;
  right: 8px;
  font-size: 0.85rem;
  color: var(--green-glow);
  font-family: sans-serif;
}

#controls {
  margin-top: 1.8rem;
  display: flex;
  gap: 1rem;
  align-items: center;
}

#regenerate-btn {
  background: transparent;
  border: 2px solid var(--gold);
  color: var(--text);
  font-family: 'Playfair Display', serif;
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  padding: 0.65rem 1.8rem;
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.2s, color 0.2s, box-shadow 0.2s;
}

#regenerate-btn:hover {
  background: var(--gold);
  color: var(--bg);
  box-shadow: 0 0 20px rgba(212, 162, 76, 0.4);
}

#progress {
  color: var(--text);
  font-style: italic;
  font-size: 0.9rem;
}

#win-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(10, 6, 2, 0.85);
  z-index: 100;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 1.5rem;
  text-align: center;
  padding: 2rem;
}

#win-overlay.show {
  display: flex;
  animation: fadeIn 0.4s ease;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

#win-overlay h2 {
  font-family: 'Playfair Display', serif;
  font-size: clamp(3rem, 8vw, 6rem);
  color: var(--gold);
  text-shadow: 0 0 60px rgba(212,162,76,0.7);
  animation: pulse 1.5s ease-in-out infinite alternate;
}

@keyframes pulse {
  from { text-shadow: 0 0 30px rgba(212,162,76,0.5); }
  to   { text-shadow: 0 0 80px rgba(212,162,76,0.9); }
}

#win-overlay p {
  color: var(--text);
  font-size: 1.2rem;
  font-style: italic;
}

#win-new-btn {
  background: var(--gold);
  color: var(--bg);
  border: none;
  font-family: 'Playfair Display', serif;
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  padding: 0.8rem 2.5rem;
  border-radius: 4px;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
}

#win-new-btn:hover {
  transform: scale(1.05);
  box-shadow: 0 0 30px rgba(212,162,76,0.5);
}
