/* ══════════════════════════════════════════════════════════
   HANGMAN HERO — style.css
   CSS custom-property driven theming; each universe swaps
   the variables and everything re-colors automatically.
   ══════════════════════════════════════════════════════════ */

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

:root {
  --primary:      #FFE81F;
  --secondary:    #FF4444;
  --accent:       #4488FF;
  --bg:           #080808;
  --bg2:          #121212;
  --bg3:          #1a1a1a;
  --text:         #FFE81F;
  --text-dim:     rgba(255,232,31,.55);
  --correct:      #4ade80;
  --wrong:        #f87171;
  --body-stroke:  #FF4444;
  --gallows:      #888;
  --card-glow:    rgba(255,232,31,.35);
  --border:       rgba(255,232,31,.25);
  --letter-bg:    #1c1c1c;
  --letter-hover: rgba(255,232,31,.15);
  --radius:       12px;
  --font-main:    'Orbitron', 'Courier New', monospace;
  --font-body:    'Rajdhani', 'Segoe UI', sans-serif;
}

html { font-size: 16px; }

body {
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  overflow-x: hidden;
  transition: background .5s ease, color .5s ease;
}

/* Animated star-field background */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse at 20% 50%, rgba(var(--primary-rgb, 255,232,31),.04) 0%, transparent 60%),
    radial-gradient(ellipse at 80% 20%, rgba(var(--secondary-rgb, 255,68,68),.04) 0%, transparent 60%);
  pointer-events: none;
  z-index: 0;
}

/* ── Screens ── */
.screen {
  display: none;
  flex-direction: column;
  align-items: center;
  min-height: 100vh;
  padding: 2rem 1rem;
  position: relative;
  z-index: 1;
}
.screen.active { display: flex; }

/* ── THEME SELECTION SCREEN ── */
.hero-header {
  text-align: center;
  margin-bottom: 2.5rem;
}

.title-glow {
  font-family: var(--font-main);
  font-size: clamp(2.5rem, 8vw, 5rem);
  font-weight: 900;
  letter-spacing: .25em;
  color: var(--primary);
  text-shadow:
    0 0 20px var(--primary),
    0 0 60px rgba(255,232,31,.4),
    0 0 120px rgba(255,232,31,.15);
  animation: pulse-glow 3s ease-in-out infinite;
}

.title-sub {
  font-family: var(--font-main);
  font-size: clamp(1rem, 3vw, 1.8rem);
  letter-spacing: .6em;
  color: var(--secondary);
  text-shadow: 0 0 15px var(--secondary);
  margin-top: -.3em;
}

.title-desc {
  font-size: 1.05rem;
  color: var(--text-dim);
  margin-top: .8rem;
  letter-spacing: .05em;
}

@keyframes pulse-glow {
  0%, 100% { text-shadow: 0 0 20px var(--primary), 0 0 60px rgba(255,232,31,.4); }
  50%       { text-shadow: 0 0 35px var(--primary), 0 0 90px rgba(255,232,31,.6), 0 0 150px rgba(255,232,31,.2); }
}

/* Theme grid */
.theme-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1.25rem;
  width: 100%;
  max-width: 1100px;
}

.theme-card {
  background: var(--bg2);
  border: 1px solid var(--t-border, rgba(255,255,255,.12));
  border-radius: var(--radius);
  padding: 1.75rem 1.25rem 1.5rem;
  cursor: pointer;
  text-align: center;
  position: relative;
  overflow: hidden;
  transition: transform .25s ease, box-shadow .25s ease, border-color .25s ease;
}

.theme-card::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, var(--t-color1, transparent) 0%, transparent 70%);
  opacity: 0;
  transition: opacity .3s ease;
}

.theme-card:hover {
  transform: translateY(-6px) scale(1.02);
  border-color: var(--t-primary, #fff);
  box-shadow: 0 8px 40px var(--t-glow, rgba(255,255,255,.2));
}

.theme-card:hover::before { opacity: .08; }

.theme-card:active { transform: translateY(-2px) scale(1.01); }

.card-icon {
  font-size: 3rem;
  margin-bottom: .6rem;
  display: block;
  filter: drop-shadow(0 0 10px var(--t-primary, #fff));
  transition: transform .3s ease;
}
.theme-card:hover .card-icon { transform: scale(1.15) rotate(-5deg); }

.card-name {
  font-family: var(--font-main);
  font-size: 1rem;
  font-weight: 700;
  color: var(--t-primary, #fff);
  letter-spacing: .08em;
  margin-bottom: .4rem;
  text-shadow: 0 0 10px var(--t-primary, transparent);
}

.card-desc {
  font-size: .82rem;
  color: rgba(255,255,255,.5);
  line-height: 1.4;
}

.card-badge {
  position: absolute;
  top: .6rem;
  right: .6rem;
  background: var(--t-primary, #fff);
  color: #000;
  font-size: .65rem;
  font-weight: 700;
  padding: .15rem .5rem;
  border-radius: 20px;
  letter-spacing: .05em;
  opacity: .85;
}

/* ── DIFFICULTY SCREEN ── */
.diff-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  width: 100%;
  max-width: 700px;
  margin-bottom: 2rem;
}

.diff-content {
  width: 100%;
  max-width: 700px;
  text-align: center;
}

.diff-title {
  font-family: var(--font-main);
  font-size: 1.5rem;
  color: var(--primary);
  letter-spacing: .1em;
  margin-bottom: 1.5rem;
  text-shadow: 0 0 15px var(--primary);
}

.diff-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
}

@media (max-width: 560px) {
  .diff-grid { grid-template-columns: 1fr; max-width: 280px; margin: 0 auto; }
}

.diff-card {
  background: var(--bg2);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 1.75rem 1rem;
  cursor: pointer;
  transition: transform .2s, box-shadow .2s, border-color .2s;
}

.diff-card:hover {
  transform: translateY(-4px);
  border-color: var(--primary);
  box-shadow: 0 6px 30px var(--card-glow);
}

.diff-icon { font-size: 2.5rem; margin-bottom: .5rem; }

.diff-name {
  font-family: var(--font-main);
  font-size: 1rem;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: .5rem;
}

.diff-desc {
  font-size: .82rem;
  color: rgba(255,255,255,.5);
  line-height: 1.5;
}

/* ── GAME SCREEN ── */
.game-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  max-width: 1000px;
  margin-bottom: 1.5rem;
  padding: .75rem 1rem;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.theme-badge {
  display: flex;
  align-items: center;
  gap: .5rem;
  font-family: var(--font-main);
  font-size: .85rem;
  color: var(--primary);
  font-weight: 700;
  text-shadow: 0 0 8px var(--primary);
}

.header-stats {
  display: flex;
  gap: .5rem;
  align-items: center;
}

.stat-chip {
  display: flex;
  flex-direction: column;
  align-items: center;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: .3rem .65rem;
  min-width: 52px;
}

.stat-chip.highlight {
  border-color: var(--primary);
  box-shadow: 0 0 10px var(--card-glow);
}

.stat-label {
  font-family: var(--font-main);
  font-size: .5rem;
  letter-spacing: .15em;
  color: var(--text-dim);
  line-height: 1;
}

.stat-value {
  font-family: var(--font-main);
  font-size: 1.1rem;
  font-weight: 900;
  color: var(--primary);
  text-shadow: 0 0 8px var(--primary);
  line-height: 1.2;
}

/* Game body layout */
.game-body {
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 1.5rem;
  width: 100%;
  max-width: 1000px;
  align-items: start;
}

@media (max-width: 700px) {
  .game-body {
    grid-template-columns: 1fr;
  }
  .left-panel { display: flex; flex-direction: column; align-items: center; }
}

/* ── Hangman SVG ── */
#hangman-svg {
  width: 100%;
  max-width: 260px;
  height: auto;
  filter: drop-shadow(0 0 8px rgba(0,0,0,.5));
}

.gallows {
  stroke: var(--gallows);
  stroke-width: 5;
  stroke-linecap: round;
  fill: none;
}

.gallows.noose {
  stroke: var(--gallows);
  stroke-width: 3;
  fill: none;
}

.body-part {
  stroke: var(--body-stroke);
  stroke-width: 5;
  stroke-linecap: round;
  fill: none;
  opacity: 0;
  transition: opacity .35s ease;
}

.body-part.visible { opacity: 1; }

#bp-head {
  stroke: var(--body-stroke);
  fill: none;
}

.face-part {
  stroke: none;
  fill: var(--body-stroke);
  stroke-width: 2.5;
}

#bp-mouth {
  stroke: var(--body-stroke);
  fill: none;
  stroke-width: 2.5;
}

/* Wrong letters */
.wrong-letters-wrap {
  margin-top: 1rem;
  width: 100%;
  text-align: center;
}

.wrong-label {
  font-size: .72rem;
  letter-spacing: .1em;
  color: var(--text-dim);
  margin-bottom: .35rem;
  text-transform: uppercase;
}

.wrong-letters {
  display: flex;
  flex-wrap: wrap;
  gap: .4rem;
  justify-content: center;
  min-height: 1.5rem;
}

.wrong-letter {
  font-family: var(--font-main);
  font-size: .9rem;
  color: var(--wrong);
  background: rgba(248, 113, 113, .1);
  border: 1px solid rgba(248, 113, 113, .3);
  border-radius: 6px;
  padding: .1rem .45rem;
  text-decoration: line-through;
  animation: pop-in .2s ease;
}

.attempts-display {
  margin-top: .75rem;
  font-family: var(--font-main);
  font-size: .8rem;
  color: var(--text-dim);
  text-align: center;
}

/* ── Right panel ── */
.right-panel {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.hint-box {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .85rem 1.25rem;
  font-size: .92rem;
  line-height: 1.5;
}

.hint-label {
  font-family: var(--font-main);
  font-size: .7rem;
  letter-spacing: .15em;
  color: var(--primary);
  margin-right: .5rem;
}

.hint-box.hidden { display: none; }

/* Word display */
.word-display {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem .75rem;
  justify-content: center;
  padding: 1rem;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  min-height: 90px;
  align-items: center;
}

.letter-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .2rem;
}

.letter-char {
  font-family: var(--font-main);
  font-size: clamp(1.2rem, 3vw, 1.8rem);
  font-weight: 700;
  color: var(--primary);
  text-shadow: 0 0 10px var(--primary);
  min-width: 1.4ch;
  text-align: center;
  height: 1.4em;
  display: flex;
  align-items: center;
  justify-content: center;
}

.letter-char.just-revealed {
  animation: reveal-letter .35s cubic-bezier(.34,1.56,.64,1);
}

@keyframes reveal-letter {
  from { transform: scale(0) rotateY(90deg); opacity: 0; }
  to   { transform: scale(1) rotateY(0deg);  opacity: 1; }
}

.letter-line {
  width: 1.6ch;
  height: 3px;
  background: var(--border);
  border-radius: 2px;
}

.letter-tile.revealed .letter-line {
  background: var(--primary);
  box-shadow: 0 0 6px var(--primary);
}

.space-tile { width: 1rem; }

/* ── Keyboard ── */
.keyboard {
  display: flex;
  flex-direction: column;
  gap: .4rem;
}

.key-row {
  display: flex;
  gap: .35rem;
  justify-content: center;
}

/* .key-btn sizing now handled by the fluid block near the bottom */

.key-btn:hover:not(:disabled) {
  background: var(--letter-hover);
  border-color: var(--primary);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px var(--card-glow);
}

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

.key-btn:disabled { cursor: not-allowed; opacity: .35; }

.key-btn.correct {
  background: rgba(74,222,128,.12);
  border-color: var(--correct);
  color: var(--correct);
  opacity: 1;
}

.key-btn.wrong {
  background: rgba(248,113,113,.08);
  border-color: var(--wrong);
  color: var(--wrong);
  opacity: .6;
}

/* ── Buttons ── */
.back-btn {
  background: transparent;
  border: 1.5px solid var(--border);
  color: var(--text-dim);
  font-family: var(--font-body);
  font-size: .9rem;
  padding: .45rem .9rem;
  border-radius: 8px;
  cursor: pointer;
  transition: border-color .2s, color .2s;
  white-space: nowrap;
}

.back-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.btn {
  font-family: var(--font-main);
  font-size: .82rem;
  font-weight: 700;
  letter-spacing: .08em;
  padding: .75rem 1.5rem;
  border-radius: var(--radius);
  border: 2px solid transparent;
  cursor: pointer;
  transition: transform .2s, box-shadow .2s;
}

.btn:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(0,0,0,.4); }
.btn:active { transform: translateY(0); }

.btn-primary {
  background: var(--primary);
  color: #000;
  border-color: var(--primary);
}

.btn-secondary {
  background: transparent;
  color: var(--primary);
  border-color: var(--primary);
}

/* ── Result Overlay ── */
.result-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.8);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  animation: fade-in .3s ease;
}

.result-overlay.hidden { display: none; }

@keyframes fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.result-card {
  background: var(--bg2);
  border: 2px solid var(--primary);
  border-radius: 20px;
  padding: 2.5rem 2rem;
  text-align: center;
  max-width: 440px;
  width: 90%;
  box-shadow: 0 0 60px var(--card-glow);
  animation: slide-up .35s cubic-bezier(.34,1.56,.64,1);
}

@keyframes slide-up {
  from { transform: translateY(40px) scale(.9); opacity: 0; }
  to   { transform: translateY(0) scale(1); opacity: 1; }
}

.result-emoji {
  font-size: 4rem;
  margin-bottom: .5rem;
  animation: bounce .5s .2s ease both;
}

@keyframes bounce {
  0%   { transform: scale(0); }
  60%  { transform: scale(1.25); }
  100% { transform: scale(1); }
}

.result-title {
  font-family: var(--font-main);
  font-size: 1.6rem;
  font-weight: 900;
  color: var(--primary);
  text-shadow: 0 0 20px var(--primary);
  margin-bottom: .75rem;
  letter-spacing: .08em;
}

.result-word-reveal {
  font-family: var(--font-main);
  font-size: 1rem;
  color: rgba(255,255,255,.7);
  margin-bottom: .5rem;
  letter-spacing: .05em;
}

.result-word-reveal strong {
  color: var(--primary);
  display: block;
  font-size: 1.2rem;
  margin-top: .25rem;
  text-shadow: 0 0 10px var(--primary);
}

.result-score {
  font-family: var(--font-main);
  font-size: .85rem;
  color: var(--text-dim);
  margin-bottom: .3rem;
  letter-spacing: .08em;
}

.result-best {
  font-family: var(--font-main);
  font-size: .75rem;
  color: var(--primary);
  margin-bottom: 1.4rem;
  letter-spacing: .08em;
  opacity: .8;
}

.result-btns {
  display: flex;
  gap: .75rem;
  justify-content: center;
  flex-wrap: wrap;
}

/* ── Utilities ── */
.hidden { display: none !important; }

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

/* Shake animation for wrong guesses */
@keyframes shake {
  0%,100% { transform: translateX(0); }
  20%     { transform: translateX(-8px); }
  40%     { transform: translateX(8px); }
  60%     { transform: translateX(-6px); }
  80%     { transform: translateX(6px); }
}

.shake { animation: shake .4s ease; }

/* ── Splash Screen ── */
#splash-screen {
  position: fixed;
  inset: 0;
  background: #080808;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  gap: .5rem;
  transition: opacity .5s ease;
}

.splash-title {
  font-family: 'Orbitron', 'Courier New', monospace;
  font-size: clamp(2.5rem, 10vw, 5rem);
  font-weight: 900;
  letter-spacing: .25em;
  color: #FFE81F;
  text-shadow: 0 0 30px #FFE81F, 0 0 80px rgba(255,232,31,.4);
  animation: pulse-glow 2s ease-in-out infinite;
}

.splash-sub {
  font-family: 'Orbitron', 'Courier New', monospace;
  font-size: clamp(.9rem, 3vw, 1.6rem);
  letter-spacing: .6em;
  color: #FF4444;
  text-shadow: 0 0 15px #FF4444;
}

.splash-dots {
  display: flex;
  gap: .5rem;
  margin-top: 1.5rem;
}

.splash-dots span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: rgba(255,232,31,.5);
  animation: dot-pulse 1.2s ease-in-out infinite;
}
.splash-dots span:nth-child(2) { animation-delay: .2s; }
.splash-dots span:nth-child(3) { animation-delay: .4s; }

@keyframes dot-pulse {
  0%, 80%, 100% { transform: scale(.6); opacity: .3; }
  40%            { transform: scale(1);  opacity: 1;  }
}

/* ── Sound Toggle ── */
.sound-btn {
  position: fixed;
  bottom: 1rem;
  right: 1rem;
  z-index: 200;
  background: var(--bg2);
  border: 1.5px solid var(--border);
  border-radius: 50%;
  width: 42px;
  height: 42px;
  font-size: 1.1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color .2s, box-shadow .2s;
  line-height: 1;
}

.sound-btn:hover {
  border-color: var(--primary);
  box-shadow: 0 0 12px var(--card-glow);
}

.sound-btn.muted { opacity: .45; }

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* ── Responsive tweaks ── */

/* Fluid key sizing so keyboard always fits the viewport */
.key-btn {
  font-family: var(--font-main);
  font-size: clamp(.58rem, 1.9vw, .78rem);
  font-weight: 700;
  width: clamp(26px, calc((100vw - 4rem) / 11.2), 38px);
  height: clamp(34px, calc((100vw - 4rem) / 10),  42px);
  border: 1.5px solid var(--border);
  border-radius: 8px;
  background: var(--letter-bg);
  color: var(--text);
  cursor: pointer;
  transition: background .15s, border-color .15s, transform .1s, opacity .2s;
  letter-spacing: .03em;
}

@media (max-width: 600px) {
  .theme-grid { grid-template-columns: repeat(2, 1fr); gap: .75rem; }
  .game-header { flex-wrap: wrap; gap: .5rem; }
  .header-stats { gap: .35rem; }
  .stat-chip { min-width: 44px; padding: .25rem .5rem; }

  /* On small screens: SVG sits above, compact */
  .game-body { grid-template-columns: 1fr; }
  .left-panel {
    display: grid;
    grid-template-columns: 140px 1fr;
    gap: .75rem;
    align-items: start;
  }
  #hangman-svg { max-width: 140px; }
  .wrong-letters-wrap { margin-top: 0; }

  /* Key row gaps tighten on narrow screens */
  .key-row { gap: clamp(2px, .6vw, 5px); }
  .keyboard { gap: clamp(3px, .7vw, 6px); }
}

@media (max-width: 380px) {
  .left-panel { grid-template-columns: 110px 1fr; }
  #hangman-svg { max-width: 110px; }
  .diff-grid { grid-template-columns: 1fr; max-width: 260px; margin: 0 auto; }
}
