
@import url('https://fonts.googleapis.com/css2?family=DM+Mono:wght@400;500&family=Manrope:wght@400;500;600;700;800&display=swap');

/* =========================================
   SQPLAYERS WORDIES — COMPLETE CSS REPLACEMENT
   Electric blue + sharp neon red
========================================= */

:root {
  color-scheme: dark;
  --bg: #050912;
  --panel: #0b1423;
  --panel-light: #111f33;
  --border: #203a59;
  --text: #f1f6ff;
  --muted: #879bb7;
  --blue: #19aaff;
  --blue-light: #65d3ff;
  --red: #ff2348;
  --red-light: #ff526b;
  --accent: #27baff;
  --green: #19d995;
  --yellow: #ffc247;
  --gray: #29394e;
  --tile-size: 48px;
  --tile-gap: 6px;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bg);
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  overflow-x: hidden;
  background:
    radial-gradient(ellipse at 8% 5%, #092b50 0, transparent 35%),
    radial-gradient(ellipse at 95% 32%, #350916 0, transparent 34%),
    radial-gradient(ellipse at 50% 100%, #081b32 0, transparent 45%),
    var(--bg);
  color: var(--text);
  font-family: "Manrope", sans-serif;
  position: relative;
  isolation: isolate;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(31, 151, 255, .045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(31, 151, 255, .045) 1px, transparent 1px);
  background-size: 44px 44px;
  mask-image: linear-gradient(to bottom, black, transparent 90%);
  animation: grid-drift 18s linear infinite;
}

body::after {
  content: "";
  position: fixed;
  width: 280px;
  height: 280px;
  top: 12%;
  right: -180px;
  z-index: -1;
  pointer-events: none;
  border-radius: 50%;
  background: rgba(255, 25, 65, .11);
  filter: blur(70px);
  animation: red-pulse 5s ease-in-out infinite alternate;
}

button,
input,
select {
  font: inherit;
}

button,
select {
  -webkit-tap-highlight-color: transparent;
}

button {
  cursor: pointer;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
a:focus-visible {
  outline: 2px solid var(--blue-light);
  outline-offset: 4px;
}

::selection {
  background: var(--red);
  color: white;
}

/* PAGE */

.page {
  width: 100%;
  min-height: 100vh;
  padding: 0 24px;
}

.topbar {
  width: 100%;
  max-width: 1080px;
  min-height: 76px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  border-bottom: 1px solid rgba(76, 157, 255, .22);
  position: relative;
}

.topbar::after {
  content: "";
  position: absolute;
  bottom: -1px;
  left: 0;
  width: 30%;
  height: 1px;
  background: var(--blue);
  box-shadow: 0 0 12px var(--blue);
}

.back-button {
  justify-self: start;
  color: var(--muted);
  text-decoration: none;
  font-size: 12px;
  font-weight: 700;
  transition: color .2s, transform .2s;
}

.back-button:hover {
  color: var(--blue-light);
  transform: translateX(-3px);
}

.brand {
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -.8px;
  color: var(--text);
}

.brand span {
  color: var(--blue-light);
  text-shadow: 0 0 14px rgba(25, 170, 255, .65);
}

.icon-button {
  justify-self: end;
  width: 36px;
  height: 36px;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: var(--panel);
  color: var(--text);
  font-weight: 800;
  transition: .25s ease;
}

.icon-button:hover {
  border-color: var(--red);
  color: var(--red-light);
  box-shadow: 0 0 18px rgba(255, 35, 72, .2);
  transform: rotate(8deg);
}

/* GAME HEADER */

.game {
  width: 100%;
  max-width: 760px;
  margin: 0 auto;
  padding: 38px 0 24px;
}

.heading {
  text-align: center;
  margin-bottom: 28px;
  animation: fade-up .65s ease both;
}

.eyebrow {
  margin: 0 0 9px;
  color: var(--blue-light);
  font-family: "DM Mono", monospace;
  font-size: 10px;
  letter-spacing: 2.2px;
  font-weight: 500;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  color: var(--text);
  font-size: clamp(42px, 8vw, 62px);
  line-height: 1.08;
  letter-spacing: -4px;
  font-weight: 800;
  text-shadow: 0 0 28px rgba(25, 170, 255, .13);
}

h1 span {
  color: var(--red);
  text-shadow: 0 0 20px rgba(255, 35, 72, .65);
}

.subtitle {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.7;
}

/* WORD LENGTH + ATTEMPTS */

.settings {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 12px;
  margin: 0 auto 22px;
}

.settings label {
  color: var(--muted);
  font-family: "DM Mono", monospace;
  font-size: 10px;
  letter-spacing: 1.1px;
}

.settings select {
  appearance: none;
  padding: 10px 32px 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background-color: var(--panel);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2365d3ff' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  color: var(--text);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: border-color .2s, box-shadow .2s;
}

.settings select:hover,
.settings select:focus {
  border-color: var(--blue);
  box-shadow: 0 0 14px rgba(25, 170, 255, .12);
}

.settings select option {
  background: var(--panel);
  color: var(--text);
}

.attempt-counter {
  min-width: 46px;
  color: var(--muted);
  font-family: "DM Mono", monospace;
  font-size: 12px;
  text-align: center;
}

/* DICTIONARY LOADING */

.loading {
  margin: 0 auto 12px;
  text-align: center;
  color: var(--blue-light);
  font-size: 12px;
  animation: loading-glow 1.2s ease-in-out infinite alternate;
}

.loading.hidden {
  display: none !important;
}

/* WORD GRID */

.board-container {
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 2px 0 8px;
  scrollbar-color: var(--border) transparent;
  scrollbar-width: thin;
}

.board {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--tile-gap);
  width: 100%;
  min-width: 0;
  margin: 0 auto;
}

.board-row {
  display: grid;
  grid-template-columns: repeat(var(--word-length), var(--tile-size));
  grid-auto-rows: var(--tile-size);
  gap: var(--tile-gap);
  width: max-content;
  flex: none;
}

.tile {
  width: var(--tile-size);
  height: var(--tile-size);
  min-width: var(--tile-size);
  max-width: var(--tile-size);
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  border: 1px solid #29425f;
  border-radius: 7px;
  background: linear-gradient(145deg, #0c1727, #09111e);
  color: var(--text);
  font-size: 20px;
  font-weight: 800;
  box-shadow: inset 0 0 12px rgba(25, 170, 255, .025);
  transition: border-color .2s, background .2s, box-shadow .2s;
}

.tile.filled {
  border-color: var(--blue);
  box-shadow: inset 0 0 12px rgba(25, 170, 255, .08);
  animation: pop .12s ease-out;
}

.tile.correct {
  border-color: var(--green);
  background: var(--green);
  color: #041b14;
  box-shadow: 0 0 15px rgba(25, 217, 149, .25);
}

.tile.misplaced {
  border-color: var(--yellow);
  background: var(--yellow);
  color: #241600;
  box-shadow: 0 0 15px rgba(255, 194, 71, .18);
}

.tile.absent {
  border-color: var(--gray);
  background: #202b3a;
  color: #b4c1d1;
}

.tile.reveal {
  animation: flip .42s ease forwards;
}

.board-row.shake {
  animation: shake .35s ease;
}

/* FEEDBACK MESSAGE */

.message {
  min-height: 22px;
  margin: 10px 0 14px;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
  line-height: 1.6;
}

.message.error {
  color: var(--red-light);
  text-shadow: 0 0 12px rgba(255, 35, 72, .15);
}

.message.success {
  color: var(--green);
}

/* GUESS INPUT */

.guess-form {
  display: flex;
  gap: 8px;
  width: 100%;
  max-width: 470px;
  margin: 0 auto 22px;
}

.guess-form input {
  flex: 1;
  min-width: 0;
  height: 46px;
  padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: rgba(11, 20, 35, .95);
  color: var(--text);
  font-family: "DM Mono", monospace;
  font-size: 13px;
  letter-spacing: 1px;
  text-transform: uppercase;
  transition: border-color .2s, box-shadow .2s;
}

.guess-form input:focus {
  border-color: var(--blue);
  box-shadow: 0 0 18px rgba(25, 170, 255, .12);
  outline: none;
}

.guess-form input::placeholder {
  color: #596f8b;
  font-size: 10px;
  letter-spacing: 1.1px;
}

.guess-form input:disabled {
  opacity: .6;
  cursor: not-allowed;
}

.guess-form button,
.primary-button {
  min-height: 46px;
  padding: 0 18px;
  border: 1px solid var(--blue-light);
  border-radius: 9px;
  background: linear-gradient(110deg, var(--blue), #1687ff);
  color: #03101e;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .6px;
  box-shadow: 0 0 18px rgba(25, 170, 255, .14);
  transition: transform .15s, filter .15s, box-shadow .2s;
}

.guess-form button:hover,
.primary-button:hover {
  filter: brightness(1.13);
  transform: translateY(-2px);
  box-shadow: 0 0 25px rgba(25, 170, 255, .28);
}

.guess-form button:active,
.primary-button:active {
  transform: scale(.97);
}

.guess-form button:disabled {
  opacity: .5;
  cursor: not-allowed;
  transform: none;
}

/* ON-SCREEN KEYBOARD */

.keyboard {
  width: 100%;
  max-width: 520px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.keyboard-row {
  display: flex;
  justify-content: center;
  gap: 5px;
}

.key {
  flex: 1 1 0;
  min-width: 0;
  height: 44px;
  padding: 0;
  border: 1px solid #263d59;
  border-radius: 6px;
  background: linear-gradient(145deg, #18283d, #101b2b);
  color: var(--text);
  font-size: 12px;
  font-weight: 800;
  box-shadow: inset 0 1px rgba(255, 255, 255, .025);
  transition: background .15s, border-color .15s, transform .1s;
}

.key:hover {
  background: #203b58;
  border-color: var(--blue);
  box-shadow: 0 0 12px rgba(25, 170, 255, .1);
}

.key:active {
  transform: scale(.94);
}

.key.wide {
  flex: 1.65 1 0;
  font-size: 9px;
}

.key.correct {
  background: var(--green);
  border-color: var(--green);
  color: #041b14;
}

.key.misplaced {
  background: var(--yellow);
  border-color: var(--yellow);
  color: #241600;
}

.key.absent {
  background: #111722;
  color: #66758a;
  border-color: #222d3c;
}

.key.absent:hover {
  background: #20252f;
  color: #b5c1d0;
}

/* NEW GAME + REVEAL ANSWER */

.actions {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 10px;
  margin: 24px 0 32px;
}

.secondary-button {
  padding: 10px 15px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(11, 20, 35, .8);
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  transition: border-color .2s, color .2s, background .2s, transform .2s;
}

.secondary-button:hover {
  border-color: var(--blue);
  background: rgba(25, 170, 255, .07);
  color: var(--blue-light);
  transform: translateY(-1px);
}

.reveal-button:hover {
  border-color: var(--red);
  background: rgba(255, 35, 72, .08);
  color: var(--red-light);
}

/* FOOTER */

footer {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  padding-top: 16px;
  border-top: 1px solid rgba(76, 157, 255, .17);
  color: #60748e;
  font-family: "DM Mono", monospace;
  font-size: 9px;
  letter-spacing: .8px;
}

/* MODALS: RESULT + HELP */

.modal {
  position: fixed;
  z-index: 100;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow-y: auto;
  padding: 20px;
  background: rgba(2, 5, 12, .86);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.modal.hidden {
  display: none !important;
}

.modal-card {
  position: relative;
  width: 100%;
  max-width: 390px;
  max-height: calc(100vh - 40px);
  overflow-y: auto;
  padding: 34px 26px 26px;
  border: 1px solid #254a70;
  border-radius: 18px;
  background:
    radial-gradient(ellipse at 100% 0%, rgba(255, 35, 72, .09), transparent 48%),
    radial-gradient(ellipse at 0% 100%, rgba(25, 170, 255, .09), transparent 48%),
    #0a1220;
  color: var(--text);
  text-align: center;
  box-shadow:
    0 20px 80px #000b,
    0 0 35px rgba(25, 170, 255, .08);
  animation: modal-in .22s ease-out;
}

.modal-close {
  position: absolute;
  top: 10px;
  right: 13px;
  width: 32px;
  height: 32px;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: var(--panel-light);
  color: var(--muted);
  font-size: 23px;
  line-height: 1;
  transition: .2s;
}

.modal-close:hover {
  border-color: var(--red);
  color: var(--red-light);
  transform: rotate(90deg);
}

.modal-card .eyebrow {
  color: var(--blue-light);
  margin-bottom: 10px;
  font-size: 10px;
}

.modal-card h2 {
  margin: 0 0 10px;
  color: var(--text);
  font-size: 28px;
  letter-spacing: -1px;
}

.modal-card > p:not(.eyebrow):not(.result-stats) {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.7;
}

/* ANSWER REVEAL */

.answer-box {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 20px 0 12px;
  padding: 15px;
  border: 1px solid rgba(255, 35, 72, .45);
  border-radius: 10px;
  background: rgba(255, 35, 72, .055);
  box-shadow: inset 0 0 20px rgba(255, 35, 72, .035);
}

.answer-box span {
  color: var(--muted);
  font-family: "DM Mono", monospace;
  font-size: 9px;
  letter-spacing: 1.6px;
}

.answer-box strong {
  color: var(--red-light);
  font-family: "DM Mono", monospace;
  font-size: 25px;
  letter-spacing: 3px;
  overflow-wrap: anywhere;
  text-shadow: 0 0 15px rgba(255, 35, 72, .25);
}

.result-stats {
  color: var(--muted);
  font-size: 11px;
}

.primary-button {
  width: 100%;
  margin-top: 12px;
}

/* HELP / RULES MODAL */

.help-card {
  text-align: left;
}

.help-card h2 {
  margin-bottom: 16px;
}

.example {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 14px 0;
}

.example-tile {
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid transparent;
  border-radius: 6px;
  font-size: 18px;
  font-weight: 800;
}

.example-tile.correct {
  background: var(--green);
  color: #041b14;
  box-shadow: 0 0 14px rgba(25, 217, 149, .15);
}

.example-tile.misplaced {
  background: var(--yellow);
  color: #241600;
}

.example-tile.absent {
  background: var(--gray);
  color: white;
}

.example strong {
  color: var(--text);
  font-size: 12px;
}

.example p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.5;
}

/* CONFETTI */

.confetti-layer {
  position: fixed;
  z-index: 120;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}

.confetti-piece {
  position: absolute;
  top: -20px;
  width: 8px;
  height: 13px;
  border-radius: 2px;
  animation: confetti-fall 2.7s linear forwards;
}

/* ANIMATIONS */

@keyframes grid-drift {
  from { background-position: 0 0; }
  to { background-position: 44px 44px; }
}

@keyframes red-pulse {
  from { opacity: .5; transform: scale(.85); }
  to { opacity: 1; transform: scale(1.15); }
}

@keyframes loading-glow {
  from { opacity: .65; }
  to { opacity: 1; }
}

@keyframes fade-up {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes pop {
  0% { transform: scale(.88); }
  100% { transform: scale(1); }
}

@keyframes flip {
  0% { transform: rotateX(0); }
  45% { transform: rotateX(90deg); }
  100% { transform: rotateX(0); }
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-5px); }
  40%, 80% { transform: translateX(5px); }
}

@keyframes modal-in {
  from { opacity: 0; transform: translateY(10px) scale(.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes confetti-fall {
  to {
    transform: translate3d(var(--drift), 105vh, 0) rotate(800deg);
    opacity: 0;
  }
}

/* TABLET + MOBILE */

@media (max-width: 600px) {
  :root {
    --tile-size: 40px;
    --tile-gap: 5px;
  }

  .page {
    padding: 0 14px;
  }

  .topbar {
    min-height: 64px;
  }

  .brand {
    font-size: 16px;
  }

  .game {
    padding-top: 28px;
  }

  .heading {
    margin-bottom: 24px;
  }

  h1 {
    letter-spacing: -2.5px;
  }

  .subtitle {
    font-size: 12px;
  }

  .settings {
    gap: 8px;
  }

  .settings label {
    font-size: 9px;
  }

  .settings select {
    padding: 9px 27px 9px 9px;
    font-size: 11px;
  }

  .tile {
    border-radius: 5px;
    font-size: 17px;
  }

  .guess-form {
    gap: 6px;
  }

  .guess-form input {
    padding: 0 10px;
  }

  .guess-form button {
    padding: 0 12px;
  }

  .keyboard {
    gap: 6px;
  }

  .keyboard-row {
    gap: 4px;
  }

  .key {
    height: 42px;
    border-radius: 5px;
    font-size: 11px;
  }

  .key.wide {
    font-size: 8px;
  }

  .actions {
    gap: 7px;
  }

  .secondary-button {
    padding: 10px 11px;
    font-size: 10px;
  }

  footer {
    line-height: 1.7;
  }

  .modal {
    padding: 12px;
  }

  .modal-card {
    padding: 34px 20px 22px;
  }
}

@media (max-width: 360px) {
  :root {
    --tile-size: 34px;
    --tile-gap: 4px;
  }

  .page {
    padding: 0 10px;
  }

  .key {
    height: 38px;
    font-size: 10px;
  }

  .guess-form button {
    padding: 0 9px;
    font-size: 10px;
  }
}

/* ACCESSIBILITY */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
    scroll-behavior: auto !important;
  }
}
