:root {
  --background: #f7f5f0;
  --surface: #ffffff;
  --surface-soft: #faf9f6;
  --text: #171717;
  --muted: #6b6b6b;
  --border: #dedbd3;

  --memoroji: #7c5cff;
  --memoroji-soft: #f1edff;
  --stitchle: #2f80ed;
  --stitchle-soft: #eef6ff;
  --nextup: #ef6c57;
  --nextup-soft: #fff1ed;

  --success: #198754;
  --success-soft: #e9f8ef;
  --warning: #c2410c;
  --warning-soft: #fff7ed;
  --warning-border: #fed7aa;
  --blue-soft: #f0f7ff;
  --blue-border: #dbeafe;
  --blue-text: #2563eb;

  --radius-large: 28px;
  --radius-medium: 18px;
  --radius-small: 14px;
  --radius-pill: 999px;

  --page-width: 1120px;
  --game-width: 800px;

  --shadow-card: 0 18px 45px rgba(20, 20, 20, 0.07);
  --shadow-hover: 0 22px 50px rgba(20, 20, 20, 0.1);
}

* {
  box-sizing: border-box;
}

html {
  font-family:
    Inter,
    ui-sans-serif,
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;

  color: var(--text);
  background: var(--background);
}

body {
  min-height: 100vh;
  margin: 0;
}

button,
textarea,
input {
  font: inherit;
}

button {
  color: inherit;
}

button:disabled {
  cursor: default;
  opacity: 0.55;
}

a {
  color: inherit;
}

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

.site-header,
.page,
.site-footer {
  width: min(var(--page-width), calc(100% - 40px));
  margin: 0 auto;
}

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 28px 0;
}

.logo {
  font-size: 1.8rem;
  font-weight: 850;
  letter-spacing: -0.06em;
  text-decoration: none;
}

.back-link {
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
  text-decoration: none;
}

.back-link:hover {
  color: var(--text);
}

.page {
  padding: 72px 0 90px;
}

.hero {
  max-width: 790px;
  margin-bottom: 56px;
}

.eyebrow,
.game-type {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: clamp(3rem, 8vw, 6rem);
  line-height: 0.95;
  letter-spacing: -0.07em;
}

.intro {
  max-width: 580px;
  margin: 26px 0 0;
  color: var(--muted);
  font-size: 1.15rem;
  line-height: 1.6;
}

.games {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 22px;
}

.game-card {
  display: flex;
  min-height: 390px;
  flex-direction: column;
  padding: 28px;
  border: 1px solid var(--border);
  border-radius: var(--radius-large);
  background: var(--surface);
  transition:
    transform 180ms ease,
    box-shadow 180ms ease;
}

.game-card:hover {
  transform: translateY(-5px);
  box-shadow: var(--shadow-hover);
}

.memoroji-card {
  border-top: 7px solid var(--memoroji);
}

.stitchle-card {
  border-top: 7px solid var(--stitchle);
}

.nextup-card {
  border-top: 7px solid var(--nextup);
}

.game-icon {
  margin-bottom: 42px;
  font-size: 2.4rem;
}

.game-content {
  flex: 1;
}

.game-card h2 {
  margin: 0 0 14px;
  font-size: 2.1rem;
  letter-spacing: -0.05em;
}

.game-card p {
  margin-top: 0;
  color: var(--muted);
  line-height: 1.55;
}

.game-link {
  display: inline-block;
  align-self: flex-start;
  padding: 11px 17px;
  border-radius: var(--radius-pill);
  background: var(--text);
  color: white;
  font-size: 0.9rem;
  font-weight: 750;
  text-decoration: none;
  transition:
    opacity 150ms ease,
    transform 150ms ease;
}

.game-link:hover {
  opacity: 0.85;
  transform: translateY(-1px);
}

.game-main {
  width: min(var(--game-width), calc(100% - 40px));
  margin: 0 auto;
  padding: 64px 0 90px;
}

.game-heading {
  margin-bottom: 36px;
}

.game-heading-centred {
  text-align: center;
}

.game-heading h1 {
  margin: 0 0 16px;
  font-size: clamp(3rem, 10vw, 5.5rem);
}

.game-heading > p:last-child {
  max-width: 620px;
  margin: 0 auto;
  color: var(--muted);
  font-size: 1.1rem;
  line-height: 1.6;
}

.game-shell {
  display: grid;
  min-height: 420px;
  place-items: center;
  padding: 32px;
  border: 1px solid var(--border);
  border-radius: var(--radius-large);
  background: var(--surface);
}

.memoroji-shell {
  border-top: 7px solid var(--memoroji);
}

.stitchle-shell {
  border-top: 7px solid var(--stitchle);
}

.nextup-shell {
  border-top: 7px solid var(--nextup);
}

.placeholder-label {
  color: var(--muted);
  font-weight: 700;
  text-align: center;
}

.game-theme {
  display: flex;
  width: fit-content;
  min-width: 220px;
  max-width: 100%;
  flex-direction: column;
  margin: 0 auto 22px;
  padding: 12px 20px;
  border: 1px solid var(--blue-border);
  border-radius: var(--radius-pill);
  background: var(--blue-soft);
  color: var(--blue-text);
  box-shadow: 0 2px 8px rgba(79, 142, 247, 0.08);
  font-weight: 750;
  text-align: center;
}

.game-theme-kicker {
  font-size: 0.7rem;
  letter-spacing: 0.1em;
  opacity: 0.72;
  text-transform: uppercase;
}

.game-theme-title {
  margin-top: 2px;
  font-size: 1rem;
}

.game-status {
  min-height: 24px;
  margin-bottom: 14px;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 650;
  text-align: center;
}

.game-message {
  margin-top: 18px;
  padding: 15px;
  border-radius: var(--radius-small);
  font-weight: 700;
  line-height: 1.55;
  text-align: center;
}

.storage-note {
  margin: 20px 0 0;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.5;
  text-align: center;
}

.copy-status {
  min-height: 20px;
  margin: 8px 0 0;
  color: var(--success);
  font-size: 0.85rem;
  font-weight: 700;
  text-align: center;
}

/* Memoroji */

.memoroji-box {
  position: relative;
  overflow: hidden;
  width: 100%;
  padding: 24px;
  border: 1px solid var(--border);
  border-top: 7px solid var(--memoroji);
  border-radius: var(--radius-large);
  background: var(--surface);
  box-shadow: var(--shadow-card);
}

.m-levels {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
}

.m-button {
  padding: 12px 19px;
  border: 1px solid var(--border);
  border-radius: var(--radius-small);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  font-weight: 750;
  transition:
    border-color 150ms ease,
    color 150ms ease,
    background 150ms ease,
    box-shadow 150ms ease,
    transform 150ms ease;
}

.m-button:hover {
  border-color: var(--memoroji);
  color: var(--memoroji);
  box-shadow: 0 5px 16px rgba(124, 92, 255, 0.13);
  transform: translateY(-1px);
}

.m-button:focus-visible,
.m-card:focus-visible {
  outline: 3px solid rgba(124, 92, 255, 0.32);
  outline-offset: 3px;
}

.m-level-button {
  min-width: 145px;
}

.m-level-button span {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 550;
}

.m-level-button.selected {
  border-color: var(--memoroji);
  background: var(--memoroji-soft);
  color: var(--memoroji);
}

.m-pause-wrap {
  display: flex;
  min-height: 48px;
  justify-content: center;
  margin: 12px 0 0;
}

.m-pause-button {
  align-self: center;
  padding: 9px 16px;
  border-radius: var(--radius-pill);
}

.m-timer {
  margin: 8px 0 12px;
  color: #374151;
  font-size: 1.1rem;
  font-weight: 750;
  text-align: center;
}

.m-grid {
  --size: 4;
  --emoji-size: 2.6rem;

  display: grid;
  width: 100%;
  grid-template-columns: repeat(var(--size), minmax(0, 1fr));
  gap: clamp(4px, 1vw, 10px);
  transition:
    opacity 150ms ease,
    filter 150ms ease;
}

.m-grid:empty {
  display: none;
}

.m-grid.m-hidden {
  pointer-events: none;
  filter: blur(12px);
  opacity: 0.16;
  user-select: none;
}

.m-card {
  display: grid;
  min-width: 0;
  aspect-ratio: 1;
  place-items: center;
  padding: 0;
  border: 1px solid #e5e7eb;
  border-radius: clamp(8px, 1.5vw, 15px);
  background: linear-gradient(145deg, #ffffff, #f3f1ff);
  color: var(--text);
  cursor: pointer;
  font-size: var(--emoji-size);
  line-height: 1;
  box-shadow: 0 3px 10px rgba(23, 23, 23, 0.05);
  transition:
    background 140ms ease,
    border-color 140ms ease,
    transform 140ms ease,
    box-shadow 140ms ease;
}

.m-card:hover {
  border-color: rgba(124, 92, 255, 0.55);
  box-shadow: 0 5px 16px rgba(124, 92, 255, 0.12);
  transform: translateY(-1px);
}

.m-card.flipped {
  border-color: var(--memoroji);
  background: var(--memoroji-soft);
}

.m-card.matched {
  border-color: #b7e4c7;
  background: var(--success-soft);
  cursor: default;
  animation: match-flash 300ms ease;
}

.m-card:disabled {
  opacity: 1;
}

.m-streak {
  border: 1px solid var(--blue-border);
  background: var(--blue-soft);
  color: var(--blue-text);
}

.m-result {
  border: 1px solid #b7e4c7;
  background: var(--success-soft);
  color: #17643a;
}

.m-share,
.s-share,
.n-share {
  margin-top: 18px;
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius-medium);
  background: var(--surface-soft);
}

.m-share > p:first-child,
.s-share > p:first-child,
.n-share > p:first-child {
  margin: 0;
  text-align: center;
}

.m-share textarea,
.s-share textarea,
.n-share textarea {
  width: 100%;
  min-height: 125px;
  margin: 12px 0;
  padding: 13px;
  border: 1px solid var(--border);
  border-radius: var(--radius-small);
  background: var(--surface);
  color: var(--text);
  line-height: 1.45;
  resize: none;
}

.m-share-actions,
.s-share-actions,
.n-share-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
}

/* Stitchle */

.stitchle-box {
  overflow: hidden;
  width: 100%;
  padding: 24px;
  border: 1px solid var(--border);
  border-top: 7px solid var(--stitchle);
  border-radius: var(--radius-large);
  background: var(--surface);
  box-shadow: var(--shadow-card);
}

.s-streak {
  margin: 0 0 16px;
  border: 1px solid var(--blue-border);
  background: var(--blue-soft);
  color: var(--blue-text);
}

.s-clue {
  margin: 12px 0;
  padding: 18px;
  border: 1px solid #e5e7eb;
  border-radius: var(--radius-medium);
  background: #f8fafc;
  color: #1f2937;
  font-size: clamp(1rem, 2.5vw, 1.2rem);
  font-weight: 750;
  line-height: 1.4;
  text-align: center;
}

.s-answer {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 28px 0 22px;
}

.s-answer-line {
  display: flex;
  width: 100%;
  justify-content: center;
  gap: 4px;
}

.s-char-input {
  width: var(--stitchle-cell-size, 42px);
  height: var(--stitchle-cell-size, 42px);
  min-width: 0;
  padding: 0;
  border: 2px solid #d1d5db;
  border-radius: 9px;
  background: var(--surface);
  color: var(--text);
  font-size: clamp(0.8rem, 3vw, 1.15rem);
  font-weight: 850;
  text-align: center;
  text-transform: uppercase;
  transition:
    transform 150ms ease,
    background 150ms ease,
    border-color 150ms ease,
    box-shadow 150ms ease;
}

.s-char-input:focus {
  outline: none;
  border-color: var(--stitchle);
  box-shadow: 0 0 0 3px rgba(47, 128, 237, 0.15);
}

.s-char-input.correct {
  border-color: #22c55e;
  background: var(--success-soft);
  color: #166534;
}

.s-char-input.flip {
  transform: rotateX(180deg);
}

.s-char-input:disabled {
  opacity: 1;
  -webkit-text-fill-color: #166534;
}

.s-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
}

.s-button {
  padding: 12px 19px;
  border: 1px solid var(--border);
  border-radius: var(--radius-small);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  font-weight: 750;
  transition:
    border-color 150ms ease,
    color 150ms ease,
    box-shadow 150ms ease,
    transform 150ms ease;
}

.s-button:not(:disabled):hover {
  border-color: var(--stitchle);
  color: var(--stitchle);
  box-shadow: 0 5px 16px rgba(47, 128, 237, 0.13);
  transform: translateY(-1px);
}

.s-button:focus-visible {
  outline: 3px solid rgba(47, 128, 237, 0.25);
  outline-offset: 3px;
}

.s-feedback {
  display: none;
  margin: 18px 0 0;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-small);
  background: #f8fafc;
  color: #1f2937;
  font-weight: 700;
  line-height: 1.5;
  text-align: center;
  white-space: pre-line;
}

.s-feedback:not(:empty) {
  display: block;
}

.s-feedback.correct {
  border-color: #b7e4c7;
  background: var(--success-soft);
  color: #166534;
}

.s-feedback.incorrect {
  border-color: var(--warning-border);
  background: var(--warning-soft);
  color: var(--warning);
}

/* Next Up */

.nextup-box {
  overflow: hidden;
  width: 100%;
  padding: 24px;
  border: 1px solid var(--border);
  border-top: 7px solid var(--nextup);
  border-radius: var(--radius-large);
  background: var(--surface);
  box-shadow: var(--shadow-card);
}

.n-streak {
  margin: 0 0 18px;
  border: 1px solid var(--blue-border);
  background: var(--blue-soft);
  color: var(--blue-text);
}

.n-sequence {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  margin: 24px 0;
}

.n-item {
  display: grid;
  min-width: 68px;
  min-height: 68px;
  place-items: center;
  padding: 12px;
  border: 1px solid #e5e7eb;
  border-radius: var(--radius-medium);
  background: #f8fafc;
  color: #1f2937;
  font-size: clamp(1.1rem, 4vw, 1.55rem);
  font-weight: 850;
  text-align: center;
  box-shadow: 0 3px 10px rgba(23, 23, 23, 0.04);
}

.n-mystery {
  border-color: rgba(239, 108, 87, 0.55);
  background: var(--nextup-soft);
  color: var(--nextup);
}

.n-answer {
  display: block;
  width: min(100%, 420px);
  margin: 0 auto 14px;
  padding: 15px 17px;
  border: 2px solid #d1d5db;
  border-radius: var(--radius-small);
  background: var(--surface);
  color: var(--text);
  font-size: 1rem;
  font-weight: 700;
  text-align: center;
}

.n-answer:focus {
  outline: none;
  border-color: var(--nextup);
  box-shadow: 0 0 0 3px rgba(239, 108, 87, 0.16);
}

.n-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
}

.n-button {
  padding: 12px 19px;
  border: 1px solid var(--border);
  border-radius: var(--radius-small);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  font-weight: 750;
  transition:
    border-color 150ms ease,
    color 150ms ease,
    box-shadow 150ms ease,
    transform 150ms ease;
}

.n-button:not(:disabled):hover {
  border-color: var(--nextup);
  color: var(--nextup);
  box-shadow: 0 5px 16px rgba(239, 108, 87, 0.14);
  transform: translateY(-1px);
}

.n-button:focus-visible {
  outline: 3px solid rgba(239, 108, 87, 0.25);
  outline-offset: 3px;
}

.n-feedback {
  display: none;
  margin: 18px 0 0;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-small);
  background: #f8fafc;
  color: #1f2937;
  font-weight: 700;
  line-height: 1.5;
  text-align: center;
  white-space: pre-line;
}

.n-feedback:not(:empty) {
  display: block;
}

.n-feedback.correct {
  border-color: #b7e4c7;
  background: var(--success-soft);
  color: #166534;
}

.n-feedback.incorrect {
  border-color: var(--warning-border);
  background: var(--warning-soft);
  color: var(--warning);
}

/* How to play */

.how-to-play {
  margin-top: 54px;
}

.how-to-play > h2 {
  margin: 0 0 24px;
  font-size: clamp(2rem, 6vw, 3.2rem);
  letter-spacing: -0.05em;
  text-align: center;
}

.how-to-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
}

.how-to-step {
  padding: 22px;
  border: 1px solid var(--border);
  border-radius: var(--radius-medium);
  background: rgba(255, 255, 255, 0.68);
}

.how-to-step:first-child {
  grid-column: 1 / -1;
}

.how-to-step h3 {
  margin: 0 0 12px;
  font-size: 1rem;
}

.how-to-step p {
  margin: 6px 0;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.55;
}

.site-footer {
  padding-bottom: 38px;
  color: var(--muted);
  font-size: 0.86rem;
}

@keyframes match-flash {
  0% {
    transform: scale(1);
  }

  50% {
    transform: scale(1.07);
  }

  100% {
    transform: scale(1);
  }
}

@keyframes shake {
  0%,
  100% {
    transform: translateX(0);
  }

  25% {
    transform: translateX(-5px);
  }

  75% {
    transform: translateX(5px);
  }
}

.m-card.shake {
  animation: shake 180ms ease 2;
}

@media (max-width: 820px) {
  .page {
    padding-top: 38px;
  }

  .games {
    grid-template-columns: 1fr;
  }

  .game-card {
    min-height: 300px;
  }
}

@media (max-width: 600px) {
  .site-header,
  .page,
  .site-footer,
  .game-main {
    width: min(100% - 28px, var(--page-width));
  }

  .game-main {
    padding-top: 34px;
  }

  .game-heading {
    margin-bottom: 28px;
  }

  .memoroji-box,
  .stitchle-box,
  .nextup-box {
    padding: 16px;
    border-radius: 22px;
  }

  .m-levels {
    display: grid;
    grid-template-columns: 1fr;
  }

  .m-level-button {
    width: 100%;
  }

  .m-grid {
    gap: 4px;
  }

  .m-card {
    border-radius: 8px;
  }

  .s-clue {
    padding: 14px;
  }

  .s-answer {
    margin-top: 22px;
  }

  .s-char-input {
    border-radius: 6px;
  }

  .n-sequence {
    gap: 7px;
  }

  .n-item {
    min-width: 54px;
    min-height: 54px;
    padding: 9px;
    border-radius: 12px;
  }

  .how-to-grid {
    grid-template-columns: 1fr;
  }

  .how-to-step:first-child {
    grid-column: auto;
  }
}