@font-face {
  font-family: "League Spartan";
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url("fonts/league-spartan.woff2") format("woff2");
}

@font-face {
  font-family: "Atkinson Hyperlegible Next";
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url("fonts/atkinson-next.woff2") format("woff2");
  unicode-range: U+0000-002F, U+003A-10FFFF;
}

@font-face {
  font-family: "Atkinson Hyperlegible Next";
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url("fonts/league-spartan.woff2") format("woff2");
  unicode-range: U+0030-0039;
}

:root {
  color-scheme: light dark;

  --bg: #f3f5f2;
  --ink: #12352b;
  --soft: #3f5d55;
  --rule: #c3cfca;
  --field: #ffffff;
  --off: #dbe4e0;
  --focus: #0b57d0;

  --blue: #2d5c8a;
  --on-blue: #ffffff;
  --rye: #e7b13a;
  --on-rye: #12352b;
  --lingon: #b3324a;
  --on-lingon: #ffffff;
  --moss: #4f6f2a;
  --on-moss: #ffffff;
  --sky: #cfe0ea;
  --on-sky: #12352b;
  --pine: #12352b;
  --on-pine: #f3f5f2;

  --game-geo: var(--blue);
  --game-hive: var(--rye);
  --game-ladder: var(--lingon);
  --game-higher: var(--sky);
  --game-logic: var(--moss);
  --game-groups: var(--pine);
  --game-crossword: var(--rye);
  --game-whoami: var(--lingon);
  --game-survey: var(--blue);
  --game-cup: var(--pine);

  --shape-geo: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'%3E%3Ccircle cx='50' cy='50' r='50'/%3E%3C/svg%3E");
  --shape-hive: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'%3E%3Cpath fill-rule='evenodd' d='M50 0a50 50 0 1 1 0 100a50 50 0 1 1 0-100zm0 30a20 20 0 1 0 0 40a20 20 0 1 0 0-40z'/%3E%3C/svg%3E");
  --shape-ladder: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'%3E%3Cpath d='M0 100V75h25V50h25V25h25V0h25v100z'/%3E%3C/svg%3E");
  --shape-higher: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'%3E%3Cpath d='M50 0l50 100H0z'/%3E%3C/svg%3E");
  --shape-logic: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'%3E%3Cpath d='M0 0h46a46 46 0 0 1-46 46zM100 54v46H54a46 46 0 0 1 46-46zM54 46h46V0a46 46 0 0 0-46 46zM0 100V54a46 46 0 0 1 46 46z'/%3E%3C/svg%3E");
  --shape-groups: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'%3E%3Cpath d='M25 3a22 22 0 1 1 0 44a22 22 0 1 1 0-44zM75 3a22 22 0 1 1 0 44a22 22 0 1 1 0-44zM25 53a22 22 0 1 1 0 44a22 22 0 1 1 0-44zM75 53a22 22 0 1 1 0 44a22 22 0 1 1 0-44z'/%3E%3C/svg%3E");
  --shape-crossword: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'%3E%3Cpath d='M0 0h45v45H0zM55 0h45v45H55zM0 55h45v45H0z'/%3E%3C/svg%3E");
  --shape-whoami: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'%3E%3Cpath d='M0 100a50 50 0 0 1 100 0zM50 6a22 22 0 1 1 0 44a22 22 0 1 1 0-44z'/%3E%3C/svg%3E");
  --shape-survey: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'%3E%3Cpath d='M0 60h22v40H0zM26 20h22v80H26zM52 40h22v60H52zM78 0h22v100H78z'/%3E%3C/svg%3E");
  --shape-cup: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'%3E%3Cpath d='M10 0h80v40a40 40 0 0 1-80 0zM40 80h20v20H40z'/%3E%3C/svg%3E");

  --font: "Atkinson Hyperlegible Next", "Verdana", sans-serif;
  --font-display: "League Spartan", "Futura", "Century Gothic", sans-serif;
  --text-xs: 0.8125rem;
  --text-sm: 0.9375rem;
  --text-md: 1.0625rem;
  --text-lg: 1.3125rem;
  --text-xl: 1.875rem;
  --text-display: clamp(2.75rem, 11vw, 5.25rem);
  --leading: 1.5;
  --leading-tight: 1.1;

  --gutter: 6px;
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --space-7: 48px;
  --tap: 44px;
  --measure: 34em;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f2a24;
    --ink: #eef2ee;
    --soft: #a9c0b8;
    --rule: #2f4d45;
    --field: #163a32;
    --off: #1f433a;
    --focus: #8ab8ff;

    --blue: #3a6e9e;
    --lingon: #a52d43;
    --moss: #4a6a26;
    --sky: #c4d8e4;
    --pine: #e8efe9;
    --on-pine: #0f2a24;
  }
}

[data-dienio-game] {
  --game-ink: var(--on-pine);
}
[data-dienio-game="geo"] {
  --game: var(--game-geo);
  --game-ink: var(--on-blue);
  --shape: var(--shape-geo);
}
[data-dienio-game="hive"] {
  --game: var(--game-hive);
  --game-ink: var(--on-rye);
  --shape: var(--shape-hive);
}
[data-dienio-game="ladder"] {
  --game: var(--game-ladder);
  --game-ink: var(--on-lingon);
  --shape: var(--shape-ladder);
}
[data-dienio-game="higher"] {
  --game: var(--game-higher);
  --game-ink: var(--on-sky);
  --shape: var(--shape-higher);
}
[data-dienio-game="logic"] {
  --game: var(--game-logic);
  --game-ink: var(--on-moss);
  --shape: var(--shape-logic);
}
[data-dienio-game="groups"] {
  --game: var(--game-groups);
  --game-ink: var(--on-pine);
  --shape: var(--shape-groups);
}
[data-dienio-game="crossword"] {
  --game: var(--game-crossword);
  --game-ink: var(--on-rye);
  --shape: var(--shape-crossword);
}
[data-dienio-game="whoami"] {
  --game: var(--game-whoami);
  --game-ink: var(--on-lingon);
  --shape: var(--shape-whoami);
}
[data-dienio-game="survey"] {
  --game: var(--game-survey);
  --game-ink: var(--on-blue);
  --shape: var(--shape-survey);
}
[data-dienio-game="cup"] {
  --game: var(--game-cup);
  --game-ink: var(--on-pine);
  --shape: var(--shape-cup);
}

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

  html {
    -webkit-text-size-adjust: 100%;
    background: var(--bg);
    color: var(--ink);
    font: 400 var(--text-md) / var(--leading) var(--font);
    -webkit-font-smoothing: antialiased;
    font-variant-numeric: lining-nums;
  }

  body {
    margin: 0;
  }

  a {
    color: inherit;
    text-underline-offset: 4px;
    text-decoration-thickness: 1px;
  }

  button,
  input,
  select,
  textarea {
    font: inherit;
    color: inherit;
  }

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

  ::selection {
    background: var(--rye);
    color: var(--on-rye);
  }

  h1,
  h2,
  h3,
  .d-display,
  .d-result-figure {
    font-family: var(--font-display);
  }

  .d-display {
    margin: 0;
    font-size: var(--text-display);
    font-weight: 700;
    line-height: 0.95;
    letter-spacing: -0.025em;
  }

  .d-tile {
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    min-height: 168px;
    padding: 14px;
    background: var(--game, var(--off));
    color: var(--game-ink, var(--ink));
    text-decoration: none;
  }

  .d-shape {
    display: block;
    width: 76px;
    height: 76px;
    background: currentColor;
    -webkit-mask: var(--shape) center / contain no-repeat;
    mask: var(--shape) center / contain no-repeat;
  }

  .d-tile > .d-shape {
    position: absolute;
    right: -22px;
    bottom: -22px;
    opacity: 0.32;
  }

  .d-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    min-height: 48px;
    padding: 0 22px;
    border: 0;
    border-radius: 0;
    background: var(--ink);
    color: var(--bg);
    font: 600 var(--text-md) / 1.15 var(--font);
    text-decoration: none;
    cursor: pointer;
  }

  .d-btn:active {
    transform: translateY(1px);
  }

  .d-btn-game {
    background: var(--game);
    color: var(--game-ink);
  }

  .d-btn-quiet {
    background: var(--off);
    color: var(--ink);
  }

  .d-btn:disabled,
  .d-btn[aria-disabled="true"] {
    background: var(--off);
    color: var(--soft);
    cursor: not-allowed;
  }

  .d-input {
    min-height: 54px;
    width: 100%;
    padding: 0 16px;
    border: 2px solid var(--ink);
    border-radius: 0;
    background: var(--field);
    color: var(--ink);
    font: 400 1.125rem / 1.2 var(--font);
  }

  .d-input::placeholder {
    color: var(--soft);
    opacity: 1;
  }

  .d-field {
    display: grid;
    grid-template-columns: 1fr auto;
  }

  .d-field .d-input {
    border-right: 0;
  }

  .d-field .d-btn {
    min-height: 54px;
  }

  .d-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0 4px;
    font-variant-numeric: tabular-nums;
  }

  .d-table th {
    padding: var(--space-1) var(--space-3);
    color: var(--soft);
    font-size: var(--text-sm);
    font-weight: 500;
    text-align: left;
  }

  .d-table td {
    padding: var(--space-3);
    background: var(--off);
  }

  .d-table .d-num {
    text-align: right;
  }

  .d-table tr[aria-current] td {
    background: var(--game, var(--rye));
    color: var(--game-ink, var(--on-rye));
    font-weight: 600;
  }

  .d-dialog {
    width: min(100% - 2 * var(--space-4), 30rem);
    max-height: min(100% - 2 * var(--space-4), 40rem);
    padding: var(--space-5);
    border: 0;
    border-radius: 0;
    background: var(--bg);
    color: var(--ink);
  }

  .d-dialog::backdrop {
    background: rgb(18 53 43 / 0.72);
  }

  .d-dialog h2 {
    margin: 0 0 var(--space-3);
    font-size: var(--text-xl);
    line-height: var(--leading-tight);
  }

  .d-result {
    display: grid;
    gap: var(--space-2);
    padding: var(--space-5);
    background: var(--game, var(--off));
    color: var(--game-ink, var(--ink));
  }

  .d-result-figure {
    margin: 0;
    font-size: clamp(2.5rem, 12vw, 4rem);
    font-weight: 700;
    line-height: 1;
    letter-spacing: -0.02em;
    font-variant-numeric: tabular-nums;
  }

  .d-share {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin: 0;
    padding: 0;
    list-style: none;
  }

  .d-share > * {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: var(--off);
  }

  .d-share > [data-dienio-game] {
    background: var(--game);
  }

  .d-visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }

  @media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
      animation-duration: 0.01ms !important;
      animation-iteration-count: 1 !important;
      transition-duration: 0.01ms !important;
      scroll-behavior: auto !important;
    }

    .d-btn:active {
      transform: none;
    }
  }
}
