/* Shared look for the AIcade pages: one comic game screen set into the beige housing of the
   Standesamt flip clock, on suit-navy ground. Single deliberate dark look. */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; }
:root {
  --ground: #141b2e;        /* suit navy */
  --ground-2: #1d2742;
  --line: #3a4769;
  --housing: #e7dfca;       /* flip clock plastic */
  --housing-edge: #c4b896;
  --flap: #1c1c20;
  --ivory: #fbf5f1;         /* dress */
  --rose: #f2edc0;          /* white roses */
  --muted: #a9b1c7;
  --font-display: "Bangers", "Impact", "Arial Black", sans-serif;
  --font-clock: "Oswald", "Arial Narrow", sans-serif;
  --font-body: "Atkinson Hyperlegible", "Segoe UI", system-ui, sans-serif;
  color-scheme: dark;
}
[hidden] { display: none !important; }
html, body { background: var(--ground); color: var(--ivory); }
body {
  font-family: var(--font-body);
  font-size: 1rem;
  line-height: 1.5;
  padding-inline: 16px;
  padding-block: 24px 40px;
  min-height: 100%;
}
.wrap { max-width: 1040px; margin: 0 auto; display: grid; gap: 18px; }
header { display: flex; flex-wrap: wrap; align-items: end; justify-content: space-between; gap: 8px 24px; }
h1 {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: clamp(2.2rem, 6vw, 3.6rem);
  line-height: 0.95;
  margin: 0;
  letter-spacing: 0.03em;
  text-wrap: balance;
}
h1 span { color: var(--rose); }
.lede { margin: 0; color: var(--muted); max-width: 46ch; }
.date {
  font-family: var(--font-clock);
  font-size: 0.85rem;
  letter-spacing: 0.14em;
  color: var(--muted);
  margin: 0 0 4px;
}

.housing {
  background: var(--housing);
  border: 2px solid var(--housing-edge);
  border-radius: 18px;
  padding: clamp(8px, 1.6vw, 16px);
  box-shadow: 0 1px 0 rgba(255,255,255,.5) inset, 0 18px 40px rgba(0,0,0,.45);
}
.stage { position: relative; width: 100%; aspect-ratio: 960 / 528; max-width: 100%; border-radius: 6px; overflow: hidden; background: #dedcd8; }
canvas#game { display: block; width: 100%; height: 100%; }
.brand {
  display: flex; justify-content: space-between; align-items: center;
  font-family: var(--font-clock); font-size: 0.7rem; letter-spacing: 0.16em;
  color: #7d7258; padding: 8px 4px 0;
}

.overlay {
  position: absolute; inset: 0;
  display: grid; place-items: center;
  background: rgba(20, 27, 46, 0.8);
  padding: 12px;
  text-align: center;
}
.panel { display: grid; gap: clamp(6px, 1.8vw, 16px); justify-items: center; max-width: 560px; }
.panel h2 {
  font-family: var(--font-display); font-weight: 400; margin: 0; letter-spacing: 0.04em;
  font-size: clamp(1.5rem, 5vw, 2.8rem); line-height: 1; color: var(--rose);
  text-wrap: balance;
}
.panel p { margin: 0; font-size: clamp(0.8rem, 2vw, 1rem); color: var(--ivory); max-width: 42ch; }
.choices { display: flex; gap: clamp(8px, 3vw, 24px); flex-wrap: wrap; justify-content: center; }
.choice {
  display: grid; justify-items: center; gap: 4px;
  background: var(--ground-2); color: var(--ivory);
  border: 2px solid var(--line); border-radius: 12px;
  padding: clamp(4px, 1.2vw, 12px) clamp(10px, 2.6vw, 24px);
  font-family: var(--font-display); font-size: clamp(1rem, 2.4vw, 1.4rem); letter-spacing: 0.05em;
  cursor: pointer;
  transition: transform .12s ease, border-color .12s ease;
}
.choice:hover { transform: translateY(-3px); border-color: var(--rose); }
.choice:focus-visible, .btn:focus-visible, .tbtn:focus-visible, .mute:focus-visible { outline: 3px solid var(--rose); outline-offset: 3px; }
.choice small { font-family: var(--font-body); font-size: 0.7rem; letter-spacing: 0.04em; color: var(--muted); margin-top: -4px; }
.choice canvas { width: clamp(52px, 11vw, 110px); height: auto; aspect-ratio: 110 / 140; }
.btns { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }
.btn {
  font-family: var(--font-display); font-size: clamp(1rem, 2.2vw, 1.25rem); letter-spacing: 0.05em;
  background: var(--rose); color: var(--flap); border: 0; border-radius: 8px;
  padding: 8px 18px; cursor: pointer;
}
.btn.ghost { background: transparent; color: var(--ivory); border: 2px solid var(--line); }
.btn.ghost:hover { border-color: var(--rose); }
.btn.small { font-size: clamp(0.85rem, 1.8vw, 1rem); padding: 6px 12px; }
.menu { display: grid; gap: clamp(6px, 1.2vw, 10px); width: min(280px, 80vw); }
.toggles { display: flex; gap: 8px; }
.toggles .btn { flex: 1; }
.menuBtn {
  position: absolute; top: 2.4%; left: 50%; transform: translateX(-50%);
  font-family: var(--font-display); font-size: clamp(0.75rem, 1.8vw, 1.05rem); letter-spacing: 0.06em;
  background: rgba(20, 27, 46, 0.85); color: var(--ivory);
  border: 2px solid var(--line); border-radius: 8px; padding: 4px 12px; cursor: pointer;
}
.menuBtn:hover { border-color: var(--rose); }
.menuBtn:focus-visible { outline: 3px solid var(--rose); outline-offset: 2px; }

.help { display: flex; flex-wrap: wrap; gap: 8px 20px; justify-content: space-between; align-items: center; color: var(--muted); font-size: 0.9rem; }
kbd {
  font-family: var(--font-clock); font-size: 0.75rem;
  background: var(--ground-2); border: 1px solid var(--line); border-bottom-width: 3px;
  border-radius: 5px; padding: 1px 6px; color: var(--ivory);
}
.mute {
  font-family: var(--font-clock); font-size: 0.75rem; letter-spacing: 0.1em;
  background: transparent; color: var(--muted); border: 1px solid var(--line); border-radius: 6px;
  padding: 6px 10px; cursor: pointer;
}

.touch { display: none; justify-content: space-between; gap: 12px; user-select: none; -webkit-user-select: none; touch-action: none; }
.touch .pad { display: flex; gap: 12px; }
.tbtn {
  width: 68px; height: 68px; border-radius: 50%;
  background: var(--ground-2); border: 2px solid var(--line); color: var(--ivory);
  font-size: 1.4rem;
  touch-action: none;
}
.tbtn.jump { width: 84px; height: 84px; background: var(--rose); color: var(--flap); font-family: var(--font-display); font-size: 1.1rem; letter-spacing: .05em; border-color: var(--rose); }
.tbtn.on { filter: brightness(1.3); transform: scale(0.96); }
/* .touch-ui is set on <html> by shared/device.js for every device with a touchscreen */
.touch-ui .touch { display: flex; }
.touch-ui .keys { display: none; }
@media (prefers-reduced-motion: reduce) {
  .choice { transition: none; }
}

.topbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.back {
  font-family: var(--font-clock); font-size: 0.8rem; letter-spacing: 0.1em;
  color: var(--muted); text-decoration: none;
  border: 1px solid var(--line); border-radius: 6px; padding: 5px 10px;
}
.back:hover { color: var(--ivory); border-color: var(--rose); }
.back:focus-visible { outline: 3px solid var(--rose); outline-offset: 2px; }
a.btn { text-decoration: none; text-align: center; }

/* Bangers has no ß glyph; uppercasing turns it into SS like a German sign would */
h1, h2, .btn, .choice, .menuBtn, .tbtn.jump, .play { text-transform: uppercase; }

/* ---------- Phones and tablets ---------- */
button, a { touch-action: manipulation; }
canvas#game { touch-action: none; -webkit-touch-callout: none; }
.stage, .touch { -webkit-user-select: none; user-select: none; }

@media (max-width: 600px) {
  body { padding-inline: 10px; padding-block: 12px 24px; }
  .wrap { gap: 12px; }
  .housing { padding: 6px; border-radius: 12px; }
  .brand { display: none; }
  .lede { font-size: 0.95rem; }
}

/* Portrait touch screens: the stage is small, so menus open over the whole screen */
@media (orientation: portrait) {
  .touch-ui .stage .overlay {
    position: fixed; z-index: 50;
    background: rgba(20, 27, 46, 0.96);
    padding: max(24px, env(safe-area-inset-top)) 16px max(24px, env(safe-area-inset-bottom));
    overflow-y: auto;
  }
  .touch-ui .housing::after {
    content: "Tipp: Handy quer halten für ein größeres Spielfeld";
    display: block; text-align: center; padding-top: 6px;
    font-family: var(--font-clock); font-size: 0.72rem; letter-spacing: 0.08em; color: #7d7258;
  }
  .touch-ui .touch { padding-bottom: env(safe-area-inset-bottom); }
}

/* Landscape phones: the game fills the screen and the controls float at its edges */
@media (orientation: landscape) and (max-height: 540px) {
  .touch-ui, .touch-ui body { height: 100%; overflow: hidden; }
  .touch-ui body { padding: 0 max(4px, env(safe-area-inset-right)) 0 max(4px, env(safe-area-inset-left)); }
  .touch-ui .wrap { max-width: none; height: 100%; display: flex; flex-direction: column; justify-content: center; gap: 0; }
  .touch-ui .wrap > header, .touch-ui .wrap > .help, .touch-ui .wrap > .topbar, .touch-ui .brand { display: none; }
  .touch-ui .housing { width: fit-content; max-width: 100%; margin: 0 auto; padding: 4px; border-width: 1px; border-radius: 10px; box-shadow: none; }
  .touch-ui .housing .stage { width: auto; height: calc(100vh - 12px); height: calc(100dvh - 12px); max-width: 100%; }
  .touch-ui .touch {
    position: fixed; left: 0; right: 0; z-index: 20;
    bottom: max(8px, env(safe-area-inset-bottom));
    padding-inline: max(8px, env(safe-area-inset-left)) max(8px, env(safe-area-inset-right));
    align-items: flex-end; pointer-events: none;
  }
  .touch-ui .touch > * { pointer-events: auto; }
  .touch-ui .touch .tbtn { width: 52px; height: 52px; opacity: 0.8; }
  .touch-ui .touch .tbtn.jump, .touch-ui .touch .tbtn.duck { width: 64px; height: 64px; font-size: 0.85rem; }
  .touch-ui .touch .dpad { grid-template-columns: repeat(3, 50px); grid-template-rows: repeat(2, 50px); gap: 4px; }
  .touch-ui .touch .dpad .tbtn { width: 50px; height: 50px; }
  .touch-ui .touch .hint { display: none; }
  /* while a menu is open, the way back to the main menu sits in the top corner */
  .touch-ui body:has(.stage .overlay:not([hidden])) .wrap > .topbar {
    display: flex; position: fixed; z-index: 60;
    top: max(6px, env(safe-area-inset-top)); left: max(8px, env(safe-area-inset-left));
  }
  .touch-ui body:has(.stage .overlay:not([hidden])) .touch { display: none; }
}
