/* Material Icons */
.material-icons {
  font-family: 'Material Icons';
  font-weight: normal;
  font-style: normal;
  display: inline-block;
  line-height: 1;
  text-transform: none;
  white-space: nowrap;
  -webkit-font-smoothing: antialiased;
}

:root {
    --rot: #E3000F;
    --dunkelrot: #790000;
    --weiss: #FFFFFF;
    --font-head: 'Karla', system-ui, sans-serif;
    --font-body: 'Archivo Narrow', system-ui, sans-serif;
  }
  * { margin: 0; padding: 0; box-sizing: border-box; }
  html, body {
    height: 100%; width: 100%; overflow: hidden;
    background: #FDE9EA;
    font-family: var(--font-body);
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
    overscroll-behavior: none;
    touch-action: none;
  }
  #game-canvas { position: fixed; inset: 0; display: block; }

  /* ---------- HUD ---------- */
  #hud {
    position: fixed; top: 0; left: 0; right: 0; z-index: 10;
    display: flex; align-items: flex-start; justify-content: space-between;
    padding: clamp(12px, 2.2vw, 26px);
    pointer-events: none;
  }
  .hud-stat {
    background: var(--weiss);
    border: 2px solid var(--rot);
    border-radius: 4px;
    padding: 5px clamp(8px, 1.5vw, 12px) 6px;
    display: flex; flex-direction: column; align-items: flex-start; gap: 1px;
    box-shadow: 0 2px 0 rgba(121,0,0,0.18);
  }
  .hud-label {
    font-family: var(--font-body);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.13em;
    font-size: clamp(9px, 1.1vw, 12px);
    color: var(--dunkelrot);
  }
  .hud-num {
    font-family: var(--font-head);
    font-weight: 800;
    font-size: clamp(18px, 2.6vw, 30px);
    color: var(--rot);
    line-height: 1;
    font-variant-numeric: tabular-nums;
  }
  #hud-stats {
    display: flex;
    gap: clamp(5px, 1.2vw, 10px);
    flex-wrap: wrap;
    align-items: flex-start;
  }
  #sound-btn {
    pointer-events: auto;
    width: clamp(34px, 4vw, 44px); height: clamp(34px, 4vw, 44px);
    border-radius: 50%;
    background: var(--weiss);
    border: 2px solid var(--rot);
    color: var(--rot);
    font-size: clamp(17px, 2.2vw, 22px);
    font-family: var(--font-head);
    font-weight: 800;
    -webkit-text-stroke: 0.6px currentColor;
    cursor: pointer; display: grid; place-items: center;
    box-shadow: 0 2px 0 rgba(121,0,0,0.18);
    transition: transform .12s ease, background .12s ease, color .12s ease;
  }
  #sound-btn img { width: 60%; height: 60%; object-fit: contain; display: block; }
  #sound-btn:hover { transform: translateY(-1px); }
  #sound-btn:active { transform: translateY(1px); }
  #sound-btn.muted { color: #B89; border-color: #E7CBCE; }

  /* ---------- Slogan-Flash ---------- */
  #slogan-flash {
    position: fixed; left: 50%; top: 22%; transform: translate(-50%, -8px);
    z-index: 12; pointer-events: none;
    background: var(--weiss);
    border-left: 6px solid var(--rot);
    padding: 12px 22px;
    font-family: var(--font-head); font-weight: 800;
    font-size: clamp(18px, 3vw, 34px);
    color: var(--rot);
    letter-spacing: -0.01em;
    box-shadow: 0 8px 30px rgba(121,0,0,0.22);
    opacity: 0; transition: opacity 1.6s ease, transform .25s ease;
    max-width: 80vw; text-align: center;
  }
  #slogan-flash.show { opacity: 1; transition: opacity .2s ease, transform .2s ease; transform: translate(-50%, 0); }
  #slogan-flash::after { content: ' ♥'; }

  /* ---------- Overlays ---------- */
  .overlay {
    position: fixed; inset: 0; z-index: 20;
    display: none; align-items: center; justify-content: center;
    background: rgba(227, 0, 15, 0.93);
    color: var(--weiss);
    padding: 24px;
    text-align: center;
    opacity: 0; transition: opacity .3s cubic-bezier(.22,.61,.36,1);
  }
  .overlay.show { display: flex; opacity: 1; }
  .overlay-inner {
    max-width: 660px; width: 100%;
    display: flex; flex-direction: column; align-items: center;
    transform: translateY(8px);
    transition: transform .35s cubic-bezier(.22,.61,.36,1);
  }
  .overlay.show .overlay-inner { transform: translateY(0); }

  .overlay-logo {
    position: absolute;
    top: clamp(12px, 2.5vw, 24px);
    right: clamp(12px, 2.5vw, 24px);
    width: clamp(58px, 17vw, 140px);
    opacity: 0.93;
    pointer-events: none;
  }

  .kicker {
    font-family: var(--font-body);
    font-weight: 600; text-transform: uppercase;
    letter-spacing: 0.22em;
    font-size: clamp(10px, 1.5vw, 14px);
    opacity: 0.92; margin-bottom: clamp(14px, 3vw, 26px);
  }
  .lockup {
    font-family: var(--font-head); font-weight: 800;
    line-height: 0.92; letter-spacing: -0.02em;
    font-size: clamp(46px, 11vw, 110px);
    text-transform: uppercase;
  }
  .lockup .wir { position: relative; display: inline-block; }
  .heart-dot {
    display: inline-block;
    height: 1cap;
    width: calc(1cap * (118.4 / 206.1));
    vertical-align: 0;
    margin-left: 0.1em;
  }
  .sub {
    font-family: var(--font-head); font-weight: 700;
    font-size: clamp(16px, 2.6vw, 26px);
    margin-top: clamp(10px, 2vw, 18px);
    letter-spacing: 0.02em;
  }
  .desc {
    font-family: var(--font-body); font-weight: 400;
    font-size: clamp(14px, 2vw, 19px);
    margin-top: clamp(14px, 2.4vw, 22px);
    line-height: 1.5; max-width: 44ch; opacity: 0.96;
  }
  .desc b { font-weight: 700; }
  .controls-hint {
    font-family: var(--font-body);
    font-size: clamp(11px, 1.5vw, 14px);
    text-transform: uppercase; letter-spacing: 0.12em;
    opacity: 0.85; margin-top: 10px;
  }
  .legal-links {
    margin-top: clamp(14px, 2.5vw, 22px);
    font-family: var(--font-body);
    font-size: clamp(10px, 1.2vw, 13px);
    opacity: 0.6;
  }
  .legal-links a {
    color: var(--weiss);
    text-decoration: none;
  }
  .legal-links a:hover { text-decoration: underline; }

  /* weißer Textbalken (Kampagnen-Stil) */
  .balken {
    display: inline-block;
    background: var(--weiss); color: var(--rot);
    font-family: var(--font-head); font-weight: 800;
    text-transform: uppercase; line-height: 1.04;
    max-width: 92vw;
    padding: 8px 20px; margin-top: clamp(20px, 3.5vw, 32px);
    text-align: center;
    font-size: clamp(17px, 3vw, 32px);
    letter-spacing: -0.01em;
    box-shadow: 0 6px 0 rgba(121,0,0,0.25);
  }
  .balken .ort, .balken .ital { font-style: italic; }

  .btn {
    margin-top: clamp(22px, 3.5vw, 34px);
    font-family: var(--font-head); font-weight: 800;
    text-transform: uppercase; letter-spacing: 0.04em;
    font-size: clamp(15px, 2vw, 20px);
    background: var(--weiss); color: var(--rot);
    border: none; border-radius: 4px;
    padding: 14px 30px; cursor: pointer;
    box-shadow: 0 4px 0 var(--dunkelrot);
    transition: transform .1s ease, box-shadow .1s ease;
  }
  .btn:hover { transform: translateY(-1px); box-shadow: 0 5px 0 var(--dunkelrot); }
  .btn:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--dunkelrot); }

  .btn-outline {
    background: transparent;
    color: var(--weiss);
    border: 2px solid rgba(255,255,255,0.55);
    box-shadow: none;
  }
  .btn-outline:hover { background: rgba(255,255,255,0.12); box-shadow: none; }
  .btn-outline:active { transform: translateY(1px); box-shadow: none; }

  .btn-row {
    display: flex; gap: 12px; margin-top: clamp(22px, 3.5vw, 34px);
    justify-content: center; flex-wrap: wrap;
  }
  .btn-row .btn { margin-top: 0; }

  /* Themen-Badges im Game-Over */
  .over-badges {
    display: flex; gap: 10px; margin-top: 18px; justify-content: center;
  }
  .over-badge {
    width: 46px; height: 46px; border-radius: 50%;
    border: 2px solid rgba(255,255,255,0.25);
    display: grid; place-items: center;
    opacity: 0.25;
    transition: opacity .35s ease, border-color .35s ease, background .35s ease;
  }
  .over-badge .material-icons { font-size: 22px; color: var(--weiss); }
  .over-badge.got {
    opacity: 1;
    border-color: var(--weiss);
    background: rgba(255,255,255,0.15);
  }

  /* Game-Over Statistik */
  .stats {
    display: flex; gap: clamp(18px, 5vw, 56px);
    margin-top: clamp(18px, 3vw, 28px); margin-bottom: 4px;
    justify-content: center;
  }
  .stat { display: flex; flex-direction: column; align-items: center; gap: 4px; }
  .stat .v { font-family: var(--font-head); font-weight: 800; font-size: clamp(34px, 6vw, 58px); line-height: 1; font-variant-numeric: tabular-nums; }
  .stat .l { font-family: var(--font-body); font-weight: 600; text-transform: uppercase; letter-spacing: 0.16em; font-size: clamp(10px, 1.4vw, 13px); opacity: 0.9; }
  #over-record {
    font-family: var(--font-head); font-weight: 800;
    text-transform: uppercase; letter-spacing: 0.1em;
    font-size: clamp(13px, 1.8vw, 17px);
    background: var(--dunkelrot); color: var(--weiss);
    padding: 5px 14px; border-radius: 3px; margin-bottom: 14px;
    display: none;
  }
  .over-title {
    font-family: var(--font-head); font-weight: 800;
    text-transform: uppercase; letter-spacing: -0.01em;
    font-size: clamp(34px, 7vw, 72px); line-height: 0.95;
    position: relative;
  }
  .over-title::before {
    content: '';
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    height: 280%;
    aspect-ratio: 118.4 / 206.1;
    background: url('../img/SPD_NDS_Visual_Hand_Herz_RGB_weiss.svg') center / contain no-repeat;
    opacity: 0.10;
    pointer-events: none;
    z-index: -1;
  }

  @media (max-height: 520px) {
    .desc { display: none; }
    .sub { margin-top: 6px; }
  }

  /* ---------- Share-Widget (Desktop-Popover) ---------- */
  .share-wrap { position: relative; display: inline-block; }

  #share-widget {
    position: absolute;
    bottom: calc(100% + 12px);
    left: 50%;
    transform: translateX(-50%) translateY(6px);
    background: var(--weiss);
    border-radius: 6px;
    box-shadow: 0 8px 28px rgba(121,0,0,0.30);
    min-width: 210px;
    overflow: hidden;
    opacity: 0;
    pointer-events: none;
    transition: opacity .15s ease, transform .15s ease;
    z-index: 30;
  }
  #share-widget.open {
    opacity: 1;
    pointer-events: auto;
    transform: translateX(-50%) translateY(0);
  }
  #share-widget::after {
    content: '';
    position: absolute;
    bottom: -7px; left: 50%;
    transform: translateX(-50%);
    border: 7px solid transparent;
    border-top-color: var(--weiss);
    border-bottom: none;
  }
  .sw-btn {
    display: block; width: 100%;
    padding: 14px 20px;
    background: none; border: none;
    font-family: var(--font-head); font-weight: 700;
    font-size: 15px; letter-spacing: 0.05em;
    text-transform: uppercase; text-align: left;
    color: var(--rot); cursor: pointer; white-space: nowrap;
    transition: background .1s ease;
  }
  .sw-btn:hover { background: #FDE9EA; }
  .sw-btn + .sw-btn { border-top: 1px solid rgba(227,0,15,0.12); }

  /* ---------- Splash ---------- */
  @keyframes splash-spin {
    from { transform: rotate(0deg); }
    to   { transform: rotate(360deg); }
  }
  #splash {
    position: fixed; inset: 0; z-index: 40;
    background: #FDE9EA;
    display: grid; place-items: center;
    transition: opacity .35s ease;
  }
  #splash .material-icons {
    font-size: 64px;
    color: #E3000F;
    animation: splash-spin 1.2s linear infinite;
  }
  #splash.hidden { opacity: 0; pointer-events: none; }

  @media (display-mode: standalone) {
    html, body { background-color: #E3000F; }
    #splash { background: #E3000F; }
    #splash .material-icons { color: #FFFFFF; }
    #hud { padding-top: calc(env(safe-area-inset-top) + 8px); }
    .overlay-logo { top: calc(env(safe-area-inset-top) + 12px); }
  }
