:root {
  --natt-djup: #0b1430;
  --sno: #f3f6fb;
  --julrod: #a81c26;
  --julrod-mork: #8f1820;
  --guld: #dcae45;
  --gran: #1f5a3c;
  --tavla: #16130c;
  --lysdiod: #ffb300;
  --papper: #f6ecd2;
  --kol: 4;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--julrod-mork);
  color: var(--sno);
  font-family: Georgia, "Iowan Old Style", "Palatino Linotype", "Times New Roman", serif;
  display: flex;
  justify-content: center;
  min-height: 100dvh;
}
button { font: inherit; color: inherit; }

/* The card: red board, gold line, the picture inside. It fills the screen
   up to a width where the doors would drift apart. */
.kalender {
  width: min(100%, 84rem);
  min-height: 100dvh;
  padding:
    max(.7rem, env(safe-area-inset-top))
    max(.7rem, env(safe-area-inset-right))
    max(.7rem, env(safe-area-inset-bottom))
    max(.7rem, env(safe-area-inset-left));
  display: flex;
  flex-direction: column;
  background:
    radial-gradient(circle at 20% 0%, rgba(255,255,255,.08), transparent 40%),
    var(--julrod);
}
.huvud {
  display: flex;
  align-items: center;
  gap: .8rem;
  padding: .3rem .3rem .7rem;
}
/* HL's mark: the letters on square wheels. */
.marke { flex: none; width: 3.2rem; height: 3.2rem; }
.titel { flex: 1; min-width: 0; }
.huvud h1 {
  margin: 0;
  /* Gold on the red is 3.6:1: large text only, so never under 24px. */
  font-size: clamp(1.5rem, 1rem + 2.2vw, 2.6rem);
  line-height: 1.05;
  font-weight: 400;
  font-style: italic;
  color: var(--guld);
  text-shadow: 0 1px 0 rgba(0,0,0,.35);
}
.huvud p {
  margin: .15rem 0 0;
  font-size: clamp(.95rem, .85rem + .4vw, 1.15rem);
  color: #f7d9d2;
}

.bild {
  position: relative;
  /* Grows to fill the screen, never shrinks below its doors. */
  flex: 1 0 auto;
  border: 2px solid var(--guld);
  outline: 1px solid rgba(220,174,69,.5);
  outline-offset: 3px;
  border-radius: 4px;
  overflow: hidden;
  background: var(--natt-djup);
  display: grid;
}
.scen {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
}

/* Door 24 takes four cells, so 27 cells in all: 4 columns on a phone, 6 on a
   tablet or a phone on its side, 9 on a wide screen. */
.luckor {
  position: relative;
  display: grid;
  grid-template-columns: repeat(var(--kol), 1fr);
  grid-auto-rows: minmax(4.4rem, 1fr);
  grid-auto-flow: dense;
  padding: .5rem;
}
@media (min-width: 36rem) { :root { --kol: 6; } }
@media (min-width: 64rem) and (min-aspect-ratio: 5/4) { :root { --kol: 9; } }

.lucka {
  position: relative;
  perspective: 600px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.lucka.stor { grid-column: span 2; grid-row: span 2; }
.lucka .ram {
  position: relative;
  width: var(--w, 72%);
  aspect-ratio: var(--ar, 1);
  max-height: 92%;
  transform: translate(var(--dx, 0), var(--dy, 0));
  transform-style: preserve-3d;
  container-type: inline-size;
}
.lucka .inne {
  position: absolute; inset: 0;
  background: var(--papper);
  box-shadow: inset 0 0 .6rem rgba(60,30,0,.55);
  display: grid; place-items: center;
  font-size: 46cqw;
  line-height: 1;
  opacity: 0;
}
.lucka .blad {
  position: absolute; inset: 0;
  transform-origin: left center;
  transition: transform .7s cubic-bezier(.3,.1,.2,1);
  transform-style: preserve-3d;
}
.lucka .fram, .lucka .bak {
  position: absolute; inset: 0;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}
.lucka .fram {
  /* Opaque, so the number reads the same over sky, windows and snow. */
  border: 2px solid var(--guld);
  background: var(--natt-djup);
  display: grid; place-items: center;
  font-size: clamp(1.2rem, 38cqw, 4rem);
  color: var(--guld);
  text-shadow: 0 1px 2px rgba(0,0,0,.8);
}
.lucka .bak {
  transform: rotateY(180deg);
  background: #cdbf9b;
  box-shadow: inset 0 0 .5rem rgba(60,30,0,.4);
}
.lucka.idag .fram {
  border-width: 3px;
  background: #3a3220;
  animation: glod 2.4s ease-in-out infinite;
}
@keyframes glod {
  50% { box-shadow: 0 0 1.1rem .15rem rgba(220,174,69,.85); }
}
.lucka.last { cursor: default; }
/* A locked door is dashed, not dimmed: it can still be pressed. */
.lucka.last .fram { border-style: dashed; border-width: 1.5px; }
.lucka.oppen .inne { opacity: 1; }
.lucka.oppen .blad { transform: rotateY(-152deg); }
.lucka:focus-visible { outline: none; }
.lucka:focus-visible .ram { outline: 3px solid var(--sno); outline-offset: 3px; }
.lucka.skaka .ram { animation: skaka .35s; }
@keyframes skaka {
  25% { translate: -4px 0; } 50% { translate: 4px 0; } 75% { translate: -2px 0; }
}

.fot {
  padding: .7rem .3rem 0;
  font-size: .875rem;
  line-height: 1.4;
  color: #f1c9c1;
}
.fot a { color: inherit; }
.fot a:focus-visible { outline: 3px solid var(--sno); outline-offset: 2px; }

/* Share the calendar: the code, the address, two buttons. */
.kort {
  background: var(--papper);
  color: #1a1a19;
  border: 2px solid var(--guld);
  border-radius: .5rem;
  padding: 1rem 1rem .8rem;
  text-align: center;
  box-shadow: 0 1.2rem 3rem rgba(0,0,0,.6);
}
.kort h2 { margin: 0 0 .7rem; font-size: 1.35rem; font-weight: 400; font-style: italic; }
.kort img { display: block; width: min(100%, 15rem); height: auto; margin: 0 auto; background: #fff; }
.kort .adress { margin: .6rem 0 0; font: 700 1.05rem/1.3 "Helvetica Neue", Arial, sans-serif; }
#dela-ruta { width: min(92vw, 22rem); }

/* The message: a departure board. */
dialog {
  border: 0; padding: 0;
  background: none;
  color: inherit;
  width: min(92vw, 34rem);
  max-height: 92dvh;
  overflow: auto;
}
dialog::backdrop { background: rgba(6,10,25,.78); }
.tavla {
  background: var(--tavla);
  border: .45rem solid #2c2a26;
  border-radius: .5rem;
  box-shadow: 0 1.2rem 3rem rgba(0,0,0,.6), inset 0 0 0 1px #000;
  padding: 1.1rem 1.1rem 1.2rem;
  font-family: "Courier New", ui-monospace, Menlo, monospace;
  color: var(--lysdiod);
  text-shadow: 0 0 .5rem rgba(255,179,0,.55);
}
.tavla .rad {
  display: flex; justify-content: space-between; gap: 1rem;
  font-size: .85rem;
  padding-bottom: .6rem;
  border-bottom: 1px dotted rgba(255,179,0,.45);
}
.tavla h2 {
  margin: .9rem 0 .5rem;
  font-size: clamp(1.3rem, 1.1rem + .8vw, 1.6rem);
  line-height: 1.2;
  font-weight: 700;
}
.tavla p {
  margin: 0;
  font-size: clamp(1.05rem, .95rem + .4vw, 1.2rem);
  line-height: 1.5;
  font-weight: 700;
}
.knappar {
  display: flex; flex-wrap: wrap; gap: .6rem; justify-content: flex-end;
  margin-top: .8rem;
}
.knapp {
  min-height: 2.9rem;
  padding: 0 1.3rem;
  border-radius: 1.5rem;
  border: 2px solid var(--guld);
  background: var(--julrod);
  color: var(--sno);
  font: inherit;
  font-size: 1rem;
  cursor: pointer;
  display: inline-grid; place-items: center;
  text-decoration: none;
}
.knapp.stang { background: transparent; }
.huvud .knapp { flex: none; }
.knapp.lank { background: var(--gran); margin-right: auto; }
.knapp[hidden] { display: none; }
.knapp:focus-visible { outline: 3px solid var(--sno); outline-offset: 2px; }

.besked {
  position: fixed;
  /* At the top, clear of the thumbs (playbook contracts/thumb.md). */
  left: 50%; top: max(1rem, env(safe-area-inset-top));
  transform: translateX(-50%);
  background: var(--natt-djup);
  color: var(--sno);
  border: 1px solid var(--guld);
  border-radius: 1.5rem;
  padding: .6rem 1.1rem;
  font-size: .95rem;
  width: max-content;
  max-width: min(84vw, 22rem);
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s;
  z-index: 10;
}
.besked.syns { opacity: 1; }

/* Snow over the whole page, on purpose a bit much. It lies over everything
   and takes no presses; under reduced motion the flakes stand still. */
.sno {
  position: fixed; inset: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: 5;
}
.sno span {
  position: absolute;
  top: -2rem;
  color: #fff;
  text-shadow: 0 0 .25rem rgba(120,160,255,.7);
  will-change: transform;
  animation: fall linear infinite, vaj ease-in-out infinite alternate;
}
@keyframes fall { to { translate: 0 calc(100dvh + 4rem); } }
@keyframes vaj { from { margin-left: -1.2rem; rotate: -40deg; } to { margin-left: 1.2rem; rotate: 40deg; } }

@media (prefers-reduced-motion: reduce) {
  .lucka .blad { transition: none; }
  .lucka.idag .fram, .lucka.skaka .ram { animation: none; }
  .sno span { animation: none; top: var(--still); }
}
