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

:root {
  --green:  #6aaa64;
  --yellow: #c9b458;
  --gray:   #787c7e;
  --light:  #d3d6da;
  --bg:     #fff9f0;
  --text:   #333;
  --tile-size: 80px;
  --font: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: 100vh;
  min-height: 100dvh;
  padding-bottom: 24px;
}

/* ── Header ─────────────────────────────────────────────── */
header {
  width: 100%;
  max-width: 480px;
  padding: 16px 0 12px;
  text-align: center;
  border-bottom: 2px solid var(--light);
}

h1 {
  font-size: 2.4rem;
  font-weight: 900;
  letter-spacing: 4px;
  color: var(--green);
}

.subtitle {
  font-size: 0.95rem;
  color: #888;
  margin-top: 4px;
  font-style: italic;
}

/* ── Main ────────────────────────────────────────────────── */
main {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
}

.hidden { display: none; }

/* ── Hint ────────────────────────────────────────────────── */
#hint {
  margin: 16px auto 0;
  max-width: 360px;
  text-align: center;
  background: #fff3cd;
  border: 2px solid #f0c040;
  border-radius: 10px;
  padding: 10px 16px;
  font-size: 1.1rem;
  line-height: 1.4;
}

#hint-label {
  font-weight: 800;
  color: #b07800;
  margin-right: 6px;
}

#hint-text {
  color: #555;
}

/* ── Board ───────────────────────────────────────────────── */
#board {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 28px 0 20px;
}

.board-row {
  display: flex;
  gap: 6px;
}

.tile {
  width: var(--tile-size);
  height: var(--tile-size);
  border: 3px solid var(--light);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.4rem;
  font-weight: 800;
  text-transform: uppercase;
  transition: border-color 0.1s;
  user-select: none;
}

.tile.filled {
  border-color: #999;
  animation: pop 0.1s ease;
}

.tile.correct  { background: var(--green);  color: #fff; border-color: var(--green); }
.tile.present  { background: var(--yellow); color: #fff; border-color: var(--yellow); }
.tile.absent   { background: var(--gray);   color: #fff; border-color: var(--gray); }

.tile.reveal {
  animation: flip 0.5s ease forwards;
}


@keyframes flip {
  0%   { transform: rotateX(0deg); }
  50%  { transform: rotateX(90deg); background: var(--light); }
  100% { transform: rotateX(0deg); }
}

@keyframes pop {
  0%   { transform: scale(1); }
  50%  { transform: scale(1.12); }
  100% { transform: scale(1); }
}

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

.shake { animation: shake 0.4s ease; }

/* ── Message ─────────────────────────────────────────────── */
#message {
  min-height: 32px;
  font-size: 1.1rem;
  font-weight: 700;
  text-align: center;
  margin-bottom: 8px;
  color: var(--text);
}

/* ── Keyboard ────────────────────────────────────────────── */
#keyboard {
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
}

.key-row {
  display: flex;
  gap: 6px;
  justify-content: center;
}

#row-bottom {
  display: flex;
  align-items: center;
  gap: 6px;
}

#row-zxcvbnm {
  display: flex;
  gap: 6px;
}

.key {
  width: 42px;
  height: 56px;
  border: none;
  border-radius: 6px;
  background: var(--light);
  color: var(--text);
  font-size: 1.05rem;
  font-weight: 700;
  cursor: pointer;
  text-transform: uppercase;
  transition: background 0.2s, color 0.2s, opacity 0.2s;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.key.wide {
  width: 64px;
  font-size: 0.9rem;
}

.key:active:not(.key-disabled) {
  filter: brightness(0.9);
}

.key.correct  { background: var(--green);  color: #fff; }
.key.present  { background: var(--yellow); color: #fff; }
.key.absent   { background: var(--gray);   color: #fff; }

.key.key-disabled {
  opacity: 0.28;
  cursor: not-allowed;
  text-decoration: line-through;
}

/* ── Confetti ────────────────────────────────────────────── */
#confetti-container {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  pointer-events: none;
  overflow: hidden;
  z-index: 999;
}

.confetti-piece {
  position: absolute;
  top: -12px;
  width: 10px;
  height: 14px;
  opacity: 0.9;
  animation: confetti-fall linear forwards;
}

@keyframes confetti-fall {
  0%   { transform: translateY(0) rotate(0deg); opacity: 1; }
  100% { transform: translateY(110vh) rotate(720deg); opacity: 0; }
}

/* ── Responsive ──────────────────────────────────────────── */
@media (max-width: 430px) {
  :root { --tile-size: 66px; }
  h1 { font-size: 2rem; }
  .key { width: 34px; height: 48px; font-size: 0.9rem; }
  .key.wide { width: 54px; }
}
