/* PB59 / Daily59 — Masterdesign colour world.
   Deep navy, slate, neon-teal route, warm amber light, pizza red, light cream text.
   Mobile-first landscape, arcade pixel UI, large touch targets. */

:root {
  --navy:        #0b1a2e;
  --navy-2:      #112844;
  --slate:       #1c3a5e;
  --slate-2:     #25496f;
  --teal:        #2ee6c9;
  --teal-dim:    #1aa890;
  --amber:       #ffb347;
  --amber-warm:  #ffcd6b;
  --red:         #ff5a4d;
  --cream:       #f4ecd8;
  --cream-dim:   #c9c2b2;
  --ink:         #07121f;
  --good:        #6ee27a;
  --warn:        #ffd23f;

  --panel-border: 3px solid var(--teal);
  --shadow: 0 6px 0 #04101c, 0 10px 24px rgba(0,0,0,.45);
  --font: "Trebuchet MS", "Segoe UI", system-ui, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  background: var(--navy);
  color: var(--cream);
  font-family: var(--font);
  -webkit-font-smoothing: none;
  overflow: hidden;
  touch-action: manipulation;
}

#app {
  position: fixed; inset: 0;
  height: 100vh; height: 100dvh;            /* dynamic viewport (iOS Safari bars) */
  max-height: 100dvh;
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;                          /* main screens never scroll (hard fit) */
  background-color: var(--navy);
  background-image:
    radial-gradient(120% 90% at 50% -10%, var(--slate) 0%, var(--navy-2) 45%, var(--navy) 100%);
  background-size: cover;
  background-position: center center;
  /* iOS safe-area: notch sits left/right in landscape, home-bar bottom */
  padding:
    max(10px, env(safe-area-inset-top))
    max(16px, env(safe-area-inset-right))
    max(10px, env(safe-area-inset-bottom))
    max(16px, env(safe-area-inset-left));
  transition: background-image .25s ease;
}

/* Legibility for brand/headings sitting over photographic backgrounds. */
.brand, .claim, .subline, .score-big, .timer { text-shadow: 0 2px 6px rgba(0,0,0,.6); }

/* ---- Rotate overlay ---- */
#rotate-overlay {
  position: fixed; inset: 0; z-index: 999;
  background: var(--navy);
  display: flex; align-items: center; justify-content: center; text-align: center;
}
#rotate-overlay[hidden] { display: none; }
.rotate-icon { font-size: 56px; margin-bottom: 12px; }
.rotate-inner h2 { color: var(--teal); letter-spacing: 1px; }
.rotate-inner p { color: var(--cream-dim); margin-top: 8px; }

/* ---- Screen shell ---- */
.screen {
  width: 100%; max-width: 920px;
  height: 100%; min-height: 0;
  display: flex; flex-direction: column; justify-content: center;
  gap: 12px; overflow: hidden;              /* hard fit: compress, never scroll */
}
.screen.center { align-items: center; text-align: center; }
.center-col { min-height: 0; max-height: 100%; }
.panel { min-height: 0; }

/* ---- Brand / titles ---- */
.brand {
  font-weight: 800; letter-spacing: 3px; text-transform: uppercase;
  color: var(--cream); line-height: 1;
}
.brand .num { color: var(--red); }
.brand-lg { font-size: clamp(34px, 7vw, 64px); }
.brand-md { font-size: clamp(22px, 4vw, 34px); }
.subline { color: var(--teal); letter-spacing: 2px; text-transform: uppercase; font-size: 13px; }
.claim { color: var(--amber-warm); letter-spacing: 4px; text-transform: uppercase; font-size: 14px; font-weight: 700; }

/* ---- Panels ---- */
.panel {
  background: var(--navy-2);
  border: var(--panel-border);
  border-radius: 4px;
  box-shadow: var(--shadow);
  padding: 16px 18px;
}
.panel.warm { border-color: var(--amber); }
.panel.red { border-color: var(--red); }
.panel-title { color: var(--teal); text-transform: uppercase; letter-spacing: 2px; font-size: 12px; margin-bottom: 8px; }

/* ---- Buttons ---- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font-family: var(--font); font-weight: 800; letter-spacing: 1.5px; text-transform: uppercase;
  border: none; border-radius: 4px; cursor: pointer;
  padding: 16px 22px; font-size: 17px;
  background: var(--cream); color: var(--ink);
  box-shadow: 0 5px 0 #998f73;
  transition: transform .05s ease;
  min-height: 56px; width: 100%;
}
.btn:active { transform: translateY(3px); box-shadow: 0 2px 0 #998f73; }
.btn.primary { background: var(--teal); color: var(--ink); box-shadow: 0 5px 0 var(--teal-dim); }
.btn.primary:active { box-shadow: 0 2px 0 var(--teal-dim); }
.btn.warm { background: var(--amber); color: var(--ink); box-shadow: 0 5px 0 #c47f1e; }
.btn.danger { background: var(--red); color: var(--cream); box-shadow: 0 5px 0 #b3382e; }
.btn.ghost { background: transparent; color: var(--cream); border: 2px solid var(--slate-2); box-shadow: none; }
.btn.sm { padding: 10px 14px; font-size: 14px; min-height: 0; width: auto; }
.btn:disabled { opacity: .4; cursor: not-allowed; }

.btn-row { display: flex; gap: 12px; flex-wrap: wrap; }
.btn-row .btn { flex: 1; }

/* ---- HUD (timer / heat) ---- */
.hud {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.timer {
  font-size: clamp(28px, 6vw, 44px); font-weight: 800; letter-spacing: 2px;
  color: var(--cream); font-variant-numeric: tabular-nums;
}
.timer.warn { color: var(--warn); }
.timer.crit { color: var(--red); animation: pulse .5s infinite alternate; }
@keyframes pulse { to { opacity: .55; } }

.heat-wrap { flex: 1; max-width: 240px; }
.heat-label { font-size: 11px; color: var(--cream-dim); text-transform: uppercase; letter-spacing: 1px; }
.heat-bar { height: 14px; background: var(--ink); border: 2px solid var(--slate-2); border-radius: 3px; overflow: hidden; }
.heat-fill { height: 100%; background: linear-gradient(90deg, var(--red), var(--amber), var(--good)); transition: width .3s ease; }

/* ---- 59-Watch hint ---- */
.watch {
  display: flex; align-items: center; gap: 10px;
  background: var(--slate); border-left: 4px solid var(--teal);
  border-radius: 4px; padding: 10px 14px; color: var(--cream);
  font-size: 15px; min-height: 44px;
}
.watch .watch-ic { font-size: 18px; }
.watch.empty { opacity: .35; }

/* ---- Option cards (route / door) ---- */
.options { display: flex; gap: 12px; flex-wrap: wrap; }
.opt {
  flex: 1 1 0; min-width: 150px;
  background: var(--navy-2); border: 2px solid var(--slate-2); border-radius: 6px;
  padding: 14px; cursor: pointer; text-align: left;
  display: flex; flex-direction: column; gap: 6px;
  transition: border-color .1s, transform .05s;
  color: var(--cream);
}
.opt:hover { border-color: var(--teal); }
.opt:active { transform: translateY(2px); }
.opt .opt-name { font-weight: 800; font-size: 17px; letter-spacing: .5px; }
.opt .opt-cue { color: var(--amber-warm); font-size: 14px; }
.opt .opt-meta { display: flex; gap: 10px; flex-wrap: wrap; font-size: 13px; color: var(--cream-dim); margin-top: 2px; }
.tag { padding: 2px 8px; border-radius: 3px; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .5px; }
.tag.sicher { background: #15422f; color: var(--good); }
.tag.schnell { background: #173a52; color: var(--teal); }
.tag.riskant { background: #5a2c14; color: var(--amber); }
.tag.heiss { background: #5a1f18; color: var(--red); }
.tag.time { background: var(--slate); color: var(--cream); }

/* ---- Bon ---- */
.bon {
  background: var(--cream); color: var(--ink);
  border-radius: 4px; padding: 18px 20px; max-width: 420px; width: 100%;
  box-shadow: var(--shadow);
  border-top: 6px solid var(--red);
}
.bon h3 { text-transform: uppercase; letter-spacing: 1px; margin-bottom: 10px; color: var(--ink); }
.bon-row { display: flex; gap: 8px; padding: 6px 0; border-bottom: 1px dashed #b9b09a; font-size: 15px; }
.bon-row .k { font-weight: 800; min-width: 92px; text-transform: uppercase; font-size: 12px; color: #6b6453; padding-top: 2px; }
.bon-row .v { flex: 1; }
.bon .hint { color: #a8431f; font-weight: 700; }

/* ---- Result / breakdown ---- */
.score-big { font-size: clamp(40px, 9vw, 72px); font-weight: 800; color: var(--teal); font-variant-numeric: tabular-nums; line-height: 1; }
.score-big.fail { color: var(--red); }
.breakdown { display: flex; flex-direction: column; gap: 4px; font-size: 15px; }
.breakdown .ln { display: flex; justify-content: space-between; }
.breakdown .ln.plus .amt { color: var(--good); }
.breakdown .ln.minus .amt { color: var(--red); }
.status-pill { display: inline-block; padding: 6px 14px; border-radius: 20px; font-weight: 800; text-transform: uppercase; letter-spacing: 1px; font-size: 13px; }
.status-pill.top59 { background: var(--teal); color: var(--ink); }
.status-pill.close { background: var(--amber); color: var(--ink); }
.status-pill.done { background: var(--slate-2); color: var(--cream); }
.status-pill.fail { background: var(--red); color: var(--cream); }

/* ---- Leaderboard ---- */
/* Leaderboard: the ONLY screen whose inner list scrolls; the app/stage stays fixed. */
.lb-wrap { display: flex; flex-direction: column; gap: 10px; align-items: center; width: 100%; height: 100%; min-height: 0; }
.lb-scroll { flex: 1 1 auto; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; width: 100%; max-width: 520px; }
.lb { width: 100%; max-width: 520px; border-collapse: collapse; }
.lb th, .lb td { text-align: left; padding: 8px 10px; font-size: 15px; }
.lb th { color: var(--teal); text-transform: uppercase; font-size: 11px; letter-spacing: 1px; }
.lb tr { border-bottom: 1px solid var(--slate); }
.lb tr.me { background: var(--slate); color: var(--cream); font-weight: 800; }
.lb td.rank { color: var(--amber-warm); font-weight: 800; width: 48px; }
.lb td.score { text-align: right; font-variant-numeric: tabular-nums; }

/* ---- misc ---- */
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.muted { color: var(--cream-dim); }
.code-chip { background: var(--ink); color: var(--teal); padding: 4px 10px; border-radius: 4px; font-weight: 800; letter-spacing: 1px; }
.warnbox { background: #3a2410; border: 2px solid var(--amber); border-radius: 4px; padding: 10px 14px; color: var(--amber-warm); font-size: 14px; }
.recovery { font-size: clamp(18px, 4vw, 26px); color: var(--amber); font-weight: 800; letter-spacing: 1px; word-break: break-all; }
.center-col { display: flex; flex-direction: column; gap: 14px; align-items: center; max-width: 560px; }
.spacer { flex: 1; }
small.foot { color: var(--cream-dim); font-size: 12px; }
a.legal { color: var(--teal); text-decoration: underline; font-size: 12px; margin: 0 6px; }
.scene {
  height: 96px; border-radius: 6px; border: 2px solid var(--slate-2);
  background:
    linear-gradient(180deg, #0e2238, #0a1828),
    repeating-linear-gradient(90deg, transparent 0 26px, rgba(255,179,71,.06) 26px 30px);
  position: relative; overflow: hidden; display: flex; align-items: center; justify-content: center;
  color: var(--cream-dim); font-size: 13px; letter-spacing: 1px; text-transform: uppercase;
}
.scene .route-line { position: absolute; bottom: 14px; left: 8%; right: 8%; height: 4px; background: var(--teal); box-shadow: 0 0 8px var(--teal); border-radius: 2px; }

/* ---- Result layout: card preview (4:5) beside score ---- */
.result-wrap { display: flex; gap: 20px; align-items: center; justify-content: center; flex-wrap: wrap; width: 100%; }
.card-preview {
  flex: 0 0 auto; width: 200px; max-width: 32vw; aspect-ratio: 4 / 5;
  border-radius: 8px; overflow: hidden; border: 2px solid var(--teal); box-shadow: var(--shadow);
}
.card-preview img { width: 100%; height: 100%; object-fit: cover; display: block; }
.card-preview.clickable { cursor: pointer; transition: transform .08s, border-color .1s; }
.card-preview.clickable:hover { transform: translateY(-2px); border-color: var(--amber); }
.result-wrap .center-col { flex: 1 1 320px; }

/* ---- Share-card fullscreen lightbox ---- */
.share-card-modal {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(4, 9, 16, .9);
  display: flex; align-items: center; justify-content: center;
  gap: 22px; flex-wrap: wrap;
  padding:
    max(12px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right))
    max(12px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
}
.scm-card { display: flex; align-items: center; justify-content: center; }
.scm-card img {
  max-width: min(86vw, 400px);
  max-height: calc(100dvh - 24px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
  aspect-ratio: 4 / 5; object-fit: contain;
  border-radius: 8px; box-shadow: 0 10px 36px rgba(0, 0, 0, .6);
}
.scm-actions { display: flex; flex-direction: column; gap: 12px; }
.scm-actions .btn { width: auto; min-width: 170px; }

/* ---- Empfang (reception / rating / tip) ---- */
.reception-panel { text-align: center; }
.reception-line { font-size: clamp(20px, 4.2vw, 28px); font-weight: 800; color: var(--cream); letter-spacing: .5px; }
.stars { letter-spacing: 6px; margin: 12px 0 8px; font-size: clamp(26px, 6vw, 40px); line-height: 1; }
.stars .star { color: var(--slate-2); }
.stars .star.on { color: var(--amber); text-shadow: 0 0 10px rgba(255,205,107,.5); }
.tip { color: var(--teal); font-weight: 800; letter-spacing: 1px; font-size: clamp(16px, 3.6vw, 20px); }

/* ---- Hard-fit compaction: shrink content on short landscape, never scroll ---- */
.clamp1 { display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; overflow: hidden; }
.clamp2 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

@media (max-height: 470px) {
  .screen { gap: 9px; }
  .center-col { gap: 9px; max-width: 660px; }
  .btn { min-height: 46px; padding: 9px 16px; font-size: 15px; }
  .btn.sm { min-height: 0; padding: 6px 12px; }
  .btn-row { gap: 9px; }
  .panel { padding: 9px 12px; }
  .panel-title { margin-bottom: 4px; font-size: 11px; }
  .brand-lg { font-size: 30px; } .brand-md { font-size: 22px; }
  .claim { font-size: 11px; letter-spacing: 3px; }
  .subline { font-size: 11px; }
  .recovery { font-size: 17px; }
  .bon { padding: 9px 12px; border-top-width: 4px; }
  .bon-row { padding: 3px 0; font-size: 12px; }
  .bon-row .k { font-size: 10px; min-width: 80px; }
  .bon h3 { margin-bottom: 5px; font-size: 15px; }
  .score-big { font-size: clamp(28px, 7vh, 50px); }
  .warnbox { padding: 6px 10px; font-size: 12px; }
  .breakdown { font-size: 12px; gap: 2px; }
  .reception-line { font-size: clamp(17px, 4.5vh, 24px); }
  .stars { font-size: clamp(22px, 6vh, 34px); margin: 6px 0 4px; }
  .tip { font-size: 15px; }
  .card-preview { width: 150px; }
  .scene { height: 64px; }
  .watch { min-height: 38px; padding: 7px 12px; font-size: 14px; }
  .timer { font-size: clamp(24px, 7vh, 40px); }
}
@media (max-height: 400px) {
  .screen { gap: 7px; }
  .center-col { gap: 7px; }
  .btn { min-height: 42px; padding: 8px 14px; font-size: 14px; }
  .panel { padding: 7px 10px; }
  .bon-row { padding: 2px 0; font-size: 11px; }
  .bon-row .k { min-width: 72px; }
  .brand-lg { font-size: 26px; } .brand-md { font-size: 20px; }
  .recovery { font-size: 15px; }
  .score-big { font-size: clamp(24px, 6.5vh, 42px); }
  .breakdown { font-size: 11px; }
  .card-preview { width: 126px; }
  .warnbox { font-size: 11px; }
  .scene { height: 52px; }
}
@media (max-height: 360px) {
  .center-col { gap: 5px; }
  .btn { min-height: 38px; padding: 6px 12px; font-size: 13px; }
  .panel { padding: 5px 9px; }
  .bon-row { font-size: 10px; padding: 1px 0; }
  .card-preview { width: 108px; }
  .score-big { font-size: clamp(22px, 6vh, 34px); }
  .breakdown { font-size: 10px; gap: 1px; }
  .scene { display: none; }
}
