.card-flagcode {
  --flagcode-red: #ef3159;
  --flagcode-red-dark: #7b102a;
  --flagcode-gold: #ffc857;
  --flagcode-ice: #78ddff;
  border-color: rgba(239, 49, 89, .58);
  background:
    radial-gradient(circle at 82% 18%, rgba(255, 200, 87, .16), transparent 27%),
    radial-gradient(circle at 18% 84%, rgba(239, 49, 89, .2), transparent 35%),
    linear-gradient(145deg, #190a10 0%, #07080c 64%, #10090d 100%);
}

.card-flagcode .card-top > b {
  color: var(--flagcode-gold);
}

.flagcode-card-preview {
  position: relative;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  width: min(100%, 292px);
  min-height: 128px;
  margin: 22px auto 18px;
  padding: 20px;
  overflow: hidden;
  border: 1px solid rgba(255, 200, 87, .5);
  background:
    linear-gradient(135deg, rgba(239, 49, 89, .13), transparent 46%),
    repeating-linear-gradient(90deg, rgba(255, 255, 255, .025) 0 1px, transparent 1px 25%);
  box-shadow: inset 0 0 32px rgba(0, 0, 0, .72), 8px 8px 0 rgba(239, 49, 89, .09);
}

.flagcode-card-preview::before,
.flagcode-card-preview::after {
  position: absolute;
  content: "";
  border: 1px solid rgba(255, 200, 87, .22);
  border-radius: 50%;
  pointer-events: none;
}

.flagcode-card-preview::before {
  inset: -58px 32%;
}

.flagcode-card-preview::after {
  inset: -24px 40%;
}

.flagcode-card-preview > span {
  position: relative;
  z-index: 1;
  display: grid;
  min-height: 58px;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, .18);
  background: rgba(3, 4, 8, .82);
  color: #fff;
  font-size: clamp(24px, 5vw, 38px);
  box-shadow: inset 0 -4px 0 rgba(239, 49, 89, .24);
}

.flagcode-card-preview > b {
  position: absolute;
  z-index: 2;
  right: 12px;
  bottom: 8px;
  padding: 5px 8px;
  background: var(--flagcode-gold);
  color: #130a05;
  font-family: var(--mono, monospace);
  font-size: 11px;
  letter-spacing: .12em;
  transform: rotate(-2deg);
}

[data-game-panel="flagcode"] {
  --flagcode-red: #ef3159;
  --flagcode-red-dark: #7b102a;
  --flagcode-gold: #ffc857;
  --flagcode-ice: #78ddff;
  --flagcode-paper: #f7eff1;
  --flagcode-ink: #06070a;
  --flagcode-panel: #0d0c11;
  color: var(--flagcode-paper);
  background: var(--flagcode-ink);
}

[data-game-panel="flagcode"][hidden] {
  display: none !important;
}

[data-game-panel="flagcode"] .flagcode-hud,
[data-game-panel="flagcode"] > .mini-hud {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  min-height: 78px;
  border-bottom: 1px solid rgba(239, 49, 89, .46);
  background:
    linear-gradient(90deg, rgba(239, 49, 89, .08), transparent 25% 75%, rgba(255, 200, 87, .08)),
    #08090d;
}

[data-game-panel="flagcode"] .flagcode-hud > div,
[data-game-panel="flagcode"] > .mini-hud > div {
  display: grid;
  align-content: center;
  min-width: 0;
  padding: 12px 15px;
  text-align: center;
}

[data-game-panel="flagcode"] .flagcode-hud > div + div,
[data-game-panel="flagcode"] > .mini-hud > div + div {
  border-left: 1px solid rgba(255, 255, 255, .08);
}

[data-game-panel="flagcode"] .flagcode-hud small,
[data-game-panel="flagcode"] > .mini-hud small {
  overflow: hidden;
  color: rgba(247, 239, 241, .58);
  font-family: var(--mono, monospace);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: .14em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

[data-game-panel="flagcode"] .flagcode-hud strong,
[data-game-panel="flagcode"] > .mini-hud strong {
  margin-top: 4px;
  color: var(--flagcode-gold);
  font-family: var(--display, sans-serif);
  font-size: clamp(20px, 4vw, 31px);
  line-height: 1;
  letter-spacing: .04em;
}

#flagcodeTries {
  color: var(--flagcode-red);
}

#flagcodeLength {
  color: var(--flagcode-ice);
}

#flagcodeRecord {
  font-size: clamp(15px, 3vw, 22px);
}

#flagcodeStage {
  position: relative;
  isolation: isolate;
  min-height: 690px;
  padding: 28px clamp(18px, 4vw, 40px) 40px;
  overflow: hidden;
  background:
    radial-gradient(circle at 50% 33%, rgba(239, 49, 89, .12), transparent 32%),
    radial-gradient(circle at 50% 33%, transparent 0 118px, rgba(255, 200, 87, .09) 119px 120px, transparent 121px 172px, rgba(239, 49, 89, .1) 173px 174px, transparent 175px),
    linear-gradient(145deg, #110b10, #06070a 55%, #0b0a0e);
}

#flagcodeStage::before {
  position: absolute;
  z-index: -2;
  inset: 0;
  content: "";
  opacity: .38;
  background:
    linear-gradient(rgba(255, 255, 255, .035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, .035) 1px, transparent 1px);
  background-size: 42px 42px;
  pointer-events: none;
  mask-image: linear-gradient(to bottom, #000, transparent 85%);
}

#flagcodeStage::after {
  position: absolute;
  z-index: -1;
  top: 72px;
  left: 50%;
  width: min(72vw, 410px);
  aspect-ratio: 1;
  content: "";
  border: 1px solid rgba(255, 200, 87, .13);
  border-radius: 50%;
  box-shadow:
    0 0 0 34px rgba(239, 49, 89, .025),
    0 0 0 35px rgba(239, 49, 89, .09),
    inset 0 0 52px rgba(0, 0, 0, .7);
  pointer-events: none;
  transform: translateX(-50%);
}

#flagcodeStage[data-phase="checking"]::after,
#flagcodeStage[data-phase="loading"]::after,
#flagcodeStage[data-phase="saving"]::after {
  animation: flagcode-vault-scan 1.1s linear infinite;
}

#flagcodeStage[data-phase="won"]::after {
  border-color: rgba(255, 200, 87, .58);
  box-shadow:
    0 0 0 34px rgba(255, 200, 87, .045),
    0 0 0 35px rgba(255, 200, 87, .32),
    0 0 54px rgba(255, 200, 87, .17);
}

#flagcodeStage[data-phase="lost"]::after,
#flagcodeStage[data-phase="error"]::after {
  border-color: rgba(239, 49, 89, .54);
  box-shadow:
    0 0 0 34px rgba(239, 49, 89, .04),
    0 0 0 35px rgba(239, 49, 89, .24);
}

#flagcodePrompt {
  position: relative;
  z-index: 2;
  max-width: 760px;
  margin: 0 auto 20px;
  color: var(--flagcode-paper);
  font-family: var(--display, sans-serif);
  font-size: clamp(20px, 4.2vw, 36px);
  font-style: italic;
  line-height: .98;
  letter-spacing: -.025em;
  text-align: center;
  text-transform: uppercase;
}

#flagcodePrompt::before {
  display: block;
  width: max-content;
  margin: 0 auto 10px;
  padding: 5px 9px;
  content: "WORLD VAULT / SLEPENAIS KODS";
  border: 1px solid rgba(255, 200, 87, .36);
  color: var(--flagcode-gold);
  font-family: var(--mono, monospace);
  font-size: 9px;
  font-style: normal;
  letter-spacing: .15em;
}

#flagcodeSlots {
  --flagcode-length: 3;
  position: relative;
  z-index: 2;
  display: grid;
  grid-template-columns: repeat(var(--flagcode-length), minmax(0, 1fr));
  gap: clamp(7px, 1.5vw, 13px);
  width: min(100%, 700px);
  margin: 0 auto 24px;
  padding: 16px;
  border: 1px solid rgba(255, 200, 87, .3);
  background:
    linear-gradient(90deg, rgba(239, 49, 89, .08), transparent, rgba(255, 200, 87, .06)),
    rgba(3, 4, 7, .84);
  box-shadow: inset 0 0 28px rgba(0, 0, 0, .75), 8px 8px 0 rgba(239, 49, 89, .07);
}

.flagcode-slot {
  position: relative;
  display: grid;
  min-width: 0;
  min-height: 104px;
  padding: 9px 5px 8px;
  overflow: hidden;
  place-items: center;
  border: 1px dashed rgba(247, 239, 241, .3);
  border-radius: 0;
  background: rgba(255, 255, 255, .025);
  color: rgba(247, 239, 241, .43);
  font: inherit;
  touch-action: manipulation;
  transition: border-color .16s ease, background .16s ease, transform .16s ease;
}

.flagcode-slot small {
  position: absolute;
  top: 5px;
  left: 7px;
  color: rgba(247, 239, 241, .4);
  font-family: var(--mono, monospace);
  font-size: 9px;
  font-weight: 900;
}

.flagcode-slot strong {
  margin-top: 7px;
  font-size: clamp(27px, 5.8vw, 43px);
  line-height: 1;
  filter: saturate(.6);
}

.flagcode-slot span {
  display: block;
  max-width: 100%;
  overflow: hidden;
  font-family: var(--mono, monospace);
  font-size: 8px;
  font-weight: 900;
  letter-spacing: .07em;
  text-overflow: ellipsis;
  text-transform: uppercase;
  white-space: nowrap;
}

.flagcode-slot.is-filled {
  border-style: solid;
  border-color: rgba(255, 200, 87, .68);
  background:
    linear-gradient(145deg, rgba(255, 200, 87, .1), transparent 58%),
    rgba(16, 10, 10, .92);
  color: var(--flagcode-paper);
  box-shadow: inset 0 -4px 0 rgba(239, 49, 89, .28);
}

.flagcode-slot.is-filled strong {
  filter: none;
}

.flagcode-slot.is-filled:not(:disabled):hover {
  border-color: var(--flagcode-red);
  background: rgba(239, 49, 89, .14);
  transform: translateY(-2px);
}

.flagcode-slot:disabled {
  cursor: default;
  opacity: .72;
}

#flagcodeCandidates {
  position: relative;
  z-index: 2;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  width: min(100%, 760px);
  margin: 0 auto;
}

.flagcode-candidate {
  position: relative;
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) 18px;
  gap: 7px;
  align-items: center;
  min-width: 0;
  min-height: 55px;
  padding: 7px 8px;
  border: 1px solid rgba(247, 239, 241, .16);
  border-radius: 0;
  background: rgba(8, 8, 12, .88);
  color: var(--flagcode-paper);
  font: inherit;
  text-align: left;
  touch-action: manipulation;
  transition: border-color .16s ease, background .16s ease, transform .16s ease;
}

.flagcode-candidate > strong {
  display: grid;
  min-height: 38px;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, .1);
  background: rgba(255, 255, 255, .025);
  font-size: 25px;
  line-height: 1;
}

.flagcode-candidate > span {
  overflow: hidden;
  font-family: var(--mono, monospace);
  font-size: 9px;
  font-weight: 900;
  letter-spacing: .055em;
  text-overflow: ellipsis;
  text-transform: uppercase;
  white-space: nowrap;
}

.flagcode-candidate > small {
  color: rgba(247, 239, 241, .36);
  font-family: var(--mono, monospace);
  font-size: 9px;
  font-weight: 900;
  text-align: center;
}

.flagcode-candidate:not(:disabled):hover {
  z-index: 1;
  border-color: rgba(255, 200, 87, .7);
  background: rgba(255, 200, 87, .08);
  transform: translateY(-2px);
}

.flagcode-candidate.is-selected {
  border-color: var(--flagcode-gold);
  background:
    linear-gradient(100deg, rgba(255, 200, 87, .2), rgba(239, 49, 89, .12)),
    #100d10;
  box-shadow: inset 4px 0 0 var(--flagcode-red);
}

.flagcode-candidate.is-selected::after {
  position: absolute;
  top: -5px;
  right: -4px;
  display: grid;
  width: 19px;
  height: 19px;
  content: "✓";
  place-items: center;
  background: var(--flagcode-gold);
  color: #120a05;
  font-family: var(--mono, monospace);
  font-size: 11px;
  font-weight: 1000;
}

.flagcode-candidate:disabled {
  cursor: wait;
  opacity: .58;
}

#flagcodeSubmit {
  position: relative;
  z-index: 2;
  display: block;
  width: min(100%, 760px);
  min-height: 58px;
  margin: 14px auto 0;
  padding: 13px 20px;
  border: 1px solid var(--flagcode-gold);
  border-radius: 0;
  background: linear-gradient(100deg, var(--flagcode-red-dark), var(--flagcode-red) 58%, var(--flagcode-gold));
  color: #fff;
  font-family: var(--mono, monospace);
  font-size: clamp(11px, 2.2vw, 14px);
  font-weight: 1000;
  letter-spacing: .13em;
  text-transform: uppercase;
  box-shadow: 8px 8px 0 rgba(0, 0, 0, .38);
  touch-action: manipulation;
  transition: filter .16s ease, transform .16s ease;
}

#flagcodeSubmit:not(:disabled):hover {
  filter: brightness(1.13);
  transform: translateY(-2px);
}

#flagcodeSubmit:disabled {
  border-color: rgba(247, 239, 241, .16);
  background: rgba(247, 239, 241, .055);
  color: rgba(247, 239, 241, .34);
  box-shadow: none;
  cursor: not-allowed;
}

#flagcodeSubmit[aria-busy="true"]::after {
  display: inline-block;
  width: 10px;
  height: 10px;
  margin-left: 9px;
  content: "";
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  vertical-align: -1px;
  animation: flagcode-spin .75s linear infinite;
}

#flagcodeFeedback {
  position: relative;
  z-index: 2;
  min-height: 46px;
  width: min(100%, 760px);
  margin: 13px auto;
  padding: 11px 14px;
  border: 1px solid rgba(247, 239, 241, .12);
  background: rgba(2, 3, 5, .76);
  color: rgba(247, 239, 241, .76);
  font-family: var(--mono, monospace);
  font-size: 10px;
  font-weight: 800;
  line-height: 1.45;
  letter-spacing: .06em;
  text-align: center;
  text-transform: uppercase;
}

#flagcodeFeedback.is-correct {
  border-color: rgba(255, 200, 87, .65);
  color: var(--flagcode-gold);
}

#flagcodeFeedback.is-hint {
  border-color: rgba(120, 221, 255, .48);
  color: var(--flagcode-ice);
}

#flagcodeFeedback.is-wrong {
  border-color: rgba(239, 49, 89, .62);
  color: #ff7894;
}

#flagcodeHistory {
  position: relative;
  z-index: 2;
  display: grid;
  gap: 8px;
  width: min(100%, 760px);
  max-height: 270px;
  margin: 0 auto;
  padding: 0;
  overflow: auto;
  overscroll-behavior: contain;
  scrollbar-color: var(--flagcode-red) rgba(255, 255, 255, .04);
}

.flagcode-history-empty {
  min-height: 44px;
  margin: 0;
  padding: 14px;
  border-top: 1px solid rgba(247, 239, 241, .11);
  color: rgba(247, 239, 241, .38);
  font-family: var(--mono, monospace);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: .1em;
  text-align: center;
}

.flagcode-history-entry {
  display: grid;
  grid-template-columns: minmax(180px, .85fr) minmax(250px, 1.15fr);
  gap: 12px;
  align-items: center;
  min-width: 0;
  padding: 10px 12px;
  border: 1px solid rgba(247, 239, 241, .12);
  border-left: 3px solid var(--flagcode-red);
  background: rgba(6, 7, 10, .88);
}

.flagcode-history-entry[data-result="won"] {
  border-color: rgba(255, 200, 87, .48);
  border-left-color: var(--flagcode-gold);
  background: linear-gradient(90deg, rgba(255, 200, 87, .1), rgba(6, 7, 10, .9));
}

.flagcode-history-entry > div:first-child {
  display: flex;
  gap: 10px;
  align-items: center;
  min-width: 0;
}

.flagcode-history-entry > div:first-child > strong {
  color: rgba(247, 239, 241, .48);
  font-family: var(--mono, monospace);
  font-size: 8px;
  letter-spacing: .08em;
  white-space: nowrap;
}

.flagcode-history-flags {
  display: flex;
  gap: 4px;
  min-width: 0;
}

.flagcode-history-flags span {
  display: grid;
  width: 32px;
  height: 28px;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, .09);
  background: rgba(255, 255, 255, .025);
  font-size: 19px;
}

.flagcode-history-verdict {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
}

.flagcode-history-verdict span {
  min-width: 0;
  padding: 7px 8px;
  border: 1px solid currentColor;
  font-family: var(--mono, monospace);
  font-size: 7px;
  font-weight: 900;
  letter-spacing: .055em;
  text-align: center;
}

.flagcode-history-verdict span b {
  margin-right: 3px;
  font-size: 13px;
}

.flagcode-history-verdict .is-exact {
  color: var(--flagcode-gold);
  background:
    repeating-linear-gradient(135deg, rgba(255, 200, 87, .09) 0 4px, transparent 4px 8px);
}

.flagcode-history-verdict .is-misplaced {
  color: var(--flagcode-ice);
  background:
    repeating-linear-gradient(45deg, rgba(120, 221, 255, .08) 0 4px, transparent 4px 8px);
}

#flagcodeCover[hidden],
#flagcodeCover.is-hidden,
#flagcodeRules[hidden],
#discardFlagcodeSave[hidden] {
  display: none !important;
}

#flagcodeCover {
  position: absolute;
  z-index: 20;
  inset: 0;
  display: grid;
  align-content: center;
  justify-items: stretch;
  padding: clamp(24px, 5vw, 56px);
  overflow: auto;
  background:
    radial-gradient(circle at 50% 35%, rgba(239, 49, 89, .2), transparent 30%),
    linear-gradient(145deg, rgba(17, 8, 13, .985), rgba(4, 5, 8, .99) 65%);
  text-align: center;
}

#flagcodeCover::before,
#flagcodeCover::after {
  position: absolute;
  left: 50%;
  content: "";
  border-radius: 50%;
  pointer-events: none;
  transform: translateX(-50%);
}

#flagcodeCover::before {
  z-index: -1;
  top: 7%;
  width: min(68vw, 430px);
  aspect-ratio: 1;
  border: 1px solid rgba(255, 200, 87, .13);
  box-shadow:
    0 0 0 38px rgba(239, 49, 89, .025),
    0 0 0 39px rgba(239, 49, 89, .1);
}

#flagcodeCover::after {
  top: max(18px, 5%);
  width: 9px;
  height: 9px;
  background: var(--flagcode-red);
  box-shadow: 0 0 19px var(--flagcode-red);
}

#flagcodeCover > small,
.flagcode-rules-kicker {
  position: relative;
  z-index: 1;
  width: max-content;
  max-width: 100%;
  margin: 0 auto 13px;
  padding: 5px 9px;
  border: 1px solid rgba(255, 200, 87, .38);
  color: var(--flagcode-gold);
  font-family: var(--mono, monospace);
  font-size: 9px;
  font-weight: 900;
  letter-spacing: .15em;
  text-transform: uppercase;
}

#flagcodeCoverTitle {
  position: relative;
  z-index: 1;
  max-width: 760px;
  margin: 0 auto 12px;
  color: #fff;
  font-family: var(--display, sans-serif);
  font-size: clamp(34px, 7vw, 66px);
  font-style: italic;
  line-height: .88;
  letter-spacing: -.045em;
  text-transform: uppercase;
}

#flagcodeCoverText {
  position: relative;
  z-index: 1;
  max-width: 700px;
  margin: 0 auto 18px;
  color: rgba(247, 239, 241, .72);
  font-size: clamp(13px, 2.1vw, 16px);
  line-height: 1.5;
}

#flagcodeRules {
  position: relative;
  z-index: 1;
  width: min(100%, 760px);
  margin: 0 auto 18px;
}

#flagcodeRules ol,
#flagcodeRules ul {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

#flagcodeRules li {
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr);
  gap: 9px;
  min-width: 0;
  padding: 12px;
  border: 1px solid rgba(247, 239, 241, .12);
  background: rgba(255, 255, 255, .026);
  text-align: left;
}

#flagcodeRules li > i,
#flagcodeRules li > span:first-child,
#flagcodeRules li > b:first-child {
  display: grid;
  width: 29px;
  height: 29px;
  place-items: center;
  border: 1px solid var(--flagcode-red);
  color: var(--flagcode-red);
  font-family: var(--mono, monospace);
  font-size: 11px;
  font-style: normal;
  font-weight: 1000;
}

#flagcodeRules li strong {
  display: block;
  margin-bottom: 4px;
  color: var(--flagcode-gold);
  font-family: var(--mono, monospace);
  font-size: 9px;
  letter-spacing: .08em;
}

#flagcodeRules li p {
  margin: 0;
  color: rgba(247, 239, 241, .6);
  font-size: 11px;
  line-height: 1.4;
}

.flagcode-rule-summary {
  margin: 10px 0 0;
  color: rgba(247, 239, 241, .54);
  font-family: var(--mono, monospace);
  font-size: 9px;
  font-weight: 900;
  letter-spacing: .08em;
}

.flagcode-rule-summary i {
  color: var(--flagcode-red);
  font-style: normal;
}

#startFlagcode,
#discardFlagcodeSave {
  position: relative;
  z-index: 1;
  width: min(100%, 760px);
  min-height: 56px;
  margin: 0 auto;
  padding: 13px 20px;
  border-radius: 0;
  font-family: var(--mono, monospace);
  font-size: 11px;
  font-weight: 1000;
  letter-spacing: .13em;
  text-transform: uppercase;
  touch-action: manipulation;
}

#startFlagcode {
  border: 1px solid var(--flagcode-gold);
  background: linear-gradient(100deg, var(--flagcode-red-dark), var(--flagcode-red) 58%, var(--flagcode-gold));
  color: #fff;
  box-shadow: 9px 9px 0 rgba(0, 0, 0, .4);
  transition: filter .16s ease, transform .16s ease;
}

#startFlagcode:hover:not(:disabled) {
  filter: brightness(1.14);
  transform: translateY(-2px);
}

#startFlagcode:disabled {
  cursor: wait;
  filter: grayscale(.45);
  opacity: .7;
}

#discardFlagcodeSave {
  margin-top: 10px;
  border: 1px solid rgba(247, 239, 241, .24);
  background: rgba(255, 255, 255, .035);
  color: rgba(247, 239, 241, .68);
}

.flagcode-slot:focus-visible,
.flagcode-candidate:focus-visible,
#flagcodeSubmit:focus-visible,
#startFlagcode:focus-visible,
#discardFlagcodeSave:focus-visible {
  outline: 3px solid var(--flagcode-ice);
  outline-offset: 3px;
}

@keyframes flagcode-vault-scan {
  to {
    transform: translateX(-50%) rotate(360deg);
  }
}

@keyframes flagcode-spin {
  to {
    transform: rotate(360deg);
  }
}

@media (max-width: 760px) {
  .game-modal[data-active-game="flagcode"] {
    padding: 0;
  }

  .game-modal[data-active-game="flagcode"] .modal-window {
    width: 100%;
    max-width: none;
    min-height: 100dvh;
    border: 0;
    border-radius: 0;
  }

  #flagcodeStage {
    min-height: calc(100dvh - 150px);
    padding: 21px 16px calc(30px + env(safe-area-inset-bottom));
  }

  #flagcodeCandidates {
    gap: 7px;
  }

  .flagcode-candidate {
    grid-template-columns: 36px minmax(0, 1fr) 14px;
    min-height: 52px;
    padding: 6px;
  }

  .flagcode-candidate > strong {
    min-height: 35px;
    font-size: 22px;
  }

  .flagcode-history-entry {
    grid-template-columns: 1fr;
    gap: 7px;
  }

  #flagcodeCover {
    align-content: start;
    padding: 34px 18px calc(34px + env(safe-area-inset-bottom));
  }
}

@media (max-width: 520px) {
  [data-game-panel="flagcode"] .flagcode-hud,
  [data-game-panel="flagcode"] > .mini-hud {
    min-height: 65px;
  }

  [data-game-panel="flagcode"] .flagcode-hud > div,
  [data-game-panel="flagcode"] > .mini-hud > div {
    padding: 9px 5px;
  }

  [data-game-panel="flagcode"] .flagcode-hud small,
  [data-game-panel="flagcode"] > .mini-hud small {
    font-size: 7px;
    letter-spacing: .07em;
  }

  [data-game-panel="flagcode"] .flagcode-hud strong,
  [data-game-panel="flagcode"] > .mini-hud strong {
    font-size: 19px;
  }

  #flagcodeRecord {
    font-size: 13px;
  }

  #flagcodePrompt {
    margin-bottom: 14px;
    font-size: clamp(20px, 7.3vw, 30px);
  }

  #flagcodeSlots {
    gap: 5px;
    margin-bottom: 15px;
    padding: 9px;
  }

  .flagcode-slot {
    min-height: 82px;
    padding-inline: 3px;
  }

  .flagcode-slot strong {
    font-size: clamp(24px, 8.3vw, 35px);
  }

  .flagcode-slot span {
    font-size: 6px;
    letter-spacing: 0;
  }

  #flagcodeCandidates {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .flagcode-candidate {
    min-height: 48px;
  }

  #flagcodeSubmit {
    min-height: 54px;
  }

  #flagcodeFeedback {
    min-height: 44px;
    margin-block: 10px;
    padding: 9px;
    font-size: 8px;
  }

  #flagcodeHistory {
    max-height: 230px;
  }

  .flagcode-history-verdict span {
    padding-inline: 4px;
    font-size: 6px;
  }

  #flagcodeCoverTitle {
    font-size: clamp(32px, 11vw, 50px);
  }

  #flagcodeRules ol,
  #flagcodeRules ul {
    grid-template-columns: 1fr;
  }

  #flagcodeRules li {
    min-height: 70px;
  }
}

@media (max-width: 370px) {
  #flagcodeStage {
    padding-inline: 10px;
  }

  #flagcodeSlots {
    gap: 3px;
    padding: 6px;
  }

  .flagcode-slot {
    min-height: 72px;
  }

  .flagcode-slot span {
    display: none;
  }

  .flagcode-candidate {
    grid-template-columns: 32px minmax(0, 1fr);
  }

  .flagcode-candidate > small {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  #flagcodeStage::after,
  #flagcodeSubmit::after,
  .flagcode-slot,
  .flagcode-candidate,
  #flagcodeSubmit,
  #startFlagcode {
    animation: none !important;
    scroll-behavior: auto !important;
    transition: none !important;
  }
}

@media (forced-colors: active) {
  .flagcode-slot,
  .flagcode-candidate,
  #flagcodeSubmit,
  .flagcode-history-entry,
  #flagcodeFeedback,
  #startFlagcode,
  #discardFlagcodeSave {
    border: 1px solid ButtonText;
    forced-color-adjust: auto;
  }

  .flagcode-candidate.is-selected,
  .flagcode-slot.is-filled {
    outline: 3px solid Highlight;
  }
}
