/* ---------- Base / Theme ---------- */
:root{
  --bg:#121213;
  --fg:#d7dadc;
  --tile-edge:#3a3a3c;
  --tile-good:#6aaa64;   
  --key:#818384;
  --key-bad:#3a3a3c;

  /* Responsive sizes */
  --tile: clamp(40px, 9vw, 76px);
  --tile-font: clamp(28px, 5vw, 38px);
  --gap: clamp(6px, 1vw, 10px);
  --kb-h: clamp(36px, 6vw, 52px);
  --kb-w: clamp(28px, 6vw, 56px);
  --title: clamp(22px, 3.2vw, 32px);
  --def: clamp(16px, 2.2vw, 20px);
}

*{box-sizing:border-box}
html,body{height:100%}
body{
  margin:0;
  font-family: "Clear Sans","Helvetica Neue",Arial,sans-serif;
  background:var(--bg);
  color:var(--fg);
  display:flex;
  flex-direction:column;
  align-items:center;
}

/* ---------- Top bar ---------- */
.topbar{
  width:100%;
  max-width:720px;
  display:flex;
  align-items:center;
  justify-content:center;
  gap:12px;
  padding:10px 16px;
  border-bottom:1px solid #2a2a2a;
}
.logo{height:80px; width:auto; object-fit:contain}
.title{font-size:var(--title); font-weight:700; letter-spacing:.04em;}

/* ---------- Containers ---------- */
.game-container, .intro-container{
  width:100%;
  max-width:720px;
  padding:18px 16px 28px;
  display:flex;
  flex-direction:column;
  align-items:center;
  gap:16px;
  text-align:center;
}

/* ---------- Intro ---------- */
.intro-screen .intro-container h2{
  margin:10px 0 0;
  font-size:clamp(20px,3vw,28px);
}
.primary-btn{
  display:inline-block;
  margin-top:8px;
  padding:12px 20px;
  border-radius:8px;
  background:var(--tile-good);
  color:white;
  text-decoration:none;
  font-weight:700;
  box-shadow:0 2px 0 #325c30;
}
.primary-btn:hover{transform:translateY(-1px)}

/* ---------- Definition ---------- */
.definition{
  max-width:620px;
  font-size:40px;
  font-style:italic;
  color:#ffffff;
  opacity:1.0;
}

/* ---------- Tiles (single row) ---------- */
.letter-row{
  display:flex;
  gap:var(--gap);
  justify-content:center;
  flex-wrap:nowrap;
}
.tile{
  width:var(--tile);
  height:var(--tile);
  border:2px solid var(--tile-edge);
  display:flex;
  align-items:center;
  justify-content:center;
  font-weight:800;
  font-size:var(--tile-font);
  text-transform:uppercase;
  background:transparent;
  color:#fff;
  border-radius:6px;
  transition:transform .2s ease;

  /* ✅ Fix flicker during flip animation */
  backface-visibility: hidden;
  will-change: transform;
}

/* Correct letters always stay green */
.tile.reveal {
  background: var(--tile-good);
  border-color: var(--tile-good);
}

/* Flip animation only if row is NOT wrong */
.letter-row:not(.wrong) .tile.reveal {
  animation: flip .45s ease;
}

@keyframes flip{
  0%{transform:rotateX(0)}
  50%{transform:rotateX(90deg)}
  100%{transform:rotateX(0)}
}

/* ---------- Status ---------- */
.status{display:flex; flex-direction:column; gap:6px; align-items:center}
.lives{font-size:clamp(16px, 2vw, 20px)}
.misses{color:#ff6b6b}
.miss{font-weight:800; margin:0 4px}

/* ---------- Banners ---------- */
.banner{margin-top:4px; font-weight:800}
.banner.win{color:var(--tile-good)}
.banner.lose{color:#ff6b6b}

/* ---------- Keyboard ---------- */
.keyboard{display:flex; flex-direction:column; gap:8px; width:100%; max-width:720px}
.kb-row{display:flex; justify-content:center; gap:8px}
.key{
  min-width:var(--kb-w);
  height:var(--kb-h);
  padding:0 10px;
  border-radius:8px;
  border:none;
  font-weight:800;
  font-size:clamp(14px,2vw,18px);
  color:white;
  background:var(--key);
  cursor:pointer;
  box-shadow:0 3px 0 #5c5c5e;
  transition:transform .05s ease;
}
.key:active{transform:translateY(1px)}
.key.good{background:var(--tile-good); box-shadow:0 3px 0 #325c30}
.key.bad{background:var(--key-bad); box-shadow:0 3px 0 #222}

/* Hide the actual input (we submit via JS) */
.hidden{position:absolute; left:-9999px; width:1px; height:1px; overflow:hidden}

/* ---------- Wrong Guess Shake ---------- */
.letter-row.wrong {
  animation: shake 0.4s ease;
}

@keyframes shake {
  0%   { transform: translateX(0); }
  20%  { transform: translateX(-10px); }
  40%  { transform: translateX(10px); }
  60%  { transform: translateX(-8px); }
  80%  { transform: translateX(8px); }
  100% { transform: translateX(0); }
}
