﻿:root {
  --bg-0: #0b1220;
  --bg-1: #131b2f;
  --bg-2: #1a243a;
  --card: rgba(20, 29, 45, 0.82);
  --text: #e7edf9;
  --muted: #9eadc7;
  --accent: #4cc9f0;
  --accent-strong: #00a6d6;
  --focus-ring: #ffd166;
  --preview-new-bg: #1d7f47;
  --preview-existing-bg: #1c5d94;
  --permanent-bg: #0b1020;
  --manual-bg: #3b2c15;
  --manual-border: rgba(255, 210, 133, 0.45);
  --solver-bg: #163f5c;
  --solver-border: rgba(140, 214, 255, 0.52);
  --permanent-border: rgba(255, 255, 255, 0.08);
  --border: #2a3856;
  --board-bg: #1a2030;
  --normal: #242b3a;
  --dl: #75b84d;
  --tl: #2d8bdc;
  --dw: #de8e2c;
  --tw: #b2364f;
  --st: #7a4f95;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Sora", "Avenir Next", "Segoe UI Variable", "Trebuchet MS", sans-serif;
  color: var(--text);
  background:
    radial-gradient(1200px 700px at 10% -20%, #2b3d5f 0%, transparent 55%),
    radial-gradient(900px 600px at 110% 0%, #123a53 0%, transparent 50%),
    linear-gradient(140deg, var(--bg-0), var(--bg-1) 55%, var(--bg-2));
  min-height: 100vh;
}

.container {
  max-width: 1160px;
  margin: 0 auto;
  padding: 20px 14px 30px;
}

h1,
h2 {
  margin: 0;
}

h1 {
  letter-spacing: 0.03em;
  font-weight: 800;
}

.subtitle {
  margin-top: 8px;
  color: var(--muted);
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px;
  margin-top: 14px;
  backdrop-filter: blur(4px);
  box-shadow: 0 10px 28px rgba(4, 8, 16, 0.26);
}

label {
  display: block;
  font-size: 0.88rem;
  font-weight: 700;
  margin-top: 8px;
  color: #d1dbef;
}

input[type="text"],
input[type="number"],
input[type="file"] {
  width: 100%;
  margin-top: 6px;
  border: 1px solid #344665;
  background: #131a2b;
  color: var(--text);
  border-radius: 10px;
  padding: 9px 11px;
  font-size: 0.95rem;
}

input[type="text"] {
  text-transform: uppercase;
}

.row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.align-end {
  display: flex;
  align-items: end;
}

.actions,
.board-actions {
  margin-top: 12px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

button {
  background: linear-gradient(180deg, #2a4f84, #1c3a67);
  color: #f4f8ff;
  border: 1px solid #3a5f94;
  border-radius: 10px;
  padding: 9px 12px;
  font-size: 0.88rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.12s ease, filter 0.12s ease;
}

button:hover {
  transform: translateY(-1px);
  filter: brightness(1.08);
}

button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

.hint {
  margin: 8px 0;
  color: var(--muted);
  font-size: 0.86rem;
}

.board {
  margin-top: 10px;
  display: grid;
  grid-template-columns: repeat(15, 34px);
  gap: 2px;
  width: fit-content;
  max-width: 100%;
  overflow: auto;
  background: #101624;
  border: 1px solid #2d3a56;
  padding: 6px;
  border-radius: 12px;
}

.cell {
  position: relative;
  width: 34px;
  height: 34px;
  background: var(--normal);
  border: 1px solid #1b2436;
  border-radius: 6px;
}

.cell input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
  background: transparent;
  text-align: center;
  font-size: 0.95rem;
  font-weight: 800;
  text-transform: uppercase;
  color: #f6fbff;
  padding: 0;
}

.cell.filled input {
  background: var(--permanent-bg);
  color: #ffffff;
  font-size: 1.05rem;
}

.cell input:focus {
  outline: none;
}

.cell-bonus {
  position: absolute;
  right: 1px;
  bottom: 1px;
  font-size: 0.55rem;
  line-height: 1;
  padding: 1px 2px;
  border-radius: 3px;
  color: #f3f7ff;
  background: rgba(15, 22, 34, 0.58);
  border: 0;
  cursor: default;
  font-weight: 700;
}

.cell-bonus:disabled {
  opacity: 1;
}

.cell.filled .cell-bonus {
  display: none;
}

.cell.normal { background: var(--normal); }
.cell.dl { background: var(--dl); }
.cell.tl { background: var(--tl); }
.cell.dw { background: var(--dw); }
.cell.tw { background: var(--tw); }
.cell.st {
  background: var(--st);
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.25);
}

.cell.permanent-letter input {
  background: var(--permanent-bg);
  box-shadow: inset 0 0 0 1px var(--permanent-border);
}

.cell.permanent-letter {
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08);
}

.cell.manual-letter input {
  background: var(--manual-bg);
  color: #fff5dc;
  box-shadow: inset 0 0 0 2px var(--manual-border);
}

.cell.solver-letter input {
  background: var(--solver-bg);
  color: #eef9ff;
  box-shadow: inset 0 0 0 2px var(--solver-border);
}

.cell.manual-letter::before,
.cell.solver-letter::before {
  position: absolute;
  left: 3px;
  top: 2px;
  z-index: 3;
  font-size: 0.48rem;
  line-height: 1;
  font-weight: 900;
  border-radius: 999px;
  padding: 1px 3px;
  pointer-events: none;
}

.cell.manual-letter::before {
  content: "H";
  color: #fff1d5;
  background: rgba(59, 34, 7, 0.92);
}

.cell.solver-letter::before {
  content: "S";
  color: #eef8ff;
  background: rgba(7, 35, 59, 0.92);
}

#results,
#bestMoves {
  margin: 10px 0 0;
  padding-left: 20px;
}

#results li,
#bestMoves li {
  margin-bottom: 7px;
}

#bestMoves li {
  cursor: pointer;
  border-radius: 8px;
  padding: 4px 6px;
}

#bestMoves li:hover {
  background: rgba(67, 132, 212, 0.18);
}

#bestMoves li.active {
  background: rgba(97, 184, 255, 0.28);
  font-weight: 700;
}

#dictInfo,
#blacklistInfo,
#resultInfo,
#bestMoveInfo {
  color: var(--muted);
}

.cell.preview-existing input {
  background: var(--preview-existing-bg);
  color: #eff7ff;
  box-shadow: inset 0 0 0 2px rgba(163, 213, 255, 0.55);
}

.cell.preview-new input {
  background: var(--preview-new-bg);
  color: #f4fff7;
  box-shadow: inset 0 0 0 2px rgba(170, 255, 201, 0.62);
}

.cell.selected-cell {
  box-shadow: 0 0 0 2px rgba(255, 209, 102, 0.32), inset 0 0 0 1px rgba(255, 209, 102, 0.46);
  border-color: var(--focus-ring);
}

.cell.selected-cell::after {
  content: "";
  position: absolute;
  inset: 2px;
  border: 2px solid var(--focus-ring);
  border-radius: 4px;
  pointer-events: none;
}

.cell.selected-cell[data-direction="horizontal"]::before,
.cell.selected-cell[data-direction="vertical"]::before {
  content: "";
  position: absolute;
  pointer-events: none;
  z-index: 1;
  opacity: 0.92;
}

.cell.selected-cell[data-direction="horizontal"]::before {
  left: 6px;
  right: 6px;
  top: 50%;
  height: 2px;
  transform: translateY(-50%);
  background: linear-gradient(90deg, transparent, var(--focus-ring) 14%, var(--focus-ring) 86%, transparent);
}

.cell.selected-cell[data-direction="vertical"]::before {
  top: 6px;
  bottom: 6px;
  left: 50%;
  width: 2px;
  transform: translateX(-50%);
  background: linear-gradient(180deg, transparent, var(--focus-ring) 14%, var(--focus-ring) 86%, transparent);
}

.cell.preview-new {
  box-shadow: inset 0 0 0 2px rgba(122, 255, 170, 0.9);
}

.cell.preview-existing {
  box-shadow: inset 0 0 0 2px rgba(122, 190, 255, 0.82);
}

.cell.preview-new::after,
.cell.preview-existing::after {
  content: "P";
  position: absolute;
  top: 2px;
  right: 3px;
  z-index: 3;
  font-size: 0.5rem;
  line-height: 1;
  font-weight: 900;
  color: #f8fcff;
  background: rgba(7, 11, 18, 0.82);
  border-radius: 999px;
  padding: 1px 3px;
}

.cell.preview-new::after {
  background: rgba(6, 41, 22, 0.92);
}

.cell.preview-existing::after {
  background: rgba(8, 31, 55, 0.92);
}

.cell.selected-word {
  box-shadow: inset 0 0 0 2px #ffe58a;
}

@media (max-width: 760px) {
  .container {
    padding: 12px 8px 24px;
  }

  .row {
    grid-template-columns: 1fr;
  }

  .board {
    grid-template-columns: repeat(15, 24px);
    padding: 4px;
  }

  .cell {
    width: 24px;
    height: 24px;
    border-radius: 4px;
  }

  .cell input {
    font-size: 0.72rem;
  }

  .cell.filled input {
    font-size: 0.8rem;
  }

  .cell-bonus {
    font-size: 0.38rem;
    padding: 1px;
  }
}
