/* Ja oder Ja? — playful, iPhone first, light and dark.
   Colour pairs are checked by tests/contrast.test.js; keep the dark values in the one
   block below so the test and the snapshots can read both modes. */

:root {
  --bg: #fff5fa;
  --surface: #ffffff;
  --surface-2: #f8eef6;
  --text: #261530;
  --muted: #6b5876;
  --line: #ecdcee;
  --accent: #7c3aed;
  --accent-text: #ffffff;
  --accent-soft: #f1e8ff;
  --danger: #b91c1c;
  --danger-text: #ffffff;
  --yes: #15803d;
  --yes-text: #ffffff;
  --no: #dc2626;
  --no-text: #ffffff;
  --tired: #6b7280;
  --card-text: #2a1433;
  --card-muted: #5b4a66;
  --card-yes: #15803d;
  --card-no: #b91c1c;
  --hero-a: #db2777;
  --hero-b: #7c3aed;
  --radius: 20px;
  --tap: 48px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #160e1c;
    --surface: #221729;
    --surface-2: #2e2236;
    --text: #f7eefb;
    --muted: #bba9c6;
    --line: #3b2c46;
    --accent: #b197fc;
    --accent-text: #1b0f2a;
    --accent-soft: #33254a;
    --danger: #ff8a80;
    --danger-text: #2a0b0b;
  }
}

/* Playing-field colours per emoji theme (white text on them). */
.theme-love { --ga: #db2777; --gb: #7c3aed; }
.theme-sport { --ga: #0e7490; --gb: #1d4ed8; }
.theme-food { --ga: #c2410c; --gb: #be123c; }
.theme-party { --ga: #7c3aed; --gb: #2563eb; }
.theme-general { --ga: #c026d3; --gb: #6d28d9; }

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; touch-action: manipulation; }

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font: 17px/1.45 ui-rounded, "SF Pro Rounded", -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
[hidden] { display: none !important; }
h1, h2, h3 { margin: 0; line-height: 1.2; }
p { margin: 0; }
.muted { color: var(--muted); }
.icon { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.boot { padding: 40vh 24px 0; text-align: center; color: var(--muted); }
.fatal { padding: calc(var(--safe-top) + 30vh) 24px 24px; display: grid; gap: 16px; text-align: center; }

/* ---- shell ---------------------------------------------------------------------------- */

.app { display: flex; flex-direction: column; min-height: 100dvh; }

.app-header {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 10px;
  padding: calc(var(--safe-top) + 10px) calc(var(--safe-right) + 16px) 8px calc(var(--safe-left) + 20px);
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
}
.app-header h1 { font-size: 24px; font-weight: 900; letter-spacing: -0.01em; }
.gear { margin-left: auto; }
.site-badge {
  font-size: 12px; font-weight: 800; letter-spacing: 0.05em;
  padding: 2px 8px; border-radius: 999px; background: #c2410c; color: #fff;
}

.app-main {
  flex: 1;
  width: 100%; max-width: 560px; margin: 0 auto;
  padding: 4px calc(var(--safe-right) + 16px) calc(var(--safe-bottom) + 96px) calc(var(--safe-left) + 16px);
}

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 5;
  display: flex; justify-content: center;
  padding: 6px 8px calc(var(--safe-bottom) + 6px);
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
}
.tab {
  flex: 1; max-width: 160px; min-height: var(--tap);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  border: 0; background: none; color: var(--muted); font-size: 12px; font-weight: 700;
}
.tab[aria-current="page"] { color: var(--accent); }

.update-banner {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  margin: 0 16px 8px; padding: 10px 14px; border-radius: var(--radius);
  background: var(--accent-soft);
}

/* ---- building blocks ---------------------------------------------------------------- */

.view { display: grid; gap: 16px; }
.screen-title { font-size: 26px; font-weight: 900; margin-top: 4px; }
.section-title { font-size: 15px; font-weight: 800; color: var(--muted); margin: 4px 4px 8px; }

.card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: 0 1px 2px rgb(38 21 48 / 0.06), 0 10px 28px -16px rgb(124 58 237 / 0.35);
}

.button {
  min-height: var(--tap); padding: 0 18px;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 0; border-radius: 999px;
  background: var(--surface-2); color: var(--text); font-weight: 700;
}
.button:disabled { opacity: 0.5; }
.button.primary { background: var(--accent); color: var(--accent-text); }
.button.danger { background: var(--danger); color: var(--danger-text); }
.button.danger-plain { color: var(--danger); }
.button.small { min-height: 36px; padding: 0 14px; font-size: 15px; }
.button.big {
  width: 100%; min-height: 62px;
  font-size: 21px; font-weight: 900;
  color: #fff;
  background: linear-gradient(135deg, var(--hero-a), var(--hero-b));
  box-shadow: 0 12px 26px -12px rgb(124 58 237 / 0.8);
}
.button.big:active { transform: scale(0.98); }
.button-row { display: flex; flex-wrap: wrap; gap: 10px; }
.button-row .button { flex: 1 1 auto; }

.link { border: 0; background: none; color: var(--accent); font-weight: 700; padding: 8px 0; }
.icon-button {
  width: 44px; height: 44px; flex: none;
  display: grid; place-items: center;
  border: 0; border-radius: 50%; background: transparent; color: var(--muted);
}
.icon-button:active { background: var(--surface-2); }

.field { display: grid; gap: 6px; }
.field-label { font-size: 14px; font-weight: 800; color: var(--muted); }
.field-hint { font-size: 14px; color: var(--muted); margin-top: 6px; }

details > summary { cursor: pointer; font-weight: 700; color: var(--accent); padding: 10px 0; list-style-position: inside; }

/* ---- ask screen ----------------------------------------------------------------------- */

.ask-card { display: grid; gap: 12px; }
.ask-head { display: flex; align-items: center; justify-content: space-between; }
.ask-head h2 { font-size: 20px; font-weight: 900; }
.ask-tools { display: flex; gap: 2px; }
.dice { color: var(--accent); }

.question-input {
  width: 100%;
  font-size: 22px; font-weight: 800; line-height: 1.3;
  padding: 12px 14px;
  border: 2px solid var(--line); border-radius: 16px;
  background: var(--surface-2); color: var(--text);
  resize: none;
}
.question-input:focus { outline: none; border-color: var(--accent); }
.question-input::placeholder { color: var(--muted); font-weight: 600; }

.chips {
  display: flex; gap: 8px;
  overflow-x: auto; scrollbar-width: none;
  margin: 0 -16px; padding: 0 16px 2px;
}
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; white-space: nowrap;
  padding: 8px 14px; border: 0; border-radius: 999px;
  background: var(--accent-soft); color: var(--text); font-size: 15px; font-weight: 600;
}

.theme-row { display: flex; flex-wrap: wrap; gap: 8px; }
.theme-chip {
  padding: 7px 12px; border-radius: 999px;
  border: 2px solid var(--line); background: var(--surface); color: var(--text);
  font-size: 15px; font-weight: 600;
}
.theme-chip.selected { border-color: var(--accent); background: var(--accent-soft); font-weight: 800; }

.answers { border-top: 1px solid var(--line); }
.answer-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.label-input {
  width: 100%; min-height: var(--tap);
  font-size: 17px; font-weight: 700;
  padding: 10px 12px; border: 2px solid var(--line); border-radius: 14px;
  background: var(--surface-2); color: var(--text);
}
.label-input:focus { outline: none; border-color: var(--accent); }

.ask-hint { color: var(--danger); font-weight: 700; text-align: center; }

.install-hint { display: flex; gap: 10px; align-items: flex-start; background: var(--accent-soft); }
.install-hint p { font-size: 15px; margin-top: 4px; }

.list { padding: 4px 0; }
.list-item {
  width: 100%; min-height: var(--tap);
  display: flex; align-items: center; gap: 12px;
  padding: 10px 16px; border: 0; background: none; text-align: left;
}
.list-item + .list-item { border-top: 1px solid var(--line); }
.list-icon { font-size: 22px; }
.list-main { flex: 1; font-weight: 700; overflow-wrap: anywhere; }
.list-detail { font-size: 14px; color: var(--muted); white-space: nowrap; }

/* ---- trophies and settings ------------------------------------------------------------- */

.big-number { font-size: 48px; font-weight: 900; color: var(--accent); line-height: 1; }
.badge-list { display: flex; flex-wrap: wrap; gap: 8px; }
.badge-chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 6px 12px; border-radius: 999px;
  background: var(--accent-soft); font-weight: 700; font-size: 15px;
}

.back-link { justify-self: start; }
.settings-section { display: grid; gap: 8px; }
.settings-section h3 { font-size: 15px; font-weight: 800; color: var(--muted); margin-left: 4px; }
.settings-section .card { display: grid; gap: 14px; }
.setting-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.setting-label { font-weight: 700; }

.segmented { display: inline-flex; padding: 3px; gap: 2px; border-radius: 999px; background: var(--surface-2); }
.segment {
  min-height: 38px; padding: 0 14px; border: 0; border-radius: 999px;
  background: none; color: var(--muted); font-size: 15px; font-weight: 700;
}
.segment.selected { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgb(0 0 0 / 0.15); }

.help details { border-top: 1px solid var(--line); }
.help details:first-child { border-top: 0; }
.help p { padding-bottom: 10px; color: var(--text); }

/* ---- sheets and toasts ---------------------------------------------------------------- */

.sheet {
  width: 100%; max-width: 560px; margin: auto auto 0;
  padding: 0; border: 0; border-radius: 24px 24px 0 0;
  background: var(--surface); color: var(--text);
}
.sheet::backdrop { background: rgb(22 14 28 / 0.45); }
.sheet-inner { display: grid; gap: 14px; padding: 18px 18px calc(var(--safe-bottom) + 18px); }
.sheet-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.sheet-header h2 { font-size: 20px; font-weight: 900; }
.sheet-actions { display: flex; gap: 10px; }
.sheet-actions .button { flex: 1; }
.sheet-error { color: var(--danger); font-weight: 700; }

.toast-host {
  position: fixed; left: 0; right: 0; z-index: 70;
  bottom: calc(var(--safe-bottom) + 76px);
  display: grid; justify-items: center; padding: 0 16px; pointer-events: none;
}
.toast {
  display: flex; align-items: center; gap: 12px;
  max-width: 520px; padding: 12px 16px; border-radius: 16px;
  background: #261530; color: #fff; font-weight: 600;
  box-shadow: 0 12px 30px -10px rgb(0 0 0 / 0.5);
  pointer-events: auto;
  animation: rise 0.25s ease-out;
}
.toast.error { background: #7f1d1d; }
.toast-action { border: 0; background: none; color: #f5d0fe; font-weight: 800; padding: 6px 0; white-space: nowrap; }

/* ---- curtain -------------------------------------------------------------------------- */

.curtain {
  position: fixed; inset: 0; z-index: 45;
  display: grid; place-items: center;
  padding: calc(var(--safe-top) + 24px) 24px calc(var(--safe-bottom) + 24px);
  background: linear-gradient(160deg, var(--ga), var(--gb));
  color: #fff; text-align: center;
}
.curtain-inner { display: grid; gap: 14px; justify-items: center; width: 100%; max-width: 420px; }
.curtain-emoji { font-size: 88px; line-height: 1; animation: bob 2.4s ease-in-out infinite; }
.curtain h1 { font-size: 32px; font-weight: 900; }
.curtain p { font-size: 18px; font-weight: 600; }
.curtain .reveal { margin-top: 18px; background: #fff; color: #5b21b6; box-shadow: 0 14px 30px -12px rgb(0 0 0 / 0.5); }
.curtain-cancel { color: #fff; }

/* ---- game ----------------------------------------------------------------------------- */

.game {
  position: fixed; inset: 0; z-index: 40;
  overflow: hidden;
  background: linear-gradient(160deg, var(--ga), var(--gb));
  color: #fff;
  touch-action: none;
  -webkit-user-select: none; user-select: none;
  -webkit-touch-callout: none;
  overscroll-behavior: none;
}
.game-safe {
  position: absolute; inset: 0;
  padding: var(--safe-top) var(--safe-right) var(--safe-bottom) var(--safe-left);
  visibility: hidden; pointer-events: none;
}
.game-top {
  position: absolute; top: 0; left: 0; right: 0;
  padding: calc(var(--safe-top) + 8px) calc(var(--safe-right) + 16px) 0 calc(var(--safe-left) + 16px);
}
.game-bar { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.exit {
  position: relative; width: 44px; height: 44px; flex: none;
  display: grid; place-items: center;
  border: 0; border-radius: 50%;
  background: rgb(0 0 0 / 0.22); color: #fff;
}
.exit-ring { position: absolute; inset: 0; width: 44px; height: 44px; transform: rotate(-90deg); }
.exit-ring circle { fill: none; stroke: #fff; stroke-width: 3; stroke-linecap: round; stroke-dasharray: 126; stroke-dashoffset: 126; }
.exit.holding .exit-ring circle { stroke-dashoffset: 0; transition: stroke-dashoffset 1s linear; }
.counter {
  padding: 6px 12px; border-radius: 999px;
  background: rgb(0 0 0 / 0.22);
  font-size: 15px; font-weight: 800; font-variant-numeric: tabular-nums;
}
.game-question {
  margin-top: 12px;
  font-size: 28px; font-weight: 900; line-height: 1.2; text-align: center;
  text-shadow: 0 2px 12px rgb(0 0 0 / 0.25);
  overflow-wrap: anywhere;
}
@media (max-width: 360px) { .game-question { font-size: 24px; } }
@media (orientation: landscape) and (max-height: 500px) {
  .game-top { display: flex; align-items: center; gap: 14px; }
  .game-question { margin: 0; flex: 1; font-size: 21px; text-align: left; }
}

.yes-btn, .no-btn { position: absolute; left: 0; top: 0; pointer-events: none; will-change: transform; }
.yes-btn { z-index: 2; transition: transform 0.25s ease, width 0.25s ease, height 0.25s ease; }
.no-btn { z-index: 3; transition: transform 140ms cubic-bezier(0.2, 0.9, 0.3, 1.25), width 0.2s ease, height 0.2s ease; }
.yes-face, .no-face {
  display: grid; place-items: center;
  width: 100%; height: 100%;
  border-radius: 999px;
  font-weight: 900; line-height: 1; white-space: nowrap;
}
.yes-face {
  background: var(--yes); color: var(--yes-text);
  box-shadow: 0 0 0 4px rgb(255 255 255 / 0.9), 0 16px 30px -10px rgb(0 0 0 / 0.5);
  animation: bob 2.6s ease-in-out infinite;
}
.no-face {
  background: var(--no); color: var(--no-text);
  box-shadow: 0 0 0 3px rgb(255 255 255 / 0.75), 0 12px 24px -10px rgb(0 0 0 / 0.5);
  animation: bob 2.1s ease-in-out infinite reverse;
}
.game.level-2 .no-face, .game.level-3 .no-face { animation: wobble 0.9s ease-in-out infinite; }
.game.level-4 .no-face { animation: wobble 0.6s ease-in-out infinite; }
.game.level-5 .no-face { animation: wobble 0.5s ease-in-out infinite; }
.game.level-5 .yes-face { animation: pulse 0.9s ease-in-out infinite; }
.no-btn.fake .no-face { animation: shiver 0.08s linear infinite; }
.game.tired .no-face { background: var(--tired); transform: rotate(8deg); animation: none; }

.bubble {
  position: absolute; left: 0; top: 0; z-index: 4;
  max-width: 220px; padding: 8px 12px;
  border-radius: 16px;
  background: #fff; color: var(--card-text);
  font-size: 16px; font-weight: 800; text-align: center;
  box-shadow: 0 10px 24px -10px rgb(0 0 0 / 0.5);
  pointer-events: none;
}
.bubble::after {
  content: ""; position: absolute; left: 50%; bottom: -7px;
  width: 14px; height: 14px; margin-left: -7px;
  background: #fff; transform: rotate(45deg); border-radius: 3px;
}
.bubble.below::after { bottom: auto; top: -7px; }

.game.flash::after {
  content: ""; position: absolute; inset: 0; z-index: 5;
  background: rgb(255 255 255 / 0.35); pointer-events: none;
  animation: fade-out 0.45s ease-out forwards;
}

/* ---- celebration and result ------------------------------------------------------------- */

.celebration {
  position: fixed; inset: 0; z-index: 50;
  display: grid; place-items: center;
  overflow: hidden;
  background: rgb(0 0 0 / 0.25);
}
.drop {
  position: absolute; top: -70px; left: var(--x);
  font-size: var(--size); line-height: 1;
  animation: fall var(--fall) linear var(--delay) both;
}
.celebration-card {
  display: grid; gap: 6px; justify-items: center;
  margin: 24px; padding: 26px 30px; border-radius: 30px;
  background: #fff; color: var(--card-text); text-align: center;
  box-shadow: 0 24px 60px -20px rgb(0 0 0 / 0.6);
  animation: pop 0.5s cubic-bezier(0.2, 1.5, 0.4, 1) both;
}
.celebration-card strong { font-size: 52px; font-weight: 900; line-height: 1.05; color: var(--card-yes); overflow-wrap: anywhere; }
.celebration.sad .celebration-card strong { color: var(--card-no); }
.celebration-card span { font-size: 18px; font-weight: 700; color: var(--card-muted); }

.result {
  position: fixed; inset: 0; z-index: 30;
  overflow-y: auto;
  display: flex; flex-direction: column; justify-content: center; gap: 18px;
  padding: calc(var(--safe-top) + 20px) calc(var(--safe-right) + 16px) calc(var(--safe-bottom) + 20px) calc(var(--safe-left) + 16px);
  background: var(--bg);
}
.result-card, .result-actions { width: 100%; max-width: 480px; margin: 0 auto; }
.result-card {
  padding: 28px 20px 18px; border-radius: 30px;
  background: linear-gradient(160deg, var(--ga), var(--gb));
  color: #fff; text-align: center;
  box-shadow: 0 20px 44px -18px rgb(0 0 0 / 0.55);
}
.result-question { font-size: 22px; font-weight: 900; line-height: 1.25; overflow-wrap: anywhere; }
.result-answer {
  display: inline-block; margin: 18px 0 12px; padding: 10px 30px;
  border-radius: 999px; font-size: 40px; font-weight: 900;
  box-shadow: 0 0 0 4px rgb(255 255 255 / 0.9);
}
.result-answer.yes { background: var(--yes); color: var(--yes-text); }
.result-answer.no { background: var(--no); color: var(--no-text); }
.result-how { font-size: 18px; font-weight: 700; }
.result-badges { margin-top: 14px; display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; }
.result-badges-title { width: 100%; font-weight: 800; }
.result .badge-chip { background: rgb(0 0 0 / 0.22); color: #fff; }
.result-brand { margin-top: 18px; font-size: 14px; font-weight: 800; opacity: 0.9; }
.result-actions { display: grid; gap: 10px; }

/* ---- motion --------------------------------------------------------------------------- */

@keyframes bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-5px); } }
@keyframes wobble { 0%, 100% { transform: rotate(-6deg); } 50% { transform: rotate(6deg) translateY(-3px); } }
@keyframes pulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.06); } }
@keyframes shiver { 0% { transform: translateX(-1.5px); } 50% { transform: translateX(1.5px); } 100% { transform: translateX(-1.5px); } }
@keyframes fall { to { transform: translateY(calc(100vh + 140px)) rotate(var(--spin)); } }
@keyframes pop { from { transform: scale(0.4); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@keyframes rise { from { transform: translateY(12px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes fade-out { from { opacity: 1; } to { opacity: 0; } }

.game.reduced .yes-btn, .game.reduced .no-btn { transition: none; }
.game.reduced .yes-face, .game.reduced .no-face { animation: none; }
.game.reduced.flash::after { animation: none; opacity: 0; }

@media (prefers-reduced-motion: reduce) {
  .yes-btn, .no-btn, .exit.holding .exit-ring circle { transition: none; }
  .yes-face, .no-face, .curtain-emoji, .celebration-card, .toast { animation: none; }
  .game.flash::after { animation: none; opacity: 0; }
}
