@font-face {
  font-family: "Oxygen";
  font-style: normal;
  font-weight: 300;
  font-display: swap;
  src: url("fonts/oxygen-300.woff2") format("woff2");
}

@font-face {
  font-family: "Oxygen";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("fonts/oxygen-700.woff2") format("woff2");
}

@font-face {
  font-family: "Merriweather";
  font-style: normal;
  font-weight: 300;
  font-display: swap;
  src: url("fonts/merriweather-300.woff2") format("woff2");
}

@font-face {
  font-family: "Merriweather";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("fonts/merriweather-300.woff2") format("woff2");
}

:root {
  color-scheme: dark;
  --background: #091311;
  --surface: #11211e;
  --surface-raised: #172a26;
  --text: #f5f3e9;
  --muted: #9ba9a4;
  --accent: #f4cd72;
  --accent-ink: #18201c;
  --border: rgba(255, 255, 255, 0.09);
  --shadow: 0 12px 30px rgba(0, 0, 0, 0.24);
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  width: 100%;
  height: 100%;
  min-height: 0;
  margin: 0;
  overflow: hidden;
  background: var(--background);
}

body {
  height: 100vh;
  height: 100dvh;
  color: var(--text);
  font-family: "Oxygen", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-weight: 300;
  -webkit-font-smoothing: antialiased;
}

button {
  font: inherit;
}

.game {
  position: relative;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: clamp(10px, 2.4vh, 20px);
  width: 100vw;
  max-width: 100%;
  height: 100vh;
  height: 100dvh;
  min-height: 0;
  overflow: hidden;
  padding:
    max(14px, env(safe-area-inset-top))
    max(18px, calc(env(safe-area-inset-right) + 10px))
    max(14px, env(safe-area-inset-bottom))
    max(18px, calc(env(safe-area-inset-left) + 10px));
  background:
    radial-gradient(circle at 8% 0%, rgba(69, 139, 113, 0.19), transparent 33%),
    radial-gradient(circle at 90% 100%, rgba(244, 205, 114, 0.08), transparent 31%),
    var(--background);
}

.game__header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 18px;
  min-height: 52px;
}

.game__title {
  justify-self: start;
  min-width: 0;
}

.game__header .shuffle-button {
  justify-self: end;
}

.game__controls {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  justify-self: end;
  gap: 12px;
}

h1 {
  margin: 0;
  font-family: "Merriweather", Georgia, serif;
  font-size: clamp(23px, 4vw, 36px);
  font-weight: 300;
  letter-spacing: -0.04em;
  line-height: 1.05;
  text-wrap: balance;
}

.resolution-control,
.duration-control {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
  letter-spacing: 0.02em;
}

.resolution-control select {
  min-height: 46px;
  padding: 0 36px 0 14px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background-color: rgba(255, 255, 255, 0.055);
  color: var(--text);
  font: inherit;
  font-size: 14px;
  cursor: pointer;
}

.resolution-control select:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

.bar-toggle {
  display: inline-grid;
  grid-template-columns: repeat(2, 1fr);
  justify-self: center;
  padding: 4px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.055);
}

.bar-toggle__option {
  min-width: 76px;
  min-height: 38px;
  padding: 0 14px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-size: 14px;
  font-weight: 750;
  cursor: pointer;
  touch-action: manipulation;
  transition: background-color 160ms ease, color 160ms ease, transform 140ms ease;
}

.bar-toggle__option.is-active {
  background: var(--text);
  color: var(--background);
}

.bar-toggle__option:active {
  transform: scale(0.96);
}

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

.sequence {
  display: grid;
  grid-template-columns: repeat(var(--eight-columns, 4), minmax(0, 1fr));
  column-gap: clamp(18px, 3.4vw, 34px);
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}

.sequence[data-resolution="2"] {
  column-gap: clamp(12px, 2vw, 20px);
}

.sequence[data-resolution="2"] .eight-column__cards {
  row-gap: clamp(5px, 1vh, 9px);
}

.sequence[data-resolution="2"] .card__label {
  font-size: clamp(14px, 2.2vw, 21px);
}

.eight-column {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
  min-height: 0;
  padding: clamp(7px, 1.2vw, 11px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: clamp(17px, 2.6vw, 25px);
  background: rgba(255, 255, 255, 0.035);
}

.eight-column__title {
  margin: 0;
  color: var(--muted);
  font-size: clamp(10px, 1.45vw, 13px);
  font-weight: 800;
  letter-spacing: 0.08em;
  line-height: 1;
  text-align: center;
  text-transform: uppercase;
}

.eight-column__cards {
  display: grid;
  grid-template-rows: repeat(var(--cards-per-column, 2), minmax(0, 1fr));
  flex: 1 1 auto;
  row-gap: clamp(7px, 1.3vh, 12px);
  min-height: 0;
}

.card {
  position: relative;
  isolation: isolate;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: clamp(12px, 1.8vw, 18px);
  background: var(--surface);
  box-shadow: var(--shadow);
  text-align: center;
  transform-origin: center;
}

.card::before {
  position: absolute;
  z-index: -1;
  inset: 0;
  background: linear-gradient(145deg, rgba(255, 255, 255, 0.06), transparent 45%);
  content: "";
}

.card[data-block="basic"] {
  --card-accent: #f4cd72;
  background: linear-gradient(140deg, #233128, #17231e);
}

.card[data-block="slow"] {
  --card-accent: #85d6c2;
  background: linear-gradient(140deg, #183a36, #122724);
}

.card[data-block="quicks"] {
  --card-accent: #e99971;
  background: linear-gradient(140deg, #3a2922, #281d19);
}

.card__label {
  max-width: 90%;
  color: var(--text);
  font-family: "Merriweather", Georgia, serif;
  font-size: clamp(17px, 2.9vw, 28px);
  font-weight: 700;
  letter-spacing: -0.035em;
  line-height: 1.05;
  text-wrap: balance;
}

.card.is-entering {
  animation: card-in 380ms cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

.shuffle-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  min-height: 48px;
  padding: 0 22px;
  border: 0;
  border-radius: 999px;
  background: var(--accent);
  box-shadow: 0 8px 24px rgba(244, 205, 114, 0.14);
  color: var(--accent-ink);
  font-weight: 800;
  cursor: pointer;
  touch-action: manipulation;
  transition: transform 140ms ease, filter 140ms ease;
}

.shuffle-button svg {
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.shuffle-button:hover {
  filter: brightness(1.06);
}

.shuffle-button:active {
  transform: scale(0.96);
}

.shuffle-button:focus-visible {
  outline: 3px solid #fff;
  outline-offset: 3px;
}

.portrait-message {
  display: none;
}

@keyframes card-in {
  from {
    opacity: 0;
    transform: translateY(7px) scale(0.97);
  }

  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@media (orientation: portrait) and (max-width: 600px) {
  .game {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 32px;
    text-align: center;
  }

  .game__header,
  .sequence,
  .shuffle-button {
    display: none;
  }

  .portrait-message {
    display: block;
    max-width: 260px;
    margin: 0;
    color: var(--text);
    font-family: "Merriweather", Georgia, serif;
    font-size: 22px;
    font-weight: 300;
    line-height: 1.25;
  }
}

@media (orientation: landscape) and (max-width: 1100px) {
  .control-label {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
  }
}

@media (orientation: landscape) and (max-height: 480px) {
  .game {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr);
    gap: clamp(6px, 2vh, 10px);
    padding:
      max(7px, env(safe-area-inset-top))
      max(10px, calc(env(safe-area-inset-right) + 6px))
      max(7px, env(safe-area-inset-bottom))
      max(10px, calc(env(safe-area-inset-left) + 6px));
  }

  .game__header {
    grid-template-columns: minmax(0, 1fr) auto auto;
    gap: 8px;
    min-width: 0;
    min-height: 0;
  }

  .game__title {
    display: block;
  }

  .game__controls {
    justify-content: flex-end;
    justify-self: end;
    gap: 8px;
    min-width: 0;
  }

  h1 {
    font-size: clamp(13px, 2.3vw, 20px);
    line-height: 1.08;
  }

  .resolution-control select {
    min-height: 40px;
    padding-right: 32px;
    padding-left: 12px;
  }

  .bar-toggle {
    padding: 3px;
  }

  .bar-toggle__option {
    min-width: 68px;
    min-height: 32px;
    padding-inline: 10px;
    font-size: 13px;
  }

  .sequence {
    height: auto;
    min-height: 0;
    column-gap: clamp(10px, 2.2vw, 18px);
  }

  .game__header .shuffle-button {
    width: 40px;
    min-height: 40px;
    padding: 0;
  }

  .game__header .shuffle-button svg {
    width: 18px;
    height: 18px;
  }

  .shuffle-button__label {
    display: none;
  }

  .eight-column {
    gap: 5px;
    padding: clamp(5px, 1vw, 8px);
    border-radius: clamp(13px, 2vw, 18px);
  }

  .eight-column__title {
    font-size: clamp(9px, 1.3vw, 11px);
  }

  .eight-column__cards {
    row-gap: clamp(4px, 1.2vh, 7px);
  }

  .card {
    border-radius: clamp(9px, 1.5vw, 14px);
  }

  .card__label {
    font-size: clamp(14px, 2.5vw, 21px);
  }

  .sequence[data-resolution="2"] .eight-column__cards {
    row-gap: clamp(3px, 0.9vh, 5px);
  }

  .sequence[data-resolution="2"] .card__label {
    font-size: clamp(12px, 2vw, 18px);
  }
}

@media (orientation: landscape) and (max-height: 330px) {
  .game {
    gap: 5px;
    padding:
      max(5px, env(safe-area-inset-top))
      max(8px, calc(env(safe-area-inset-right) + 4px))
      max(5px, env(safe-area-inset-bottom))
      max(8px, calc(env(safe-area-inset-left) + 4px));
  }

  .game__header {
    gap: 6px;
  }

  h1 {
    font-size: clamp(11px, 2.1vw, 14px);
  }

  .resolution-control select {
    min-height: 34px;
    padding-right: 28px;
    padding-left: 10px;
    font-size: 12px;
  }

  .bar-toggle__option {
    min-width: 60px;
    min-height: 28px;
    padding-inline: 7px;
    font-size: 12px;
  }

  .game__header .shuffle-button {
    width: 34px;
    min-height: 34px;
  }

  .eight-column {
    gap: 4px;
    padding: 4px;
  }

  .eight-column__title {
    font-size: 8px;
  }

  .card__label,
  .sequence[data-resolution="2"] .card__label {
    font-size: clamp(11px, 1.9vw, 15px);
  }
}

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