:root {
  --bg: #17131d;
  --panel: #211b28;
  --panel-2: #292230;
  --line: #49404f;
  --text: #eeeaf0;
  --muted: #8d8493;
  --pink: #f13f91;
  --red: #f02d55;
  --yellow: #f4e72b;
  --cyan: #43d5dc;
  --green: #8be667;
  --orange: #ff8a24;
  --cell: clamp(43px, 5.4vw, 72px);
  --gap: clamp(5px, .7vw, 10px);
}

* { box-sizing: border-box; }

html, body { min-height: 100%; }

body {
  margin: 0;
  color: var(--text);
  background:
    radial-gradient(circle at 50% 35%, rgba(91, 47, 90, .18), transparent 34%),
    linear-gradient(#1b1720, #151119);
  font-family: "Courier New", Consolas, monospace;
  overflow-x: hidden;
}

button { font: inherit; }

.game-shell {
  width: min(1180px, calc(100% - 32px));
  min-height: 100vh;
  margin: 0 auto;
  padding: 18px 0 24px;
  display: flex;
  flex-direction: column;
}

.brand-row, .help-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand {
  color: #b7abbc;
  letter-spacing: 3px;
  font-size: 13px;
  font-weight: 700;
}

.brand-mark { color: var(--pink); text-shadow: 0 0 12px var(--pink); }

.sound-button {
  width: 36px;
  height: 32px;
  border: 1px solid #514656;
  border-radius: 3px;
  color: var(--cyan);
  background: transparent;
  cursor: pointer;
}

.sound-button:hover { border-color: var(--cyan); box-shadow: 0 0 10px rgba(67,213,220,.2); }
.sound-button.muted { color: var(--muted); }

.hud {
  position: relative;
  min-height: 84px;
  margin-top: 14px;
  padding: 14px 28px;
  display: grid;
  grid-template-columns: 1fr .8fr 1.35fr .8fr 1fr .7fr;
  gap: 12px;
  align-items: center;
  background: rgba(28, 23, 33, .9);
  border: 3px solid var(--pink);
  border-radius: 12px 3px 12px 3px;
  box-shadow: 0 0 16px rgba(241, 63, 145, .14), inset 0 0 22px rgba(241, 63, 145, .035);
  clip-path: polygon(12px 0, calc(100% - 12px) 0, 100% 12px, 100% calc(100% - 12px), calc(100% - 12px) 100%, 12px 100%, 0 calc(100% - 12px), 0 12px);
}

.hud-cell { text-align: center; }
.hud-cell span { display: block; margin-bottom: 3px; color: var(--pink); font-size: 13px; font-weight: 700; letter-spacing: 1px; }
.hud-cell strong { font-size: clamp(18px, 2vw, 28px); line-height: 1; letter-spacing: 1px; text-shadow: 0 0 8px currentColor; }
.hud-cell.cyan span { color: var(--cyan); }
.hud-cell.green span { color: var(--green); }
.hud-cell.time-cell span { color: var(--yellow); }
.time-cell strong { color: var(--yellow); }

.time-track { height: 5px; margin: 8px auto 0; border: 1px solid var(--pink); background: #352331; }
.time-track i { display: block; width: 100%; height: 100%; background: linear-gradient(90deg, var(--yellow), var(--pink)); transition: width .25s linear; box-shadow: 0 0 8px var(--yellow); }

.lives { display: flex; justify-content: center; gap: 8px; }
.heart { position: relative; width: 22px; height: 20px; color: var(--pink); filter: drop-shadow(0 0 5px var(--pink)); }
.heart::before { content: "♥"; font-size: 24px; line-height: 20px; }
.heart.lost { color: #3c3340; filter: none; }

.arena {
  position: relative;
  height: clamp(350px, 47vh, 510px);
  min-height: 350px;
  overflow: hidden;
  isolation: isolate;
}

.stars, .stars::before, .stars::after {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background-image:
    radial-gradient(circle, var(--pink) 0 1px, transparent 2px),
    radial-gradient(circle, var(--yellow) 0 1px, transparent 2px),
    radial-gradient(circle, #ff4e4e 0 1px, transparent 2px);
  background-size: 187px 173px, 251px 211px, 311px 223px;
  background-position: 30px 20px, 90px 65px, 160px 10px;
  opacity: .65;
  animation: starDrift 16s linear infinite;
}

.stars::before, .stars::after { content: ""; opacity: .45; transform: translateX(100px); }
.stars::after { transform: translateX(-80px) translateY(50px); animation-duration: 23s; }

@keyframes starDrift { to { background-position: 30px 193px, 90px 276px, 160px 233px; } }

.grid {
  position: absolute;
  z-index: -1;
  left: 8%;
  right: 8%;
  bottom: -15px;
  height: 150px;
  opacity: .26;
  background-image:
    linear-gradient(rgba(241,63,145,.7) 1px, transparent 1px),
    linear-gradient(90deg, rgba(241,63,145,.7) 1px, transparent 1px);
  background-size: 55px 27px;
  transform: perspective(220px) rotateX(58deg);
  transform-origin: bottom;
  mask-image: linear-gradient(transparent 8%, black 85%);
}

.status-line {
  position: absolute;
  top: 18px;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  color: #716879;
  font-size: 11px;
  letter-spacing: 2px;
  text-align: center;
}

.words-stage {
  position: absolute;
  z-index: 3;
  top: 68px;
  left: 0;
  right: 0;
}

.word-row {
  min-height: calc(var(--cell) + 8px);
  display: flex;
  justify-content: center;
  gap: var(--gap);
}

.preview-word { margin-bottom: clamp(34px, 5vh, 62px); }

.letter-tile {
  position: relative;
  width: var(--cell);
  height: var(--cell);
  display: grid;
  place-items: center;
  border: 2px solid currentColor;
  color: var(--yellow);
  background: rgba(35, 31, 31, .9);
  font-size: clamp(25px, 3.4vw, 45px);
  font-weight: 900;
  line-height: 1;
  text-transform: uppercase;
  text-shadow: 0 0 9px currentColor;
  box-shadow: 0 0 9px rgba(244,231,43,.17), inset 0 0 15px rgba(244,231,43,.05);
  clip-path: polygon(7px 0, calc(100% - 5px) 0, 100% 6px, 100% calc(100% - 8px), calc(100% - 7px) 100%, 5px 100%, 0 calc(100% - 6px), 0 7px);
  transition: color .15s, border-color .15s, opacity .2s, transform .2s;
}

.letter-tile::before, .letter-tile::after {
  content: "";
  position: absolute;
  background: currentColor;
  opacity: .28;
}
.letter-tile::before { width: 12px; height: 2px; top: 7px; right: 5px; }
.letter-tile::after { width: 2px; height: 13px; bottom: 5px; left: 6px; }

.preview-word .letter-tile {
  color: var(--red);
  background: rgba(43, 25, 32, .88);
  transform: scale(.92);
  filter: saturate(.82);
}

.active-word .letter-tile.next {
  transform: translateY(-4px) scale(1.05);
  box-shadow: 0 0 18px rgba(244,231,43,.47), inset 0 0 14px rgba(244,231,43,.09);
  animation: targetPulse 1s ease-in-out infinite;
}

@keyframes targetPulse { 50% { filter: brightness(1.35); } }

.letter-tile.targeted { color: var(--orange); }
.letter-tile.hit {
  color: #4d4734;
  border-color: #4e4835;
  background: rgba(20, 19, 21, .82);
  text-shadow: none;
  box-shadow: inset 0 0 20px #0b0a0c;
  animation: tileHit .38s ease-out;
}
.letter-tile.hit span { opacity: .12; }

@keyframes tileHit {
  0% { transform: scale(1.12); color: white; filter: brightness(2); }
  35% { transform: rotate(-3deg) scale(.94); }
  100% { transform: scale(1); }
}

.letter-tile.spawn { animation: tileSpawn .42s cubic-bezier(.16,.78,.25,1.28) both; }
@keyframes tileSpawn { from { opacity: 0; transform: translateY(-75px) rotate(10deg) scale(.4); } }

.words-stage.shift .active-word { animation: activeVanish .5s ease-in both; }
.words-stage.shift .preview-word { animation: previewDrop .7s cubic-bezier(.2,.75,.25,1) both; }
@keyframes activeVanish { to { opacity: 0; transform: translateY(55px) scale(.75); filter: blur(5px); } }
@keyframes previewDrop { to { transform: translateY(calc(var(--cell) + clamp(34px, 5vh, 62px))) scale(1.087); filter: hue-rotate(48deg) brightness(1.2); } }

.launcher {
  position: absolute;
  z-index: 3;
  left: 50%;
  bottom: 62px;
  width: 34px;
  height: 34px;
  transform: translateX(-50%);
}
.launcher-core { position: absolute; inset: 10px; border-radius: 50%; background: #fff9a8; box-shadow: 0 0 10px var(--yellow), 0 0 25px var(--orange); }
.launcher-ring { position: absolute; inset: 2px; border: 2px solid var(--yellow); border-radius: 50%; animation: launcherSpin 3s linear infinite; }
.launcher-ring::before { content: ""; position: absolute; width: 8px; height: 3px; top: -2px; left: 3px; background: var(--orange); box-shadow: 17px 25px 0 var(--pink); }
@keyframes launcherSpin { to { transform: rotate(360deg); } }

.projectile {
  position: absolute;
  z-index: 8;
  width: 15px;
  height: 15px;
  margin: -7px;
  border-radius: 50%;
  background: #fffbd0;
  box-shadow: 0 0 6px #fff, 0 0 14px var(--yellow), 0 0 28px var(--orange);
  pointer-events: none;
}
.projectile::after {
  content: "";
  position: absolute;
  top: 6px;
  left: 7px;
  width: 70px;
  height: 3px;
  background: linear-gradient(90deg, var(--orange), var(--pink), transparent);
  transform: rotate(var(--trail-angle)) translateX(-100%);
  transform-origin: right;
  filter: blur(.2px);
}

.spark { position: absolute; z-index: 9; width: 5px; height: 2px; background: var(--yellow); box-shadow: 0 0 7px currentColor; pointer-events: none; animation: spark .5s ease-out both; }
@keyframes spark { to { opacity: 0; transform: translate(var(--sx), var(--sy)) rotate(170deg); } }

.combo {
  position: absolute;
  z-index: 10;
  left: calc(50% + 38px);
  bottom: 65px;
  min-width: 70px;
  color: var(--orange);
  font-weight: 900;
  text-shadow: 0 0 8px var(--orange);
}
.combo.pop { animation: comboPop .35s ease-out; }
@keyframes comboPop { 50% { transform: scale(1.25) rotate(-3deg); } }

.arena.wrong { animation: wrongShake .25s linear; }
@keyframes wrongShake { 25% { transform: translateX(-6px); filter: saturate(2); } 75% { transform: translateX(6px); } }

.keyboard-wrap { position: relative; z-index: 5; margin-top: -18px; }
.finger-hint { min-height: 20px; margin-bottom: 7px; color: var(--muted); font-size: 11px; text-align: center; letter-spacing: 1px; }
.finger-hint strong { color: var(--yellow); }
.keyboard { display: flex; flex-direction: column; gap: 5px; align-items: center; user-select: none; }
.key-row { width: 100%; display: flex; justify-content: center; gap: 5px; }
.key {
  height: clamp(38px, 4.8vw, 54px);
  min-width: clamp(31px, 4.8vw, 54px);
  flex: 0 1 54px;
  display: grid;
  place-items: center;
  padding: 0 6px;
  border: 1px solid #4d4551;
  border-radius: 5px;
  color: #9eabb0;
  background: linear-gradient(145deg, #29242d, #211d25);
  font-size: clamp(12px, 1.5vw, 18px);
  box-shadow: inset 0 -3px 0 rgba(0,0,0,.2);
  transition: .12s ease;
}
.key.wide { flex-basis: 95px; }
.key.wider { flex-basis: 130px; }
.key.space { flex-basis: 360px; }
.key.target {
  color: var(--yellow);
  border-color: var(--yellow);
  background: #323021;
  box-shadow: 0 0 11px rgba(244,231,43,.25), inset 0 -3px 0 rgba(0,0,0,.25);
  transform: translateY(-2px);
}
.key.pressed { color: white; border-color: var(--cyan); background: #254149; transform: translateY(2px); box-shadow: 0 0 12px rgba(67,213,220,.35); }
.key.bad { color: white; border-color: var(--pink); background: #57233d; animation: keyBad .28s; }
@keyframes keyBad { 50% { transform: translateY(3px); } }

.help-row { margin-top: 14px; color: #736b78; font-size: 11px; letter-spacing: 1px; }
kbd { padding: 3px 5px; border: 1px solid #514855; border-radius: 3px; color: #a49ba8; background: #252029; font: inherit; }

.modal {
  position: fixed;
  z-index: 50;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(12, 9, 15, .82);
  backdrop-filter: blur(8px);
  opacity: 0;
  visibility: hidden;
  transition: opacity .25s, visibility .25s;
}
.modal.open { opacity: 1; visibility: visible; }
.modal-card {
  width: min(520px, 100%);
  padding: 36px clamp(24px, 5vw, 55px);
  text-align: center;
  background: linear-gradient(155deg, rgba(39,31,45,.98), rgba(24,20,29,.98));
  border: 2px solid var(--pink);
  border-radius: 15px 3px 15px 3px;
  box-shadow: 0 0 40px rgba(241,63,145,.22), inset 0 0 35px rgba(241,63,145,.04);
  clip-path: polygon(14px 0, calc(100% - 14px) 0, 100% 14px, 100% calc(100% - 14px), calc(100% - 14px) 100%, 14px 100%, 0 calc(100% - 14px), 0 14px);
}
.modal-card.compact { width: min(390px, 100%); }
.modal-icon { color: var(--yellow); font-size: 36px; text-shadow: 0 0 12px var(--yellow), 0 0 30px var(--orange); animation: iconPulse 1.2s ease-in-out infinite; }
@keyframes iconPulse { 50% { transform: scale(1.2); } }
.eyebrow { margin: 10px 0; color: var(--cyan); font-size: 11px; font-weight: 700; letter-spacing: 2px; }
.modal h1 { margin: 6px 0 16px; font-size: clamp(42px, 8vw, 72px); line-height: .86; letter-spacing: 4px; text-shadow: 4px 4px 0 #5a1537; }
.modal h1 span { color: var(--pink); }
.modal h2 { margin: 10px 0 28px; font-size: 42px; color: var(--pink); letter-spacing: 4px; text-shadow: 3px 3px 0 #511732; }
.modal-copy { color: #bcb3c0; font-family: Arial, sans-serif; font-size: 15px; line-height: 1.55; }
.primary-button {
  min-width: 230px;
  margin-top: 16px;
  padding: 15px 24px;
  border: 0;
  border-radius: 4px;
  color: #1b131c;
  background: var(--yellow);
  font-weight: 900;
  letter-spacing: 2px;
  cursor: pointer;
  box-shadow: 0 0 18px rgba(244,231,43,.3), inset 0 -4px 0 rgba(173,128,14,.35);
  transition: transform .15s, filter .15s;
}
.primary-button:hover { transform: translateY(-2px); filter: brightness(1.12); }
.primary-button:active { transform: translateY(2px); }
.small-note { margin: 16px 0 0; color: #756d79; font-size: 10px; }
.result-card { width: min(480px, 100%); }
.result-score span, .result-grid span { display: block; color: var(--muted); font-size: 11px; letter-spacing: 2px; }
.result-score strong { color: var(--yellow); font-size: 44px; text-shadow: 0 0 12px rgba(244,231,43,.4); }
.result-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 22px 0 5px; }
.result-grid > div { padding: 12px 5px; border: 1px solid #463c4b; background: #211c26; }
.result-grid strong { display: block; margin-top: 6px; font-size: 21px; }
.new-record { min-height: 18px; color: var(--pink); font-weight: 700; }

@media (max-width: 760px) {
  :root { --cell: clamp(38px, 11vw, 58px); --gap: 5px; }
  .game-shell { width: min(100% - 14px, 1180px); padding-top: 8px; }
  .brand-row { display: none; }
  .hud { min-height: 72px; margin-top: 0; padding: 10px 8px; grid-template-columns: repeat(5, 1fr); gap: 3px; border-width: 2px; }
  .hud-cell span { font-size: 8px; letter-spacing: 0; }
  .hud-cell strong { font-size: 15px; }
  .hud-cell.lives { display: none; }
  .time-track { margin-top: 5px; }
  .arena { height: 370px; }
  .words-stage { top: 78px; }
  .preview-word { margin-bottom: 45px; }
  .letter-tile { font-size: 25px; }
  .keyboard-wrap { margin-top: -25px; overflow-x: auto; padding-bottom: 4px; }
  .keyboard { min-width: 680px; }
  .key { height: 42px; min-width: 36px; font-size: 13px; }
  .help-row { display: none; }
}

@media (max-height: 760px) and (min-width: 761px) {
  .game-shell { padding-top: 8px; }
  .brand-row { display: none; }
  .hud { margin-top: 0; min-height: 70px; padding-top: 9px; padding-bottom: 9px; }
  .arena { height: 360px; }
  .words-stage { top: 55px; }
  .keyboard-wrap { margin-top: -35px; }
  .key { height: 40px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
}
