/* Quintari — distinctive visual design
 * Palette (deliberately different from Wordle):
 *   correct (right letter, right spot)  : violet  #7c3aed / #a78bfa
 *   present (right letter, wrong spot)  : amber   #f59e0b / #fbbf24
 *   absent  (letter not in word)        : slate   #475569 / #64748b
 *   accent (chrome / buttons)           : teal    #0ea5e9
 *   background                          : warm off-white gradient with violet tint
 * Tile shape: rounded corners + soft inner shadow + colour LED dot in corner
 * Layout: board on the left / keyboard on the right on desktop; stacked on mobile
 */

.qt-app {
  --qt-bg-1: #fbf8ff;
  --qt-bg-2: #eef2ff;
  --qt-ink: #1e1b4b;
  --qt-ink-soft: #4b5563;
  --qt-surface: #ffffff;
  --qt-line: #e5e7eb;
  --qt-correct: #7c3aed;
  --qt-correct-2: #6d28d9;
  --qt-present: #f59e0b;
  --qt-present-2: #d97706;
  --qt-absent: #475569;
  --qt-absent-2: #334155;
  --qt-accent: #0ea5e9;
  --qt-danger: #dc2626;
  --qt-good: #16a34a;
  --qt-radius: 14px;
  --qt-radius-sm: 8px;
  --qt-shadow: 0 4px 14px rgba(79, 70, 229, 0.08);
  --qt-shadow-hv: 0 6px 22px rgba(79, 70, 229, 0.14);
  --qt-key-bg: #eef2ff;
  --qt-key-ink: #1e1b4b;

  font-family: "Inter", "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--qt-ink);
  background: linear-gradient(140deg, var(--qt-bg-1) 0%, var(--qt-bg-2) 100%);
  border-radius: 18px;
  box-shadow: var(--qt-shadow);
  padding: 20px;
  max-width: 1080px;
  margin: 0 auto;
}

.qt-app[data-theme="dark"] {
  --qt-bg-1: #11122a;
  --qt-bg-2: #1b1d3a;
  --qt-ink: #f5f3ff;
  --qt-ink-soft: #cbd5e1;
  --qt-surface: #1f2145;
  --qt-line: #2e3065;
  --qt-key-bg: #2a2c55;
  --qt-key-ink: #f5f3ff;
  --qt-correct: #a78bfa;
  --qt-correct-2: #7c3aed;
  --qt-present: #fbbf24;
  --qt-present-2: #f59e0b;
  --qt-absent: #64748b;
  --qt-absent-2: #475569;
}

.qt-app,
.qt-app *,
.qt-app *::before,
.qt-app *::after {
  box-sizing: border-box;
}

.qt-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}

.qt-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.qt-logo {
  width: 46px;
  height: 46px;
  border-radius: 12px;
  background:
    radial-gradient(circle at 30% 30%, #a78bfa 0%, #7c3aed 55%, #5b21b6 100%);
  display: grid;
  place-items: center;
  color: #fff;
  font-weight: 800;
  font-size: 22px;
  letter-spacing: 1px;
  box-shadow: 0 6px 14px rgba(124, 58, 237, 0.35);
}

.qt-logo::after {
  content: "";
  position: absolute;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #fbbf24;
  box-shadow: 0 0 8px rgba(251, 191, 36, 0.7);
  transform: translate(14px, -14px);
}

.qt-brand-text h1 {
  margin: 0;
  font-size: 26px;
  font-weight: 800;
  letter-spacing: 0.5px;
  background: linear-gradient(90deg, #7c3aed, #0ea5e9);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.qt-brand-text p {
  margin: 2px 0 0;
  font-size: 13px;
  color: var(--qt-ink-soft);
}

.qt-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.qt-btn {
  appearance: none;
  border: 1px solid var(--qt-line);
  background: var(--qt-surface);
  color: var(--qt-ink);
  padding: 8px 14px;
  border-radius: var(--qt-radius-sm);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.1s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.qt-btn:hover {
  box-shadow: var(--qt-shadow-hv);
  transform: translateY(-1px);
}

.qt-btn[data-active="1"] {
  background: var(--qt-accent);
  border-color: var(--qt-accent);
  color: #fff;
}

.qt-btn-primary {
  background: linear-gradient(135deg, #7c3aed, #0ea5e9);
  color: #fff;
  border-color: transparent;
}

.qt-layout {
  display: grid;
  grid-template-columns: minmax(280px, 420px) 1fr;
  gap: 22px;
  align-items: start;
}

@media (max-width: 860px) {
  .qt-layout {
    grid-template-columns: 1fr;
  }
}

.qt-panel {
  background: var(--qt-surface);
  border: 1px solid var(--qt-line);
  border-radius: var(--qt-radius);
  padding: 18px;
  box-shadow: var(--qt-shadow);
}

.qt-modebar {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.qt-modebar label {
  font-size: 12px;
  font-weight: 600;
  color: var(--qt-ink-soft);
  margin-right: 4px;
  display: flex;
  align-items: center;
}

.qt-board {
  display: grid;
  gap: 8px;
  justify-content: center;
  margin: 6px 0 14px;
}

.qt-row {
  display: grid;
  gap: 8px;
  justify-content: center;
}

.qt-tile {
  width: 54px;
  height: 54px;
  border-radius: var(--qt-radius-sm);
  background: var(--qt-surface);
  border: 2px solid var(--qt-line);
  display: grid;
  place-items: center;
  font-size: 24px;
  font-weight: 800;
  letter-spacing: 1px;
  color: var(--qt-ink);
  text-transform: uppercase;
  position: relative;
  transition: transform 0.25s ease, background 0.3s ease,
    border-color 0.3s ease, color 0.3s ease;
}

.qt-tile::after {
  /* distinctive LED corner dot — not present in Wordle */
  content: "";
  position: absolute;
  top: 5px;
  right: 5px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: transparent;
  transition: background 0.3s ease;
}

.qt-tile[data-state="filled"] {
  border-color: var(--qt-accent);
  transform: scale(1.04);
}

.qt-tile[data-state="correct"] {
  background: linear-gradient(135deg, var(--qt-correct), var(--qt-correct-2));
  border-color: var(--qt-correct-2);
  color: #fff;
}
.qt-tile[data-state="correct"]::after { background: #fde68a; box-shadow: 0 0 6px #fde68a; }

.qt-tile[data-state="present"] {
  background: linear-gradient(135deg, var(--qt-present), var(--qt-present-2));
  border-color: var(--qt-present-2);
  color: #fff;
}
.qt-tile[data-state="present"]::after { background: #ffffff; box-shadow: 0 0 6px #ffffff; }

.qt-tile[data-state="absent"] {
  background: linear-gradient(135deg, var(--qt-absent), var(--qt-absent-2));
  border-color: var(--qt-absent-2);
  color: #f1f5f9;
}
.qt-tile[data-state="absent"]::after { background: #94a3b8; }

.qt-tile.qt-flip {
  animation: qt-flip 0.55s ease forwards;
}
.qt-tile.qt-shake {
  animation: qt-shake 0.45s ease;
}
.qt-tile.qt-pop {
  animation: qt-pop 0.15s ease;
}

@keyframes qt-flip {
  0%   { transform: rotateX(0); }
  45%  { transform: rotateX(90deg); }
  55%  { transform: rotateX(90deg); }
  100% { transform: rotateX(0); }
}
@keyframes qt-shake {
  0%,100% { transform: translateX(0); }
  20%,60% { transform: translateX(-6px); }
  40%,80% { transform: translateX(6px); }
}
@keyframes qt-pop {
  0%   { transform: scale(1); }
  50%  { transform: scale(1.1); }
  100% { transform: scale(1.04); }
}

.qt-keyboard {
  display: grid;
  gap: 6px;
}

.qt-krow {
  display: flex;
  gap: 6px;
  justify-content: center;
  flex-wrap: wrap;
}

.qt-key {
  appearance: none;
  border: 0;
  background: var(--qt-key-bg);
  color: var(--qt-key-ink);
  font-weight: 700;
  font-size: 14px;
  padding: 0 10px;
  min-width: 32px;
  height: 48px;
  border-radius: 8px;
  cursor: pointer;
  text-transform: uppercase;
  position: relative;
  overflow: hidden;
  transition: transform 0.1s ease, background 0.3s ease, color 0.3s ease;
}

.qt-key.qt-k-wide {
  min-width: 62px;
  font-size: 12px;
}

.qt-key:hover {
  transform: translateY(-1px);
}

/* key colouring uses coloured UNDER-BAR (different from Wordle's solid fill) */
.qt-key::after {
  content: "";
  position: absolute;
  left: 10%;
  right: 10%;
  bottom: 3px;
  height: 4px;
  border-radius: 2px;
  background: transparent;
  transition: background 0.3s ease;
}
.qt-key[data-state="correct"]::after { background: var(--qt-correct); }
.qt-key[data-state="present"]::after { background: var(--qt-present); }
.qt-key[data-state="absent"] {
  opacity: 0.55;
  color: var(--qt-ink-soft);
}
.qt-key[data-state="absent"]::after { background: var(--qt-absent); }

.qt-message {
  min-height: 28px;
  text-align: center;
  font-weight: 600;
  font-size: 14px;
  margin: 6px 0 0;
  color: var(--qt-ink-soft);
}
.qt-message[data-tone="good"]  { color: var(--qt-good); }
.qt-message[data-tone="bad"]   { color: var(--qt-danger); }

.qt-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-top: 14px;
}
.qt-stat {
  background: var(--qt-surface);
  border: 1px solid var(--qt-line);
  border-radius: var(--qt-radius-sm);
  padding: 10px;
  text-align: center;
}
.qt-stat strong {
  display: block;
  font-size: 20px;
  color: var(--qt-correct);
}
.qt-stat span {
  display: block;
  font-size: 11px;
  color: var(--qt-ink-soft);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.qt-legend {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  font-size: 12px;
  color: var(--qt-ink-soft);
  margin-top: 10px;
}
.qt-legend span::before {
  content: "";
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 3px;
  margin-right: 6px;
  vertical-align: -2px;
}
.qt-legend .lg-correct::before { background: var(--qt-correct); }
.qt-legend .lg-present::before { background: var(--qt-present); }
.qt-legend .lg-absent::before  { background: var(--qt-absent); }

.qt-modal-bg {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  display: none;
  z-index: 1000;
  align-items: center;
  justify-content: center;
  padding: 18px;
}
.qt-modal-bg[data-open="1"] { display: flex; }
.qt-modal {
  background: var(--qt-surface);
  border-radius: 16px;
  padding: 22px;
  max-width: 460px;
  width: 100%;
  box-shadow: 0 12px 40px rgba(15, 23, 42, 0.3);
  color: var(--qt-ink);
}
.qt-modal h2 {
  margin-top: 0;
  font-size: 20px;
  background: linear-gradient(90deg, #7c3aed, #0ea5e9);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.qt-modal pre {
  background: var(--qt-bg-2);
  padding: 10px;
  border-radius: 8px;
  font-family: "Consolas", "Menlo", monospace;
  font-size: 16px;
  line-height: 1.4;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--qt-ink);
}

.qt-help-list {
  padding-left: 18px;
  color: var(--qt-ink-soft);
  font-size: 14px;
  line-height: 1.55;
}
.qt-help-list li { margin: 4px 0; }

.qt-help-tiles {
  display: flex;
  gap: 6px;
  margin: 6px 0 10px;
}
.qt-help-tiles .qt-tile {
  width: 36px;
  height: 36px;
  font-size: 16px;
}
