:root {
  color-scheme: dark;
  --bg: #090604;
  --panel: rgba(27, 16, 10, .97);
  --panel-2: rgba(43, 25, 14, .96);
  --line: rgba(255, 178, 71, .34);
  --line-strong: rgba(255, 192, 82, .78);
  --text: #fff8eb;
  --muted: #d5c1a5;
  --amber: #ffb23e;
  --orange: #ff7422;
  --gold: #ffd675;
  --green: #79e39d;
  --danger: #ff786e;
  --shadow: rgba(0, 0, 0, .55);
  --radius: 20px;
  --global-bar-height: var(--lexapyr-header-height, 98px);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  min-height: 100%;
  background: var(--bg);
}

body {
  min-width: 320px;
  min-height: 100dvh;
  margin: 0;
  overflow-x: hidden;
  color: var(--text);
  background:
    radial-gradient(circle at 20% 5%, rgba(255, 111, 20, .15), transparent 34rem),
    radial-gradient(circle at 82% 68%, rgba(255, 183, 63, .09), transparent 42rem),
    linear-gradient(155deg, #140a06, #070403 72%);
  font-size: 19px;
}

button,
input,
select {
  font: inherit;
}

button {
  color: inherit;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
input:focus-visible {
  outline: 4px solid rgba(255, 215, 122, .86);
  outline-offset: 3px;
}

[hidden] {
  display: none !important;
}

.ambient {
  position: fixed;
  z-index: 0;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}

.ambient::before {
  position: absolute;
  inset: -22%;
  content: "";
  opacity: .35;
  background:
    repeating-linear-gradient(118deg, transparent 0 72px, rgba(255, 168, 42, .045) 74px 76px, transparent 78px 156px);
  mask-image: radial-gradient(ellipse, #000 10%, transparent 70%);
  animation: weave 36s linear infinite;
}

.ember-flow,
.pyramid-glow {
  position: absolute;
  display: block;
}

.ember-flow {
  inset: -240px 0;
  background-repeat: repeat;
}

.ember-flow-a {
  opacity: .58;
  background-image:
    radial-gradient(circle, rgba(255, 230, 156, .95) 0 1.3px, rgba(255, 120, 24, .45) 2px, transparent 3.6px),
    radial-gradient(circle, rgba(255, 167, 46, .75) 0 1.7px, transparent 3.4px);
  background-size: 154px 218px, 231px 303px;
  animation: embers 22s linear infinite;
}

.ember-flow-b {
  opacity: .3;
  filter: blur(.5px);
  background-image:
    radial-gradient(circle, rgba(255, 186, 73, .8) 0 1.4px, transparent 3px),
    radial-gradient(circle, rgba(199, 49, 12, .75) 0 2px, transparent 4px);
  background-size: 111px 164px, 277px 351px;
  animation: embers-sway 17s ease-in-out infinite alternate;
}

.pyramid-glow {
  width: 110vmax;
  aspect-ratio: 1;
  left: 50%;
  top: 58%;
  translate: -50% -50%;
  opacity: .26;
  background:
    conic-gradient(from 30deg, transparent, rgba(255, 120, 20, .2), transparent 21%, rgba(255, 190, 74, .1), transparent 52%);
  clip-path: polygon(50% 0, 100% 92%, 0 92%);
  filter: blur(20px);
  animation: pyramid-breathe 13s ease-in-out infinite alternate;
}

.lexapyr-topbar,
.game-shell,
footer {
  position: relative;
  z-index: 1;
}

.game-shell {
  width: min(100%, 1180px);
  min-height: calc(100dvh - var(--global-bar-height));
  margin: 0 auto;
  padding: 12px 7px max(28px, env(safe-area-inset-bottom));
}

.mode-badge {
  width: fit-content;
  margin: 0 auto 10px;
  padding: 10px 18px;
  border: 2px solid rgba(121, 227, 157, .55);
  border-radius: 999px;
  color: #dcffe7;
  background: rgba(20, 67, 39, .9);
  font-size: 20px;
  font-weight: 950;
}

.admin-test-panel {
  margin: 0 0 12px;
  padding: 14px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr)) auto;
  gap: 10px;
  align-items: end;
  border: 2px solid rgba(121, 227, 157, .5);
  border-radius: 16px;
  background: rgba(16, 55, 33, .9);
}

.admin-test-panel label {
  display: grid;
  gap: 5px;
  font-size: 20px;
  font-weight: 850;
}

.admin-test-panel input,
.admin-test-panel select,
.admin-test-panel button {
  min-height: 58px;
  padding: 7px 10px;
  border: 1px solid rgba(197, 255, 216, .45);
  border-radius: 11px;
  color: var(--text);
  background: rgba(6, 27, 15, .82);
}

.status-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 9px;
  margin-bottom: 10px;
}

.status-strip > div {
  position: relative;
  min-width: 0;
  min-height: 94px;
  padding: 20px 4px 10px;
  display: grid;
  place-content: center;
  gap: 7px;
  text-align: center;
  border: 1.2px solid var(--line);
  border-radius: 16px;
  background:
    linear-gradient(150deg, rgba(255, 190, 82, .1), transparent 48%),
    rgba(22, 13, 9, .95);
  box-shadow: inset 0 1px rgba(255, 255, 255, .05), 0 10px 24px rgba(0, 0, 0, .24);
}

.status-strip span {
  position: absolute;
  top: -13px;
  left: 50%;
  max-width: calc(100% - 16px);
  padding: 0 6px;
  translate: -50% 0;
  overflow: hidden;
  color: var(--muted);
  background: #160d09;
  font-size: 26px;
  font-weight: 850;
  line-height: 1;
  letter-spacing: .04em;
  text-transform: uppercase;
  white-space: nowrap;
}

.status-strip strong {
  min-width: 0;
  overflow: hidden;
  color: var(--gold);
  font-size: 39px;
  font-weight: 950;
  line-height: 1;
  text-overflow: ellipsis;
}

.forge {
  padding: 12px;
  border: 1.2px solid var(--line);
  border-radius: var(--radius);
  background:
    radial-gradient(circle at 50% -8%, rgba(255, 151, 36, .12), transparent 45%),
    linear-gradient(155deg, rgba(43, 25, 15, .97), rgba(15, 9, 6, .98));
  box-shadow: 0 20px 54px var(--shadow), inset 0 1px rgba(255, 255, 255, .055);
}

.board-tools {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.tool-button {
  min-height: 75px;
  padding: 0 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  border: 2px solid var(--line-strong);
  border-radius: 18px;
  background: rgba(20, 12, 8, .9);
  font-size: 30px;
  font-weight: 900;
}

.tool-button b {
  font-size: 35px;
}

.help-button {
  width: 75px;
  padding: 0;
  border-radius: 50%;
  font-size: 38px;
}

.play-layout {
  display: grid;
  gap: 12px;
}

.pyramid-panel,
.input-panel {
  min-width: 0;
  padding: 18px 12px;
  border: 1.2px solid rgba(255, 181, 66, .25);
  border-radius: 19px;
  background: rgba(10, 6, 4, .48);
}

.pyramid-rows {
  min-height: 440px;
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 8px;
}

.pyramid-row {
  display: flex;
  justify-content: center;
  gap: 7px;
}

.pyramid-row.current {
  filter: drop-shadow(0 0 13px rgba(255, 174, 57, .3));
}

.pyramid-cell {
  width: 63px;
  height: 63px;
  display: grid;
  place-items: center;
  border: 1.2px solid rgba(255, 174, 52, .42);
  border-radius: 10px;
  color: rgba(255, 246, 229, .42);
  background: linear-gradient(160deg, rgba(78, 41, 19, .54), rgba(20, 11, 7, .84));
  font-size: 29px;
  font-weight: 950;
  text-transform: uppercase;
}

.pyramid-row.found .pyramid-cell {
  color: var(--text);
  border-color: rgba(255, 196, 76, .78);
  background:
    radial-gradient(circle at 45% 20%, rgba(255, 179, 63, .25), transparent 43%),
    linear-gradient(155deg, #5a2b13, #271108);
}

.pyramid-row.locked .pyramid-cell {
  opacity: .46;
}

.row-prompt {
  margin: 0 0 13px;
  color: var(--muted);
  text-align: center;
  font-size: 29px;
  font-weight: 850;
}

.answer-slots,
.letter-bank {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.answer-slots {
  min-height: 94px;
  margin-bottom: 18px;
}

.answer-slot,
.letter-button {
  width: 88px;
  height: 88px;
  flex: 0 0 88px;
  display: grid;
  place-items: center;
  border-radius: 14px;
  font-size: 42px;
  font-weight: 950;
  line-height: 1;
  text-transform: uppercase;
}

.answer-slot {
  border: 2px solid rgba(255, 187, 65, .44);
  color: var(--text);
  background: rgba(12, 7, 5, .72);
}

.answer-slot.filled {
  border-color: var(--line-strong);
  background: linear-gradient(155deg, rgba(114, 55, 20, .92), rgba(44, 20, 10, .98));
}

.answer-slot.hint {
  color: var(--gold);
  box-shadow: inset 0 0 20px rgba(255, 175, 45, .25);
}

.letter-bank {
  min-height: 100px;
}

.letter-button {
  border: 2px solid rgba(255, 179, 56, .72);
  color: var(--text);
  background:
    radial-gradient(circle at 40% 22%, rgba(255, 184, 70, .27), transparent 42%),
    linear-gradient(155deg, #673215, #2a1209);
  box-shadow: 0 9px 18px rgba(0, 0, 0, .3), inset 0 1px rgba(255, 255, 255, .08);
}

.letter-button:active {
  translate: 0 3px;
}

.letter-button.used {
  opacity: .18;
  pointer-events: none;
  transform: scale(.92);
}

.letter-button.shuffling {
  animation: tile-shuffle .46s ease both;
}

.feedback {
  min-height: 44px;
  margin: 16px 0 9px;
  color: var(--muted);
  text-align: center;
  font-size: 25px;
  font-weight: 750;
}

.feedback.success {
  color: var(--green);
}

.feedback.error {
  color: var(--danger);
}

.primary-actions,
.secondary-actions,
.completion-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.primary-actions {
  margin-bottom: 10px;
}

.primary-actions button,
.secondary-actions button,
.completion-actions button,
.wide-button {
  min-height: 86px;
  border: 2px solid var(--line-strong);
  border-radius: 17px;
  background: rgba(31, 17, 10, .92);
  font-size: 30px;
  font-weight: 950;
}

.accent {
  border-color: rgba(255, 208, 112, .86) !important;
  color: #1b0e07;
  background: linear-gradient(135deg, #ffd273, #ff8428) !important;
}

button:disabled {
  opacity: .35;
  cursor: not-allowed;
}

footer {
  width: min(100%, 1180px);
  margin: 0 auto;
  padding: 24px 16px 40px;
  color: rgba(215, 194, 165, .62);
  text-align: center;
  font-size: 17px;
}

.modal {
  width: min(850px, calc(100% - 32px));
  max-height: min(1086px, calc(100dvh - 28px));
  margin: auto;
  padding: 24px;
  overflow: auto;
  color: var(--text);
  border: 1.2px solid var(--line-strong);
  border-radius: 20px;
  background:
    radial-gradient(circle at 50% 0, rgba(255, 153, 40, .15), transparent 37%),
    linear-gradient(160deg, #351a0f, #120a06 74%);
  box-shadow: 0 30px 90px rgba(0, 0, 0, .78);
}

.levels-modal {
  inset: 0;
  width: 100%;
  height: 100dvh;
  max-width: 100%;
  max-height: 100dvh;
  margin: 0;
}

.modal::backdrop {
  background: rgba(2, 1, 1, .84);
  backdrop-filter: blur(10px);
}

.modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 14px;
}

.eyebrow {
  display: block;
  color: var(--amber);
  font-size: 26px;
  font-weight: 950;
  letter-spacing: .11em;
}

.modal h2 {
  margin: 3px 0 0;
  font-size: 44px;
  line-height: 1.05;
}

.close-button {
  width: 75px;
  height: 75px;
  flex: 0 0 75px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 2px solid var(--line-strong);
  border-radius: 50%;
  background: rgba(24, 13, 8, .82);
  font-size: 48px;
  line-height: 1;
}

.height-tabs {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin: 5px 0 14px;
}

.height-tab {
  min-height: 75px;
  border: 1.2px solid var(--line);
  border-radius: 14px;
  background: rgba(20, 11, 7, .72);
  font-size: 30px;
  font-weight: 950;
}

.height-tab.active {
  color: #1b0d06;
  border-color: var(--gold);
  background: linear-gradient(135deg, #ffd373, #ff8c2d);
}

.height-tab.locked {
  opacity: .42;
}

.jump-form {
  margin-bottom: 14px;
}

.jump-form label {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 28px;
}

.jump-form > div {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 118px;
  gap: 8px;
}

.jump-form input,
.jump-form button {
  min-height: 64px;
  border: 1.2px solid var(--line);
  border-radius: 13px;
  color: var(--text);
  background: rgba(13, 7, 5, .8);
  font-size: 30px;
  font-weight: 850;
}

.jump-form input {
  padding: 0 18px;
}

.jump-form button {
  color: #1c0d05;
  background: linear-gradient(135deg, #ffd373, #ff8428);
}

.level-groups {
  display: grid;
  gap: 10px;
}

.level-range {
  border: 1.2px solid rgba(255, 185, 65, .3);
  border-radius: 17px;
  overflow: hidden;
  background: rgba(37, 19, 11, .52);
}

.level-range > summary {
  min-height: 78px;
  padding: 0 20px;
  display: flex;
  align-items: center;
  cursor: pointer;
  color: var(--text);
  font-size: 32px;
  font-weight: 950;
  list-style: none;
}

.level-range > .level-group {
  margin: 0 8px 8px;
}

.level-group {
  border: 1.2px solid var(--line);
  border-radius: 15px;
  overflow: hidden;
  background: rgba(13, 8, 5, .48);
}

.level-group > summary {
  min-height: 74px;
  padding: 0 19px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  color: var(--gold);
  font-size: 30px;
  font-weight: 950;
  list-style: none;
}

.level-grid {
  padding: 8px;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.level-card {
  position: relative;
  min-height: 106px;
  padding: 8px 2px;
  display: grid;
  place-content: center;
  gap: 6px;
  border: 1.2px solid var(--line);
  border-radius: 13px;
  background: rgba(31, 17, 11, .84);
  font-size: 32px;
  font-weight: 950;
}

.level-card small {
  color: var(--amber);
  font-size: 30px;
  line-height: 1;
}

.level-card.current {
  border: 3px solid var(--gold);
  box-shadow: 0 0 20px rgba(255, 186, 63, .2);
}

.level-card.locked {
  opacity: .42;
}

.height-pin {
  position: absolute;
  top: -5px;
  right: -4px;
  min-width: 34px;
  height: 34px;
  padding: 0 6px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255, 222, 139, .64);
  border-radius: 999px;
  color: #211006;
  background: var(--gold);
  font-size: 17px;
}

.help-content {
  display: grid;
  gap: 12px;
}

.rule-row {
  display: grid;
  grid-template-columns: 53px minmax(0, 1fr);
  gap: 11px;
  align-items: start;
}

.rule-row > span {
  width: 53px;
  height: 53px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: #1c0d05;
  background: var(--amber);
  font-size: 32px;
  font-weight: 950;
}

.rule-row p {
  margin: 3px 0;
  color: var(--muted);
  font-size: 32px;
  line-height: 1.5;
}

.wide-button {
  width: 100%;
  margin-top: 8px;
}

.complete-modal {
  text-align: center;
}

.completion-mark {
  width: 112px;
  height: 112px;
  margin: 6px auto 14px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: #211006;
  background: var(--amber);
  box-shadow: 0 0 34px rgba(255, 171, 49, .38);
  font-size: 58px;
}

.complete-modal h2 {
  margin: 10px 0;
  font-size: 52px;
}

.earned-stars {
  margin: 8px 0 18px;
  color: var(--amber);
  font-size: 68px;
  letter-spacing: 8px;
}

.complete-stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 18px;
}

.complete-stat {
  min-height: 108px;
  display: grid;
  place-content: center;
  gap: 5px;
  border: 1.2px solid var(--line);
  border-radius: 15px;
  background: rgba(20, 11, 7, .72);
}

.complete-stat span {
  color: var(--muted);
  font-size: 25px;
}

.complete-stat strong {
  color: var(--gold);
  font-size: 38px;
}

@media (min-width: 1101px) {
  .play-layout {
    grid-template-columns: minmax(0, .95fr) minmax(0, 1.05fr);
  }

  .pyramid-rows {
    min-height: 560px;
  }

  .input-panel {
    display: grid;
    align-content: center;
  }

  .answer-slot,
  .letter-button {
    width: 57px;
    height: 72px;
    flex-basis: 57px;
    font-size: 32px;
  }

  .status-strip > div {
    min-height: 82px;
  }

  .status-strip span {
    top: -9px;
    font-size: 18px;
  }

  .status-strip strong {
    font-size: 32px;
  }

  .tool-button {
    min-height: 58px;
    font-size: 22px;
  }

  .help-button {
    width: 58px;
  }
}

@media (max-width: 1100px) {
  .admin-test-panel {
    grid-template-columns: 1fr;
  }

  .admin-test-panel label {
    font-size: 28px;
  }

  .admin-test-panel input,
  .admin-test-panel select,
  .admin-test-panel button {
    min-height: 70px;
    font-size: 28px;
  }
}

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

@keyframes embers {
  from { background-position: 14% 100%, 77% 70%; }
  to { background-position: 20% -20%, 69% -30%; }
}

@keyframes embers-sway {
  from { transform: translate3d(-26px, 20px, 0) rotate(-1deg); }
  to { transform: translate3d(34px, -28px, 0) rotate(1deg); }
}

@keyframes weave {
  to { transform: translate3d(120px, -90px, 0); }
}

@keyframes pyramid-breathe {
  from { transform: scale(.88) rotate(-2deg); opacity: .17; }
  to { transform: scale(1.08) rotate(2deg); opacity: .32; }
}

@keyframes tile-shuffle {
  0% { transform: translateY(0) rotate(0); }
  42% { transform: translateY(-24px) rotate(8deg) scale(1.05); }
  100% { transform: translateY(0) rotate(0); }
}
