:root {
  --bg: #102a5c;
  --panel: #0c2047;
  --tile: #153668;
  --tile-border: #24528f;
  --correct: #d92926;
  --present: #f3c623;
  --text: #f8fbff;
  --muted: #b7c7e6;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Trebuchet MS", "Verdana", sans-serif;
  background: radial-gradient(circle at top, #1d478f 0%, var(--bg) 55%, #081733 100%);
  color: var(--text);
  display: grid;
  place-items: center;
  padding: 16px;
}

.app {
  width: min(560px, 100%);
  background: linear-gradient(180deg, #123067 0%, var(--panel) 100%);
  border: 1px solid #2f61ad;
  border-radius: 16px;
  padding: 20px;
  box-shadow: 0 20px 44px rgba(0, 0, 0, 0.34);
}

h1 {
  margin: 0 0 8px;
  font-size: clamp(1.5rem, 2.6vw, 2rem);
}

.top-nav {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
}

.top-nav a {
  color: #d7e6ff;
  text-decoration: none;
  font-weight: 700;
  border: 1px solid #2f61ad;
  border-radius: 999px;
  padding: 4px 10px;
}

.top-nav a.active {
  color: #1a1a1a;
  background: #f7c91f;
  border-color: #f7c91f;
}

.top-nav a:hover {
  text-decoration: underline;
}

.hint {
  margin: 0 0 18px;
  color: var(--muted);
}

.hint-inline {
  color: var(--muted);
  font-size: 0.95rem;
}

.length-toggle {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 12px;
}

.active-toggle {
  outline: 2px solid #f7c91f;
  outline-offset: 1px;
}

.board {
  display: grid;
  gap: 8px;
}

.row {
  display: grid;
  gap: 8px;
}

.tile {
  aspect-ratio: 1 / 1;
  border-radius: 8px;
  border: 2px solid var(--tile-border);
  background: var(--tile);
  display: grid;
  place-items: center;
  font-size: clamp(1rem, 2.5vw, 1.35rem);
  font-weight: 700;
  text-transform: uppercase;
  position: relative;
}

.tile.correct {
  background: var(--correct);
  border-color: #ff8886;
}

.tile.present::before {
  content: "";
  position: absolute;
  width: 70%;
  height: 70%;
  border-radius: 999px;
  background: var(--present);
}

.tile.present span {
  position: relative;
  z-index: 1;
  color: #402c02;
}

.tile.fixed {
  border-color: #ff8886;
}

.tile.fixed span {
  opacity: 0.95;
}

form {
  display: flex;
  gap: 10px;
  margin-top: 16px;
}

input {
  flex: 1;
  border-radius: 8px;
  border: 1px solid #3f71bc;
  background: #091833;
  color: var(--text);
  padding: 10px 12px;
  font-size: 1rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

button {
  border: none;
  border-radius: 8px;
  background: #f7c91f;
  color: #352500;
  font-weight: 700;
  padding: 10px 14px;
  cursor: pointer;
}

button.secondary {
  background: #f0f5ff;
  color: #102449;
}

.actions {
  margin-top: 10px;
}

.status {
  margin-top: 14px;
  min-height: 24px;
  color: #ffeaa9;
}

.helper-form {
  display: grid;
  gap: 10px;
}

.helper-row {
  margin: 8px 0 4px;
}

.helper-tile {
  padding: 0;
  overflow: hidden;
  cursor: text;
}

.helper-tile.active {
  border-color: #f7c91f;
  box-shadow: 0 0 0 2px rgba(247, 201, 31, 0.3);
}

.helper-tile input {
  width: 100%;
  height: 100%;
  border: none;
  margin: 0;
  background: transparent;
  text-align: center;
  font: inherit;
  color: inherit;
  padding: 0;
  position: relative;
  z-index: 1;
}

.helper-tile input:focus {
  outline: none;
}

.helper-tile.present input {
  color: #402c02;
}

.helper-actions {
  display: flex;
  gap: 10px;
}

.helper-form label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 0.95rem;
}

.results {
  margin-top: 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.result-chip {
  background: #143361;
  border: 1px solid #2f61ad;
  border-radius: 999px;
  padding: 6px 10px;
  font-weight: 700;
}

@media (max-width: 520px) {
  .app {
    padding: 14px;
  }

  .row {
    gap: 5px;
  }

  .tile {
    border-width: 1px;
  }
}
