.card-scramble {
  --scramble-lime: #baff37;
  --scramble-cyan: #54e6ff;
  background:
    linear-gradient(145deg, rgba(186, 255, 55, .1), transparent 44%),
    radial-gradient(circle at 92% 7%, rgba(84, 230, 255, .18), transparent 34%),
    #08120f;
  border-color: rgba(186, 255, 55, .34);
}

.card-scramble::before {
  background: linear-gradient(90deg, var(--scramble-lime), var(--scramble-cyan));
}

.card-scramble .card-top b {
  color: var(--scramble-lime);
}

.scramble-card-preview {
  min-height: 122px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  position: relative;
  overflow: hidden;
}

.scramble-card-preview::after {
  content: "";
  width: 190px;
  height: 54px;
  position: absolute;
  left: 50%;
  bottom: 15px;
  translate: -50% 0;
  background: rgba(84, 230, 255, .18);
  filter: blur(24px);
}

.scramble-card-preview span {
  width: 32px;
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  position: relative;
  z-index: 1;
  color: #06110d;
  background: linear-gradient(145deg, #efffcf, var(--scramble-lime));
  border: 1px solid #f7ffe5;
  border-radius: 7px;
  box-shadow: 0 8px 22px rgba(186, 255, 55, .14);
  font: 900 1rem/1 var(--font-mono, monospace);
  transform: rotate(var(--tile-turn, -4deg));
}

.scramble-card-preview span:nth-child(even) {
  --tile-turn: 4deg;
  translate: 0 5px;
}

.scramble-card-preview b {
  width: 48px;
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  position: absolute;
  z-index: 2;
  right: 8px;
  top: 8px;
  color: var(--scramble-cyan);
  background: #06110d;
  border: 1px solid rgba(84, 230, 255, .55);
  border-radius: 50%;
  box-shadow: 0 0 0 7px rgba(84, 230, 255, .06);
  font: 900 1.25rem/1 var(--font-mono, monospace);
}

.game-modal[data-active-game="scramble"] .modal-window {
  border-color: rgba(186, 255, 55, .46);
  box-shadow: 0 28px 90px rgba(0, 0, 0, .68), 0 0 50px rgba(84, 230, 255, .08);
}

.game-modal[data-active-game="scramble"] .modal-head small {
  color: #baff37;
}

.scramble-panel {
  --scramble-lime: #baff37;
  --scramble-cyan: #54e6ff;
  --scramble-violet: #c178ff;
}

.scramble-hud {
  border-bottom-color: rgba(186, 255, 55, .22);
}

.scramble-hud strong {
  color: var(--scramble-lime);
}

.scramble-stage {
  min-height: 600px;
  padding: clamp(18px, 3vw, 34px);
  display: flex;
  flex-direction: column;
  gap: clamp(18px, 3vw, 30px);
  position: relative;
  overflow: hidden;
  isolation: isolate;
  background:
    linear-gradient(rgba(84, 230, 255, .035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(84, 230, 255, .035) 1px, transparent 1px),
    radial-gradient(circle at 50% 12%, rgba(186, 255, 55, .11), transparent 34%),
    radial-gradient(circle at 88% 90%, rgba(193, 120, 255, .1), transparent 34%),
    #050d0b;
  background-size: 42px 42px, 42px 42px, auto, auto, auto;
}

.scramble-stage::after {
  content: "WORLD • WORD • MIX";
  position: absolute;
  z-index: -1;
  right: -12px;
  bottom: -9px;
  color: rgba(255, 255, 255, .022);
  white-space: nowrap;
  font: 900 clamp(2.7rem, 9vw, 6.8rem)/1 var(--font-display, sans-serif);
  letter-spacing: -.05em;
}

.scramble-flag-card {
  width: min(100%, 560px);
  min-height: 112px;
  margin-inline: auto;
  padding: 16px 20px;
  display: grid;
  grid-template-columns: 76px 1fr;
  align-items: center;
  gap: 18px;
  color: rgba(255, 255, 255, .68);
  background: linear-gradient(135deg, rgba(255, 255, 255, .055), rgba(255, 255, 255, .018));
  border: 1px solid rgba(255, 255, 255, .12);
  border-radius: 18px;
  box-shadow: inset 0 1px rgba(255, 255, 255, .04);
  transition: border-color .25s ease, background .25s ease, transform .25s ease;
}

.scramble-flag-card > span {
  width: 76px;
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  color: rgba(255, 255, 255, .36);
  background:
    repeating-linear-gradient(135deg, rgba(255, 255, 255, .06) 0 8px, transparent 8px 16px),
    #07100e;
  border: 1px dashed rgba(255, 255, 255, .22);
  border-radius: 16px;
  font: 900 2rem/1 var(--font-display, sans-serif);
}

.scramble-flag-card div {
  min-width: 0;
  display: grid;
  gap: 7px;
}

.scramble-flag-card small,
.scramble-question > small,
.scramble-form > label,
.scramble-form > small {
  color: rgba(255, 255, 255, .52);
  font: 800 .72rem/1.35 var(--font-mono, monospace);
  letter-spacing: .15em;
}

.scramble-flag-card strong {
  overflow-wrap: anywhere;
  color: rgba(255, 255, 255, .78);
  font: 900 clamp(1.05rem, 3vw, 1.5rem)/1.05 var(--font-display, sans-serif);
  letter-spacing: -.02em;
}

.scramble-flag-card.is-revealed {
  color: #fff;
  background:
    linear-gradient(135deg, rgba(186, 255, 55, .14), rgba(84, 230, 255, .08)),
    #08130f;
  border-color: rgba(186, 255, 55, .66);
  transform: translateY(-2px);
}

.scramble-flag-card.is-revealed > span {
  color: #fff;
  background: rgba(255, 255, 255, .08);
  border-style: solid;
  border-color: rgba(255, 255, 255, .24);
  font-size: 3.4rem;
  animation: scramble-flag-reveal .5s cubic-bezier(.2, .9, .3, 1.2);
}

.scramble-flag-card.is-revealed small {
  color: var(--scramble-lime);
}

.scramble-flag-card.is-revealed strong {
  color: #fff;
}

.scramble-question {
  display: grid;
  justify-items: center;
  gap: 14px;
  text-align: center;
}

.scramble-question > small {
  color: var(--scramble-cyan);
}

.scramble-letters {
  max-width: 760px;
  min-height: 66px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: clamp(5px, 1.2vw, 9px);
}

.scramble-letters > span:not(.is-separator) {
  width: clamp(39px, 7vw, 56px);
  height: clamp(48px, 8vw, 64px);
  display: grid;
  place-items: center;
  color: #07110d;
  background: linear-gradient(155deg, #f3ffd8 0%, var(--scramble-lime) 72%);
  border: 1px solid #f8ffe9;
  border-radius: 10px;
  box-shadow:
    0 10px 28px rgba(186, 255, 55, .13),
    inset 0 -5px 0 rgba(6, 17, 13, .12);
  font: 900 clamp(1.15rem, 4vw, 1.7rem)/1 var(--font-mono, monospace);
  animation: scramble-tile-in .35s both;
}

.scramble-letters > span:nth-child(2n) {
  animation-delay: .035s;
}

.scramble-letters > span:nth-child(3n) {
  animation-delay: .07s;
}

.scramble-letters > .is-separator {
  width: 18px;
  color: var(--scramble-cyan);
  font: 900 1.4rem/1 var(--font-mono, monospace);
}

.scramble-form {
  width: min(100%, 700px);
  margin-inline: auto;
  display: grid;
  gap: 10px;
}

.scramble-form > label {
  color: rgba(255, 255, 255, .72);
}

.scramble-input-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
}

.scramble-input-row input {
  width: 100%;
  min-width: 0;
  height: 60px;
  padding: 0 18px;
  color: #fff;
  caret-color: var(--scramble-lime);
  background: rgba(0, 0, 0, .34);
  border: 1px solid rgba(255, 255, 255, .2);
  border-radius: 10px;
  outline: none;
  font: 800 1.05rem/1 var(--font-mono, monospace);
  transition: border-color .18s ease, box-shadow .18s ease, background .18s ease;
}

.scramble-input-row input::placeholder {
  color: rgba(255, 255, 255, .32);
}

.scramble-input-row input:focus {
  background: rgba(0, 0, 0, .5);
  border-color: var(--scramble-cyan);
  box-shadow: 0 0 0 3px rgba(84, 230, 255, .13);
}

.scramble-input-row input[aria-invalid="true"] {
  border-color: #ff6f87;
  box-shadow: 0 0 0 3px rgba(255, 70, 102, .12);
}

.scramble-input-row input:disabled {
  opacity: .56;
}

.scramble-input-row button {
  min-width: 190px;
  min-height: 60px;
  padding: 0 20px;
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  color: #06110d;
  background: linear-gradient(100deg, var(--scramble-lime), #e5ffad);
  border: 0;
  border-radius: 10px;
  box-shadow: 0 12px 26px rgba(186, 255, 55, .13);
  cursor: pointer;
  font: 900 .84rem/1 var(--font-mono, monospace);
  letter-spacing: .08em;
  transition: translate .16s ease, filter .16s ease, opacity .16s ease;
}

.scramble-input-row button:hover:not(:disabled) {
  translate: 0 -2px;
  filter: brightness(1.08);
}

.scramble-input-row button:focus-visible {
  outline: 3px solid var(--scramble-cyan);
  outline-offset: 3px;
}

.scramble-input-row button:disabled {
  cursor: wait;
  opacity: .48;
}

.scramble-input-row button b {
  font-size: 1.25rem;
}

.scramble-form > small {
  color: rgba(255, 255, 255, .4);
  letter-spacing: .08em;
}

.scramble-feedback {
  width: min(100%, 700px);
  min-height: 48px;
  margin: 0 auto;
  padding: 12px 15px;
  display: grid;
  place-items: center;
  color: rgba(255, 255, 255, .58);
  background: rgba(255, 255, 255, .025);
  border: 1px solid rgba(255, 255, 255, .08);
  border-radius: 9px;
  text-align: center;
  font: 800 .76rem/1.45 var(--font-mono, monospace);
  letter-spacing: .05em;
}

.scramble-feedback.is-correct {
  color: var(--scramble-lime);
  background: rgba(186, 255, 55, .07);
  border-color: rgba(186, 255, 55, .34);
}

.scramble-feedback.is-wrong {
  color: #ff8ca0;
  background: rgba(255, 70, 102, .07);
  border-color: rgba(255, 70, 102, .32);
}

.scramble-stage.is-wrong .scramble-letters {
  animation: scramble-wrong .34s ease;
}

.scramble-cover {
  padding: clamp(18px, 4vw, 34px);
  background:
    radial-gradient(circle at 50% 35%, rgba(186, 255, 55, .12), transparent 36%),
    rgba(3, 9, 7, .94);
  backdrop-filter: blur(7px);
}

.scramble-rules-kicker {
  margin: 0 0 8px;
  color: var(--scramble-cyan);
  font: 900 .7rem/1 var(--font-mono, monospace);
  letter-spacing: .2em;
}

.scramble-rules-kicker[hidden] {
  display: none;
}

.scramble-cover > h3 {
  max-width: 650px;
  margin: 0;
  color: var(--scramble-lime);
  font: italic 950 clamp(2rem, 6vw, 3.55rem)/.95 var(--font-display, sans-serif);
  letter-spacing: -.04em;
}

.scramble-cover > p {
  max-width: 650px;
  margin: 12px 0 22px;
  color: #c0cdc4;
  font-size: .93rem;
  line-height: 1.5;
}

.scramble-rules {
  width: min(100%, 700px);
  margin: 0 0 22px;
}

.scramble-rules[hidden] {
  display: none;
}

.scramble-rules ol {
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 9px;
  list-style: none;
}

.scramble-rules li {
  min-width: 0;
  padding: 15px 13px;
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  align-items: start;
  gap: 10px;
  border: 1px solid rgba(84, 230, 255, .18);
  border-top-color: rgba(186, 255, 55, .45);
  border-radius: 11px;
  background: linear-gradient(145deg, rgba(186, 255, 55, .07), rgba(84, 230, 255, .035));
  text-align: left;
}

.scramble-rules li > i {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  color: #06110d;
  background: var(--scramble-lime);
  border-radius: 8px;
  font: normal 950 .85rem/1 var(--font-mono, monospace);
}

.scramble-rules li > div {
  min-width: 0;
}

.scramble-rules strong {
  display: block;
  color: #f3ffe9;
  font: 900 .69rem/1.25 var(--font-mono, monospace);
  letter-spacing: .08em;
}

.scramble-rules li p {
  margin: 6px 0 0;
  color: rgba(226, 239, 230, .62);
  font-size: .75rem;
  line-height: 1.42;
}

.scramble-rule-summary {
  margin: 11px 0 0;
  color: var(--scramble-cyan);
  font: 850 .68rem/1.35 var(--font-mono, monospace);
  letter-spacing: .08em;
}

.scramble-rule-summary i {
  padding-inline: 5px;
  color: rgba(255, 255, 255, .3);
  font-style: normal;
}

.scramble-cover > button:not(.scramble-discard-save) {
  min-width: min(100%, 340px);
  min-height: 62px;
  color: #06110d;
  background: linear-gradient(100deg, var(--scramble-lime), #e4ffad);
}

.scramble-discard-save {
  margin-top: 8px;
  color: rgba(255, 255, 255, .62);
  background: transparent;
  border: 1px solid rgba(255, 255, 255, .18);
}

@keyframes scramble-tile-in {
  from {
    opacity: 0;
    transform: translateY(9px) rotate(-3deg);
  }
  to {
    opacity: 1;
    transform: translateY(0) rotate(0);
  }
}

@keyframes scramble-flag-reveal {
  from {
    opacity: .25;
    transform: scale(.5) rotate(-8deg);
  }
  to {
    opacity: 1;
    transform: scale(1) rotate(0);
  }
}

@keyframes scramble-wrong {
  0%,
  100% {
    transform: translateX(0);
  }
  25% {
    transform: translateX(-8px);
  }
  75% {
    transform: translateX(8px);
  }
}

@media (max-width: 680px) {
  .scramble-stage {
    min-height: 590px;
    padding: 16px 13px 22px;
    gap: 18px;
  }

  .scramble-flag-card {
    min-height: 92px;
    padding: 12px;
    grid-template-columns: 62px 1fr;
    gap: 13px;
    border-radius: 13px;
  }

  .scramble-flag-card > span {
    width: 62px;
    border-radius: 12px;
  }

  .scramble-flag-card.is-revealed > span {
    font-size: 2.7rem;
  }

  .scramble-letters {
    min-height: 54px;
    gap: 5px;
  }

  .scramble-letters > span:not(.is-separator) {
    width: clamp(34px, 10vw, 43px);
    height: clamp(43px, 12vw, 52px);
    border-radius: 8px;
    font-size: clamp(1rem, 5vw, 1.28rem);
  }

  .scramble-letters > .is-separator {
    width: 10px;
  }

  .scramble-input-row {
    grid-template-columns: 1fr;
  }

  .scramble-input-row input,
  .scramble-input-row button {
    min-height: 58px;
    height: 58px;
  }

  .scramble-input-row input {
    font-size: 16px;
  }

  .scramble-input-row button {
    width: 100%;
    min-width: 0;
  }

  .scramble-cover.has-rules {
    justify-content: flex-start;
    overflow-y: auto;
    padding: 20px 14px 22px;
  }

  .scramble-cover > p {
    margin: 9px 0 14px;
    font-size: .82rem;
  }

  .scramble-rules {
    margin-bottom: 16px;
  }

  .scramble-rules ol {
    grid-template-columns: 1fr;
    gap: 7px;
  }

  .scramble-rules li {
    padding: 10px 11px;
    grid-template-columns: 30px minmax(0, 1fr);
    gap: 9px;
  }

  .scramble-rules li > i {
    width: 30px;
    height: 30px;
  }

  .scramble-rules li p {
    margin-top: 3px;
    font-size: .7rem;
  }

  .scramble-rule-summary {
    margin-top: 9px;
    font-size: .61rem;
  }

  .scramble-cover > button:not(.scramble-discard-save) {
    width: 100%;
    min-width: 0;
    min-height: 58px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .scramble-letters > span,
  .scramble-flag-card.is-revealed > span,
  .scramble-stage.is-wrong .scramble-letters {
    animation: none;
  }

  .scramble-flag-card,
  .scramble-input-row button {
    transition: none;
  }
}
