:root {
  --bg: #171c2c;
  --panel: #222a3f;
  --tile: #2f3953;
  --tile-border: #4f6188;
  --correct: #e2572f;
  --present: #ffd86b;
  --text: #f7faff;
  --muted: #b4c1de;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Trebuchet MS", "Verdana", sans-serif;
  background: radial-gradient(circle at 15% 10%, #35486d 0%, var(--bg) 52%, #101520 100%);
  color: var(--text);
  display: grid;
  place-items: center;
  padding: 16px;
}

.app {
  width: min(560px, 100%);
  background: linear-gradient(180deg, #263251 0%, var(--panel) 100%);
  border: 1px solid #556899;
  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;
}

.tab-button {
  color: #d9e4ff;
  font-weight: 700;
  border: 1px solid #556899;
  border-radius: 999px;
  padding: 4px 10px;
  background: transparent;
}

.tab-button.active {
  color: #1f2333;
  background: #ffb86f;
  border-color: #ffb86f;
}

.tab-button:hover {
  background: rgba(255, 184, 111, 0.16);
}

.tab-panel.hidden {
  display: none;
}

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

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

.cta-play {
  width: 100%;
  margin: 0 0 16px;
  padding: 16px 18px;
  font-size: 1.2rem;
  font-weight: 800;
  letter-spacing: 0.02em;
  border-radius: 12px;
  background: linear-gradient(180deg, #ffcf78 0%, #ffb455 100%);
  color: #2a1600;
  box-shadow: 0 10px 20px rgba(0, 0, 0, 0.26);
}

.cta-play:hover {
  filter: brightness(1.04);
}

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

.active-toggle {
  outline: 2px solid #ffb86f;
  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, calc(48vw / var(--wlen, 5)), 4.4rem);
  line-height: 1;
  font-weight: 700;
  text-transform: uppercase;
  position: relative;
  overflow: hidden;
}

.tile.guide span {
  color: #ffffff;
  opacity: 0.95;
}

.tile.thrown {
  opacity: 0.58;
}

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

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

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

.tile.checking {
  border-color: #f7c91f;
  box-shadow: 0 0 0 3px rgba(247, 201, 31, 0.35);
  animation: checking-pulse 0.42s ease-in-out;
}

@keyframes checking-pulse {
  0%   { transform: scale(1);    opacity: 1; }
  30%  { transform: scale(1.08); opacity: 0.85; }
  100% { transform: scale(1);    opacity: 1; }
}

.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: #ffb86f;
  color: #2c1a00;
  font-weight: 700;
  padding: 10px 14px;
  cursor: pointer;
}

button.secondary {
  background: #e8f0ff;
  color: #1e2a44;
}

.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;
  }

  .cta-play {
    padding: 14px 16px;
    font-size: 1.08rem;
  }

  .row {
    gap: 5px;
  }

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