:root {
  --paper: #fffdf6;
  --paper-2: #f6f1e4;
  --ink: #1d2140;
  --ink-2: #4a4f72;
  --muted: #777b98;
  --line: #d9e4f5;
  --margin: #ff9aa8;
  --yellow: #ffe45c;
  --pink: #ff7ab6;
  --mint: #5ee6b0;
  --blue: #6cb8ff;
  --violet: #9b8cff;
  --orange: #ffa45c;
  --good: #19a974;
  --bad: #e0435a;
  --radius: 16px;
  --shadow: 4px 4px 0 var(--ink);
  --shadow-sm: 2px 2px 0 var(--ink);
  --font-head: 'Fredoka', 'Nunito', system-ui, sans-serif;
  --font: 'Nunito', system-ui, -apple-system, 'Segoe UI', sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink);
  background-color: var(--paper);
  background-image: repeating-linear-gradient(to bottom, transparent 0 31px, var(--line) 31px 32px);
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
main { flex: 1; width: 100%; max-width: 1080px; margin: 0 auto; padding: 0 16px 48px; }
h1, h2, h3 { font-family: var(--font-head); line-height: 1.15; margin: 0 0 .4em; font-weight: 600; }
h1 { font-size: clamp(2rem, 6vw, 3.4rem); }
h2 { font-size: clamp(1.4rem, 3.5vw, 1.9rem); }
h3 { font-size: 1.2rem; }
a { color: inherit; }
p { margin: 0 0 1em; }
.muted { color: var(--muted); }
.small { font-size: .88rem; }
.center { text-align: center; }
[hidden] { display: none !important; }

/* Highlighter swipe behind a word */
.hl { background: linear-gradient(100deg, transparent 2%, var(--yellow) 4%, var(--yellow) 94%, transparent 97%); padding: 0 .15em; border-radius: 4px; }
.hl.pink { background: linear-gradient(100deg, transparent 2%, var(--pink) 4%, var(--pink) 94%, transparent 97%); }
.hl.mint { background: linear-gradient(100deg, transparent 2%, var(--mint) 4%, var(--mint) 94%, transparent 97%); }

/* ---- Header / footer ---- */
.site-header { max-width: 1080px; margin: 0 auto; padding: 14px 16px; display: flex; align-items: center; gap: 12px; width: 100%; }
.logo { display: inline-flex; align-items: center; gap: 8px; text-decoration: none; font-family: var(--font-head); font-weight: 600; font-size: 1.2rem; }
.logo-mark { width: 38px; height: 38px; border: 2.5px solid var(--ink); border-radius: 10px; background: var(--yellow); display: grid; place-items: center; box-shadow: var(--shadow-sm); font-size: 1.2rem; transform: rotate(-4deg); }
.logo b { background: var(--pink); padding: 0 .2em; border-radius: 4px; }
.site-header nav { margin-left: auto; display: flex; gap: 8px; }
.site-footer { border-top: 2px dashed var(--ink); background: var(--paper-2); padding: 20px 16px; text-align: center; font-size: .9rem; color: var(--ink-2); }
.site-footer a { margin: 0 8px; }

/* ---- Cards and buttons ---- */
.card { background: #fff; border: 2.5px solid var(--ink); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font: 700 1rem var(--font); color: var(--ink); background: #fff;
  border: 2.5px solid var(--ink); border-radius: 12px; padding: 10px 16px; min-height: 44px;
  box-shadow: var(--shadow-sm); cursor: pointer; text-decoration: none;
  transition: transform .08s, box-shadow .08s, background .15s;
}
.btn:hover { transform: translate(-1px, -1px); box-shadow: 3px 3px 0 var(--ink); }
.btn:active { transform: translate(2px, 2px); box-shadow: 0 0 0 var(--ink); }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; box-shadow: var(--shadow-sm); }
.btn-primary { background: var(--yellow); }
.btn-pink { background: var(--pink); }
.btn-mint { background: var(--mint); }
.btn-blue { background: var(--blue); }
.btn-big { font-size: 1.15rem; padding: 14px 24px; min-height: 54px; border-radius: 14px; }
.btn-small { padding: 6px 10px; min-height: 36px; font-size: .9rem; }
.btn-ghost { background: transparent; box-shadow: none; border-color: transparent; }
.btn-ghost:hover { box-shadow: none; background: rgba(29, 33, 64, .06); }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }

input[type=text], select, textarea {
  font: 1rem var(--font); color: var(--ink); background: #fff;
  border: 2.5px solid var(--ink); border-radius: 12px; padding: 10px 12px; min-height: 44px; width: 100%;
}
textarea { resize: vertical; min-height: 140px; line-height: 1.5; }
input:focus-visible, select:focus-visible, textarea:focus-visible, .btn:focus-visible { outline: 3px solid var(--blue); outline-offset: 2px; }
label { font-weight: 700; }

.pill { display: inline-block; border: 2px solid var(--ink); border-radius: 999px; padding: 1px 10px; font-size: .8rem; font-weight: 700; background: #fff; }
.error { background: #ffe1e6; border: 2px solid var(--bad); border-radius: 12px; padding: 10px 14px; color: #8a1328; font-weight: 600; }

/* ---- Modals / toast / confetti ---- */
.overlay { position: fixed; inset: 0; background: rgba(29, 33, 64, .55); display: grid; place-items: center; padding: 16px; z-index: 50; overflow-y: auto; }
.modal { width: 100%; max-width: 460px; text-align: center; display: grid; gap: 12px; }
.modal h2 { margin: 0; }
.modal p { margin: 0; }
.modal-emoji { font-size: 2.6rem; }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); opacity: 0; background: var(--ink); color: #fff; padding: 10px 18px; border-radius: 999px; font-weight: 700; transition: .25s; z-index: 60; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 70; overflow: hidden; }
.confetti i { position: absolute; top: -20px; width: 10px; height: 14px; border-radius: 2px; animation: fall linear forwards; }
@keyframes fall { to { top: 105%; transform: rotate(720deg) translateX(40px); } }

/* ---- Ads ---- */
.ad-slot { margin: 28px auto; max-width: 728px; min-height: 100px; text-align: center; }
.ad-label { display: block; font-size: .72rem; color: var(--muted); margin-bottom: 4px; text-transform: uppercase; letter-spacing: .06em; }

/* ---- Home ---- */
.hero { display: grid; grid-template-columns: 1.1fr 1fr; gap: 32px; align-items: center; padding: 28px 0 12px; }
.hero p.lead { font-size: 1.15rem; color: var(--ink-2); max-width: 34em; }
.sticker { display: inline-block; transform: rotate(-3deg); background: var(--mint); border: 2.5px solid var(--ink); border-radius: 10px; padding: 2px 10px; font-weight: 800; font-size: .9rem; box-shadow: var(--shadow-sm); margin-bottom: 14px; }
.maker { display: grid; gap: 14px; }
.drop { border: 2.5px dashed var(--ink); border-radius: 14px; background: var(--paper-2); padding: 22px 16px; text-align: center; cursor: pointer; transition: background .15s; }
.drop.over { background: #fff6bf; }
.drop strong { display: block; font-size: 1.1rem; }
.file-list { display: grid; gap: 6px; }
.file-chip { display: flex; align-items: center; gap: 8px; background: #fff; border: 2px solid var(--ink); border-radius: 10px; padding: 6px 10px; font-size: .92rem; }
.file-chip span { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.or { display: flex; align-items: center; gap: 10px; color: var(--muted); font-weight: 700; font-size: .85rem; }
.or::before, .or::after { content: ''; flex: 1; border-top: 2px dashed var(--line); }
.progress { display: grid; gap: 10px; text-align: center; padding: 10px 0; }
.progress .bar { height: 14px; border: 2.5px solid var(--ink); border-radius: 999px; overflow: hidden; background: #fff; }
.progress .bar i { display: block; height: 100%; width: 0; background: repeating-linear-gradient(45deg, var(--yellow) 0 12px, var(--orange) 12px 24px); transition: width .6s; }
.steps { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin: 36px 0; }
.step { text-align: center; }
.step .num { font-family: var(--font-head); font-size: 2rem; width: 56px; height: 56px; border: 2.5px solid var(--ink); border-radius: 50%; display: grid; place-items: center; margin: 0 auto 8px; background: var(--blue); box-shadow: var(--shadow-sm); }
.join-box { display: flex; gap: 8px; }
.join-box input { text-transform: uppercase; letter-spacing: .2em; font-weight: 800; }
.my-packs { display: grid; gap: 8px; }
.my-pack { display: flex; align-items: center; gap: 10px; text-decoration: none; background: #fff; border: 2px solid var(--ink); border-radius: 12px; padding: 10px 14px; }
.my-pack:hover { background: #fffbe0; }
.my-pack b { flex: 1; }

/* ---- Game cards (home showcase + pack page) ---- */
.games { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 18px; }
.game-card { display: flex; flex-direction: column; gap: 8px; padding: 18px; position: relative; }
.game-card .icon { width: 56px; height: 56px; border: 2.5px solid var(--ink); border-radius: 14px; display: grid; place-items: center; font-size: 1.8rem; box-shadow: var(--shadow-sm); }
.game-card h3 { margin: 6px 0 0; }
.game-card p { margin: 0; color: var(--ink-2); font-size: .95rem; flex: 1; }
.game-card .tags { display: flex; gap: 6px; flex-wrap: wrap; }
.game-card .actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 6px; }
.game-card .actions .wide { grid-column: 1 / -1; }
.game-card.off { opacity: .55; }
.c-yellow { background: var(--yellow); } .c-pink { background: var(--pink); } .c-mint { background: var(--mint); }
.c-blue { background: var(--blue); } .c-violet { background: var(--violet); } .c-orange { background: var(--orange); }
.new-tag { position: absolute; top: -10px; right: 14px; transform: rotate(4deg); background: var(--pink); }

/* ---- Pack page ---- */
.pack-head { padding: 22px 0 8px; display: grid; gap: 10px; }
.pack-head .row { gap: 8px; }
.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.tabs button { font: 700 .9rem var(--font); border: 2px solid var(--ink); background: #fff; border-radius: 999px; padding: 6px 12px; cursor: pointer; }
.tabs button[aria-selected=true] { background: var(--ink); color: #fff; }
.board { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.board li { display: flex; gap: 10px; align-items: center; background: #fff; border: 2px solid var(--ink); border-radius: 10px; padding: 6px 12px; }
.board li .rank { font-family: var(--font-head); width: 28px; }
.board li .name { flex: 1; font-weight: 700; overflow: hidden; text-overflow: ellipsis; }
.board li .score { font-family: var(--font-head); }
.board li.me { background: #fff6bf; }
.board li.done .name::after { content: ' ✓'; color: var(--good); }

/* ---- Play page ---- */
.play-bar { display: flex; align-items: center; gap: 10px; padding: 8px 0 14px; flex-wrap: wrap; }
.play-bar h1 { font-size: clamp(1.4rem, 4vw, 2rem); margin: 0; }
.play-bar .stats { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }
.stat { background: #fff; border: 2px solid var(--ink); border-radius: 10px; padding: 4px 10px; font-weight: 800; font-family: var(--font-head); font-size: 1.05rem; }
.stat small { font-family: var(--font); font-weight: 700; color: var(--muted); font-size: .72rem; display: block; line-height: 1; text-transform: uppercase; }
.play-layout { display: grid; grid-template-columns: 1fr; gap: 18px; }
.play-layout.with-room { grid-template-columns: 1fr 260px; }
.room-panel { align-self: start; position: sticky; top: 12px; }
.room-panel h3 { display: flex; justify-content: space-between; align-items: baseline; }
.game-root { min-width: 0; }
.intro { text-align: center; max-width: 560px; margin: 20px auto; display: grid; gap: 14px; justify-items: center; }
.intro .icon { font-size: 3rem; }
.intro ul { text-align: left; margin: 0; padding-left: 1.2em; }

.result { max-width: 520px; }
.result .big-score { font-family: var(--font-head); font-size: 3.4rem; line-height: 1; }
.result .lb-form { display: flex; gap: 8px; }
.result .summary { text-align: left; max-height: 240px; overflow-y: auto; display: grid; gap: 6px; font-size: .92rem; }

/* Shared feedback chips */
.fb { border-radius: 12px; padding: 10px 14px; border: 2px solid var(--ink); font-weight: 600; }
.fb.good { background: #d6f8ea; }
.fb.bad { background: #ffe1e6; }
.shake { animation: shake .35s; }
@keyframes shake { 25% { transform: translateX(-6px); } 50% { transform: translateX(6px); } 75% { transform: translateX(-3px); } }
.pop { animation: pop .3s; }
@keyframes pop { 50% { transform: scale(1.08); } }

/* ---- Print page ---- */
.print-tools { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; padding: 14px 0; }
.print-tools label { display: flex; align-items: center; gap: 6px; font-weight: 700; }
.print-tools select { width: auto; }
.sheet { background: #fff; color: #000; max-width: 210mm; margin: 0 auto 24px; padding: 14mm 14mm; border: 1px solid #ccc; box-shadow: 0 4px 20px rgba(0,0,0,.08); font-family: var(--font); }
.sheet + .sheet { break-before: page; }
.sheet-head { display: flex; justify-content: space-between; align-items: flex-end; border-bottom: 2px solid #000; padding-bottom: 6px; margin-bottom: 12px; gap: 12px; }
.sheet-head h1 { font-size: 1.7rem; margin: 0; }
.sheet-head .sub { font-size: .85rem; }
.sheet-name { font-size: .9rem; white-space: nowrap; }
.sheet-foot { margin-top: 14px; font-size: .72rem; color: #555; text-align: right; }
.key-badge { display: inline-block; border: 2px solid #000; padding: 0 8px; border-radius: 6px; font-weight: 800; font-size: .8rem; margin-left: 8px; vertical-align: middle; }

@media print {
  @page { size: A4; margin: 10mm; }
  body { background: #fff; }
  .site-header, .site-footer, .print-tools, .ad-slot, .no-print { display: none !important; }
  main { padding: 0; max-width: none; }
  .sheet { border: 0; box-shadow: none; padding: 0; margin: 0; max-width: none; }
}

/* ---- Small screens ---- */
@media (max-width: 820px) {
  .hero { grid-template-columns: 1fr; padding-top: 8px; }
  .play-layout.with-room { grid-template-columns: 1fr; }
  .room-panel { position: static; order: 2; }
  .steps { grid-template-columns: 1fr; }
}
@media (max-width: 480px) {
  .site-header nav .btn span { display: none; }
  .game-card .actions { grid-template-columns: 1fr; }
  .card { padding: 16px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* Game versions on pack cards */
.versions { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.vchip { font: 800 .85rem var(--font); min-width: 32px; height: 32px; border: 2px solid var(--ink); border-radius: 8px; background: #fff; color: var(--ink); cursor: pointer; padding: 0 8px; }
.vchip.on { background: var(--ink); color: #fff; }
.vchip.new { background: var(--yellow); }
.vchip:disabled { opacity: .6; cursor: wait; }
