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

:root {
  --bg: #0f172a;
  --surface: #1e293b;
  --surface2: #334155;
  --accent: #6366f1;
  --accent-hover: #818cf8;
  --success: #22c55e;
  --danger: #ef4444;
  --text: #f1f5f9;
  --text-muted: #94a3b8;
  --border: #334155;
  --radius: 12px;
  --radius-sm: 8px;
}

html, body {
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  line-height: 1.5;
}

/* ===== App Layout ===== */
.app {
  max-width: 900px;
  margin: 0 auto;
  padding: 24px 16px 48px;
}

header {
  text-align: center;
  margin-bottom: 32px;
}

header h1 {
  font-size: clamp(2rem, 5vw, 3rem);
  font-weight: 800;
  letter-spacing: -0.5px;
  background: linear-gradient(135deg, var(--accent) 0%, #a78bfa 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.tagline {
  color: var(--text-muted);
  font-size: 1rem;
  margin-top: 4px;
}

/* ===== Game Area ===== */
.game-area {
  display: flex;
  gap: 32px;
  align-items: flex-start;
  flex-wrap: wrap;
}

/* ===== Scaffold ===== */
.scaffold-area {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.hangman-svg {
  width: min(200px, 40vw);
  height: auto;
}

.gallows {
  stroke: #64748b;
  stroke-width: 4;
  stroke-linecap: round;
}

.body-part {
  stroke: var(--danger);
  stroke-width: 4;
  stroke-linecap: round;
  fill: none;
  display: none;
}

circle.body-part {
  fill: none;
  stroke: var(--danger);
}

.wrong-count {
  font-size: 0.875rem;
  color: var(--text-muted);
  background: var(--surface);
  padding: 4px 12px;
  border-radius: 20px;
  border: 1px solid var(--border);
}

/* ===== Word Area ===== */
.word-area {
  flex: 1;
  min-width: 280px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* ===== Hint ===== */
.hint-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.hint-label {
  color: var(--accent-hover);
  font-weight: 600;
  margin-right: 6px;
}

/* ===== Word Display ===== */
.word-display {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.letter-tile {
  width: 40px;
  height: 48px;
  border-bottom: 3px solid var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text);
  transition: border-color 0.2s, color 0.2s;
}

.letter-tile.revealed {
  border-color: var(--accent);
  color: var(--accent-hover);
  animation: pop 0.2s ease;
}

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

/* ===== Alphabet ===== */
.alphabet {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.letter-btn {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
  text-transform: uppercase;
}

.letter-btn:hover:not(:disabled) {
  background: var(--accent);
  border-color: var(--accent);
  transform: translateY(-1px);
}

.letter-btn:active:not(:disabled) {
  transform: translateY(0);
}

.letter-btn.correct {
  background: var(--success);
  border-color: var(--success);
  color: #fff;
}

.letter-btn.wrong {
  background: var(--surface2);
  border-color: var(--border);
  color: var(--text-muted);
  text-decoration: line-through;
}

.letter-btn:disabled {
  cursor: not-allowed;
  opacity: 0.7;
}

/* ===== Messages ===== */
.game-message {
  font-size: 1.1rem;
  font-weight: 600;
  min-height: 28px;
  text-align: center;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
}

.game-message.win {
  background: rgba(34, 197, 94, 0.15);
  color: var(--success);
  border: 1px solid rgba(34, 197, 94, 0.3);
}

.game-message.lose {
  background: rgba(239, 68, 68, 0.15);
  color: var(--danger);
  border: 1px solid rgba(239, 68, 68, 0.3);
}

/* ===== New Game Button ===== */
.new-game-btn {
  padding: 12px 28px;
  border-radius: var(--radius);
  border: none;
  background: var(--accent);
  color: #fff;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
  align-self: flex-start;
}

.new-game-btn:hover {
  background: var(--accent-hover);
  transform: translateY(-1px);
}

.new-game-btn:active {
  transform: translateY(0);
}

/* ===== Responsive ===== */
@media (max-width: 600px) {
  .game-area {
    flex-direction: column;
    align-items: center;
  }

  .scaffold-area {
    width: 100%;
  }

  .hangman-svg {
    width: 150px;
  }

  .letter-tile {
    width: 32px;
    height: 40px;
    font-size: 1.25rem;
  }

  .letter-btn {
    width: 32px;
    height: 32px;
    font-size: 0.75rem;
  }
}
