:root {
  --ink: #171717;
  --muted: #647084;
  --page: #eef3f9;
  --page-edge: #e6e7f0;
  --card: #ffffff;
  --line: #d7d4cf;
  --tile: #f8f8f8;
  --tile-border: #d8d8d8;
  --selected: #222222;
  --blue-accent: #273be0;

  /* Category colors only appear once a group is solved / in results. */
  --green-bg: #d9e8d7;
  --green-border: #7b9c76;
  --green-text: #254322;
  --yellow-bg: #f3e3ad;
  --yellow-border: #bd9a34;
  --yellow-text: #594500;
  --blue-bg: #dbe4ef;
  --blue-border: #617c9b;
  --blue-text: #233c58;
  --purple-bg: #eadce4;
  --purple-border: #9b6078;
  --purple-text: #552b3e;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
html { background: var(--page-edge); }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--page-edge);
  color: var(--ink);
  font-family: Inter, Arial, sans-serif;
}
button, dialog { font: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }

.shell {
  width: min(760px, calc(100% - 18px));
  min-height: calc(100vh - 18px);
  margin: 9px auto;
  padding: 42px 28px 70px;
  background: var(--page);
  border: 1px solid #d9dee7;
}
.screen { width: 100%; }
.card, .game-board {
  background: var(--card);
  border: 1px solid #dedede;
  border-radius: 28px;
  box-shadow: none;
}

.start-screen {
  text-align: center;
  padding: 58px 36px 44px;
}
.eyebrow {
  color: #586980;
  font-size: 12px;
  letter-spacing: .18em;
  font-weight: 800;
}
h1 {
  font-family: "Libre Franklin", Inter, sans-serif;
  font-size: clamp(34px, 7vw, 54px);
  line-height: 1;
  margin: 12px 0 8px;
  letter-spacing: -.055em;
}
.puzzle-meta {
  margin: 0 0 25px;
  color: #78849a;
  font-size: 14px;
  font-weight: 700;
}
.lede {
  max-width: 560px;
  margin: 0 auto 30px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 21px;
  line-height: 1.3;
}

.primary-button, .secondary-button {
  min-height: 46px;
  border-radius: 9px;
  padding: 10px 22px;
  font-weight: 600;
  font-size: 17px;
  transition: background .12s ease, color .12s ease, border-color .12s ease, transform .12s ease;
}
.primary-button {
  background: #111;
  color: #fff;
  border: 1.5px solid #111;
}
.primary-button:hover { background: #2a2a2a; }
.primary-button:disabled {
  background: #aaa;
  border-color: #aaa;
  color: #fff;
  cursor: not-allowed;
}
.start-button {
  width: min(100%, 520px);
  border-color: var(--blue-accent);
  box-shadow: inset 0 0 0 1px var(--blue-accent);
}
.secondary-button {
  background: #fff;
  color: var(--ink);
  border: 1.5px solid #b8b8b8;
}
.secondary-button:hover { background: #f4f4f4; }

.game-board {
  margin-top: 36px;
  padding: 28px 30px 24px;
}
.game-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
  border-bottom: 1px solid #cbc5bb;
  padding-bottom: 16px;
  margin-bottom: 28px;
}
.game-header h1 {
  margin: 0;
  font-size: clamp(30px, 5vw, 42px);
}
.text-button {
  border: 0;
  background: transparent;
  color: #596982;
  font-size: 13px;
  padding: 4px 0;
}
.selection-prompt {
  margin: 0 0 14px;
  text-align: center;
  color: #607089;
  font-size: 14px;
  font-weight: 600;
}

.solved-groups {
  display: grid;
  gap: 8px;
  margin-bottom: 12px;
}
.solved-group {
  border-radius: 11px;
  border: 1px solid;
  padding: 14px 12px;
  text-align: center;
  animation: solvedSettle .38s ease-out;
}
.solved-group h3 {
  margin: 0 0 5px;
  text-transform: uppercase;
  font-size: 13px;
  letter-spacing: .045em;
}
.solved-group p {
  margin: 0;
  font-size: 13px;
  line-height: 1.3;
  font-weight: 700;
}
.green { background: var(--green-bg); border-color: var(--green-border); color: var(--green-text); }
.yellow { background: var(--yellow-bg); border-color: var(--yellow-border); color: var(--yellow-text); }
.blue { background: var(--blue-bg); border-color: var(--blue-border); color: var(--blue-text); }
.purple { background: var(--purple-bg); border-color: var(--purple-border); color: var(--purple-text); }

.tile-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 7px;
}
.tile {
  min-height: 94px;
  border: 1px solid var(--tile-border);
  border-radius: 11px;
  background: var(--tile);
  color: var(--ink);
  padding: 8px 6px;
  box-shadow: none;
  font-family: "Barlow Semi Condensed", Inter, Arial, sans-serif;
  font-size: clamp(12px, 1.9vw, 14px);
  font-weight: 700;
  line-height: 1.05;
  letter-spacing: .005em;
  overflow-wrap: anywhere;
  word-break: normal;
  text-wrap: balance;
  text-transform: uppercase;
  transition: transform .12s ease, background .12s ease, color .12s ease, border-color .12s ease;
}
.tile:hover { background: #f1f1f1; }
.tile.selected {
  background: var(--selected);
  color: #fff;
  border-color: var(--selected);
}
.tile.solving { animation: lockBounce .35s ease; pointer-events: none; }
.tile.shake { animation: shake .35s; }

.status-bar {
  min-height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-top: 5px;
}
.mistakes-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
}
.mistakes { display: flex; gap: 7px; }
.mistake-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #202020;
}
.mistake-dot.used { background: #c7c7c7; }
.message {
  min-height: 22px;
  font-size: 14px;
  font-weight: 700;
  text-align: right;
}
.controls {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 9px;
  margin-top: 8px;
}
.reveal-controls { display: flex; justify-content: center; margin-top: 22px; }
.reveal-heading { text-align: center; margin: 4px 0 18px; }
.reveal-heading h2 { margin: 0 0 4px; font-size: 30px; }
.reveal-heading p { margin: 0; color: var(--muted); }

.end-screen {
  text-align: center;
  padding: 55px 32px;
}
.end-screen h1 { margin-bottom: 8px; }
.end-kicker {
  margin: 0;
  color: #6e7b8d;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 17px;
}
.share-grid {
  width: 180px;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  margin: 25px auto;
  grid-auto-rows: 40px;
}
.share-square { aspect-ratio: 1; border-radius: 5px; border: 1px solid rgba(0,0,0,.08); }
.end-actions { display: flex; justify-content: center; gap: 10px; flex-wrap: wrap; margin: 24px 0; }
.keep-playing {
  margin: 28px auto 0;
  text-align: center;
}
.keep-playing h2 {
  margin: 0 0 18px;
  color: #4f5874;
  font-size: 20px;
  font-weight: 800;
}
.game-promo {
  display: flex;
  align-items: center;
  gap: 22px;
  padding: 28px 36px;
  border: 1px solid #d7d7d7;
  border-radius: 26px;
  background: #fff;
  color: #171717;
  text-align: left;
  text-decoration: none;
  transition: transform .15s ease, box-shadow .15s ease;
}
.game-promo:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0,0,0,.06);
}
.game-promo-placeholder {
  display: grid;
  place-items: center;
  flex: 0 0 150px;
  height: 112px;
  background: #dff5fb;
  color: #61708a;
  font-size: 30px;
  font-weight: 800;
}
.game-promo-eyebrow {
  color: #315b9a;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .03em;
}
.game-promo-title {
  margin-top: 3px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 38px;
  line-height: 1;
}
.game-promo p {
  margin: 10px 0 0;
  font-size: 16px;
  line-height: 1.35;
}


dialog {
  width: min(440px, calc(100% - 32px));
  border: 1px solid #d7d7d7;
  border-radius: 18px;
  padding: 30px;
  background: #fff;
  box-shadow: 0 20px 55px rgba(0,0,0,.2);
}
dialog::backdrop { background: rgba(18,18,18,.5); }
.dialog-close { float: right; border: 0; background: none; font-size: 28px; }
.toast {
  position: fixed;
  left: 50%; bottom: 28px;
  transform: translateX(-50%);
  background: #171717; color: #fff;
  padding: 12px 18px; border-radius: 999px;
  font-weight: 700;
}

@keyframes shake {
  0%,100% { transform: translateX(0) }
  25% { transform: translateX(-6px) }
  75% { transform: translateX(6px) }
}
@keyframes lockBounce {
  0% { transform: scale(1); }
  50% { transform: scale(1.035); }
  100% { transform: scale(1); }
}
@keyframes solvedSettle {
  from { opacity: 0; transform: translateY(7px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (max-width: 600px) {
  .shell {
    width: 100%;
    margin: 0 auto;
    padding: 24px 5px 44px;
    border-left: 0;
    border-right: 0;
  }
  .start-screen { padding: 45px 20px 42px; }
  .eyebrow { font-size: 11px; }
  .start-screen h1 { font-size: 34px; }
  .lede { font-size: 19px; line-height: 1.27; }

  .game-board {
    margin-top: 18px;
    padding: 24px 12px 18px;
    border-radius: 20px;
  }
  .game-header { margin-bottom: 28px; padding-bottom: 15px; }
  .game-header h1 { font-size: 32px; }
  .text-button { font-size: 12px; }
  .tile-grid { gap: 5px; }
  .tile {
    min-width: 0;
    min-height: 79px;
    border-radius: 10px;
    padding: 6px 2px;
    font-size: 13.5px;
    line-height: 1;
  }
  .status-bar {
    align-items: flex-start;
    flex-direction: column;
    gap: 6px;
    margin-top: 7px;
  }
  .message { text-align: left; }
  .controls {
    grid-template-columns: 1fr;
    gap: 8px;
    margin-top: 16px;
  }
  .controls .primary-button,
  .controls .secondary-button { width: 100%; }
  #submit-button { order: 1; }
  #shuffle-button { order: 2; }
  #deselect-button { order: 3; }
  .solved-group { padding: 12px 8px; }
  .solved-group p { font-size: 12px; }
  .game-promo { padding: 20px; gap: 15px; border-radius: 20px; }
  .game-promo-placeholder { flex-basis: 105px; height: 88px; }
  .game-promo-title { font-size: 30px; }
  .game-promo p { font-size: 14px; }
}


/* End-screen cross-promotion card */
.keep-playing {
  width: 100%;
  margin: 30px auto 0;
  text-align: center;
}

.keep-playing h2 {
  margin: 0 0 20px;
  color: #4f5874;
  font-family: Inter, Arial, sans-serif;
  font-size: 22px;
  line-height: 1.1;
  font-weight: 800;
  letter-spacing: -.02em;
}

.game-promo,
.game-promo:link,
.game-promo:visited,
.game-promo:hover,
.game-promo:active {
  color: var(--ink);
  text-decoration: none;
}

.game-promo {
  width: 100%;
  min-height: 178px;
  display: grid;
  grid-template-columns: 190px minmax(0, 1fr);
  align-items: center;
  gap: 28px;
  padding: 28px 34px;
  background: #fff;
  border: 1px solid #d7d7d7;
  border-radius: 24px;
  text-align: left;
  box-shadow: none;
}

.game-promo:hover {
  transform: none;
  background: #fff;
  box-shadow: 0 5px 18px rgba(0,0,0,.045);
}

.game-promo-placeholder {
  width: 190px;
  height: 132px;
  display: grid;
  place-items: center;
  background: #dff5fb;
  color: #5c6f85;
  font-family: "Libre Franklin", Inter, sans-serif;
  font-size: 24px;
  font-weight: 800;
  letter-spacing: -.04em;
}

.game-promo-copy {
  min-width: 0;
}

.game-promo-eyebrow {
  margin: 0 0 5px;
  color: #315b9a;
  font-family: Inter, Arial, sans-serif;
  font-size: 13px;
  line-height: 1.15;
  font-weight: 600;
  letter-spacing: 0;
  text-transform: uppercase;
}

.game-promo-title {
  margin: 0;
  color: #111;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 42px;
  line-height: .98;
  font-weight: 400;
  letter-spacing: -.035em;
}

.game-promo p {
  max-width: 410px;
  margin: 12px 0 0;
  color: #171717;
  font-family: Inter, Arial, sans-serif;
  font-size: 17px;
  line-height: 1.35;
  font-weight: 500;
}

.game-promo-placeholder {
  overflow: hidden;
}
.game-promo-placeholder img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

@media (max-width: 600px) {
  .keep-playing { margin-top: 24px; }
  .keep-playing h2 { font-size: 20px; margin-bottom: 16px; }

  .game-promo {
    grid-template-columns: 112px minmax(0, 1fr);
    gap: 16px;
    min-height: 132px;
    padding: 18px;
    border-radius: 20px;
  }

  .game-promo-placeholder {
    width: 112px;
    height: 92px;
    font-size: 19px;
  }

  .game-promo-eyebrow { font-size: 10px; }
  .game-promo-title { font-size: 30px; }
  .game-promo p { margin-top: 8px; font-size: 13px; line-height: 1.3; }
}
