:root { --blue: #1f4e79; --blue-dark: #163a5a; --bg: #f4f6f9; --card: #fff; --ink: #1c2430; --muted: #5d6b7a; --line: #d9dee5; --ok: #2e8b57; --fail: #c0392b; --skip: #8a6d1d; --accent: #f2b134; }
@media (prefers-color-scheme: dark) { :root { --bg: #141a22; --card: #1e2730; --ink: #e8edf2; --muted: #9aa7b4; --line: #34404c; --blue: #4f8fcf; --blue-dark: #3b73aa; } }
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; }
.top { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 20px; padding: 14px 16px; background: var(--blue); color: #fff; }
.top h1 { font-size: 1.15rem; margin: 0; display: flex; align-items: center; gap: 10px; }
.logo { display: inline-grid; place-items: center; width: 30px; height: 38px; border-radius: 6px; background: #fff; color: var(--blue); font-weight: 800; font-size: 1.3rem; }
.tabs { display: flex; gap: 4px; flex: 1; }
.tab { background: transparent; color: #fff; border: 1px solid rgba(255,255,255,.4); border-radius: 999px; padding: 6px 14px; cursor: pointer; font-size: .95rem; }
.tab.active { background: #fff; color: var(--blue); border-color: #fff; font-weight: 600; }
.lang { display: flex; gap: 2px; }
.lang-btn { background: transparent; color: #fff; border: 1px solid rgba(255,255,255,.4); padding: 4px 8px; cursor: pointer; font-size: .8rem; }
.lang-btn:first-child { border-radius: 6px 0 0 6px; } .lang-btn:last-child { border-radius: 0 6px 6px 0; }
.lang-btn.active { background: var(--accent); color: #222; border-color: var(--accent); font-weight: 700; }
main { max-width: 760px; margin: 0 auto; padding: 16px; }
.panel { display: none; } .panel.active { display: block; }
.card-box { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 18px 20px; margin-bottom: 16px; box-shadow: 0 1px 2px rgba(0,0,0,.04); }
.card-box h2 { margin: 0 0 10px; font-size: 1.2rem; }
.hidden { display: none !important; }
.hint { color: var(--muted); font-size: .9rem; margin: 8px 0; }
.hint.warn { color: var(--fail); font-weight: 600; }
label { display: inline-flex; align-items: center; gap: 8px; margin: 6px 12px 6px 0; }
input[type=number], select, textarea { font: inherit; padding: 6px 8px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); color: var(--ink); }
input[type=number] { width: 5.5em; }
textarea { width: 100%; resize: vertical; }
button { font: inherit; cursor: pointer; border-radius: 10px; border: 1px solid var(--line); background: var(--card); color: var(--ink); padding: 10px 16px; }
button.primary { background: var(--blue); color: #fff; border-color: var(--blue); font-weight: 600; }
button.primary:hover { background: var(--blue-dark); }
button.ghost { background: transparent; }
button.small { padding: 4px 10px; font-size: .85rem; }
.row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; margin: 6px 0; }
.status { color: var(--muted); margin: 0 0 8px; }
.numbers { display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px; margin: 14px 0; }
.num { font-size: 2rem; font-weight: 700; padding: 22px 0; border: 2px solid var(--blue); color: var(--blue); background: var(--card); }
.num:hover { background: var(--blue); color: #fff; }
.actions { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 10px; }
.actions button { font-weight: 600; color: #fff; border: 0; padding: 14px 0; }
.actions .ok { background: var(--ok); } .actions .fail { background: var(--fail); } .actions .skip { background: var(--skip); }
.big { font-size: 2.2rem; margin: 6px 0; }
.rating { font-size: 1.1rem; }
.cats { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 4px 12px; }
.cats label { margin: 2px 0; }
.cats small { color: var(--muted); }
.prose ol { padding-left: 1.3em; } .prose li { margin: 4px 0; }
footer { text-align: center; color: var(--muted); font-size: .85rem; padding: 20px; }
footer a { color: inherit; }

@media print {
  @page { size: A4 portrait; margin: 0; }
  body { background: #fff; } .top, footer, .no-print, .panel:not(#tab-print) { display: none !important; }
  main { max-width: none; padding: 0; } #tab-print { display: block !important; }
  .sheet { box-shadow: none; margin: 0; height: 296mm; min-height: 0; overflow: hidden; break-inside: avoid; page-break-after: always; transform: none; }
  .sheet:last-child { page-break-after: auto; }
}

/* ---- the card: 63 × 88 mm portrait, five framed rows, everything sized from the card's width (--u) ---- */
.jo { --u: .63mm; aspect-ratio: 63 / 88; width: calc(100 * var(--u)); background: #fff; color: #111; border-radius: 8%/5.7%; overflow: hidden; }
.jo .face { height: 100%; display: grid; grid-template-rows: repeat(5, 1fr); gap: calc(3.6 * var(--u)); padding: calc(6 * var(--u)) calc(6 * var(--u)) calc(6 * var(--u)) calc(3.5 * var(--u)); }
.jo .line { display: grid; grid-template-columns: calc(11 * var(--u)) 1fr; align-items: center; min-height: 0; }
.jo .line:nth-child(2) { transform: rotate(.35deg); } .jo .line:nth-child(4) { transform: rotate(-.3deg); }
.jo .no { color: var(--c); text-align: center; font-family: "Arial Rounded MT Bold", "Nunito", "Varela Round", "Segoe UI", system-ui, sans-serif; font-weight: 900; font-size: calc(8 * var(--u)); line-height: 1; transform: rotate(-9deg); text-shadow: calc(.3 * var(--u)) calc(.3 * var(--u)) 0 #444; }
.jo .slot { height: 100%; border: calc(.8 * var(--u)) solid var(--c); border-radius: calc(.8 * var(--u)); min-width: 0; }
.jo .slot .in { height: 100%; border-top: calc(.9 * var(--u)) solid #cfcfcf; border-left: calc(.9 * var(--u)) solid #cfcfcf; border-right: calc(.35 * var(--u)) solid #e2e2e2; border-bottom: calc(.35 * var(--u)) solid #e2e2e2; display: grid; place-items: center; overflow: hidden; }
.jo .w { font-family: "Arial Rounded MT Bold", "Nunito", "Varela Round", "Segoe UI", system-ui, sans-serif; font-weight: 700; font-size: calc(7.4 * var(--u)); white-space: nowrap; line-height: 1; }
.jo .w.long { font-size: calc(6.2 * var(--u)); } .jo .w.xlong { font-size: calc(5 * var(--u)); }
.jo .c1 { --c: #2f9bd8; } .jo .c2 { --c: #6a9e3a; } .jo .c3 { --c: #cf2f35; } .jo .c4 { --c: #ef8a2c; } .jo .c5 { --c: #f2b02e; }
.jo.pick .line:not(.chosen) { opacity: .5; }
.jo.pick .line.chosen .slot { box-shadow: 0 0 0 calc(1.2 * var(--u)) rgba(240,179,35,.55); }
/* on screen: the card for the clue-givers, the chosen row standing out */
.jo-wrap { display: flex; justify-content: center; margin: 12px 0; }
.jo-wrap .jo { --u: min(3.4px, calc((100vw - 82px) / 100)); box-shadow: 0 6px 20px rgba(0,0,0,.18); border: 1px solid #ddd; }
/* the back: the parrot centred on white */
.jo.back { display: grid; place-items: center; }
.jo.back img { width: 100%; height: 100%; object-fit: contain; padding: calc(7 * var(--u)); box-sizing: border-box; display: block; }
#play-pick .jo-wrap .jo { --u: min(2.4px, calc((100vw - 82px) * .007)); }
/* print sheets: 3 × 3 cards of 63 × 88 mm on A4 (or 12 smaller) */
.sheet { background: #fff; color: #000; width: 210mm; min-height: 297mm; margin: 0 auto 12px; padding: 16.5mm 10.5mm; display: grid; grid-template-columns: repeat(3, 63mm); grid-auto-rows: 88mm; justify-content: center; align-content: start; }
.sheet .jo { width: 63mm; height: 88mm; aspect-ratio: auto; border-radius: 3mm; }
.sheet .jo .face { height: 88mm; }
.sheet.l12 { grid-template-columns: repeat(4, 47.25mm); grid-auto-rows: 66mm; }
.sheet.l12 .jo { --u: .4725mm; width: 47.25mm; height: 66mm; }
.sheet.l12 .jo .face { height: 66mm; }
.sheet.marks .jo { outline: .25mm dashed #aaa; outline-offset: -.1mm; }
@media screen { .sheet { box-shadow: 0 2px 8px rgba(0,0,0,.15); transform-origin: top center; } @media (max-width: 820px) { .sheet { transform: scale(.45); margin-bottom: -150mm; } } }

/* the language of the words */
.wl { display: flex; align-items: center; gap: 0; margin: 4px 0 10px; }
.wl > span { margin-right: 10px; }
.wl-btn { padding: 6px 14px; border-radius: 0; } .wl-btn:nth-of-type(1) { border-radius: 8px 0 0 8px; } .wl-btn:nth-of-type(2) { border-radius: 0 8px 8px 0; border-left: 0; }
.wl-btn.active { background: var(--blue); color: #fff; border-color: var(--blue); font-weight: 600; }
/* editing the lists */
.cats { grid-template-columns: 1fr; }
.cat { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 0 12px; border-top: 1px solid var(--line); padding: 2px 0; }
.cat details { text-align: right; } .cat details[open] { flex-basis: 100%; text-align: left; padding-bottom: 10px; }
.cat summary { cursor: pointer; color: var(--blue); font-size: .9rem; }
label.block { display: block; margin: 8px 0; } label.block input, label.block textarea { display: block; width: 100%; margin-top: 4px; font: inherit; padding: 6px 8px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); color: var(--ink); }

/* choosing the lists on the print tab */
.print-cats { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 0 12px; margin-bottom: 8px; }
.print-cats label { margin: 2px 0; } .print-cats small { color: var(--muted); }

/* duplicates found among the selected words */
.dup-warn { background: #fff6dc; color: #5c4400; border: 1px solid #ecd28b; border-radius: 8px; padding: 8px 12px; margin: 8px 0; font-size: .92rem; }
.dup-warn summary { cursor: pointer; font-weight: 600; }
.dup-warn ul { margin: 6px 0 0; padding-left: 1.2em; max-height: 220px; overflow-y: auto; }

/* "Bearbeiten" stays at the top right of its row, open or closed */
.cat { position: relative; display: block; }
.cat > label { padding-right: 7em; margin-right: 0; }
.cat summary { position: absolute; top: 8px; right: 0; }
.cat details[open] { text-align: left; }

/* the back image is laid exactly over the card: as a grid item its height could push the row past the card's 88 mm */
.jo.back { position: relative; }
.jo.back img { position: absolute; inset: 0; }

/* the backs moved to match the printer (print tab: Rückseiten ausrichten) */
.back-sheet .jo.back { top: var(--dy, 0mm); left: var(--dx, 0mm); }

/* twelve smaller cards: three rows of 66 mm centred on A4 as well */
.sheet.l12 { padding-top: 49.5mm; padding-bottom: 49.5mm; }
