/* Derpy Deer. Palette borrows from US road signs: warning yellow, guide-sign green. */

html, body { height: 100%; margin: 0; background: #0b1020; overflow: hidden; }

#dd-root {
  --night: #0b1020; --ink: #101114; --sign: #ffcc00; --guide: #00693e; --white: #f5f3ea;
  --paper: #ebe4d2; --paper-ink: #1f1b16; --paper-soft: #5b5247; --brake: #e0352b;
  position: fixed; inset: 0; overflow: hidden; background: var(--night); color: var(--white);
  font-family: 'Overpass', 'Arial Narrow', system-ui, sans-serif;
  -webkit-user-select: none; user-select: none; touch-action: none; -webkit-tap-highlight-color: transparent;
}
#dd-root [hidden] { display: none !important; }
#dd-root canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }

/* ---- full-screen effect layers (driven from main.js) */
.dd-layer { position: absolute; inset: 0; pointer-events: none; }
#dd-glare { opacity: 0; }
#dd-edgeL { background: linear-gradient(90deg, rgba(224,53,43,.6), rgba(224,53,43,0) 16%); opacity: 0; }
#dd-edgeR { background: linear-gradient(270deg, rgba(224,53,43,.6), rgba(224,53,43,0) 16%); opacity: 0; }
#dd-hurt { background: radial-gradient(ellipse at center, rgba(90,0,0,0) 25%, rgba(90,0,0,.92) 100%); opacity: 0; }
#dd-flash { background: #fffbe8; opacity: 0; }

/* ---- HUD: a green highway guide sign */
#dd-hud { position: absolute; top: calc(12px + env(safe-area-inset-top, 0px)); left: 16px; }
.guide { background: var(--guide); color: var(--white); border: 2px solid var(--white); outline: 3px solid var(--guide); border-radius: 9px; padding: 7px 14px 5px; min-width: 150px; box-shadow: 0 6px 18px rgba(0,0,0,.45); }
.g-road { font-size: 11px; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; opacity: .85; }
.g-name { font-size: 24px; font-weight: 900; line-height: 1.1; }
.g-stats { display: flex; gap: 14px; font-size: 11px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; margin-top: 2px; font-variant-numeric: tabular-nums; }
.g-stats b { font-size: 14px; letter-spacing: 0; }
.dd-chip { position: absolute; top: calc(12px + env(safe-area-inset-top, 0px)); right: 16px; background: rgba(11,16,32,.6); color: var(--white); border: 1px solid rgba(245,243,234,.35); border-radius: 999px; padding: 7px 12px 5px; font: 700 11px/1 'Overpass', system-ui, sans-serif; letter-spacing: .1em; text-transform: uppercase; cursor: pointer; z-index: 3; }
.dd-chip:focus-visible, .dd-btn:focus-visible, .tbtn:focus-visible, .dia:focus-visible { outline: 3px solid var(--white); outline-offset: 3px; }

/* ---- toast messages */
.dd-toast { position: absolute; left: 16px; right: 16px; top: 22%; text-align: center; font-weight: 900; font-size: clamp(22px, 4.2vw, 42px); line-height: 1.1; text-wrap: balance; color: var(--white);
  text-shadow: 0 2px 0 #000, 0 0 24px rgba(0,0,0,.85); opacity: 0; transform: translateY(8px); transition: opacity .25s, transform .25s; pointer-events: none; }
.dd-toast.show { opacity: 1; transform: none; }
.dd-toast small { display: block; font-size: max(14px, .42em); font-weight: 700; letter-spacing: .05em; margin-top: .5em; opacity: .9; }

/* ---- headlight freeze QTE: yellow warning-sign diamonds */
#dd-qte { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); width: min(92vw, 520px); display: flex; flex-direction: column; align-items: center; gap: 12px; pointer-events: none; }
.q-band { background: var(--sign); color: var(--ink); font-weight: 900; font-size: clamp(20px, 4vw, 30px); letter-spacing: .06em; text-transform: uppercase; padding: 7px 18px 3px; border: 3px solid var(--ink); border-radius: 6px; animation: ddpulse .45s ease-in-out infinite alternate; text-align: center; }
.q-sub { margin: 0; font-weight: 700; font-size: 15px; letter-spacing: .04em; text-shadow: 0 1px 0 #000, 0 0 10px #000; text-align: center; }
.q-keys { display: flex; gap: 30px; padding: 16px 8px; flex-wrap: wrap; justify-content: center; }
.dia { position: relative; width: 62px; height: 62px; border: 0; padding: 0; background: transparent; display: grid; place-items: center; pointer-events: auto; cursor: pointer; touch-action: none; }
.dia::before { content: ""; position: absolute; inset: 0; background: var(--sign); border: 3px solid var(--ink); border-radius: 7px; transform: rotate(45deg); box-shadow: 0 0 0 2px var(--sign); }
.dia span { position: relative; font: 900 28px/1 'Overpass', system-ui, sans-serif; color: var(--ink); padding-top: 4px; }
.dia.wide { width: 92px; height: 92px; }
.dia.wide span { font-size: 17px; letter-spacing: .06em; }
.dia.done::before { background: #3b3f47; box-shadow: none; border-color: #23262c; }
.dia.done span { color: #8a8f99; }
.dia.next::before { animation: ddglow .3s ease-in-out infinite alternate; }
.dia.wait { opacity: .4; cursor: default; }
#dd-qte.intro .q-band { animation: none; background: var(--white); }
#dd-qte.intro .q-timer { opacity: .35; }
.q-meter { width: 80%; height: 14px; background: rgba(0,0,0,.55); border: 2px solid var(--sign); border-radius: 4px; overflow: hidden; }
.q-meter i { display: block; height: 100%; width: 0; background: var(--sign); }
.q-timer { width: 70%; height: 5px; background: rgba(255,255,255,.2); border-radius: 3px; overflow: hidden; }
.q-timer i { display: block; height: 100%; width: 100%; background: var(--brake); }
@keyframes ddpulse { to { transform: scale(1.05); } }
@keyframes ddglow { to { box-shadow: 0 0 0 2px var(--sign), 0 0 28px 8px rgba(255,204,0,.8); } }

/* ---- controls: keyboard hint and touch buttons */
#dd-hint { position: absolute; bottom: calc(14px + env(safe-area-inset-bottom, 0px)); left: 16px; right: 16px; text-align: center; font-size: 11px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; opacity: .6; pointer-events: none; }
#dd-hint b { color: var(--sign); }
#dd-touch { position: absolute; left: 0; right: 0; bottom: 0; padding: 0 16px calc(16px + env(safe-area-inset-bottom, 0px)); display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; pointer-events: none; }
.tbtn { pointer-events: auto; background: rgba(11,16,32,.55); color: var(--white); border: 2px solid rgba(245,243,234,.5); border-radius: 14px; font: 900 15px/1 'Overpass', system-ui, sans-serif; letter-spacing: .06em; text-transform: uppercase; padding: 20px 14px 16px; min-width: 84px; touch-action: none; }
.tbtn.on { background: rgba(245,243,234,.3); }
.tbtn.big { background: var(--sign); color: var(--ink); border-color: var(--ink); min-width: 112px; padding: 24px 14px 20px; font-size: 18px; }
.tbtn.small { padding: 10px; font-size: 12px; }
.tmid { display: flex; flex-direction: column; gap: 8px; }

/* ---- full-screen overlays: title and obituary */
.dd-screen { position: absolute; inset: 0; display: flex; padding: 16px; background: rgba(6,9,18,.55); overflow-y: auto; touch-action: pan-y; z-index: 4; }
.dd-screen > * { margin: auto; }

.t-card { display: flex; gap: 30px; align-items: center; max-width: 780px; width: 100%; }
.xing { flex: none; width: 190px; height: 190px; display: grid; place-items: center; position: relative; }
.xing::before { content: ""; position: absolute; inset: 28px; background: var(--sign); border: 6px solid var(--ink); outline: 4px solid var(--sign); border-radius: 14px; transform: rotate(45deg); box-shadow: 0 22px 60px rgba(0,0,0,.55); }
.xing-in { position: relative; display: flex; flex-direction: column; align-items: center; color: var(--ink); font-weight: 900; font-size: 32px; line-height: .95; padding-top: 6px; }
.t-body { min-width: 0; }
.t-eyebrow { margin: 0 0 6px; font-size: 12px; font-weight: 700; letter-spacing: .22em; text-transform: uppercase; color: var(--sign); }
.t-body h1 { margin: 0; font-size: clamp(46px, 8vw, 78px); font-weight: 900; line-height: .9; letter-spacing: -.02em; text-wrap: balance; }
.t-body h1 span { color: var(--sign); }
.t-tag { margin: 14px 0 0; font-size: 17px; line-height: 1.45; max-width: 44ch; color: rgba(245,243,234,.88); }
.t-keys { list-style: none; padding: 0; margin: 18px 0 22px; display: grid; gap: 9px; font-size: 14px; line-height: 1.4; color: rgba(245,243,234,.85); }
.t-keys kbd { display: inline-block; min-width: 22px; padding: 3px 6px 1px; margin-right: 5px; border: 1px solid rgba(245,243,234,.55); border-bottom-width: 3px; border-radius: 5px; font: 700 12px/1.3 'Overpass', system-ui, sans-serif; text-align: center; color: var(--white); }
#dd-root.is-touch .only-keys, #dd-root:not(.is-touch) .only-touch { display: none; }
.dd-btn { background: var(--sign); color: var(--ink); border: 3px solid var(--ink); outline: 2px solid var(--sign); border-radius: 8px; padding: 13px 24px 9px; font: 900 18px/1 'Overpass', system-ui, sans-serif; letter-spacing: .05em; text-transform: uppercase; cursor: pointer; transition: transform .12s; }
.dd-btn:hover { transform: translateY(-2px); }
.t-gen { margin: 16px 0 0; font-size: 13px; color: rgba(245,243,234,.7); }
.t-credit { margin: 10px 0 0; font-size: 11px; color: rgba(245,243,234,.45); }
.t-credit a { color: inherit; }

/* obituary: a clipping from the local paper */
.paper { background: var(--paper); color: var(--paper-ink); width: min(100%, 470px); padding: 22px 26px 24px; font-family: 'Libre Caslon Text', Georgia, 'Times New Roman', serif;
  box-shadow: 0 30px 80px rgba(0,0,0,.65); transform: rotate(-1.2deg); border-radius: 2px; -webkit-user-select: text; user-select: text; animation: ddin .6s cubic-bezier(.2,.8,.2,1); }
@keyframes ddin { from { transform: translateY(24px) rotate(-4deg); } }
.mast { display: flex; justify-content: space-between; gap: 10px; border-bottom: 3px double var(--paper-ink); padding-bottom: 6px; font: 700 11px/1.2 'Overpass', system-ui, sans-serif; letter-spacing: .1em; text-transform: uppercase; }
.o-sec { margin: 12px 0 4px; font: 700 11px/1 'Overpass', system-ui, sans-serif; letter-spacing: .26em; text-transform: uppercase; color: var(--paper-soft); }
.paper h2 { margin: 0; font-size: 36px; font-weight: 700; line-height: 1.05; }
.o-dates { margin: 4px 0 14px; font-style: italic; font-size: 14px; color: var(--paper-soft); }
.o-photo { float: right; width: 120px; margin: 4px 0 10px 16px; }
.o-photo img { display: block; width: 100%; aspect-ratio: 1; object-fit: cover; filter: grayscale(1) contrast(1.4) brightness(1.15); border: 1px solid var(--paper-ink); }
.o-photo figcaption { margin-top: 4px; font: 700 9px/1.2 'Overpass', system-ui, sans-serif; letter-spacing: .14em; text-transform: uppercase; color: var(--paper-soft); }
#dd-obody p { margin: 0 0 10px; font-size: 15px; line-height: 1.55; }
#dd-obody p:first-child::first-letter { float: left; font-size: 46px; line-height: .82; padding: 5px 6px 0 0; font-weight: 700; }
#dd-obody .o-foot { clear: both; border-top: 1px solid rgba(31,27,22,.3); padding-top: 8px; margin-top: 12px; font-size: 13px; font-style: italic; color: var(--paper-soft); }
.dd-btn.dark { margin-top: 8px; background: var(--paper-ink); color: var(--paper); border-color: var(--paper-ink); outline-color: transparent; font-size: 15px; }

@media (max-width: 620px) {
  .t-card { flex-direction: column; align-items: flex-start; gap: 4px; }
  .xing { width: 124px; height: 124px; margin-left: -8px; }
  .xing::before { inset: 18px; border-width: 4px; outline-width: 3px; }
  .xing-in { font-size: 21px; }
  .paper { padding: 18px 18px 20px; }
  .paper h2 { font-size: 30px; }
  .o-photo { width: 96px; }
}
@media (prefers-reduced-motion: reduce) {
  .q-band, .dia.next::before, .paper { animation: none; }
  .dd-toast { transition: none; }
}
