:root {
  --navy: #0b165d;
  --navy-deep: #0a1248;
  --yellow: #ffc72f;
  --ink: #14182b;
  --muted: #4a5168;
  --paper: #f4f6fb;
  --sky: #d9e4f7;
  --white: #ffffff;
  --absent: #6b7280;
  --present: #c9850a;
  --correct: #1f7a3f;
  --system: #2a3f9e;
  --radius: 0.85rem;
  --font: Montserrat, system-ui, -apple-system, "Segoe UI", sans-serif;
  --shadow: 0 12px 32px rgba(11, 22, 93, 0.12);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100dvh;
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(120% 80% at 100% 0%, rgba(255, 199, 47, 0.16), transparent 50%),
    linear-gradient(180deg, #eef2fb 0%, var(--paper) 40%, #e8edf8 100%);
}

.rw-shell {
  width: min(100% - 1.25rem, 28rem);
  margin: 0 auto;
  padding: 1.1rem 0 2.5rem;
}

.rw-hero {
  background: linear-gradient(165deg, var(--navy) 0%, #13207a 55%, var(--navy-deep) 100%);
  color: var(--white);
  border-radius: var(--radius);
  padding: 1.15rem 1.15rem 1.25rem;
  box-shadow: var(--shadow);
  margin-bottom: 0.9rem;
}

.rw-kicker {
  margin: 0 0 0.35rem;
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--yellow);
}

.rw-title {
  margin: 0 0 0.45rem;
  font-size: clamp(1.35rem, 5.5vw, 1.7rem);
  font-weight: 800;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  line-height: 1.15;
}

.rw-blurb {
  margin: 0;
  font-size: 0.92rem;
  line-height: 1.45;
  color: rgba(255, 255, 255, 0.9);
}

.rw-card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 1rem 1rem 1.15rem;
  box-shadow: var(--shadow);
  border: 1px solid rgba(11, 22, 93, 0.06);
}

.rw-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 0.65rem;
  align-items: center;
  margin-bottom: 0.85rem;
}

.rw-badge,
.rw-chip {
  display: inline-flex;
  align-items: center;
  min-height: 1.6rem;
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.rw-badge {
  background: var(--yellow);
  color: var(--navy);
}

.rw-chip {
  background: var(--sky);
  color: var(--navy);
}

.rw-chip--muted {
  background: #eef1f7;
  color: var(--muted);
  font-weight: 700;
  text-transform: none;
  letter-spacing: 0;
}

.rw-clue-label {
  margin: 0 0 0.25rem;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--navy);
}

.rw-clue {
  margin: 0 0 1rem;
  font-size: 1.05rem;
  font-weight: 700;
  line-height: 1.4;
  color: var(--ink);
}

.rw-grid {
  --cell-count: 8;
  display: grid;
  grid-template-columns: repeat(var(--cell-count), minmax(0, 1fr));
  gap: 0.28rem;
  margin: 0 0 1rem;
}

.rw-cell {
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 0.4rem;
  font-weight: 800;
  font-size: clamp(0.7rem, 3.6vw, 1.05rem);
  border: 2px solid var(--sky);
  background: #f8fafc;
  color: var(--navy);
  text-transform: uppercase;
}

.rw-cell--empty {
  border-style: dashed;
  color: transparent;
}

.rw-cell--locked {
  border-color: var(--correct);
  background: #e8f6ec;
  color: var(--correct);
  box-shadow: inset 0 -3px 0 rgba(31, 122, 63, 0.35);
}

.rw-cell--system {
  border-color: var(--system);
  border-style: double;
  background: #e8ecfb;
  color: var(--system);
}

.rw-cell--flash {
  animation: rw-flash 0.55s ease;
}

@keyframes rw-flash {
  0% {
    transform: scale(1);
  }
  40% {
    transform: scale(1.08);
  }
  100% {
    transform: scale(1);
  }
}

@media (prefers-reduced-motion: reduce) {
  .rw-cell--flash {
    animation: none;
  }
}

.rw-history {
  margin: 0 0 1rem;
}

.rw-history__label {
  margin: 0 0 0.4rem;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.rw-history__list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.rw-history__row {
  display: grid;
  grid-template-columns: repeat(var(--cell-count, 8), minmax(0, 1fr));
  gap: 0.22rem;
}

.rw-tile {
  position: relative;
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 0.35rem;
  font-weight: 800;
  font-size: clamp(0.65rem, 3.2vw, 0.95rem);
  text-transform: uppercase;
  border: 2px solid transparent;
}

.rw-tile__mark {
  position: absolute;
  right: 1px;
  bottom: 0;
  font-size: 0.55rem;
  line-height: 1;
  font-weight: 800;
}

.rw-tile--correct {
  background: #d9f0e1;
  color: var(--correct);
  border-color: var(--correct);
  box-shadow: inset 0 -3px 0 rgba(31, 122, 63, 0.4);
}

.rw-tile--present {
  background: #fff3d6;
  color: #8a5a00;
  border-color: var(--present);
  border-style: dashed;
}

.rw-tile--absent {
  background: #eef0f3;
  color: var(--absent);
  border-color: #c5cad3;
  opacity: 0.92;
}

.rw-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  margin: 0 0 1rem;
  font-size: 0.72rem;
  color: var(--muted);
}

.rw-legend span {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
}

.rw-dot {
  width: 0.7rem;
  height: 0.7rem;
  border-radius: 0.2rem;
  border: 2px solid currentColor;
  display: inline-block;
}

.rw-dot--correct {
  background: #d9f0e1;
  color: var(--correct);
  box-shadow: inset 0 -2px 0 rgba(31, 122, 63, 0.4);
}
.rw-dot--present {
  background: #fff3d6;
  color: var(--present);
  border-style: dashed;
}
.rw-dot--absent {
  background: #eef0f3;
  color: #9aa1ad;
}
.rw-dot--system {
  background: #e8ecfb;
  color: var(--system);
  border-style: double;
}

.rw-form {
  display: flex;
  gap: 0.5rem;
  align-items: stretch;
}

.rw-input {
  flex: 1;
  min-width: 0;
  min-height: 3rem;
  padding: 0.65rem 0.8rem;
  border-radius: 0.65rem;
  border: 2px solid var(--sky);
  font: inherit;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--navy);
  background: #fbfcfe;
}

.rw-input:focus-visible {
  outline: 3px solid var(--navy);
  outline-offset: 2px;
}

.rw-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 3rem;
  padding: 0.65rem 1rem;
  border-radius: 999px;
  border: 2px solid transparent;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
  text-decoration: none;
  color: inherit;
}

.rw-btn:focus-visible {
  outline: 3px solid var(--navy);
  outline-offset: 2px;
}

.rw-btn--primary {
  background: var(--yellow);
  color: var(--navy);
  flex: 0 0 auto;
  min-width: 5.5rem;
}

.rw-btn--navy {
  background: var(--navy);
  color: var(--white);
  width: 100%;
}

.rw-btn--ghost {
  background: transparent;
  border-color: rgba(11, 22, 93, 0.2);
  color: var(--navy);
  min-height: 2.4rem;
  font-size: 0.82rem;
  padding: 0.4rem 0.75rem;
}

.rw-feedback {
  margin: 0.65rem 0 0;
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--navy);
}

.rw-feedback.is-error {
  color: #9b1c1c;
}

.rw-result {
  margin-top: 0.85rem;
  padding-top: 0.85rem;
  border-top: 1px solid var(--sky);
}

.rw-result__title {
  margin: 0 0 0.25rem;
  font-size: 1.15rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--navy);
}

.rw-result__answer {
  margin: 0 0 0.35rem;
  font-size: 1.55rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink);
}

.rw-result__score {
  margin: 0 0 0.85rem;
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--muted);
}

.rw-result__expl {
  margin: 0 0 0.85rem;
  font-size: 0.92rem;
  line-height: 1.5;
  color: var(--ink);
}

.rw-result__meta {
  margin: 0.55rem 0 0.85rem;
  font-size: 0.78rem;
  line-height: 1.4;
  color: var(--muted);
}

.rw-result__actions {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.rw-proto {
  margin-top: 1rem;
  padding: 0.75rem 0.85rem;
  border-radius: var(--radius);
  background: rgba(11, 22, 93, 0.04);
  border: 1px dashed rgba(11, 22, 93, 0.18);
}

.rw-proto__label {
  margin: 0 0 0.5rem;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--muted);
}

.rw-proto__row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.rw-foot {
  margin: 1rem 0 0;
  font-size: 0.75rem;
  line-height: 1.45;
  color: var(--muted);
  text-align: center;
}
