/* Lenormand: dark vintage table, gold accents. Mobile first. */

@font-face {
  font-family: "Old Standard TT";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url(/fonts/old-standard-tt-cyrillic-400-normal.woff2) format("woff2");
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
  font-family: "Old Standard TT";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url(/fonts/old-standard-tt-latin-400-normal.woff2) format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Old Standard TT";
  font-style: italic;
  font-weight: 400;
  font-display: swap;
  src: url(/fonts/old-standard-tt-cyrillic-400-italic.woff2) format("woff2");
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
  font-family: "Old Standard TT";
  font-style: italic;
  font-weight: 400;
  font-display: swap;
  src: url(/fonts/old-standard-tt-latin-400-italic.woff2) format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Old Standard TT";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url(/fonts/old-standard-tt-cyrillic-700-normal.woff2) format("woff2");
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
  font-family: "Old Standard TT";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url(/fonts/old-standard-tt-latin-700-normal.woff2) format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  --bg: #120d09;
  --ink: #efe6d2;
  --muted: #b5a487;
  --faint: #857659;
  --gold: #d9b66a;
  --gold-hi: #fce7ac;
  --line: rgba(217, 182, 106, 0.3);
  --quantum: #8fe0cf;
  --serif: "Old Standard TT", Georgia, "Times New Roman", serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  /* rounded corners of the card art: 88 px on a 1548 x 1968 card */
  --corner: 5.685% / 4.472%;
  --gutter: 16px;
  color-scheme: dark;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  background: var(--bg);
}

html:has(dialog[open]) {
  overflow: hidden;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  color: var(--ink);
  background:
    radial-gradient(130% 60% at 50% -12%, #3d2b17 0%, #20160d 48%, rgba(18, 13, 9, 0) 78%),
    var(--bg);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.5;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  overflow-x: hidden;
}

.defs {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

button {
  font: inherit;
  color: inherit;
}

a {
  color: var(--muted);
  text-underline-offset: 2px;
}

:focus-visible {
  outline: 2px solid var(--gold-hi);
  outline-offset: 3px;
}

/* ---------- header ---------- */

.top {
  text-align: center;
  padding: 26px var(--gutter) 2px;
}

.title {
  margin: 0;
  font-family: var(--serif);
  font-weight: 700;
  font-size: clamp(38px, 11vw, 58px);
  line-height: 1.1;
  letter-spacing: 0.05em;
  color: var(--gold-hi);
  background: linear-gradient(180deg, #fff3cf 0%, #e9c77c 52%, #a77f3c 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 3px 10px rgba(0, 0, 0, 0.55));
}

.subtitle {
  margin: 6px 0 0;
  font-family: var(--serif);
  font-style: italic;
  font-size: 16px;
  color: var(--muted);
  text-wrap: balance;
}

.subtitle::before,
.subtitle::after {
  content: "";
  display: inline-block;
  width: 26px;
  height: 1px;
  margin: 0 10px;
  vertical-align: 0.32em;
  background: linear-gradient(90deg, transparent, var(--gold));
}

.subtitle::after {
  background: linear-gradient(90deg, var(--gold), transparent);
}

@media (max-width: 479px) {
  .subtitle::before,
  .subtitle::after {
    display: none;
  }
}

/* ---------- spread picker ---------- */

.spreads {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  max-width: 640px;
  margin: 0 auto;
  padding: 18px var(--gutter) 0;
}

.chip {
  min-height: 40px;
  padding: 9px 15px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 240, 210, 0.04);
  font-size: 14px;
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
  transition: background-color 0.2s, border-color 0.2s, color 0.2s, box-shadow 0.2s;
  -webkit-tap-highlight-color: transparent;
}

.chip:hover {
  border-color: rgba(217, 182, 106, 0.6);
}

.chip[aria-pressed="true"] {
  color: #24170b;
  border-color: transparent;
  background: linear-gradient(180deg, #f6dd9d, #c99f52);
  box-shadow: 0 3px 14px rgba(217, 182, 106, 0.28);
}

.variants {
  display: flex;
  justify-content: center;
  margin-top: 10px;
}

.seg {
  min-height: 34px;
  padding: 7px 14px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.seg:first-child {
  border-radius: 999px 0 0 999px;
}

.seg:last-child {
  border-radius: 0 999px 999px 0;
  border-left: 0;
}

.seg[aria-pressed="true"] {
  color: var(--gold-hi);
  background: rgba(217, 182, 106, 0.16);
}

/* ---------- deal button ---------- */

.actions {
  display: flex;
  justify-content: center;
  padding: 18px var(--gutter) 6px;
}

.deal {
  min-width: 220px;
  min-height: 52px;
  padding: 14px 34px;
  border: 1px solid #f6dfa0;
  border-radius: 999px;
  color: #24170b;
  background: linear-gradient(180deg, #fde9b0 0%, #dcb465 58%, #b98c43 100%);
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.55);
  font-family: var(--serif);
  font-size: 19px;
  font-weight: 700;
  letter-spacing: 0.03em;
  line-height: 1;
  cursor: pointer;
  transition: transform 0.12s, filter 0.2s, opacity 0.2s;
  -webkit-tap-highlight-color: transparent;
}

.deal:hover {
  filter: brightness(1.05);
}

.deal:active {
  transform: translateY(1px) scale(0.99);
}

.deal:disabled {
  opacity: 0.65;
  cursor: default;
  transform: none;
}

/* ---------- table ---------- */

.table-wrap {
  padding: 14px var(--gutter) 0;
}

.table-tools {
  display: flex;
  justify-content: flex-end;
  max-width: 1180px;
  margin: 0 auto 8px;
}

.tool {
  min-height: 34px;
  padding: 6px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.tool[aria-pressed="true"] {
  color: var(--gold-hi);
  background: rgba(217, 182, 106, 0.16);
}

@media (min-width: 900px) {
  .table-tools {
    display: none;
  }
}

.table {
  --gap: 10px;
  --max: 600px;
  display: grid;
  grid-template-columns: repeat(var(--cols, 3), minmax(0, 1fr));
  gap: calc(var(--gap) * 1.4) var(--gap);
  max-width: var(--max);
  margin: 0 auto;
}

.table.l-day {
  --max: 270px;
}

.table.l-three {
  --max: 600px;
}

.table.l-five {
  --max: 860px;
  --gap: 6px;
}

.table.l-nine {
  --max: 470px;
  --gap: 9px;
}

.table.l-gt84,
.table.l-gt94 {
  --max: 1180px;
  --gap: 4px;
}

.table.l-gt84 .slot:nth-child(33) {
  grid-column: 3;
}

@media (min-width: 700px) {
  .table.l-day {
    --max: 320px;
  }

  .table.l-three {
    --max: 760px;
    --gap: 18px;
  }

  .table.l-nine {
    --max: 560px;
  }

  .table.l-five {
    --gap: 14px;
  }

  .table.l-gt84,
  .table.l-gt94 {
    --gap: 10px;
  }
}

.table-wrap.zoomed {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 8px;
}

.table-wrap.zoomed .table {
  width: calc(var(--cols) * 84px + (var(--cols) - 1) * var(--gap));
  max-width: none;
}

.slot {
  container-type: inline-size;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 7px;
  min-width: 0;
  animation: slot-in 0.5s cubic-bezier(0.2, 0.8, 0.2, 1) both;
  animation-delay: var(--appear, 0ms);
}

@keyframes slot-in {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.96);
  }
}

.card {
  all: unset;
  display: block;
  width: 100%;
  border-radius: var(--corner);
  cursor: pointer;
  perspective: 1100px;
  -webkit-tap-highlight-color: transparent;
}

.card:focus-visible {
  outline: 2px solid var(--gold-hi);
  outline-offset: 3px;
}

.card-inner {
  position: relative;
  display: block;
  width: 100%;
  aspect-ratio: 1548 / 1968;
  transform-style: preserve-3d;
  transition: transform 0.8s cubic-bezier(0.3, 0.75, 0.25, 1);
  transition-delay: var(--delay, 0ms);
}

.slot.open .card-inner {
  transform: rotateY(180deg);
}

@media (hover: hover) {
  .card:hover .card-inner {
    translate: 0 -2px;
  }
}

.face {
  position: absolute;
  inset: 0;
  display: block;
  overflow: hidden;
  border-radius: var(--corner);
  background: #281d14;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.5), 0 1px 3px rgba(0, 0, 0, 0.6);
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
}

.face.front {
  transform: rotateY(180deg);
}

.face.back svg {
  display: block;
  width: 100%;
  height: 100%;
}

.scene {
  position: absolute;
  left: 6%;
  top: 3.5%;
  width: 88%;
  height: 93%;
  display: block;
  object-fit: cover;
}

.frame {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
}

.marks {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.marks text {
  font-family: var(--serif);
  font-weight: 700;
}

.marks .m-kw {
  font-weight: 400;
  font-style: italic;
}

.slot.sig.open .face.front {
  box-shadow: 0 0 0 2px #f3d58e, 0 0 16px 2px rgba(243, 213, 142, 0.55), 0 6px 16px rgba(0, 0, 0, 0.5);
}

.label {
  max-width: 100%;
  font-family: var(--serif);
  font-size: 14px;
  line-height: 1.25;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  opacity: 0;
  transform: translateY(-3px);
  transition: opacity 0.4s, transform 0.4s;
  transition-delay: calc(var(--delay, 0ms) + 0.5s);
}

.slot:not(.open) .label {
  transition-delay: 0s;
}

.slot.open .label {
  opacity: 1;
  transform: none;
}

.label .n {
  color: var(--gold);
  font-variant-numeric: tabular-nums;
}

/* the main card of a line or a square: gold name */
.slot.key .label .name {
  color: var(--gold);
  font-weight: 700;
}

@media (min-width: 700px) {
  .l-three .label,
  .l-five .label,
  .l-nine .label {
    font-size: 16px;
  }
}

.label .kw {
  display: block;
  margin-top: 3px;
  font-style: italic;
  font-size: 14px;
  color: var(--muted);
  white-space: normal;
}

.l-day .label {
  font-size: 22px;
  color: var(--gold-hi);
  overflow: visible;
}

.l-gt84 .label,
.l-gt94 .label {
  font-size: 12px;
}

@container (max-width: 76px) {
  .label {
    font-size: 11px;
  }

  .label .nm {
    display: none;
  }
}

/* ---------- status, hint, footer ---------- */

.status {
  text-wrap: balance;
  max-width: 640px;
  min-height: 1.5em;
  margin: 22px auto 0;
  padding: 0 var(--gutter);
  text-align: center;
  font-size: 14px;
  color: var(--muted);
}

.status .badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-weight: 600;
  color: var(--gold-hi);
}

.status .badge::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 10px currentColor;
}

.status.quantum .badge {
  color: var(--quantum);
}

.status.local .badge {
  color: var(--gold);
}

.status.offline .badge {
  color: var(--muted);
}

.status .note {
  display: block;
  margin-top: 2px;
}

.hint {
  text-wrap: balance;
  max-width: 560px;
  margin: 12px auto 0;
  padding: 0 var(--gutter);
  text-align: center;
  font-family: var(--serif);
  font-style: italic;
  font-size: 17px;
  color: var(--muted);
}

.foot {
  padding: 40px var(--gutter) 30px;
  text-align: center;
  font-size: 13px;
  color: var(--faint);
}

.foot p {
  margin: 4px 0;
}

.noscript {
  text-align: center;
  color: var(--muted);
}

/* ---------- card sheet ---------- */

.sheet {
  width: 100%;
  max-width: 100vw;
  max-height: 94vh;
  max-height: 94dvh;
  margin: auto 0 0;
  padding: 0;
  border: 0;
  border-radius: 20px 20px 0 0;
  color: var(--ink);
  background: linear-gradient(180deg, #2b2016 0%, #17100b 100%);
  box-shadow: 0 -12px 40px rgba(0, 0, 0, 0.6);
  overscroll-behavior: contain;
}

.sheet::backdrop {
  background: rgba(8, 5, 3, 0.74);
}

.sheet[open] {
  animation: sheet-up 0.34s cubic-bezier(0.2, 0.8, 0.2, 1);
}

@keyframes sheet-up {
  from {
    transform: translateY(48px);
    opacity: 0;
  }
}

.sheet-inner {
  display: flex;
  flex-direction: column;
  padding: 6px 18px calc(14px + env(safe-area-inset-bottom));
}

.sheet-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 46px;
}

.sheet-pos {
  font-size: 13px;
  color: var(--muted);
  letter-spacing: 0.02em;
}

.icon-btn,
.nav-btn {
  all: unset;
  display: grid;
  place-items: center;
  border-radius: 50%;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.icon-btn {
  width: 44px;
  height: 44px;
  margin-right: -10px;
}

.nav-btn {
  width: 48px;
  height: 48px;
  border: 1px solid var(--line);
}

.nav-btn:disabled {
  opacity: 0.3;
  cursor: default;
}

.icon-btn:focus-visible,
.nav-btn:focus-visible {
  outline: 2px solid var(--gold-hi);
  outline-offset: 2px;
}

.icon-btn svg,
.nav-btn svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: var(--ink);
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.sheet-main {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  touch-action: pan-y;
}

.sheet-card {
  width: min(66vw, 300px);
  flex: none;
}

.bigcard {
  position: relative;
  display: block;
  width: 100%;
  aspect-ratio: 1548 / 1968;
  overflow: hidden;
  border-radius: var(--corner);
  background: #281d14;
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.6), 0 2px 6px rgba(0, 0, 0, 0.6);
}

.sheet-text {
  width: 100%;
  max-width: 520px;
}

.sheet-title {
  margin: 0;
  font-family: var(--serif);
  font-size: 30px;
  font-weight: 700;
  line-height: 1.15;
  text-align: center;
  color: var(--gold-hi);
}

.sheet-sub {
  margin: 6px 0 0;
  text-align: center;
  font-size: 14px;
  color: var(--muted);
}

.sheet-sub .suit {
  display: inline-block;
  width: 12px;
  height: 12px;
  margin-left: 4px;
  vertical-align: -1px;
}

.sheet-sub .suit.red {
  fill: #e0725f;
}

.sheet-sub .suit.black {
  fill: var(--ink);
}

.sheet-kw {
  margin: 10px 0 0;
  text-align: center;
  font-family: var(--serif);
  font-style: italic;
  font-size: 18px;
  color: var(--gold);
}

.sheet-meaning {
  margin: 12px 0 0;
  font-family: var(--serif);
  font-size: 19px;
  line-height: 1.5;
}

.sheet-house {
  margin: 10px 0 0;
  font-size: 14px;
  color: var(--muted);
}

.sheet-house:empty {
  display: none;
}

.sheet-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 16px;
}

.sheet-count {
  font-size: 14px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

@media (min-width: 760px) {
  .sheet {
    width: min(880px, calc(100vw - 48px));
    max-height: calc(100dvh - 48px);
    margin: auto;
    border-radius: 20px;
  }

  .sheet-inner {
    padding: 8px 26px 20px;
  }

  .sheet-main {
    flex-direction: row;
    align-items: flex-start;
    gap: 30px;
  }

  .sheet-card {
    width: 340px;
  }

  .sheet-title,
  .sheet-sub,
  .sheet-kw {
    text-align: left;
  }

  .sheet-text {
    padding-top: 8px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-delay: 0s !important;
    transition-duration: 0.01ms !important;
    transition-delay: 0s !important;
  }
}
