/* ── Variables ─────────────────────────────────────────────────── */
:root {
  --bg:      #0a0a0f;
  --panel:   #12121a;
  --border:  #1e1e2e;
  --accent:  #e8c44a;
  --accent2: #e84a7a;
  --text:    #e8e8f0;
  --muted:   #5a5a7a;
  --glow:    rgba(232,196,74,0.18);
  --peg:     clamp(26px, 4.5vw, 36px);
  --cbtn:    clamp(30px, 5vw, 42px);
  --fb:      clamp(9px,  1.6vw, 13px);
  --gap:     clamp(5px,  0.9vw, 8px);
}

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

/* ── Base ───────────────────────────────────────────────────────── */
body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Share Tech Mono', monospace;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 20px 12px 40px;
  background-image:
    radial-gradient(ellipse 80% 40% at 50% 0%, rgba(232,196,74,0.07) 0%, transparent 70%),
    repeating-linear-gradient(0deg,  transparent, transparent 39px, rgba(255,255,255,0.02) 40px),
    repeating-linear-gradient(90deg, transparent, transparent 39px, rgba(255,255,255,0.02) 40px);
}

/* ── Header ─────────────────────────────────────────────────────── */
header { text-align: center; margin-bottom: 12px; }

h1 {
  font-family: 'Bebas Neue', sans-serif;
  font-size: clamp(2.6rem, 9vw, 5.5rem);
  letter-spacing: 0.18em;
  color: var(--accent);
  text-shadow: 0 0 40px rgba(232,196,74,0.5), 0 0 80px rgba(232,196,74,0.2);
  line-height: 1;
}

.subtitle {
  font-size: clamp(0.52rem, 1.4vw, 0.7rem);
  letter-spacing: 0.3em;
  color: var(--muted);
  margin-top: 4px;
  text-transform: uppercase;
}

/* ── Attempt track ──────────────────────────────────────────────── */
.attempt-track { display:flex; gap:6px; justify-content:center; margin-bottom:6px; }

.attempt-dot { width:8px; height:8px; border-radius:50%; background:var(--border); transition:background .3s; }
.attempt-dot.used { background: var(--accent); }
.attempt-dot.fail { background: var(--accent2); }

/* ── Status bar ─────────────────────────────────────────────────── */
.status-bar {
  text-align: center;
  font-size: clamp(0.52rem, 1.4vw, 0.66rem);
  letter-spacing: 0.18em;
  color: var(--muted);
  padding: 6px 0 10px;
  min-height: 30px;
  text-transform: uppercase;
}
.status-bar.win  { color: var(--accent);  text-shadow: 0 0 20px var(--accent); }
.status-bar.lose { color: var(--accent2); text-shadow: 0 0 20px var(--accent2); }

/* ── Main layout ────────────────────────────────────────────────── */
.game-wrap {
  display: flex;
  gap: clamp(10px, 2.5vw, 22px);
  align-items: stretch;
  justify-content: center;
  width: 100%;
  max-width: 780px;
}

/* ── Board ──────────────────────────────────────────────────────── */
.board {
  display: flex;
  flex-direction: column;
  gap: clamp(5px, 0.9vw, 8px);
  flex: 0 0 auto;
}

.row {
  display: flex;
  align-items: center;
  gap: clamp(6px, 1vw, 10px);
  padding: clamp(6px, 1.1vw, 10px) clamp(8px, 1.4vw, 12px);
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--panel);
  transition: border-color .3s, box-shadow .3s;
}
.row.active {
  border-color: var(--accent);
  box-shadow: 0 0 18px var(--glow), inset 0 0 8px rgba(232,196,74,0.04);
}

.row-num {
  font-size: clamp(0.52rem, 1.1vw, 0.62rem);
  color: var(--muted);
  width: 14px;
  text-align: center;
}

.pegs { display: flex; gap: var(--gap); }

/* ── Guess pegs ─────────────────────────────────────────────────── */
.peg {
  width:  var(--peg);
  height: var(--peg);
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.12);
  cursor: pointer;
  transition: transform .15s, box-shadow .15s, border-color .15s;
  background: #1e1e2e;
  flex-shrink: 0;
  position: relative;
}
.peg::after {
  content: ''; position: absolute;
  top:18%; left:22%; width:28%; height:22%;
  border-radius: 50%; background: rgba(255,255,255,0.28);
  pointer-events: none;
}
.peg.filled { border-color: rgba(255,255,255,0.3); }
.row.active .peg:hover { transform: scale(1.08); }

/* ── Feedback pegs (3×2 grid) ───────────────────────────────────── */
.feedback {
  display: grid;
  grid-template-columns: repeat(3, var(--fb));
  grid-template-rows:    repeat(2, var(--fb));
  gap: 3px;
  margin-left: clamp(4px, 0.8vw, 8px);
}
.fb-peg {
  width: var(--fb); height: var(--fb);
  border-radius: 50%;
  border: 1px solid rgba(255,255,255,0.1);
  background: #1e1e2e;
}
.fb-peg.black { background:#f0f0f0; border-color:#f0f0f0; box-shadow:0 0 5px rgba(240,240,240,.5); }
.fb-peg.white { background:transparent; border:2px solid #f0f0f0; box-shadow:0 0 5px rgba(240,240,240,.3); }

/* ── Side panel ─────────────────────────────────────────────────── */
.side-panel {
  display: flex;
  flex-direction: column;
  gap: clamp(8px, 1.3vw, 13px);
  flex: 0 0 auto;
  min-width: 0;
}

/* ── Palette ────────────────────────────────────────────────────── */
.palette {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: clamp(10px, 1.4vw, 15px);
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1 1 0;
}
.palette-title {
  font-size: clamp(0.5rem, 1.1vw, 0.6rem);
  letter-spacing: 0.3em;
  color: var(--muted);
  text-transform: uppercase;
}
.color-grid {
  display: grid;
  grid-template-columns: repeat(4, var(--cbtn));
  gap: clamp(5px, 1.1vw, 9px);
  flex: 1 1 0;
  align-content: center;
  justify-content: center;
}
.color-btn {
  width: var(--cbtn); height: var(--cbtn);
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.1);
  cursor: pointer;
  transition: transform .15s, box-shadow .2s, border-color .15s;
  position: relative;
}
.color-btn::after {
  content: ''; position: absolute;
  top:18%; left:22%; width:28%; height:22%;
  border-radius: 50%; background: rgba(255,255,255,0.3);
  pointer-events: none;
}
.color-btn:hover { transform: scale(1.12); }
.color-btn.active-color {
  border-color: var(--accent) !important;
  box-shadow: 0 0 16px var(--glow);
  transform: scale(1.15);
}

/* ── Controls ───────────────────────────────────────────────────── */
.controls {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: clamp(10px, 1.3vw, 14px);
  display: flex;
  flex-direction: column;
  gap: 7px;
}

button.action {
  font-family: 'Share Tech Mono', monospace;
  font-size: clamp(0.58rem, 1.2vw, 0.73rem);
  letter-spacing: 0.17em;
  text-transform: uppercase;
  padding: clamp(8px, 1.2vw, 11px) clamp(10px, 1.8vw, 18px);
  border: 1px solid;
  border-radius: 4px;
  cursor: pointer;
  transition: background .2s, box-shadow .2s, transform .1s;
  white-space: nowrap;
}
button.action:active { transform: scale(.97); }

.btn-confirm { background:var(--accent); border-color:var(--accent); color:#0a0a0f; }
.btn-confirm:hover { box-shadow: 0 0 20px rgba(232,196,74,0.5); }
.btn-confirm:disabled { opacity:.35; cursor:not-allowed; }

.btn-clear { background:transparent; border-color:var(--muted); color:var(--muted); }
.btn-clear:hover { border-color:var(--accent2); color:var(--accent2); }

.btn-new { background:transparent; border-color:var(--border); color:var(--text); }
.btn-new:hover { border-color:var(--text); }

/* ── Legend ─────────────────────────────────────────────────────── */
.legend {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: clamp(10px, 1.3vw, 14px);
  font-size: clamp(0.5rem, 1.05vw, 0.6rem);
  letter-spacing: 0.08em;
  color: var(--muted);
  line-height: 2;
}
.legend-row { display:flex; align-items:center; gap:8px; }
.legend-dot { width:11px; height:11px; border-radius:50%; flex-shrink:0; }

/* ── Modal ──────────────────────────────────────────────────────── */
.modal-bg {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.75);
  backdrop-filter: blur(4px);
  z-index: 100;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.modal-bg.show { display: flex; }

.modal {
  background: var(--panel);
  border: 1px solid var(--accent);
  border-radius: 12px;
  padding: clamp(22px, 5vw, 40px) clamp(22px, 6vw, 48px);
  text-align: center;
  box-shadow: 0 0 60px rgba(232,196,74,0.25);
  animation: pop .35s cubic-bezier(.175,.885,.32,1.275);
  max-width: 360px;
  width: 100%;
}

@keyframes pop {
  from { transform: scale(.7); opacity: 0; }
  to   { transform: scale(1);  opacity: 1; }
}

.modal-title {
  font-family: 'Bebas Neue', sans-serif;
  font-size: clamp(2.2rem, 7vw, 3.2rem);
  letter-spacing: .15em;
  margin-bottom: 8px;
}
.win-title  { color: var(--accent);  text-shadow: 0 0 30px rgba(232,196,74,.6); }
.lose-title { color: var(--accent2); text-shadow: 0 0 30px rgba(232,74,122,.6); }

.modal-msg {
  font-size: clamp(0.6rem, 1.5vw, 0.72rem);
  letter-spacing: .1em;
  color: var(--muted);
  margin-bottom: 18px;
  line-height: 1.8;
}

.secret-reveal {
  display: flex;
  gap: 6px;
  justify-content: center;
  flex-wrap: wrap;
  margin-bottom: 20px;
}
.secret-reveal .peg { cursor: default; }

/* ── Responsive ─────────────────────────────────────────────────── */
@media (max-width: 560px) {
  :root {
    --peg:  clamp(22px, 8.5vw, 30px);
    --cbtn: clamp(26px, 9.5vw, 36px);
    --fb:   clamp(8px,  2.8vw, 11px);
    --gap:  clamp(4px,  1.6vw, 6px);
  }
  .game-wrap {
    flex-direction: column;
    align-items: stretch;
  }
  .side-panel {
    flex-direction: row;
    flex-wrap: wrap;
  }
  .palette  { flex: 1 1 170px; }
  .controls { flex: 1 1 130px; }
  .legend   { flex: 1 1 100%;  }
}
