:root {
  --navy: #000050;
  --blue: #123d82;
  --gold: #f3c85b;
  --cream: #fffaf0;
  --ink: #172033;
  --green: #247a47;
  --red: #a52b2b;
  --line: #d9dfeb;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: linear-gradient(145deg, var(--navy), #173b78);
  font-family: Arial, Helvetica, sans-serif;
}

button { font: inherit; }

.game-shell {
  width: min(100% - 2rem, 980px);
  margin: 0 auto;
  padding: 2rem 0;
}

.game-header {
  color: white;
  text-align: center;
  margin-bottom: 1.25rem;
}

.game-header h1 {
  margin: .15rem 0 .5rem;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(2rem, 5vw, 3.4rem);
}

.game-header p { margin: .3rem auto; max-width: 700px; }
.eyebrow { color: var(--gold); font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }

.panel {
  background: var(--cream);
  border: 4px solid var(--gold);
  border-radius: 18px;
  padding: clamp(1rem, 3vw, 2rem);
  box-shadow: 0 14px 36px rgb(0 0 0 / .28);
}

.panel h2 { text-align: center; color: var(--navy); }

.category-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: .6rem;
  margin: 1rem 0;
}

.category-button {
  min-height: 64px;
  padding: .55rem .45rem;
  border: 2px solid var(--blue);
  border-radius: 9px;
  color: var(--navy);
  background: white;
  cursor: pointer;
  font-weight: 700;
  font-size: .94rem;
  line-height: 1.12;
  box-shadow: 0 3px 0 var(--blue);
}

.category-button:hover, .category-button:focus-visible {
  color: white;
  background: var(--blue);
  transform: translateY(-1px);
}

.category-button small {
  display: block;
  margin-top: .25rem;
  font-size: .72rem;
  font-weight: 400;
  line-height: 1.08;
}

.status-row {
  display: flex;
  justify-content: space-between;
  gap: .75rem;
  flex-wrap: wrap;
  padding-bottom: .8rem;
  border-bottom: 1px solid var(--line);
  font-weight: 700;
}

.clue-card {
  max-width: 700px;
  margin: 1.2rem auto;
  padding: .8rem 1.2rem;
  text-align: center;
  border-radius: 12px;
  background: #eef4ff;
}

.label { margin: 0; color: var(--blue); font-size: .78rem; font-weight: 700; text-transform: uppercase; }
.clue { margin: .35rem 0; font-size: clamp(1.1rem, 3vw, 1.4rem); }

.lamps {
  display: flex;
  justify-content: center;
  gap: .7rem;
  margin: 1rem 0;
}

.lamp {
  width: 34px;
  height: 34px;
  border: 2px solid #82661b;
  border-radius: 50% 50% 42% 42%;
  background: var(--gold);
  box-shadow: 0 0 13px #ffd760;
}

.lamp.off { background: #c7c7c7; border-color: #777; box-shadow: none; }

.word-display {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: .45rem;
  min-height: 70px;
  margin: 1rem auto;
}

.letter-slot {
  display: grid;
  place-items: center;
  width: clamp(26px, 6vw, 42px);
  height: 52px;
  border-bottom: 3px solid var(--ink);
  font-size: clamp(1.35rem, 4vw, 2rem);
  font-weight: 700;
}

.letter-slot.space { width: 20px; border: 0; }
.letter-slot.punctuation { border: 0; }
.used-letters { min-height: 1.3rem; text-align: center; color: var(--red); font-weight: 700; }

.keyboard {
  display: grid;
  grid-template-columns: repeat(13, 1fr);
  gap: .4rem;
  max-width: 800px;
  margin: 1.2rem auto;
}

.key {
  min-height: 42px;
  border: 0;
  border-radius: 7px;
  color: white;
  background: var(--blue);
  cursor: pointer;
  font-weight: 700;
}

.key:hover:not(:disabled), .key:focus-visible:not(:disabled) { background: var(--navy); }
.key:disabled { color: #6d7480; background: #d5d9df; cursor: default; }

.feedback {
  margin: 1.2rem auto 0;
  padding: 1rem;
  text-align: center;
  border: 2px solid var(--line);
  border-radius: 12px;
  background: white;
}

.feedback.correct { border-color: var(--green); }
.feedback.incorrect { border-color: var(--red); }
.feedback h2 { margin: 0 0 .5rem; }
.reference { font-weight: 700; color: var(--blue); }
.game-actions { margin-top: 1rem; text-align: center; }

.primary-button, .secondary-button, .text-button {
  padding: .7rem 1.1rem;
  border-radius: 8px;
  cursor: pointer;
}

.primary-button { border: 2px solid var(--navy); color: white; background: var(--navy); font-weight: 700; }
.secondary-button { border: 2px solid var(--navy); color: var(--navy); background: white; font-weight: 700; }
.text-button { border: 0; color: var(--blue); background: transparent; text-decoration: underline; }
.results { text-align: center; }
.final-score { margin: 1rem 0; color: var(--navy); font-size: clamp(1.6rem, 5vw, 2.5rem); font-weight: 700; }
.result-actions { display: flex; justify-content: center; flex-wrap: wrap; gap: .8rem; }

dialog {
  width: min(90%, 560px);
  border: 4px solid var(--gold);
  border-radius: 14px;
  color: var(--ink);
}

dialog::backdrop { background: rgb(0 0 40 / .72); }
dialog li { margin-bottom: .55rem; }

@media (max-width: 700px) {
  .category-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .category-button { min-height: 60px; }
  .keyboard { grid-template-columns: repeat(7, 1fr); }
}

@media (min-width: 701px) and (max-width: 900px) {
  .category-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; transition: none !important; }
}
