:root {
  --bg-primary: #0a0a0f;
  --bg-secondary: #14141f;
  --bg-tertiary: #1e1e2e;
  --text-primary: #ffffff;
  --text-secondary: #a0a0b0;
  --text-muted: #606070;
  --accent: #00d4ff;
  --accent-secondary: #00ff88;
  --danger: #ff4466;
  --focus-ring: #00d4ff;
  --focus-glow: rgba(0, 212, 255, 0.4);
  --radius-md: 12px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  width: 600px; height: 600px; overflow: hidden;
  background: #000;
  color: var(--text-primary);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

#app { width: 100%; height: 100%; position: relative; }

.screen {
  width: 100%; height: 100%;
  position: absolute; top: 0; left: 0;
  display: flex; flex-direction: column;
}
.screen.hidden { display: none; }

.focusable {
  transition: all 0.15s ease;
  border: 2px solid transparent;
  cursor: pointer; outline: none;
}
.focusable:focus {
  border-color: var(--focus-ring);
  box-shadow: 0 0 20px var(--focus-glow);
}

.hidden { display: none !important; }

button { font-family: inherit; }

/* ----- Home + Win ----- */
#home, #win {
  align-items: center;
  justify-content: center;
  gap: 18px;
  padding: 40px;
}

.title {
  font-size: 56px;
  font-weight: 800;
  letter-spacing: 4px;
  line-height: 1.0;
  text-align: center;
  text-shadow: 0 0 30px rgba(0, 212, 255, 0.35);
  color: #fff;
}
.subtitle {
  font-size: 17px;
  color: var(--text-secondary);
  margin-bottom: 8px;
  text-align: center;
  letter-spacing: 0.5px;
}

.btn {
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border-radius: var(--radius-md);
  padding: 0 36px;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 2px;
  min-height: 88px;
  min-width: 320px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid transparent;
}
.btn.primary {
  background: linear-gradient(135deg, #003344, #005577);
  color: var(--accent);
}

/* ----- Win ----- */
.win-title {
  font-size: 48px;
  font-weight: 800;
  color: var(--accent-secondary);
  letter-spacing: 4px;
  text-shadow: 0 0 30px rgba(0, 255, 136, 0.35);
}
.win-stats {
  font-size: 22px;
  color: var(--text-primary);
  font-weight: 600;
}
#winBest {
  font-size: 14px;
  color: var(--text-secondary);
  letter-spacing: 2px;
  margin-bottom: 6px;
  text-transform: uppercase;
  font-weight: 700;
}

/* ----- Game ----- */
#game {
  padding: 8px;
}
.game-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 16px;
  background: var(--bg-secondary);
  border-radius: var(--radius-md);
  height: 44px;
  flex-shrink: 0;
}
.game-title {
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 3px;
  color: var(--text-secondary);
}
.game-counter {
  font-size: 20px;
  color: var(--accent);
  font-weight: 800;
  letter-spacing: 2px;
}
.game-body {
  display: flex;
  gap: 6px;
  margin-top: 6px;
}

.grid-wrap {
  background: var(--bg-secondary);
  border-radius: var(--radius-md);
  padding: 4px;
  width: 457px;
  height: 457px;
  flex-shrink: 0;
}
.grid {
  display: grid;
  grid-template-columns: repeat(10, 44px);
  grid-template-rows: repeat(10, 44px);
  gap: 1px;
}
.cell {
  background: var(--bg-tertiary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  font-weight: 700;
  color: var(--text-primary);
  border-radius: 4px;
  border: 2px solid transparent;
  position: relative;
  transition: background 0.1s, color 0.1s, border-color 0.1s, box-shadow 0.1s;
}
.cell.selecting {
  background: #003d52;
  color: var(--accent);
}
.cell.anchor {
  background: #006080;
  color: #ffffff;
}
.cell.found {
  background: #003322;
  color: var(--accent-secondary);
}
.cell.cursor {
  border-color: var(--accent);
  box-shadow: 0 0 14px var(--focus-glow);
  z-index: 2;
}

.words-panel {
  background: var(--bg-secondary);
  border-radius: var(--radius-md);
  padding: 10px 6px;
  width: 121px;
  height: 457px;
  flex-shrink: 0;
  overflow: hidden;
}
.words-title {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 3px;
  text-align: center;
  margin-bottom: 8px;
  font-weight: 700;
}
#wordList {
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.word {
  font-size: 14px;
  font-weight: 700;
  text-align: center;
  padding: 6px 4px;
  background: var(--bg-tertiary);
  border-radius: 6px;
  letter-spacing: 1.5px;
  color: var(--text-primary);
}
.word.found {
  color: var(--accent-secondary);
  text-decoration: line-through;
  background: #001a14;
}

.game-footer {
  margin-top: 6px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  color: var(--text-secondary);
  background: var(--bg-secondary);
  border-radius: var(--radius-md);
  padding: 0 12px;
  text-align: center;
  letter-spacing: 0.5px;
}
.game-footer.error {
  color: var(--danger);
}
.game-footer.win {
  color: var(--accent-secondary);
}

/* ----- Help ----- */
#help {
  padding: 26px 30px;
  gap: 10px;
}
.help-title {
  font-size: 30px;
  font-weight: 800;
  letter-spacing: 3px;
  color: var(--accent);
  text-align: center;
}
.help-list {
  flex: 1;
  font-size: 15px;
  line-height: 1.55;
  color: var(--text-secondary);
  padding: 0 6px;
}
.help-list p {
  margin-bottom: 10px;
}
.help-list strong {
  color: var(--text-primary);
}
#help .btn {
  align-self: center;
  min-width: 260px;
  min-height: 72px;
}
