:root {
  --bg: #f4f1ea;
  --ink: #1d2433;
  --muted: #5d6578;
  --card: #ffffff;
  --line: #e2ddd1;
  --accent: #e4572e;
  --accent-ink: #ffffff;
  --navy: #14213d;
  --hot: #d7263d;
  --warm: #f08a24;
  --mild: #f2c14e;
  --cool: #7aa6c2;
  --cold: #4a6fa5;
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.5;
  min-height: 100vh;
  padding-bottom: 90px; /* keeps the bottom-right corner free for the CLAILA badge */
}

.wrap {
  max-width: 680px;
  margin: 0 auto;
  padding: 24px 16px 0;
}

.top { text-align: center; margin-bottom: 20px; }

h1 {
  margin: 0 0 6px;
  font-size: clamp(2rem, 6vw, 2.6rem);
  letter-spacing: -0.02em;
  color: var(--navy);
}

.lead { margin: 0 auto 8px; max-width: 520px; color: var(--muted); }

.meta { margin: 0; font-size: 0.9rem; color: var(--muted); }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 18px;
  margin-bottom: 16px;
  box-shadow: 0 1px 2px rgba(20, 33, 61, 0.05);
}

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0);
  white-space: nowrap; border: 0;
}

.guess-form { display: flex; gap: 8px; }

.guess-form input {
  flex: 1;
  min-width: 0;
  font: inherit;
  font-size: 1.05rem;
  padding: 12px 14px;
  border: 1.5px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: var(--ink);
}

.guess-form input:focus {
  outline: 3px solid rgba(228, 87, 46, 0.35);
  border-color: var(--accent);
}

button {
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  border: 0;
  border-radius: 10px;
  padding: 12px 18px;
  background: var(--accent);
  color: var(--accent-ink);
}

button:hover { filter: brightness(1.05); }
button:disabled { opacity: 0.6; cursor: wait; }
button:focus-visible { outline: 3px solid rgba(20, 33, 61, 0.4); outline-offset: 2px; }

button.ghost {
  background: transparent;
  color: var(--navy);
  border: 1.5px solid var(--navy);
}

.message {
  min-height: 1.5em;
  margin: 10px 0 0;
  font-size: 0.95rem;
}
.message.error { color: var(--hot); }

.win {
  margin-top: 12px;
  padding: 14px;
  border-radius: 10px;
  background: #fff4e6;
  border: 1px solid #f5d3a8;
}
.win[hidden] { display: none; }
.win-title { margin: 0 0 6px; font-size: 1.05rem; }
.win p { margin: 0 0 10px; }

.list-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

h2 { margin: 0; font-size: 1.15rem; color: var(--navy); }

.count { font-size: 0.9rem; color: var(--muted); }

.hint { margin: 6px 0 12px; font-size: 0.88rem; color: var(--muted); }

.guesses {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.guesses li {
  display: grid;
  grid-template-columns: 1fr;
  gap: 4px 12px;
  align-items: center;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #fbfaf7;
}

.guesses li.new { animation: flash 0.9s ease-out; }
@keyframes flash { from { background: #ffe3c2; } to { background: #fbfaf7; } }

.g-word { font-weight: 600; font-size: 1.02rem; }
.g-rank { font-size: 0.85rem; color: var(--muted); text-align: right; }
.g-bar {
  grid-column: 1 / -1;
  height: 8px;
  border-radius: 999px;
  background: #e9e5da;
  overflow: hidden;
}
.g-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--cold), var(--cool), var(--mild), var(--warm), var(--hot));
}
.g-heat { grid-column: 1 / -1; font-size: 0.85rem; color: var(--muted); }
.g-heat strong { color: var(--ink); }

.how ul { margin: 8px 0 0; padding-left: 20px; color: var(--muted); }
.how li { margin-bottom: 6px; }

.foot {
  text-align: center;
  font-size: 0.85rem;
  color: var(--muted);
  padding: 8px 16px 24px;
}
.foot p { margin: 0; }

@media (max-width: 480px) {
  .guess-form { flex-direction: column; }
  .guess-form button { width: 100%; }
}

.confetti {
  position: fixed; left: 50%; top: 40%;
  width: 0; height: 0;
  pointer-events: none; z-index: 50;
}
.confetti i {
  position: absolute; left: 0; top: 0;
  width: 9px; height: 14px;
  opacity: 0;
  animation: pop 2s cubic-bezier(.15,.7,.3,1) forwards;
}
@keyframes pop {
  0%   { opacity: 1; transform: translate(0, 0) rotate(0); }
  45%  { opacity: 1; transform: translate(var(--x), var(--y)) rotate(var(--r)); }
  100% { opacity: 0; transform: translate(var(--x), calc(var(--y) + var(--fall))) rotate(calc(var(--r) * 2)); }
}

button.small { padding: 6px 12px; font-size: 0.85rem; margin: 4px 0 8px; }
button.reset { display: block; margin: 14px auto 0; }

@media (max-width: 600px) {
  .wrap { padding: 10px 10px 0; }
  .top { margin-bottom: 10px; }
  h1 { font-size: 1.6rem; margin: 0; }
  .lead { display: none; }
  .meta { font-size: 0.8rem; }
  .card { padding: 12px; margin-bottom: 10px; border-radius: 12px; }
  .guess-form { flex-direction: row; }
  .guess-form button { width: auto; padding: 10px 14px; }
  .guess-form input { padding: 10px 12px; }
  .message { min-height: 1.2em; margin-top: 6px; font-size: 0.88rem; }
  .hint { display: none; }
  .list-head { margin-bottom: 8px; }
  .guesses { gap: 4px; }
  .guesses li {
    grid-template-columns: 1fr auto;
    gap: 2px 8px;
    padding: 6px 10px;
  }
  .g-word { font-size: 0.95rem; }
  .g-heat { grid-column: 2; grid-row: 1; text-align: right; font-size: 0.8rem; }
  .g-bar { grid-row: 2; height: 5px; }
}
