/* =========================================================================
   Duell – Art-Déco-Theme (Gold auf Mattschwarz)
   ========================================================================= */

@font-face {
  font-family: 'Limelight';
  src: url('/fonts/limelight.woff2') format('woff2');
  font-weight: 400; font-display: swap;
}
@font-face {
  font-family: 'Marcellus';
  src: url('/fonts/marcellus.woff2') format('woff2');
  font-weight: 400; font-display: swap;
}
@font-face {
  font-family: 'Cinzel';
  src: url('/fonts/cinzel.woff2') format('woff2');
  font-weight: 500 700; font-display: swap;
}

:root {
  --ink:        #0c0b09;
  --ink-2:      #15120c;
  --ink-3:      #1d1810;
  --gold:       #c8a24c;
  --gold-soft:  #b6924a;
  --gold-deep:  #7d6128;
  --gold-bright:#ecd08a;
  --line:       rgba(200, 162, 76, .55);
  --line-dim:   rgba(200, 162, 76, .28);
  --cream:      #efe4c8;
  --cream-dim:  rgba(239, 228, 200, .72);
  --danger:     #cf6a55;

  --gold-grad: linear-gradient(168deg,#f7e6b4 0%,#dcb462 26%,#b3852f 52%,#edcd84 74%,#c89a45 100%);
  --font-display: 'Limelight', 'Cinzel', Georgia, serif;
  --font-head: 'Cinzel', Georgia, serif;
  --font-body: 'Marcellus', Georgia, 'Times New Roman', serif;

  --ease: cubic-bezier(.2,.72,.2,1);
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

html, body { height: 100%; overflow: hidden; }

body {
  font-family: var(--font-body);
  color: var(--cream);
  background:
    radial-gradient(120% 80% at 50% -10%, #1a160e 0%, var(--ink) 60%) fixed,
    var(--ink);
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

#app { position: relative; width: 100%; height: 100dvh; }

/* ---------------------------------------------------------------- screens */
.screen {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: calc(env(safe-area-inset-top) + 18px) 20px calc(env(safe-area-inset-bottom) + 18px);
  opacity: 0; visibility: hidden;
  transform: translateY(12px) scale(.992);
  transition: opacity .5s var(--ease), transform .5s var(--ease), visibility .5s;
  overflow: auto;
}
.screen.is-active { opacity: 1; visibility: visible; transform: none; }
#app.loading .screen { transition: none; }

.vignette {
  position: absolute; inset: 0; pointer-events: none; z-index: 0;
  background:
    radial-gradient(130% 90% at 50% 50%, transparent 52%, rgba(0,0,0,.55) 100%),
    repeating-linear-gradient(135deg, rgba(255,255,255,.012) 0 2px, transparent 2px 5px);
}

/* ---------------------------------------------------------------- gold text */
.logo-word, .logo-das, .panel-title, .q-answer-value, .ring-num,
.front-banner, .deco-card-title, .settings-title, .greeting b {
  background: var(--gold-grad);
  -webkit-background-clip: text; background-clip: text;
  color: transparent;
}

/* ---------------------------------------------------------------- logo */
.logo {
  --w: clamp(2.4rem, 11vw, 4.2rem);
  display: flex; flex-direction: column; align-items: center;
  user-select: none; line-height: 1;
}
.logo-das {
  font-family: var(--font-head); font-weight: 600;
  letter-spacing: .42em; text-indent: .42em;
  font-size: calc(var(--w) * .26);
  margin-bottom: calc(var(--w) * .12);
  opacity: .92;
}
.logo-main { display: flex; align-items: center; gap: calc(var(--w) * .28); }
.logo-word {
  font-family: var(--font-display);
  font-size: var(--w); letter-spacing: .04em;
  filter: drop-shadow(0 1px 0 rgba(0,0,0,.6));
}
.logo-mid {
  width: calc(var(--w) * .92); height: calc(var(--w) * .92);
  flex: none; position: relative;
  display: grid; place-items: center;
  transform: rotate(45deg);
  border: 1.5px solid var(--gold);
  box-shadow: inset 0 0 0 4px transparent, inset 0 0 0 5px var(--line-dim),
              0 0 0 4px transparent, 0 0 0 5px var(--line-dim);
}
.logo-um {
  transform: rotate(-45deg);
  font-family: var(--font-head); font-weight: 600;
  font-size: calc(var(--w) * .2); line-height: 1; text-align: center;
  color: var(--gold-bright); letter-spacing: .04em;
}
.logo-rule {
  margin-top: calc(var(--w) * .32);
  width: calc(var(--w) * 4.4); height: 1px; max-width: 70vw;
  background: linear-gradient(90deg, transparent, var(--gold) 18%, var(--gold) 82%, transparent);
  position: relative;
}
.logo-rule::after {
  content: '✦'; position: absolute; top: 50%; left: 50%;
  transform: translate(-50%,-52%); font-size: calc(var(--w)*.28);
  color: var(--gold); background: var(--ink); padding: 0 .5em;
}
.logo--sm { --w: clamp(1.9rem, 9vw, 2.6rem); }
.logo--md { --w: clamp(2.1rem, 8.5vw, 3.4rem); }
.logo--lg { --w: clamp(2.2rem, 10vw, 3.8rem); }

/* ---------------------------------------------------------------- buttons */
.gold-btn {
  font-family: var(--font-head); font-weight: 600;
  letter-spacing: .14em; text-transform: uppercase;
  font-size: 1rem; color: #20180a;
  background: var(--gold-grad);
  border: none; border-radius: 999px;
  padding: 16px 34px; cursor: pointer;
  box-shadow: 0 2px 0 rgba(0,0,0,.5), 0 0 0 1px var(--gold-deep),
              inset 0 1px 0 rgba(255,255,255,.45);
  transition: transform .18s var(--ease), box-shadow .25s var(--ease), filter .25s;
  position: relative; overflow: hidden;
}
.gold-btn::after {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(110deg, transparent 20%, rgba(255,255,255,.55) 50%, transparent 80%);
  transform: translateX(-130%); transition: transform .8s var(--ease);
}
.gold-btn:hover::after { transform: translateX(130%); }
.gold-btn:active { transform: translateY(1px) scale(.985); }
.gold-btn.slim { padding: 12px 26px; font-size: .92rem; }
.gold-btn[disabled] { filter: grayscale(.5) opacity(.6); pointer-events: none; }

.start-btn { margin-top: 6px; font-size: 1.12rem; padding: 18px 44px; }

.ghost-btn {
  font-family: var(--font-head); font-weight: 600;
  letter-spacing: .12em; text-transform: uppercase; font-size: .82rem;
  color: var(--gold); background: transparent;
  border: 1px solid var(--line); border-radius: 999px;
  padding: 13px 22px; cursor: pointer; width: 100%;
  transition: background .25s var(--ease), border-color .25s, color .25s, transform .15s;
}
.ghost-btn:hover { background: rgba(200,162,76,.08); border-color: var(--gold); }
.ghost-btn:active { transform: translateY(1px); }
.ghost-btn.danger { color: var(--danger); border-color: rgba(207,106,85,.45); }
.ghost-btn.danger:hover { background: rgba(207,106,85,.1); border-color: var(--danger); }

.icon-btn {
  width: 44px; height: 44px; flex: none;
  display: grid; place-items: center;
  background: transparent; border: 1px solid var(--line-dim);
  border-radius: 50%; color: var(--gold); cursor: pointer;
  transition: border-color .25s, background .25s, transform .15s, opacity .25s;
}
.icon-btn:hover { border-color: var(--gold); background: rgba(200,162,76,.07); }
.icon-btn:active { transform: scale(.92); }
.icon-btn.placeholder { border: none; pointer-events: none; }
.icon-btn .ic { width: 22px; height: 22px; }
.corner-tr { position: absolute; top: calc(env(safe-area-inset-top) + 16px); right: 18px; z-index: 5; }

/* ---------------------------------------------------------------- fields */
.field { display: block; margin-bottom: 16px; text-align: left; }
.field-label {
  display: block; font-family: var(--font-head); font-weight: 600;
  font-size: .7rem; letter-spacing: .2em; text-transform: uppercase;
  color: var(--gold-soft); margin: 0 0 7px 4px;
}
.field input {
  width: 100%; font-family: var(--font-body); font-size: 1.15rem;
  color: var(--cream); background: rgba(0,0,0,.35);
  border: 1px solid var(--line-dim); border-radius: 12px;
  padding: 13px 15px; outline: none;
  transition: border-color .25s, box-shadow .25s, background .25s;
}
.field input:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(200,162,76,.16);
  background: rgba(0,0,0,.5);
}
.form-error {
  min-height: 1.1em; color: var(--danger); font-size: .9rem;
  letter-spacing: .02em; margin: 2px 2px 12px; text-align: center;
  opacity: 0; transform: translateY(-4px); transition: opacity .3s, transform .3s;
}
.form-error.show { opacity: 1; transform: none; }

/* ---------------------------------------------------------------- panels */
.deco-panel {
  position: relative; z-index: 1;
  width: min(94vw, 380px);
  background: linear-gradient(180deg, var(--ink-2), var(--ink));
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 34px 28px 30px;
  box-shadow: 0 24px 60px rgba(0,0,0,.6), inset 0 0 0 1px rgba(0,0,0,.5),
              inset 0 0 0 7px transparent, inset 0 0 0 8px var(--line-dim);
}
.login-panel .logo { margin-bottom: 26px; }
.login-panel form { margin-top: 4px; }
.login-panel .gold-btn { width: 100%; margin-top: 6px; }

/* ---------------------------------------------------------------- home */
.home-inner {
  position: relative; z-index: 1;
  display: flex; flex-direction: column; align-items: center;
  gap: 26px; text-align: center;
}
.greeting { font-size: 1.05rem; color: var(--cream-dim); letter-spacing: .03em; }
.greeting span { color: var(--gold-bright); }

/* ---------------------------------------------------------------- game top */
#screen-game { justify-content: flex-start; padding-top: 0; padding-bottom: 0; }
.game-top {
  position: relative; z-index: 4;
  width: 100%; max-width: 640px;
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(env(safe-area-inset-top) + 12px) 4px 6px;
}
.game-progress {
  font-family: var(--font-head); font-weight: 600;
  letter-spacing: .26em; font-size: .82rem; color: var(--gold-soft);
}

/* ---------------------------------------------------------------- stage + card */
.stage {
  position: relative; z-index: 1; flex: 1; width: 100%;
  display: grid; place-items: center;
  perspective: 1800px; padding: 8px 0 4px;
}
.card {
  position: relative;
  width: min(92vw, 520px);
  height: min(74dvh, 700px);
  will-change: transform;
  user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
}
.card-inner {
  position: absolute; inset: 0;
  transform-style: preserve-3d;
  transition: transform .8s var(--ease);
}
.card.flipped .card-inner { transform: rotateY(180deg); }

.card-face {
  position: absolute; inset: 0;
  backface-visibility: hidden; -webkit-backface-visibility: hidden;
  border-radius: 18px; overflow: hidden;
  background:
    radial-gradient(120% 100% at 50% 0%, #191309 0%, var(--ink-2) 55%, #0a0805 100%);
  box-shadow: 0 26px 60px rgba(0,0,0,.62), 0 2px 0 rgba(255,255,255,.04),
              inset 0 0 70px rgba(0,0,0,.55);
}
.card-front { transform: rotateY(180deg); }

/* frame (gemeinsam) */
.frame {
  position: absolute; inset: 12px;
  border: 1.5px solid var(--gold);
  border-radius: 8px;
  display: flex; flex-direction: column;
}
.frame::before {
  content: ''; position: absolute; inset: 6px;
  border: 1px solid var(--line-dim); border-radius: 4px; pointer-events: none;
}

/* Art-Déco-Ecken */
.corner { position: absolute; width: 30px; height: 30px; pointer-events: none; }
.corner::before, .corner::after { content: ''; position: absolute; background: var(--gold); }
.corner::before { left: 0; top: 0; width: 30px; height: 2px; }
.corner::after  { left: 0; top: 0; width: 2px; height: 30px; }
.corner.c-tl { left: -1px; top: -1px; }
.corner.c-tr { right: -1px; top: -1px; transform: scaleX(-1); }
.corner.c-bl { left: -1px; bottom: -1px; transform: scaleY(-1); }
.corner.c-br { right: -1px; bottom: -1px; transform: scale(-1,-1); }
/* zweite, eingerückte Eck-Linie */
.frame--back .corner { width: 42px; height: 42px; }
.frame--back .corner::before { width: 42px; } .frame--back .corner::after { height: 42px; }
.frame .corner i { display: none; }

/* gestufte Fächer (Rückseite) */
.steps {
  position: absolute; left: 50%; transform: translateX(-50%);
  display: flex; flex-direction: column; align-items: center; gap: 3px;
}
.steps i { display: block; height: 2px; background: var(--gold); border-radius: 1px; }
.steps i:nth-child(1) { width: 46px; } .steps i:nth-child(2) { width: 36px; }
.steps i:nth-child(3) { width: 26px; } .steps i:nth-child(4) { width: 16px; }
.steps i:nth-child(5) { width: 7px; }
.steps--top { top: 14px; }
.steps--bottom { bottom: 14px; flex-direction: column-reverse; }

/* Rückseiten-Mitte */
.back-center {
  margin: auto; display: flex; flex-direction: column; align-items: center;
  gap: 14px; padding: 10px; z-index: 1;
}
.back-flourish { color: var(--gold-soft); font-size: 1.1rem; opacity: .8; }
.card-back { cursor: pointer; }
.card-back .frame--back { animation: backGlow 5s ease-in-out infinite; }
@keyframes backGlow {
  0%,100% { box-shadow: none; } 50% { box-shadow: 0 0 26px rgba(200,162,76,.08); }
}

/* Vorderseite (Frage) */
.front-banner {
  flex: none; text-align: center; padding: 14px 10px 8px;
  font-family: var(--font-head); font-weight: 600;
  letter-spacing: .22em; font-size: .82rem;
}
.front-banner .diamond { color: var(--gold); margin: 0 .35em; font-size: .7em; vertical-align: middle; }
.front-scroll {
  flex: 1; overflow-y: auto; overscroll-behavior: contain;
  scrollbar-width: thin; scrollbar-color: var(--line-dim) transparent;
  padding: 4px 6px;
  -webkit-mask-image: linear-gradient(180deg, transparent 0, #000 14px, #000 calc(100% - 14px), transparent 100%);
          mask-image: linear-gradient(180deg, transparent 0, #000 14px, #000 calc(100% - 14px), transparent 100%);
}
.front-scroll::-webkit-scrollbar { width: 5px; }
.front-scroll::-webkit-scrollbar-thumb { background: var(--line-dim); border-radius: 3px; }
.front-content {
  min-height: 100%;
  display: flex; flex-direction: column; align-items: center; justify-content: flex-start;
  gap: 18px; padding: 12px clamp(14px, 5vw, 30px) 22px; text-align: center;
}
.q-question {
  font-size: clamp(1.15rem, 2.4vw + .8rem, 1.6rem);
  line-height: 1.34; color: var(--gold-bright);
  letter-spacing: .01em; text-wrap: balance;
}
.q-hints { display: flex; flex-direction: column; gap: 16px; width: 100%; }

.hint {
  position: relative; padding-top: 16px;
  font-size: clamp(1rem, 1.3vw + .76rem, 1.24rem);
  line-height: 1.38; color: var(--cream);
  opacity: 0; transform: translateY(16px); filter: blur(7px);
  transition: opacity .6s var(--ease), transform .6s var(--ease), filter .6s var(--ease);
}
.hint::before {
  content: '✦'; position: absolute; top: -2px; left: 50%;
  transform: translateX(-50%); color: var(--gold); font-size: .7rem; opacity: .85;
}
.hint.show { opacity: 1; transform: none; filter: none; }

.q-answer {
  width: 100%; margin-top: 4px;
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  opacity: 0; transform: translateY(18px) scale(.9);
  transition: opacity .55s var(--ease), transform .55s var(--ease);
  pointer-events: none;
}
.q-answer.show { opacity: 1; transform: none; }
.q-answer-label {
  font-family: var(--font-head); font-weight: 600; letter-spacing: .3em;
  text-transform: uppercase; font-size: .72rem; color: var(--gold-soft);
}
.q-answer-value {
  font-family: var(--font-display);
  font-size: clamp(3rem, 13vw, 5.2rem); line-height: 1;
  text-shadow: 0 0 24px rgba(200,162,76,.5), 0 0 6px rgba(200,162,76,.35);
}
.q-answer.show .q-answer-value { animation: answerPop .7s var(--ease) both; }
@keyframes answerPop {
  0% { transform: scale(.6); opacity: 0; }
  60% { transform: scale(1.08); opacity: 1; }
  100% { transform: scale(1); }
}

/* Karten-Übergänge */
.card.leaving  { animation: cardLeave .42s var(--ease) forwards; }
.card.entering { animation: cardEnter .5s var(--ease) both; }
@keyframes cardLeave {
  to { transform: translateX(-62vw) rotateZ(-7deg); opacity: 0; }
}
@keyframes cardEnter {
  from { transform: translateX(58vw) rotateZ(6deg); opacity: 0; }
  to   { transform: none; opacity: 1; }
}

/* ---------------------------------------------------------------- cue */
.cue {
  position: relative; z-index: 3;
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 10px 0 calc(env(safe-area-inset-bottom) + 12px);
  color: var(--gold-soft); transition: opacity .4s var(--ease);
  min-height: 58px;
}
.cue.hidden { opacity: 0; pointer-events: none; }
.cue-text {
  font-family: var(--font-head); font-weight: 600;
  letter-spacing: .18em; text-transform: uppercase; font-size: .74rem;
}
.cue-chevron { width: 22px; height: 22px; position: relative; }
.cue-chevron::before, .cue-chevron::after {
  content: ''; position: absolute; left: 50%; width: 12px; height: 2px;
  background: var(--gold); border-radius: 2px; top: 8px;
}
.cue-chevron::before { transform: translateX(-50%) rotate(45deg) translateX(-3px); }
.cue-chevron::after  { transform: translateX(-50%) rotate(-45deg) translateX(3px); }
.cue[data-dir="up"] .cue-chevron { animation: bobUp 1.6s ease-in-out infinite; }
.cue[data-dir="tap"] .cue-chevron { animation: tapPulse 1.7s ease-in-out infinite; }
.cue[data-dir="left"] .cue-chevron { transform: rotate(90deg); animation: bobLeft 1.6s ease-in-out infinite; }
@keyframes bobUp { 0%,100% { transform: translateY(2px); } 50% { transform: translateY(-4px); } }
@keyframes bobLeft { 0%,100% { transform: rotate(90deg) translateY(2px); } 50% { transform: rotate(90deg) translateY(-5px); } }
@keyframes tapPulse { 0%,100% { transform: scale(.85); opacity: .5; } 50% { transform: scale(1.05); opacity: 1; } }
.cue[data-dir="tap"] .cue-chevron::before,
.cue[data-dir="tap"] .cue-chevron::after { display: none; }
.cue[data-dir="tap"] .cue-chevron {
  border: 2px solid var(--gold); border-radius: 50%; width: 18px; height: 18px;
}

/* ---------------------------------------------------------------- settings */
#screen-settings { justify-content: flex-start; }
.settings-top {
  position: relative; z-index: 2; width: min(94vw, 460px);
  display: flex; align-items: center; justify-content: space-between;
  padding-top: 6px; margin-bottom: 18px;
}
.settings-title {
  font-family: var(--font-head); font-weight: 600;
  letter-spacing: .16em; text-transform: uppercase; font-size: 1.1rem;
}
.settings-body {
  position: relative; z-index: 1; width: min(94vw, 460px);
  display: flex; flex-direction: column; gap: 18px; padding-bottom: 30px;
}
.deco-card {
  background: linear-gradient(180deg, var(--ink-2), var(--ink));
  border: 1px solid var(--line-dim); border-radius: 16px;
  padding: 22px 20px;
  box-shadow: inset 0 0 0 6px transparent, inset 0 0 0 7px rgba(200,162,76,.12);
}
.deco-card-title {
  font-family: var(--font-head); font-weight: 600;
  letter-spacing: .14em; text-transform: uppercase; font-size: .82rem;
  text-align: center; margin-bottom: 18px;
}
.progress-wrap { position: relative; width: 150px; height: 150px; margin: 0 auto 18px; }
.ring { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring-track { fill: none; stroke: rgba(200,162,76,.16); stroke-width: 8; }
.ring-fill {
  fill: none; stroke: var(--gold); stroke-width: 8; stroke-linecap: round;
  stroke-dasharray: 326.7; stroke-dashoffset: 326.7;
  transition: stroke-dashoffset 1s var(--ease);
  filter: drop-shadow(0 0 6px rgba(200,162,76,.4));
}
.ring-center {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 2px;
}
.ring-num { font-family: var(--font-display); font-size: 1.7rem; }
.ring-sub {
  font-family: var(--font-head); font-size: .66rem; letter-spacing: .22em;
  text-transform: uppercase; color: var(--gold-soft);
}
#pin-form .gold-btn { width: 100%; margin-top: 4px; }

/* ---------------------------------------------------------------- toast */
#toast {
  position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom) + 26px);
  transform: translate(-50%, 20px); z-index: 50;
  background: rgba(20,16,10,.96); color: var(--cream);
  border: 1px solid var(--line); border-radius: 12px;
  padding: 13px 20px; font-size: .94rem; letter-spacing: .02em;
  box-shadow: 0 16px 40px rgba(0,0,0,.6);
  opacity: 0; pointer-events: none; transition: opacity .3s, transform .3s var(--ease);
  max-width: 86vw; text-align: center;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }
#toast.err { border-color: rgba(207,106,85,.6); color: #f0c8bf; }

/* ---------------------------------------------------------------- landscape (phones) */
@media (orientation: landscape) and (max-height: 560px) {
  #screen-game { overflow: hidden; }
  .stage { min-height: 0; padding: 4px 0; }
  .card { width: min(72vw, 720px); height: min(72dvh, 300px); }
  .front-content { gap: 12px; padding-top: 6px; }
  .q-question { font-size: clamp(1rem, 1.4vw + .7rem, 1.4rem); line-height: 1.26; }
  .hint { font-size: clamp(.92rem, 1vw + .68rem, 1.12rem); padding-top: 12px; }
  .q-answer-value { font-size: clamp(2.4rem, 9vw, 4rem); }
  .front-banner { padding: 8px 10px 4px; }
  .cue { min-height: 44px; padding-top: 4px; }
  .logo--lg { --w: clamp(2.2rem, 9vw, 3.4rem); }
  .home-inner { gap: 16px; }
  .login-panel { padding: 22px 26px; }
  .login-panel .logo { margin-bottom: 14px; }
}

/* ---------------------------------------------------------------- a11y */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .08s !important; }
  .card-inner { transition: transform .25s linear; }
}

@media (max-height: 720px) and (orientation: portrait) {
  .card { height: min(70dvh, 620px); }
}
