/* Patas y Palabras – mobile first */
:root {
  --bg: #10221a;
  --bg2: #183327;
  --card: #1f3d2f;
  --card2: #29503d;
  --line: #ffffff18;
  --text: #f5eedb;
  --muted: #b9c6b4;
  --gold: #f4bd4f;
  --ok: #5fc46e;
  --bad: #e5675a;
  --clan: #6dbb5a;
  --r: 16px;
  --tap: 52px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  color-scheme: dark;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100vh; min-height: 100dvh;
  font-family: ui-rounded, "SF Pro Rounded", "Nunito", "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  font-size: 17px; line-height: 1.4; color: var(--text);
  background: radial-gradient(120% 60% at 50% 0%, #24493a 0%, var(--bg) 60%) fixed, var(--bg);
  overscroll-behavior-y: none;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; touch-action: manipulation; }
h1 { font-size: 1.5rem; margin: .4em 0; line-height: 1.2; }
h2 { font-size: 1.15rem; margin: 1.6em 0 .6em; color: var(--gold); }
h3 { font-size: 1.05rem; margin: 0 0 .6em; }
small { color: var(--muted); }
code { background: #0003; padding: 1px 5px; border-radius: 5px; font-size: .9em; }

.wrap { max-width: 640px; margin: 0 auto; padding: 12px 16px calc(32px + var(--safe-b)); }
.lead { color: var(--muted); margin: .4em 0 1em; }
.foot { text-align: center; color: var(--muted); font-size: .85rem; margin-top: 2em; }
.hintline { color: var(--muted); font-size: .9rem; margin: .4em 0 .8em; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4em;
  min-height: var(--tap); padding: 10px 18px; width: 100%;
  border-radius: 14px; border: 1px solid var(--line); background: var(--card2);
  font-weight: 700; text-align: center; transition: transform .08s, filter .15s;
}
.btn:active { transform: scale(.97); }
.btn.primary { background: var(--gold); color: #2a1d05; border-color: transparent; box-shadow: 0 4px 0 #b9862a; }
.btn.primary:active { box-shadow: 0 1px 0 #b9862a; transform: translateY(3px); }
.btn.big { min-height: 58px; font-size: 1.1rem; margin-top: 12px; }
.btn.ok { background: var(--ok); color: #082b0e; border-color: transparent; }
.btn.bad { background: #5a2420; border-color: #e5675a55; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.sm { min-height: 40px; padding: 6px 12px; width: auto; font-size: .9rem; }
.btn:disabled { opacity: .45; }
.ghost { background: none; border: 0; padding: 0; }
.ghost.icon { font-size: 1.5rem; width: var(--tap); height: var(--tap); }
.stack { display: grid; gap: 10px; margin-top: 12px; }
.pill { background: #0004; border-radius: 99px; padding: 6px 12px; font-weight: 700; font-size: .95rem; white-space: nowrap; }
.badge { background: var(--bad); color: #fff; border-radius: 99px; min-width: 28px; height: 28px; display: inline-grid; place-items: center; font-weight: 800; font-size: .9rem; padding: 0 8px; }
.badge.sm { min-width: 22px; height: 22px; font-size: .75rem; padding: 0 6px; }
.stars { color: var(--gold); letter-spacing: 1px; white-space: nowrap; }

/* ---------- Bars ---------- */
.bar { height: 12px; background: #0005; border-radius: 99px; overflow: hidden; flex: 1; display: block; }
.bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--clan), var(--gold)); border-radius: 99px; transition: width .4s; }
.bar.thin { height: 6px; margin-top: 6px; }
.row { display: flex; justify-content: space-between; gap: 8px; margin-bottom: 6px; font-weight: 700; }
.row.small { font-size: .85rem; font-weight: 400; color: var(--muted); margin: 12px 0 0; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 16px; margin: 12px 0; }
.card.danger { border-color: #e5675a44; }

/* ---------- Top bars ---------- */
.bar-top, .roundhead {
  position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 10px;
  padding: calc(8px + var(--safe-t)) 12px 8px; background: #10221ae6; backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.bar-top h1 { flex: 1; font-size: 1.15rem; margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.back { font-size: 2rem; line-height: 1; width: 44px; height: 44px; color: var(--text); flex: none; }
.roundhead .back { font-size: 1.4rem; color: var(--muted); }

/* ---------- Home ---------- */
.me { display: flex; align-items: center; gap: 12px; padding-top: var(--safe-t); }
.me .cat { width: 72px; height: 72px; flex: none; filter: drop-shadow(0 4px 6px #0006); }
.me-txt { flex: 1; min-width: 0; }
.greet { font-weight: 800; font-size: 1.2rem; overflow: hidden; text-overflow: ellipsis; }
.sub { color: var(--muted); font-size: .95rem; }
.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin: 14px 0 0; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 10px 6px; text-align: center; }
.stat b { display: block; font-size: 1.2rem; }
.stat small { font-size: .75rem; }

.patrol {
  width: 100%; display: flex; align-items: center; gap: 14px; text-align: left;
  padding: 16px; margin: 4px 0; border-radius: var(--r); border: 0;
  background: linear-gradient(135deg, var(--clan), #2d6a4a); box-shadow: 0 5px 0 #0005; color: #fff;
}
.patrol:active { transform: translateY(3px); box-shadow: 0 2px 0 #0005; }
.patrol .pi { font-size: 2rem; }
.patrol b { display: block; font-size: 1.15rem; }
.patrol small { color: #ffffffd0; }
.patrol > span:nth-child(2) { flex: 1; }

.units { display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; }
.unit {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left;
  min-height: 72px; padding: 10px 14px; border-radius: var(--r);
  background: var(--card); border: 1px solid var(--line);
}
.unit:active { background: var(--card2); }
.u-icon { font-size: 1.9rem; width: 46px; height: 46px; display: grid; place-items: center; background: #0003; border-radius: 12px; flex: none; }
.u-icon.big { font-size: 2.6rem; width: 70px; height: 70px; border-radius: 18px; }
.u-txt { flex: 1; min-width: 0; }
.u-txt b { display: block; }
.u-txt small { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.u-side { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }

.tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.tile {
  display: flex; flex-direction: column; align-items: flex-start; gap: 2px; text-align: left;
  padding: 14px; min-height: 100px; border-radius: var(--r); background: var(--card); border: 1px solid var(--line); font-weight: 700;
}
.tile span { font-size: 1.6rem; }
.tile small { font-weight: 400; font-size: .8rem; }

/* ---------- Unit ---------- */
.unit-hero { display: flex; align-items: center; gap: 14px; margin-top: 8px; }
.unit-hero h2 { margin: 0; color: var(--text); font-size: 1.4rem; }
.unit-hero p { margin: 0; color: var(--muted); }
.modes { display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; }
.mode {
  display: flex; align-items: center; gap: 14px; text-align: left; width: 100%; min-height: 74px;
  padding: 12px 14px; border-radius: var(--r); background: var(--card); border: 1px solid var(--line);
  border-left: 5px solid var(--clan);
}
.mode:active { background: var(--card2); }
.m-icon { font-size: 1.8rem; }
.mode b { display: block; font-size: 1.05rem; }
.mode small { display: block; }
.wordlist { margin-top: 20px; background: var(--card); border-radius: var(--r); border: 1px solid var(--line); }
.wordlist summary, .ctable summary { padding: 14px 16px; cursor: pointer; font-weight: 700; min-height: var(--tap); }
.wordlist ul { list-style: none; margin: 0; padding: 0 8px 8px; }
.wordlist li { display: grid; grid-template-columns: 1fr 1fr auto auto; gap: 8px; align-items: center; padding: 8px; border-top: 1px solid var(--line); font-size: .95rem; }
.wordlist .es { font-weight: 700; color: var(--gold); }
.lv { font-size: .6rem; color: var(--ok); letter-spacing: 1px; }
.lv i { color: #ffffff30; font-style: normal; }
.spk { background: #0003; border: 0; border-radius: 10px; width: 44px; height: 44px; font-size: 1.15rem; flex: none; vertical-align: middle; margin-left: 6px; }
.spk:active { background: #0006; }

/* ---------- Round ---------- */
.round { padding-top: 16px; }
.retry { text-align: center; color: var(--gold); font-weight: 700; margin-bottom: 8px; }
.qcard { background: var(--card); border: 1px solid var(--line); border-radius: 20px; padding: 18px 16px; text-align: center; margin-bottom: 16px; }
.qlabel { color: var(--muted); margin: 0 0 8px; text-align: center; font-size: .95rem; }
.qword { font-size: 1.7rem; font-weight: 800; line-height: 1.25; word-break: break-word; display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 6px; }
.qsub { color: var(--muted); margin-top: 6px; text-align: center; }
.hint { margin-top: 10px; font-size: 1.3rem; letter-spacing: 2px; color: var(--gold); }

.opts { display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; }
.opt {
  display: flex; align-items: center; gap: 12px; text-align: left; width: 100%; min-height: 60px;
  padding: 12px 14px; border-radius: 14px; background: var(--card2); border: 2px solid transparent; font-weight: 700; font-size: 1.08rem;
}
.opt i { font-style: normal; font-size: .8rem; width: 26px; height: 26px; display: grid; place-items: center; background: #0004; border-radius: 8px; color: var(--muted); flex: none; }
.opt:active { transform: scale(.98); }
.opt.ok { background: #1f5a2b; border-color: var(--ok); }
.opt.bad { background: #5a2420; border-color: var(--bad); animation: shake .35s; }
.opt:disabled { opacity: 1; }
.opt:disabled:not(.ok):not(.bad) { opacity: .5; }

.typeform { display: flex; gap: 8px; }
.typeform input {
  flex: 1; min-width: 0; min-height: 58px; padding: 10px 14px; border-radius: 14px;
  border: 2px solid var(--line); background: #0004; font-size: 1.25rem; /* >=16px: kein iOS-Zoom */
}
.typeform input:focus { outline: none; border-color: var(--gold); }
.typeform input.ok { border-color: var(--ok); }
.typeform input.bad { border-color: var(--bad); animation: shake .35s; }
.typeform .btn { width: auto; }
.keys { display: grid; grid-template-columns: repeat(9, 1fr); gap: 5px; margin-top: 10px; }
.keys button { min-height: 46px; border-radius: 10px; border: 1px solid var(--line); background: var(--card2); font-size: 1.15rem; font-weight: 700; padding: 0; }
.keys button:active { background: var(--gold); color: #000; }
.hintbtn { margin-top: 8px; }

.feedback { margin-top: 16px; padding: 14px; border-radius: 16px; background: var(--card); border: 2px solid var(--line); animation: pop .2s; }
.feedback.ok { border-color: var(--ok); }
.feedback.bad { border-color: var(--bad); }
.fbmsg { font-weight: 700; font-size: 1.1rem; }
.sol { font-size: 1.35rem; font-weight: 800; color: var(--gold); margin-top: 6px; display: flex; align-items: center; flex-wrap: wrap; gap: 4px; }
.feedback .btn { margin-top: 12px; }

/* Flashcard */
.flash { display: grid; width: 100%; min-height: 240px; perspective: 1000px; border: 0; background: none; padding: 0; }
.flash .face {
  grid-area: 1 / 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
  padding: 20px; border-radius: 22px; background: var(--card); border: 1px solid var(--line);
  backface-visibility: hidden; -webkit-backface-visibility: hidden; transition: transform .45s;
}
.flash .face b { font-size: 1.8rem; line-height: 1.25; word-break: break-word; }
.flash .face em { color: var(--muted); font-style: normal; }
.flash .back { transform: rotateY(180deg); background: var(--card2); border-color: var(--gold); }
.flash.flipped .front { transform: rotateY(-180deg); }
.flash.flipped .back { transform: rotateY(0); }
.row-btns { display: flex; gap: 10px; margin-top: 16px; align-items: center; }
.row-btns .spk { width: var(--tap); height: var(--tap); margin: 0; }

/* Match */
.match { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.mcol { display: grid; gap: 8px; align-content: start; }
.mcard {
  min-height: 62px; padding: 8px; border-radius: 14px; background: var(--card); border: 2px solid var(--line);
  font-weight: 700; font-size: .98rem; word-break: break-word; transition: opacity .3s, transform .1s;
}
.mcol.es .mcard { color: var(--gold); }
.mcard.sel { border-color: var(--gold); background: var(--card2); transform: scale(1.03); }
.mcard.done { opacity: .15; border-color: var(--ok); }
.mcard.wrong { border-color: var(--bad); background: #5a2420; animation: shake .35s; }

/* Result */
.result { text-align: center; }
.hero { display: grid; place-items: center; margin-top: 12px; }
.hero .cat { width: 130px; height: 130px; filter: drop-shadow(0 6px 10px #0007); animation: bob 2.4s ease-in-out infinite; }
.score { font-size: 1.1rem; }
.score b { font-size: 2.2rem; color: var(--gold); }
.earned { font-size: 1.8rem; font-weight: 800; margin: 8px 0; }
.earned small { display: block; font-size: .85rem; font-weight: 400; }
.rankup, .newbadge { background: linear-gradient(135deg, #f4bd4f33, #f4bd4f11); border: 1px solid var(--gold); border-radius: 16px; padding: 14px; margin: 10px 0; animation: pop .4s; }
.newbadge { display: flex; gap: 12px; align-items: center; text-align: left; }
.newbadge span { font-size: 2rem; }
.newbadge small { display: block; }
.result .card { text-align: left; }
.mistakes { list-style: none; margin: 0; padding: 0; }
.mistakes li { display: grid; grid-template-columns: 1fr auto auto; gap: 8px; align-items: center; padding: 8px 0; border-top: 1px solid var(--line); }
.mistakes b { color: var(--gold); text-align: right; }

/* Setup */
.setup .hero .cat { width: 120px; height: 120px; }
.setup h1 { text-align: center; }
.field { display: block; margin: 16px 0; }
.field > span { display: block; font-weight: 700; margin-bottom: 8px; }
.field input, .field textarea, .field select {
  width: 100%; min-height: var(--tap); padding: 10px 14px; border-radius: 14px; border: 2px solid var(--line);
  background: #0004; font-size: 1.05rem;
}
.field textarea { font-family: ui-monospace, Menlo, monospace; font-size: 16px; line-height: 1.5; resize: vertical; }
.field input:focus, .field textarea:focus, .field select:focus { outline: none; border-color: var(--gold); }
.swatches { display: flex; flex-wrap: wrap; gap: 10px; }
.swatch { width: 48px; height: 48px; border-radius: 50%; background: var(--c); border: 3px solid #ffffff30; }
.swatch.on { border-color: var(--gold); box-shadow: 0 0 0 3px #f4bd4f55; transform: scale(1.08); }
.seg { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); background: #0004; border-radius: 14px; padding: 4px; gap: 4px; }
.seg button { min-height: 44px; border: 0; border-radius: 10px; background: none; font-weight: 700; font-size: .95rem; }
.seg button.on { background: var(--gold); color: #2a1d05; }
.clans { display: grid; gap: 10px; }
.clan { text-align: left; padding: 14px; border-radius: 14px; background: var(--card); border: 2px solid var(--line); border-left: 6px solid var(--c); }
.clan small { display: block; }
.clan.on { border-color: var(--c); background: var(--card2); }

/* Conjugation */
.verbs { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.verb { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 14px; background: var(--card); border: 2px solid var(--line); min-height: 60px; }
.verb:has(input:checked) { border-color: var(--gold); background: var(--card2); }
.verb input { width: 22px; height: 22px; accent-color: var(--gold); flex: none; }
.verb span { flex: 1; min-width: 0; }
.verb b { display: block; }
.verb small { display: block; font-size: .75rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.verb .stars { font-size: .75rem; }
.ctable { background: var(--card); border-radius: 14px; margin: 8px 0; border: 1px solid var(--line); }
.ctable table { width: 100%; border-collapse: collapse; margin: 0 0 8px; }
.ctable td { padding: 6px 16px; border-top: 1px solid var(--line); }
.ctable td:nth-child(2) { color: var(--gold); }
.ctable td:last-child { text-align: right; width: 60px; }

/* Custom */
.clist { display: grid; gap: 8px; }
.citem { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-radius: 14px; background: var(--card); border: 1px solid var(--line); }
.citem span { flex: 1; min-width: 0; }
.citem b, .citem small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Badges & stats */
.badges { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.bdg { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 14px 10px; text-align: center; opacity: .55; }
.bdg.has { opacity: 1; border-color: var(--gold); }
.bdg span { font-size: 2rem; display: block; }
.bdg b { display: block; font-size: .95rem; }
.bdg small { font-size: .78rem; }
.statlist { list-style: none; padding: 0; margin: 0; }
.statlist li { display: flex; justify-content: space-between; padding: 8px 0; border-top: 1px solid var(--line); color: var(--muted); }
.statlist li.reached { color: var(--text); }

/* Settings */
.tog { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); min-height: 64px; cursor: pointer; }
.tog span { flex: 1; }
.tog small { display: block; }
.tog input { position: absolute; opacity: 0; pointer-events: none; }
.tog i { width: 52px; height: 30px; border-radius: 99px; background: #0005; position: relative; flex: none; transition: background .2s; }
.tog i::after { content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; transition: transform .2s; }
.tog input:checked + i { background: var(--ok); }
.tog input:checked + i::after { transform: translateX(22px); }
.tog input:focus-visible + i { outline: 2px solid var(--gold); }
.filebtn { position: relative; overflow: hidden; }
.filebtn input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }

/* Toast & effects */
#toast {
  position: fixed; left: 50%; bottom: calc(20px + var(--safe-b)); transform: translate(-50%, 150%);
  width: max-content; max-width: calc(100vw - 32px); background: #000d; color: #fff; padding: 12px 18px; border-radius: 14px;
  font-weight: 700; z-index: 50; transition: transform .3s, opacity .3s; pointer-events: none; text-align: center; opacity: 0;
}
#toast.show { transform: translate(-50%, 0); opacity: 1; }
.prey { position: fixed; left: 50%; top: 40%; font-size: 3rem; z-index: 40; pointer-events: none; animation: prey .9s ease-out forwards; }

@keyframes shake { 0%, 100% { transform: translateX(0); } 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }
@keyframes pop { from { transform: scale(.92); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@keyframes bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }
@keyframes prey { from { transform: translate(-50%, 0) scale(.6); opacity: 1; } to { transform: translate(-50%, -140px) scale(1.4); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

/* Sehr kleine Handys */
@media (max-width: 360px) {
  body { font-size: 16px; }
  .keys { grid-template-columns: repeat(5, 1fr); }
  .verbs, .tiles { grid-template-columns: 1fr; }
  .qword { font-size: 1.45rem; }
}
/* Größere Bildschirme (Tablet / Desktop) */
@media (min-width: 700px) {
  .units { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tiles { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .modes { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .opts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .badges { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .verbs { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .stack { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (hover: hover) {
  .unit:hover, .mode:hover, .tile:hover, .opt:not(:disabled):hover, .mcard:not(:disabled):hover { border-color: #ffffff40; }
}
.brand { text-align: center; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; font-size: .85rem; color: var(--gold); margin-top: 8px; }
