:root {
  --ink: #1b1516;
  --paper: #fffaf6;
  --panel: #fff;
  --rose: #b76e79;
  --rose-deep: #8f4654;
  --rose-light: #f5dedd;
  --gold: #b57a20;
  --line: #ead2d0;
  --shadow: 0 18px 45px rgba(45, 24, 27, 0.14);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  min-width: 320px;
  color: var(--ink);
  background: linear-gradient(180deg, #fff7f4, #fff 42%, #faece9);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
button, input { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }

.kids-header {
  color: #fff;
  background:
    radial-gradient(circle at 18% 24%, rgba(239, 208, 207, 0.3), transparent 22%),
    radial-gradient(circle at 84% 22%, rgba(181, 122, 32, 0.24), transparent 20%),
    linear-gradient(135deg, #080707, #321f22 58%, #8f4654);
}
.kids-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  width: min(1120px, calc(100% - 32px));
  margin: auto;
  padding: 18px 0;
}
.kids-brand { color: #efd0cf; font-weight: 900; text-decoration: none; }
.kids-nav-links { display: flex; gap: 10px; }
.kids-nav-links a {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  padding: 0 16px;
  border: 1px solid rgba(255,255,255,.44);
  border-radius: 999px;
  color: #fff;
  font-weight: 800;
  text-decoration: none;
}
.kids-intro { width: min(900px, calc(100% - 32px)); margin: auto; padding: 60px 0 72px; text-align: center; }
.kids-kicker, .game-label { margin: 0 0 8px; color: #efd0cf; font-size: .8rem; font-weight: 900; letter-spacing: .12em; text-transform: uppercase; }
.kids-intro h1 { margin: 0; font-family: Georgia, serif; font-size: clamp(3rem, 11vw, 6.5rem); line-height: .95; }
.kids-intro p:last-child { max-width: 650px; margin: 20px auto 0; font-size: clamp(1rem, 3vw, 1.25rem); line-height: 1.6; }

.game-shell { width: min(1120px, calc(100% - 24px)); margin: -34px auto 60px; position: relative; }
.game-tabs { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; max-width: 850px; margin: 0 auto 18px; padding: 8px; border-radius: 22px; background: #fff; box-shadow: var(--shadow); }
.game-tab { min-height: 52px; border: 0; border-radius: 15px; background: transparent; color: var(--rose-deep); font-weight: 900; cursor: pointer; }
.game-tab.is-active { background: linear-gradient(135deg, var(--rose), var(--rose-deep)); color: #fff; }
.game-panel { padding: clamp(18px, 4vw, 38px); border: 1px solid var(--line); border-radius: 24px; background: rgba(255,255,255,.96); box-shadow: var(--shadow); }
.game-panel[hidden] { display: none; }
.game-heading { display: flex; align-items: center; justify-content: space-between; gap: 18px; margin-bottom: 12px; }
.game-label { color: var(--rose-deep); }
.game-heading h2 { margin: 0; font-family: Georgia, serif; font-size: clamp(1.7rem, 4vw, 2.6rem); }
.small-button, .picture-button { min-height: 44px; padding: 0 16px; border: 1px solid rgba(143,70,84,.35); border-radius: 999px; background: #fff7f4; color: var(--rose-deep); font-weight: 900; cursor: pointer; }
.small-button:hover, .small-button:focus-visible, .picture-button:hover, .picture-button:focus-visible { background: var(--rose-light); }
.small-button:disabled { cursor: not-allowed; opacity: .48; }
.game-status, .game-help { margin: 8px 0 18px; color: #6e6263; font-weight: 750; }
.how-to-play { margin: 14px 0 22px; padding: 16px 20px; border: 1px solid #e7c7c4; border-radius: 17px; background: #fff7f4; color: #5f5153; }
.how-to-play h3 { margin: 0 0 8px; color: var(--rose-deep); font-family: Georgia, serif; font-size: 1.3rem; }
.how-to-play ol { margin: 0; padding-left: 24px; line-height: 1.65; }
.how-to-play p { margin: 8px 0 0; font-weight: 800; }

.memory-board { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; max-width: 760px; margin: auto; }
.memory-card { position: relative; aspect-ratio: 1 / .86; border: 0; border-radius: 16px; background: linear-gradient(145deg, var(--rose-deep), #2e1e21); color: #fff; cursor: pointer; box-shadow: 0 8px 18px rgba(48,25,29,.18); transform-style: preserve-3d; transition: transform .25s ease; }
.memory-card::before { content: "?"; font: 900 clamp(1.7rem, 6vw, 3rem)/1 Georgia, serif; }
.memory-card span { display: none; font-size: clamp(1.9rem, 7vw, 3.4rem); }
.memory-card.is-flipped, .memory-card.is-matched { background: #fff7f4; color: var(--ink); transform: rotateY(180deg); outline: 3px solid var(--rose-light); }
.memory-card.is-flipped::before, .memory-card.is-matched::before { display: none; }
.memory-card.is-flipped span, .memory-card.is-matched span { display: inline; transform: rotateY(180deg); }
.memory-card.is-matched { outline-color: #8ec9a7; }

.word-layout { display: grid; grid-template-columns: minmax(0, 1fr) 240px; gap: 28px; align-items: start; }
.word-grid { display: grid; grid-template-columns: repeat(11, minmax(26px, 1fr)); gap: 4px; width: min(100%, 680px); margin: auto; user-select: none; }
.word-cell { aspect-ratio: 1; border: 1px solid var(--line); border-radius: 7px; background: #fffaf7; color: var(--ink); font-weight: 900; cursor: pointer; }
.word-cell.is-start { background: var(--rose-light); outline: 2px solid var(--rose); }
.word-cell.is-found { background: #dff3e7; border-color: #6eaa87; color: #24593a; }
.word-list-wrap { padding: 18px; border-radius: 18px; background: #fff7f4; }
.word-list-wrap h3 { margin-top: 0; font-family: Georgia, serif; }
.word-list { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; padding: 0; list-style: none; }
.word-list li { padding: 7px 8px; border-radius: 8px; font-weight: 900; }
.word-list li.is-found { color: #377052; background: #dff3e7; text-decoration: line-through; }

.tic-options { display: flex; justify-content: center; gap: 10px; margin: 18px 0; }
.tic-options .is-active { background: var(--rose-deep); color: #fff; }
.tic-board { display: grid; grid-template-columns: repeat(3, 1fr); gap: 9px; width: min(100%, 430px); margin: 18px auto; padding: 10px; border-radius: 22px; background: #f3dbd8; }
.tic-cell { aspect-ratio: 1; border: 0; border-radius: 16px; background: #fff; color: var(--rose-deep); font-size: clamp(2.6rem, 12vw, 5rem); font-weight: 900; cursor: pointer; box-shadow: 0 4px 10px rgba(66,31,37,.1); }
.tic-cell[data-mark="ring"] { color: var(--gold); }
.tic-cell.is-winning { background: #dff3e7; outline: 3px solid #6eaa87; }

.difference-layout { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.difference-picture { position: relative; overflow: hidden; border: 2px solid var(--line); border-radius: 20px; background: #fffaf6; }
.difference-picture svg { display: block; width: 100%; height: auto; }
.difference-picture-label { position: absolute; top: 10px; left: 12px; z-index: 2; padding: 5px 10px; border-radius: 999px; background: rgba(255,255,255,.9); color: var(--rose-deep); font-weight: 900; }
.difference-hit { position: absolute; width: 14%; aspect-ratio: 1; translate: -50% -50%; border: 0; border-radius: 50%; background: transparent; cursor: pointer; }
.difference-hit.is-found { border: 4px solid #42a36c; background: rgba(154,231,183,.2); }
.difference-hit.is-found::after { content: "✓"; position: absolute; right: -6px; top: -10px; display: grid; place-items: center; width: 25px; height: 25px; border-radius: 50%; background: #42a36c; color: #fff; font-weight: 900; }

.coloring-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin: 20px 0; }
.picture-buttons { display: flex; flex-wrap: wrap; gap: 8px; }
.picture-button.is-active { background: var(--rose-deep); color: #fff; }
.color-mode-buttons { display: flex; flex-wrap: wrap; gap: 8px; }
.color-mode-buttons .is-active { background: var(--rose-deep); color: #fff; }
.coloring-help { margin: -8px 0 14px; color: var(--muted); font-weight: 750; }
.palette { display: flex; flex-wrap: wrap; gap: 7px; }
.color-swatch { width: 42px; height: 42px; border: 3px solid #fff; border-radius: 50%; box-shadow: 0 0 0 1px #bda7a8; cursor: pointer; }
.color-swatch.is-active { box-shadow: 0 0 0 3px var(--ink); }
.brush-control { display: inline-flex; align-items: center; gap: 8px; font-weight: 800; }
.canvas-wrap { overflow: hidden; max-width: 900px; margin: auto; border: 2px solid var(--line); border-radius: 18px; background: #fff; touch-action: none; }
#coloringCanvas { display: block; width: 100%; height: auto; cursor: crosshair; touch-action: none; }

.kids-footer { padding: 34px 16px; background: #080707; color: #efd0cf; text-align: center; }
.kids-footer p { margin: 5px 0; }

@media (max-width: 720px) {
  .kids-nav { align-items: flex-start; }
  .kids-nav-links { display: grid; }
  .game-heading { align-items: flex-start; flex-direction: column; }
  .memory-board { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .word-layout { grid-template-columns: 1fr; }
  .word-list-wrap { text-align: center; }
  .word-list { grid-template-columns: repeat(4, 1fr); }
  .game-tabs { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 470px) {
  .game-tabs { font-size: .85rem; }
  .game-tab { padding: 0 6px; }
  .memory-board { gap: 8px; }
  .difference-layout { grid-template-columns: 1fr; }
  .word-grid { gap: 2px; }
  .word-cell { min-width: 0; padding: 0; font-size: .78rem; border-radius: 5px; }
  .word-list { grid-template-columns: repeat(2, 1fr); }
}
