/* Ganze Bildschirme: Titel, neues Spiel und Ende. Hinter allen liegt die Stadt als Kulisse. */

.backdrop { position: fixed; inset: 0; z-index: -1; line-height: 0; background: var(--lapis-900); }
.backdrop svg { width: 100%; height: 100%; display: block; }
.backdrop::after { content: ""; position: absolute; inset: 0; background: rgba(7, 13, 24, .72); }

.title-screen, .end-screen { position: relative; min-height: 100vh; min-height: 100dvh; padding: 2rem 1.2rem; }
.continue { display: flex; gap: .5rem; justify-content: center; flex-wrap: wrap; margin: 0 0 1.1rem; }

/* ───── Hauptmenü ───── */
.title-tools { position: absolute; z-index: 2; top: calc(.7rem + var(--safe-t)); inset-inline-end: calc(.8rem + var(--safe-r)); display: flex; gap: .3rem; }
.title-tools .tool { color: var(--paper-50); background: rgba(7, 13, 24, .6); backdrop-filter: blur(4px); }
.title-tools .tool span { display: none; }

/* Das eigene Profil oben links, wie in vielen Spielen: Medaillon in der eigenen Farbe, Name, Neues bei den Freunden.
   Ein Tipp klappt darunter ein kleines Menü auf. Rechts bleibt Platz für Vollbild und Installieren. */
.profile-corner { position: absolute; z-index: 3; top: calc(.7rem + var(--safe-t)); inset-inline-start: calc(.8rem + var(--safe-l)); max-width: calc(100% - 8rem - var(--safe-l) - var(--safe-r)); }
.profile-chip {
  display: flex; align-items: center; gap: .55rem; max-width: 100%; min-height: 48px; padding: .25rem .7rem .25rem .3rem; text-align: start;
  font-family: var(--label); font-weight: 700; font-size: 1rem; line-height: 1.15; color: var(--paper-50);
  background: rgba(7, 13, 24, .66); backdrop-filter: blur(4px); border: 1px solid var(--line); border-radius: 999px;
  transition: border-color .15s, background .15s;
}
.profile-chip:hover, .profile-chip[aria-expanded="true"] { border-color: var(--gold-300); background: rgba(17, 31, 51, .92); }
.profile-chip > span, .profile-pop-head > span { min-width: 0; }
.profile-chip b, .profile-chip small, .profile-pop-head strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.profile-chip small { font-weight: 500; font-size: .78rem; color: var(--paper-300); }
.profile-chip .chev { flex: none; width: 16px; height: 16px; color: var(--gold-300); transform: rotate(90deg); transition: transform .15s; }
.profile-chip[aria-expanded="true"] .chev { transform: rotate(-90deg); }
.profile-avatar {
  position: relative; flex: none; display: grid; place-items: center; width: 38px; height: 38px; border-radius: 50%;
  font-family: var(--display); font-style: normal; font-weight: 700; font-size: 1.25rem; line-height: 1; color: #fff; text-shadow: 0 1px 2px rgba(0, 0, 0, .65);
  background: radial-gradient(circle at 35% 30%, rgba(255, 255, 255, .35), transparent 62%), var(--c);
  border: 2px solid var(--gold-300); box-shadow: 0 0 0 2px rgba(7, 13, 24, .75), 0 2px 8px rgba(0, 0, 0, .45);
}
.profile-alert {
  position: absolute; top: -5px; inset-inline-end: -6px; min-width: 19px; height: 19px; padding: 0 4px; border-radius: 10px;
  font-family: var(--label); font-size: .72rem; font-weight: 700; line-height: 16px; text-align: center; text-shadow: none;
  color: #fff; background: var(--ember); border: 1.5px solid var(--lapis-900);
}
.profile-pop {
  position: absolute; top: calc(100% + .4rem); inset-inline-start: 0; width: min(19rem, calc(100vw - 1.6rem - var(--safe-l) - var(--safe-r)));
  padding: .4rem; background: rgba(13, 24, 41, .97); border: 1px solid var(--line-strong); border-radius: 8px; box-shadow: var(--shadow);
  animation: profile-pop .14s ease-out;
}
.profile-pop[hidden] { display: none; }
@keyframes profile-pop { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }
.profile-pop-head { display: flex; align-items: center; gap: .65rem; padding: .35rem .45rem .6rem; margin-bottom: .3rem; border-bottom: 1px solid var(--line); }
.profile-pop-head .profile-avatar { width: 46px; height: 46px; font-size: 1.5rem; }
.profile-pop-head strong { font-family: var(--display); font-size: 1.25rem; color: var(--gold-100); }
.profile-pop-head small { display: block; font-family: var(--label); font-size: .8rem; color: var(--paper-300); }
.profile-pop-head .friend-code { color: var(--paper-50); letter-spacing: .06em; }
.profile-pop-item {
  display: flex; align-items: center; gap: .65rem; width: 100%; min-height: 48px; padding: .3rem .55rem; text-align: start;
  font-family: var(--label); font-weight: 700; font-size: 1rem; line-height: 1.15; color: var(--paper-50);
  background: none; border: 1px solid transparent; border-radius: 6px;
}
.profile-pop-item:hover, .profile-pop-item:focus-visible { background: rgba(232, 200, 119, .12); border-color: var(--line-strong); }
.profile-pop-item .ic { flex: none; width: 22px; height: 22px; color: var(--gold-300); }
.profile-pop-item small { display: block; font-weight: 500; font-size: .8rem; color: var(--paper-300); }
.hero { display: flex; align-items: center; padding: clamp(1rem, 4vh, 3rem) clamp(1rem, 7vw, 7rem); }
.hero .backdrop::after { background: linear-gradient(90deg, rgba(7, 13, 24, .93) 0, rgba(7, 13, 24, .8) 34%, rgba(7, 13, 24, .1) 66%, transparent 100%), linear-gradient(0deg, rgba(7, 13, 24, .5), transparent 30%); }
.hero-card { width: min(100%, 470px); text-align: center; }
.hero-rosette { display: block; width: 76px; height: 76px; margin: 0 auto .25rem; filter: drop-shadow(0 0 16px rgba(232, 200, 119, .4)); }
.title-screen .ar { font-family: var(--arabic); font-weight: 700; font-size: clamp(4rem, 12vh, 6.2rem); line-height: 1.05; color: var(--gold-300); text-shadow: 0 2px 22px rgba(232, 200, 119, .32); }
.title-screen h1 { font-family: var(--display); font-weight: 600; font-size: clamp(2.2rem, 6vh, 3rem); letter-spacing: .28em; text-indent: .28em; text-transform: uppercase; color: var(--paper-50); }
.title-screen .lead { font-family: var(--display); font-weight: 600; font-style: italic; font-size: 1.4rem; line-height: 1.2; color: var(--gold-100); margin: .15rem 0 .7rem; }
.title-screen .intro { max-width: 620px; margin: 0 auto 1.1rem; font-size: 1.05rem; line-height: 1.42; color: var(--paper-100); }
.main-menu { display: grid; gap: .45rem; text-align: start; }
.menu-item {
  display: flex; align-items: center; gap: .75rem; width: 100%; min-height: 54px; padding: .45rem 1rem; text-align: start;
  font-family: var(--label); font-weight: 700; font-size: 1.08rem; line-height: 1.15; color: var(--paper-50);
  background: linear-gradient(90deg, rgba(33, 57, 90, .78), rgba(17, 31, 51, .6));
  border: 1px solid var(--line); border-radius: 6px;
  transition: border-color .15s, background .15s, transform .15s;
}
.menu-item .ic { width: 24px; height: 24px; color: var(--gold-300); }
.menu-item small { display: block; font-weight: 500; font-size: .85rem; color: var(--paper-300); }
.menu-item:hover, .menu-item:focus-visible { border-color: var(--gold-300); background: linear-gradient(90deg, rgba(33, 57, 90, .96), rgba(33, 57, 90, .7)); transform: translateX(4px); }
.menu-item.first { color: #2a1c08; background: linear-gradient(180deg, var(--gold-100), var(--gold-300) 45%, var(--gold-500)); border-color: var(--gold-700); box-shadow: inset 0 1px 0 rgba(255, 255, 255, .55), 0 4px 14px rgba(0, 0, 0, .35); }
.menu-item.first .ic, .menu-item.first small { color: #4a3510; }
.fine { color: var(--paper-300); font-size: .85rem; line-height: 1.35; max-width: 620px; margin: 1rem auto 0; }
/* Impressum und Datenschutz, auf dem Titelbild und im Fenster „Über dieses Spiel“. Die Ränder machen die Links fingerbreit. */
.legal-links { margin: .2rem 0 0; font-family: var(--label); font-size: .85rem; color: var(--paper-300); }
.legal-links a { display: inline-block; padding: .75rem .35rem; color: inherit; text-underline-offset: 3px; }
.legal-links a:hover { color: var(--gold-100); }
.sheet .legal-links { margin: .6rem 0 0; color: var(--ink-soft); }
.sheet .legal-links a:hover { color: var(--rubric); }

/* ───── Neues Spiel ───── */
.setup-inner { max-width: 1120px; margin: 0 auto; }
.setup-head { position: relative; display: flex; align-items: center; justify-content: center; min-height: 46px; }
.setup-head .back { position: absolute; left: 0; color: var(--paper-50); min-height: 44px; padding-inline: .7rem; }
.setup .lead, .setup-inner > .lead { text-align: center; }
.setup h1 { font-size: clamp(1.7rem, 4vw, 2.5rem); letter-spacing: .12em; text-indent: .12em; }
.start-step { display: flex; align-items: center; gap: .6rem; font-family: var(--display); font-size: 1.7rem; color: var(--gold-100); margin: 1.5rem 0 .15rem; }
.start-step i { display: grid; place-items: center; width: 2rem; height: 2rem; font-family: var(--label); font-style: normal; font-weight: 700; font-size: .98rem; color: var(--lapis-900); background: var(--gold-300); clip-path: polygon(50% 0, 100% 50%, 50% 100%, 0 50%); }
.start-note { font-size: .98rem; color: var(--paper-200); margin: 0 0 .65rem; }
.origins { display: grid; grid-template-columns: repeat(auto-fit, minmax(205px, 1fr)); gap: .6rem; }
/* Die Karten liegen in einem Band: Snap auf jede Karte, die nächste schaut am Rand hervor,
   damit man sieht, dass es weitergeht. Pfeile nur mit Maus, am Touchscreen genügt Wischen. */
.carousel { position: relative; }
.carousel-track {
  display: flex; gap: .7rem; position: relative; overflow-x: auto; overscroll-behavior-x: contain;
  scroll-snap-type: x mandatory; scroll-behavior: smooth; scrollbar-width: none;
  padding: .25rem 0 .35rem; margin: -.25rem 0 0;
}
.carousel-track::-webkit-scrollbar { display: none; }
.carousel-track > * { flex: 0 0 min(370px, 82%); scroll-snap-align: start; }
.carousel-track > .origin:hover { transform: none; }
.carousel[data-at-end="false"] .carousel-track { -webkit-mask-image: linear-gradient(90deg, #000 calc(100% - 4.5rem), transparent); mask-image: linear-gradient(90deg, #000 calc(100% - 4.5rem), transparent); }
.carousel-arrow {
  position: absolute; top: 65px; z-index: 2; translate: 0 -50%;
  display: grid; place-items: center; width: 44px; height: 44px; padding: 0; border-radius: 50%;
  color: var(--gold-300); background: rgba(7, 13, 24, .9); border: 1px solid var(--gold-700);
  box-shadow: 0 4px 14px rgba(0, 0, 0, .45); transition: opacity .15s, border-color .15s;
}
.carousel-arrow.prev { left: -.6rem; }
.carousel-arrow.next { right: -.6rem; }
.carousel-arrow:hover, .carousel-arrow:focus-visible { border-color: var(--gold-300); }
.carousel-arrow:disabled { opacity: 0; pointer-events: none; }
.carousel-dots { display: flex; justify-content: center; gap: .15rem; margin-top: .35rem; }
.carousel-dot { width: 24px; height: 24px; padding: 0; background: none; border: 0; display: grid; place-items: center; }
.carousel-dot::before { content: ""; width: 9px; height: 9px; rotate: 45deg; border: 1px solid var(--gold-700); background: transparent; transition: background .15s, border-color .15s; }
.carousel-dot.seen::before { border-color: var(--gold-300); }
.carousel-dot.chosen::before { background: var(--gold-300); border-color: var(--gold-300); }
@media (hover: none) { .carousel-arrow { display: none; } }
.origin {
  display: flex; flex-direction: column; gap: .2rem; min-height: 54px; padding: .75rem .85rem; text-align: start; overflow: hidden;
  color: var(--paper-100);
  background: linear-gradient(180deg, rgba(33, 57, 90, .82), rgba(17, 31, 51, .92));
  border: 1px solid var(--line); border-radius: 8px;
  transition: border-color .15s, background .15s, transform .15s;
}
.origin:hover, .origin:focus-visible { border-color: var(--gold-300); transform: translateY(-2px); }
.origin.chosen { border-color: var(--gold-300); box-shadow: inset 0 0 0 1px var(--gold-300), 0 0 18px rgba(232, 200, 119, .18); }
.origin strong { display: flex; align-items: center; gap: .45rem; font-family: var(--text); font-weight: 700; font-size: 1.04rem; line-height: 1.2; color: var(--gold-300); margin-bottom: .1rem; }
.origin > span { font-size: .94rem; line-height: 1.3; }
.origin.world { padding-top: 0; }
.world-span { display: block; margin-bottom: .2rem; font-family: var(--label); font-style: normal; font-size: .8rem; letter-spacing: .04em; text-transform: uppercase; color: var(--paper-200); }
.origin .map-thumb { display: block; width: calc(100% + 1.7rem); margin: 0 -.85rem .55rem; height: 130px; border-bottom: 1px solid var(--line); }
/* Die Seite ist lang: Die Leiste bleibt unten stehen, damit Starten immer erreichbar ist. */
.start-bar {
  position: sticky; bottom: calc(.6rem + var(--safe-b)); z-index: 1;
  display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-top: 1.4rem; padding: .6rem .85rem;
  background: rgba(7, 13, 24, .94); border: 1px solid var(--gold-700); border-radius: 8px; box-shadow: 0 6px 20px rgba(0, 0, 0, .45);
}
.start-bar p { margin: 0; min-width: 0; font-family: var(--label); font-weight: 500; font-size: .98rem; line-height: 1.25; color: var(--paper-100); }
.start-bar .primary { flex: none; min-width: 9rem; }
/* Am Handy öffnet jede Zeile ihren Schritt als Fenster von unten. */
.setup-rows { display: none; }
.setup-row {
  display: flex; align-items: center; gap: .7rem; width: 100%; min-height: 68px; padding: .55rem .8rem; text-align: start;
  color: var(--paper-100);
  background: linear-gradient(180deg, rgba(33, 57, 90, .82), rgba(17, 31, 51, .92));
  border: 1px solid var(--line); border-radius: 10px;
}
.setup-row.open { border-color: var(--gold-300); }
.setup-row > span { flex: 1; display: grid; gap: .05rem; min-width: 0; }
.setup-row small { font-family: var(--label); font-weight: 500; font-size: .84rem; color: var(--paper-200); }
.setup-row strong { font-family: var(--text); font-weight: 700; font-size: 1.1rem; line-height: 1.2; color: var(--gold-300); }
.setup-row .world-span { margin: .1rem 0 0; font-size: .72rem; }
.setup-row > .ic { flex: none; color: var(--gold-300); }
.setup-row .map-thumb { flex: none; width: 54px; height: 54px; border-radius: 6px; border: 1px solid var(--line); }
.sheet .start-step { align-items: flex-start; font-size: 1.6rem; line-height: 1.15; margin: 1.3rem 0 .3rem; }
.sheet .start-step:first-child { margin-top: 0; }
.sheet .start-step i { flex: none; }
.sheet .start-note { color: var(--ink-soft); }

/* ───── Ende ───── */
.end-screen { max-width: 860px; margin: 0 auto; }
.end-screen .desk { text-align: start; }
.end-screen .kicker { font-family: var(--label); font-weight: 700; color: var(--gold-300); letter-spacing: .14em; text-transform: uppercase; font-size: .84rem; margin-bottom: .9rem; text-align: center; }
.end-screen h3 { font-family: var(--label); font-weight: 700; font-size: .78rem; letter-spacing: .13em; text-transform: uppercase; color: var(--rubric); margin: 1rem 0 .3rem; }
.end-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: .45rem; margin: 1rem 0; font-family: var(--label); font-weight: 700; font-size: 1.3rem; color: var(--lapis-800); }
.end-stats div { background: var(--paper-50); border: 1px solid var(--paper-300); border-radius: 6px; padding: .4rem .6rem; }
.end-stats small { display: block; font-weight: 500; color: var(--ink-soft); font-size: .78rem; }
.chronicle { max-height: 300px; overflow-y: auto; padding: 0; margin: .3rem 0 1rem; list-style: none; border-top: 1px solid var(--paper-300); }
.chronicle li { padding: .4rem 0; border-bottom: 1px solid var(--paper-300); font-size: .97rem; }
.chronicle small { display: block; color: var(--ink-soft); font-size: .88rem; }

@media (max-width: 760px) {
  .hero { align-items: flex-end; padding: 1rem 1rem calc(1rem + var(--safe-b)); }
  .hero .backdrop::after { background: linear-gradient(0deg, rgba(7, 13, 24, .96) 0, rgba(7, 13, 24, .82) 58%, rgba(7, 13, 24, .22) 100%); }
  .hero-card { margin: 0 auto; }
  .hero-rosette { width: 58px; height: 58px; }
  .title-screen .lead { font-size: 1.25rem; }
  .title-screen .intro { font-size: 1rem; }
  .setup { padding: 1rem .75rem calc(1.5rem + var(--safe-b)); }
  .setup-head .back span { display: none; }
  .setup-inner { display: flex; flex-direction: column; min-height: calc(100dvh - 2.5rem - var(--safe-b)); }
  .setup-inner > .start-note { text-align: center; }
  .setup-steps { display: none; }
  .setup-rows { display: grid; gap: .5rem; margin-block: .4rem 1rem; }
  .origin .map-thumb { height: 110px; }
  .start-bar { margin-top: auto; }
  .start-bar .primary { flex: 1; min-width: 7rem; }
  .start-sum { display: none; }
  .end-screen { padding: 1.2rem .6rem calc(1.5rem + var(--safe-b)); }
}
/* Bei 100 % Zoom auf einem Laptop passt das ganze Hauptmenü in die Fensterhöhe. */
@media (max-height: 860px) and (min-width: 761px) {
  .hero { padding-block: .7rem; }
  .hero-rosette { width: 46px; height: 46px; margin-bottom: 0; }
  .title-screen .ar { font-size: 3.6rem; line-height: 1; }
  .title-screen h1 { font-size: 2rem; }
  .title-screen .lead { font-size: 1.2rem; margin-bottom: .35rem; }
  .title-screen .intro { font-size: .96rem; line-height: 1.3; margin-bottom: .55rem; }
  .main-menu { gap: .3rem; }
  .menu-item { min-height: 44px; padding-block: .2rem; font-size: 1rem; }
  .menu-item small { font-size: .8rem; }
  .fine { margin-top: .5rem; font-size: .8rem; line-height: 1.25; }
  .beta-note { margin-top: .5rem; font-size: .86rem; line-height: 1.25; }
  .legal-links a { padding-block: .3rem; }
}
@media (max-height: 700px) and (min-width: 761px) {
  .hero-rosette { display: none; }
  .title-screen .intro { display: none; }
  .title-screen .ar { font-size: 3rem; }
  .menu-item { min-height: 42px; }
}
@media (max-height: 560px) {
  .hero { align-items: flex-start; }
  .hero-rosette, .title-screen .intro { display: none; }
}
/* Oben bleibt immer Platz für das Profil-Abzeichen, auch wenn das Menü bis an den Rand reicht. */
.hero { padding-top: max(clamp(1rem, 4vh, 3rem), calc(4.2rem + var(--safe-t))); }

/* ───── Version, Beta und Fehlerbox (A1) ───── */
.legal-links .version { display: inline-block; padding: .75rem .35rem; white-space: nowrap; }
.beta {
  display: inline-block; margin-inline-start: .4rem; padding: .05rem .4rem; vertical-align: .12em;
  font-family: var(--label); font-weight: 700; font-size: .68rem; letter-spacing: .08em; text-transform: uppercase; line-height: 1.3;
  color: #2a1c08; background: var(--gold-300); border-radius: 3px;
}
.beta-note { max-width: 620px; margin: .9rem auto 0; color: var(--paper-100); font-size: .92rem; line-height: 1.35; }
.beta-note .beta { margin-inline: 0 .35rem; }
.sheet-hint { margin-top: .4rem; color: var(--ink-soft); font-size: .88rem; }
a.sheet-item { text-decoration: none; }
.sheet-item small { margin-inline-start: auto; color: var(--ink-soft); font-size: .85rem; }
.panel h3 .beta { margin-inline-start: .2rem; letter-spacing: .08em; }
#fehlerbox {
  position: fixed; z-index: 100; inset: auto 1rem max(1rem, env(safe-area-inset-bottom)) 1rem; max-width: 34rem; margin: 0 auto;
  padding: 1rem 1.1rem; color: var(--ink); background: var(--paper-50); border: 1px solid var(--gold-700); border-radius: 8px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, .5); font-size: .95rem; line-height: 1.4;
}
#fehlerbox strong { display: block; font-family: var(--label); font-size: 1.05rem; margin-bottom: .3rem; }
#fehlerbox p { margin: 0 0 .5rem; }
#fehlerbox summary { cursor: pointer; color: var(--ink-soft); font-size: .85rem; }
#fehlerbox pre { max-height: 8rem; overflow: auto; margin: .3rem 0 0; padding: .4rem; font-size: .75rem; white-space: pre-wrap; word-break: break-word; background: rgba(0, 0, 0, .06); border-radius: 4px; }
.fehlerbox-knoepfe { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .7rem; }
.fehlerbox-knoepfe a, .fehlerbox-knoepfe button {
  min-height: 40px; padding: .45rem .9rem; font-family: var(--label); font-weight: 700; font-size: .92rem;
  color: var(--ink); background: transparent; border: 1px solid var(--ink-soft); border-radius: 5px; text-decoration: none; cursor: pointer;
  display: inline-flex; align-items: center;
}
.fehlerbox-knoepfe .fehlerbox-melden { color: #2a1c08; background: linear-gradient(180deg, var(--gold-100), var(--gold-300) 45%, var(--gold-500)); border-color: var(--gold-700); }

/* ───── Fenster über dem Titelbild: Neues Spiel, Gemeinsam spielen ───── */
.page-dialog { position: fixed; inset: 0; z-index: 35; overflow-y: auto; }
.page-dialog-box { outline: none; }
.page-dialog-x { display: none; }
@media (min-width: 761px) {
  .page-dialog { display: grid; place-items: center; padding: 1.5rem; overflow: hidden; background: rgba(4, 9, 18, .7); backdrop-filter: blur(3px); }
  .page-dialog > .backdrop { display: none; }
  .page-dialog-box {
    position: relative; width: min(100%, 1040px); max-height: calc(100vh - 3rem); max-height: calc(100dvh - 3rem); overflow-y: auto;
    padding: 1.3rem 1.8rem 1.4rem;
    background: linear-gradient(180deg, rgba(22, 40, 66, .98), rgba(9, 17, 30, .98));
    border: 1px solid var(--gold-700); border-radius: 10px;
    box-shadow: inset 0 0 0 4px var(--lapis-900), inset 0 0 0 5px var(--line), 0 24px 60px rgba(0, 0, 0, .6);
  }
  .page-dialog.fresh .page-dialog-box { animation: sheet-in .22s ease-out; }
  .page-dialog .title-screen { min-height: 0; padding: 0; }
  .page-dialog .setup, .page-dialog .fit-page { justify-content: flex-start; }
  .page-dialog .dialog-back { display: none; }
  .page-dialog-x { display: inline-flex; position: absolute; z-index: 1; top: .7rem; inset-inline-end: .7rem; color: var(--paper-100); }
}
