:root {
  --font-game: "Playpen Sans", cursive;
}

*, :before, :after {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
  margin: 0;
  padding: 0;
}

input {
  -webkit-user-select: text;
  user-select: text;
  touch-action: auto;
}

html, body {
  width: 100%;
  height: 100%;
  font-family: var(--font-game);
  background: #2a2a2a;
  overflow: hidden;
}

.screen {
  -webkit-overflow-scrolling: touch;
  flex-direction: column;
  display: none;
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  right: 0;
  overflow-y: auto;
}

.screen.active {
  display: flex;
}

#screen-login, #screen-start {
  background: linear-gradient(#87ceeb 0%, #87ceeb 50%, #5a8a36 50%, #5a8a36 58%, #8b6914 58%, #8b6914 76%, #b34a00 76%);
  justify-content: flex-start;
  align-items: center;
  padding: 10px 14px 18px;
}

.mc-char {
  pointer-events: none;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  filter: drop-shadow(2px 2px #00000080);
  display: block;
  position: absolute;
  bottom: 42%;
}

.mc-char--left {
  left: 8px;
}

.mc-char--right {
  right: 8px;
}

.start-inner {
  flex-direction: column;
  flex-shrink: 0;
  gap: 10px;
  width: 100%;
  max-width: 460px;
  margin: 0 auto;
  display: flex;
}

.logo-block {
  text-align: center;
  padding: 6px 0 2px;
}

.logo-icon {
  filter: drop-shadow(3px 3px #0009);
  margin-bottom: 5px;
  font-size: 48px;
  line-height: 1;
}

.logo-title {
  font-family: "Press Start 2P", monospace;
  font-size: 36px;
  color: #fff;
  text-shadow: 3px 3px #000, -1px -1px #000, 1px -1px #000, -1px 1px #000;
  letter-spacing: 6px;
  font-size: max(26px, min(8.5vw, 36px));
  line-height: 1.4;
}

.logo-tagline {
  color: #ffffffd9;
  text-shadow: 1px 1px #000;
  letter-spacing: 1px;
  margin-top: 5px;
  font-size: 12px;
}

.hs-panel {
  background: #1e1e1e;
  border: 3px solid #000;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  display: flex;
  box-shadow: inset -3px -3px #0a0a0a, inset 3px 3px #3a3a3a;
}

.hs-left {
  flex-direction: column;
  gap: 3px;
  display: flex;
}

.hs-label {
  color: #aaa;
  font-size: 11px;
}

.hs-value {
  color: gold;
  text-shadow: 2px 2px #000;
  font-size: 26px;
}

.lb-open-btn {
  color: #fff;
  font-family: var(--font-game);
  cursor: pointer;
  background: #5c3a0a;
  border: 2px solid #000;
  flex-direction: column;
  flex-shrink: 0;
  align-items: center;
  gap: 3px;
  padding: 8px 12px;
  display: flex;
  box-shadow: inset -3px -3px #2e1c04, inset 3px 3px #9a6418;
}

.lb-open-btn:active {
  transform: translate(1px, 1px);
  box-shadow: inset 3px 3px #2e1c04, inset -3px -3px #9a6418;
}

.lb-open-icon {
  font-size: 22px;
  line-height: 1;
}

.lb-open-label {
  letter-spacing: 1px;
  font-size: 10px;
}

.version-label {
  color: #0000004d;
  text-align: center;
  letter-spacing: 2px;
  padding-top: 2px;
  font-size: 10px;
}

.diff-heading {
  color: #1a1a1a;
  text-shadow: 1px 1px #ffffff40;
  text-align: center;
  letter-spacing: 1px;
  font-size: 10px;
}

.diff-buttons {
  flex-direction: column;
  gap: 8px;
  padding-bottom: 8px;
  display: flex;
}

.diff-btn {
  cursor: pointer;
  width: 100%;
  font-family: var(--font-game);
  color: #fff;
  text-align: left;
  border: 3px solid #000;
  align-items: center;
  gap: 14px;
  padding: 12px 16px;
  transition: transform 50ms;
  display: flex;
}

.diff-btn:active {
  transform: translate(2px, 2px);
}

.diff-easy {
  background: #3d8a2a;
  box-shadow: inset -4px -4px #1f4a12, inset 4px 4px #5dc048;
}

.diff-easy:active {
  box-shadow: inset 4px 4px #1f4a12, inset -4px -4px #5dc048;
}

.diff-medium {
  background: #b88c10;
  box-shadow: inset -4px -4px #6a4e06, inset 4px 4px #eaba28;
}

.diff-medium:active {
  box-shadow: inset 4px 4px #6a4e06, inset -4px -4px #eaba28;
}

.diff-hard {
  background: #9e2020;
  box-shadow: inset -4px -4px #560808, inset 4px 4px #cc4848;
}

.diff-hard:active {
  box-shadow: inset 4px 4px #560808, inset -4px -4px #cc4848;
}

.diff-icon {
  flex-shrink: 0;
  font-size: 36px;
  line-height: 1;
}

.diff-info {
  flex-direction: column;
  gap: 5px;
  display: flex;
}

.diff-name {
  font-size: 17px;
  text-shadow: 2px 2px #0009;
  font-size: max(13px, min(4.5vw, 17px));
  display: block;
}

.diff-desc {
  color: #fffc;
  text-shadow: 1px 1px #00000080;
  font-size: 11px;
  line-height: 1.8;
  display: block;
}

.mode-tabs {
  border: 3px solid #000;
  margin-bottom: 4px;
  display: flex;
}

.mode-tab {
  color: #999;
  font-family: var(--font-game);
  cursor: pointer;
  letter-spacing: .5px;
  background: #3a3a4a;
  border: none;
  border-right: 2px solid #000;
  flex: 1;
  padding: 10px 6px;
  font-size: 12px;
  box-shadow: inset -2px -2px #1e1e2e, inset 2px 2px #5a5a6a;
}

.mode-tab:last-child {
  border-right: none;
}

.mode-tab:active {
  background: #2e2e3e;
  box-shadow: inset 2px 2px #1e1e2e, inset -2px -2px #5a5a6a;
}

.mode-tab-active {
  color: gold;
  background: #1e1e30;
  box-shadow: inset 0 -3px gold, inset -2px 0 #1e1e2e, inset 2px 2px #3a3a5a;
}

.mode-panel {
  flex-direction: column;
  display: flex;
}

.train-config {
  flex-direction: column;
  gap: 6px;
  padding-bottom: 8px;
  display: flex;
}

.train-heading {
  color: #ffffffd9;
  text-shadow: 1px 1px #000;
  letter-spacing: 1px;
  margin-top: 6px;
  font-size: 12px;
}

.train-range-presets {
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  display: grid;
}

.train-preset-btn, .train-errmode-btn {
  font-family: var(--font-game);
  color: #999;
  cursor: pointer;
  letter-spacing: .5px;
  background: #2e2e3e;
  border: 3px solid #000;
  padding: 10px 4px;
  font-size: 11px;
  transition: transform 50ms;
  box-shadow: inset -3px -3px #16161e, inset 3px 3px #46465a;
}

.train-preset-btn:active, .train-errmode-btn:active {
  transform: translate(2px, 2px);
  box-shadow: inset 3px 3px #16161e, inset -3px -3px #46465a;
}

.train-preset-active, .train-errmode-active {
  color: #fff;
  background: #2a5cb8;
  box-shadow: inset -3px -3px #142e6a, inset 3px 3px #4880dc;
}

.train-custom-row {
  align-items: center;
  gap: 8px;
  display: flex;
}

.train-custom-label {
  color: #ccc;
  text-shadow: 1px 1px #000;
  font-size: 13px;
}

.train-custom-input, .train-timer-input {
  max-width: 90px;
  font-family: var(--font-game);
  color: gold;
  background: #111;
  border: 3px solid #000;
  outline: none;
  flex: 1;
  min-width: 0;
  padding: 8px 10px;
  font-size: 15px;
  box-shadow: inset -3px -3px #0a0a0a, inset 3px 3px #3a3a3a;
}

.train-custom-input:focus, .train-timer-input:focus {
  border-color: gold;
  box-shadow: inset -3px -3px #0a0a0a, inset 3px 3px #3a3a3a, 0 0 0 2px #ffd70040;
}

.train-ops {
  flex-direction: column;
  gap: 4px;
  display: flex;
}

.train-op-chk {
  color: #ddd;
  letter-spacing: .5px;
  cursor: pointer;
  background: #1e1e2e;
  border: 2px solid #000;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  font-size: 12px;
  display: flex;
}

.train-op-chk input[type="checkbox"] {
  accent-color: #3d8a2a;
  flex-shrink: 0;
  width: 16px;
  height: 16px;
}

.train-op-disabled {
  opacity: .45;
  cursor: default;
}

.train-soon-badge {
  color: #b88c10;
  letter-spacing: .5px;
  flex-shrink: 0;
  margin-left: auto;
  font-size: 9px;
}

.train-error {
  color: #cc4848;
  letter-spacing: .5px;
  padding: 2px 2px 4px;
  font-size: 11px;
}

.train-slider {
  accent-color: #3d8a2a;
  width: 100%;
  height: 18px;
}

.train-toggle-row {
  color: #ddd;
  letter-spacing: .5px;
  cursor: pointer;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  display: flex;
}

.train-toggle-row input[type="checkbox"] {
  accent-color: #3d8a2a;
  flex-shrink: 0;
  width: 16px;
  height: 16px;
}

.train-timer-row {
  color: #ccc;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  display: flex;
}

.train-errmode-tabs {
  grid-template-columns: repeat(2, 1fr);
  gap: 6px;
  display: grid;
}

.train-start-btn {
  margin-top: 10px;
}

.mc-btn:disabled {
  opacity: .4;
  cursor: default;
}

#screen-game, #screen-game-training {
  background: #2e2e2e;
  overflow: hidden;
}

.game-header {
  background: #1a1a1a;
  border-bottom: 3px solid #000;
  flex-shrink: 0;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  display: flex;
}

.stat-box {
  text-align: center;
  min-width: 60px;
}

.stat-label {
  color: #666;
  letter-spacing: 1px;
  margin-bottom: 4px;
  font-size: 10px;
}

.stat-value {
  color: gold;
  text-shadow: 2px 2px #000;
  font-size: 18px;
}

.quit-btn {
  color: #fff;
  font-family: var(--font-game);
  cursor: pointer;
  letter-spacing: 1px;
  background: #7a1a1a;
  border: 2px solid #000;
  padding: 8px 10px;
  font-size: 10px;
  box-shadow: inset -2px -2px #3e0000, inset 2px 2px #aa3838;
}

.quit-btn:active {
  transform: translate(1px, 1px);
  box-shadow: inset 2px 2px #3e0000, inset -2px -2px #aa3838;
}

.progress-track {
  background: #111;
  border-bottom: 2px solid #000;
  flex-shrink: 0;
  height: 10px;
}

.progress-bar {
  background: #3d8a2a;
  width: 0%;
  height: 100%;
  transition: width .4s;
  box-shadow: inset 0 3px #5dc048, inset 0 -2px #1f4a12;
}

.problem-section {
  flex-direction: column;
  flex: 1;
  justify-content: center;
  align-items: center;
  min-height: 0;
  padding: 16px 20px;
  display: flex;
  position: relative;
}

.problem-label {
  color: #666;
  letter-spacing: 1px;
  min-height: 14px;
  margin-bottom: 12px;
  font-size: 11px;
}

.problem-display {
  font-size: 48px;
  color: #fff;
  text-align: center;
  text-shadow: 3px 3px #000;
  letter-spacing: 4px;
  word-break: break-all;
  font-size: max(26px, min(9vw, 48px));
  line-height: 1.6;
}

.cmp-placeholder {
  vertical-align: middle;
  border: 3px solid #fff;
  width: .75em;
  height: .75em;
  margin: 0 4px;
  display: inline-block;
  box-shadow: 2px 2px #000;
}

.feedback-overlay {
  z-index: 50;
  cursor: pointer;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 20px;
  display: flex;
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  right: 0;
}

.feedback-overlay.hidden {
  display: none;
}

.feedback-overlay.correct {
  background: #287814;
}

.feedback-overlay.wrong {
  background: #a01e1e;
}

.feedback-text {
  font-size: 24px;
  color: #fff;
  text-align: center;
  text-shadow: 2px 2px #000;
  white-space: pre-line;
  font-size: max(17px, min(5.5vw, 24px));
  line-height: 2.2;
}

#train-feedback-overlay {
  gap: 14px;
  overflow-y: auto;
}

#train-feedback-overlay .feedback-text {
  line-height: 1.4;
}

.train-feedback-solution {
  white-space: nowrap;
  color: #fff;
  font-size: 13px;
  text-align: center;
  text-shadow: 2px 2px #000;
  justify-content: center;
  align-items: center;
  font-size: max(13px, min(4vw, 48px));
  display: flex;
}

#train-feedback-arrow {
  margin: 0 .35em;
}

@media (min-width: 700px) {
  .train-feedback-solution {
    font-size: 28px;
    font-size: max(28px, min(4vw, 48px));
  }
}

@media (min-width: 900px) {
  .train-feedback-solution {
    font-size: 36px;
    font-size: max(36px, min(4vw, 48px));
  }
}

.train-feedback-given-value {
  text-decoration: line-through;
  text-decoration-thickness: 2px;
}

.train-feedback-correct-value {
  color: #fff2a3;
}

.feedback-continue {
  color: #fff;
  text-align: center;
  text-shadow: 1px 1px #000;
  letter-spacing: .5px;
  margin-top: 10px;
  font-size: 12px;
  animation: .8s ease-in-out infinite alternate badge-pulse;
}

.feedback-continue.hidden {
  display: none;
}

.answer-section {
  flex-direction: column;
  flex-shrink: 0;
  align-items: center;
  gap: 4px;
  padding: 6px 16px 8px;
  display: flex;
}

.answer-label {
  color: #555;
  letter-spacing: 1px;
  font-size: 10px;
}

.answer-box {
  color: gold;
  font-size: 42px;
  text-align: center;
  letter-spacing: 8px;
  text-shadow: 2px 2px #000;
  background: #111;
  border: 3px solid #000;
  min-width: 130px;
  padding: 8px 24px;
  font-size: max(26px, min(9vw, 42px));
  box-shadow: inset 3px 3px #080808, inset -3px -3px #2a2a2a;
}

.keyboard {
  background: #1a1a1a;
  border-top: 3px solid #000;
  flex-shrink: 0;
  padding: 8px 10px 10px;
}

.keyboard.hidden {
  display: none;
}

.key-row {
  gap: 8px;
  margin-bottom: 8px;
  display: flex;
}

.key-row:last-child {
  margin-bottom: 0;
}

.key {
  cursor: pointer;
  height: 72px;
  font-family: var(--font-game);
  -webkit-tap-highlight-color: transparent;
  border: 2px solid #000;
  flex: 1;
  justify-content: center;
  align-items: center;
  font-size: 20px;
  transition: transform 50ms;
  display: flex;
}

.key:active {
  transform: translate(1px, 1px);
}

.num-key {
  color: #fff;
  text-shadow: 2px 2px #000;
  background: #6e6e6e;
  box-shadow: inset -3px -3px #3a3a3a, inset 3px 3px #9a9a9a;
}

.num-key:active {
  box-shadow: inset 3px 3px #3a3a3a, inset -3px -3px #9a9a9a;
}

.bksp-key {
  color: #fff;
  background: #7a5c14;
  font-size: 22px;
  box-shadow: inset -3px -3px #3e2c06, inset 3px 3px #aa8028;
}

.bksp-key:active {
  box-shadow: inset 3px 3px #3e2c06, inset -3px -3px #aa8028;
}

.check-key {
  color: #fff;
  background: #3d8a2a;
  font-size: 24px;
  box-shadow: inset -3px -3px #1f4a12, inset 3px 3px #5dc048;
}

.check-key:active {
  box-shadow: inset 3px 3px #1f4a12, inset -3px -3px #5dc048;
}

.keyboard-cmp {
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 18px 16px 20px;
  display: flex;
}

.keyboard-cmp.hidden {
  display: none;
}

.cmp-label {
  color: #666;
  text-align: center;
  letter-spacing: 1px;
  font-size: 11px;
}

.cmp-keys {
  gap: 14px;
  width: 100%;
  max-width: 340px;
  display: flex;
}

.cmp-key {
  color: #fff;
  height: 86px;
  font-family: var(--font-game);
  cursor: pointer;
  text-shadow: 2px 2px #000;
  background: #2a5cb8;
  border: 3px solid #000;
  flex: 1;
  justify-content: center;
  align-items: center;
  font-size: 30px;
  display: flex;
  box-shadow: inset -4px -4px #142e6a, inset 4px 4px #4880dc;
}

.cmp-key:active {
  transform: translate(2px, 2px);
  box-shadow: inset 4px 4px #142e6a, inset -4px -4px #4880dc;
}

#screen-result, #screen-result-training {
  background: linear-gradient(#0d0d1f 0%, #0a1a3a 50%, #0d0d1f 100%);
  justify-content: center;
  align-items: center;
  padding: 20px 16px;
}

.result-inner {
  flex-direction: column;
  align-items: center;
  gap: 12px;
  width: 100%;
  max-width: 460px;
  display: flex;
}

.result-emoji {
  filter: drop-shadow(3px 3px #00000080);
  font-size: 72px;
  line-height: 1;
}

.result-title {
  font-size: 26px;
  color: #fff;
  text-shadow: 3px 3px #000;
  text-align: center;
  letter-spacing: 2px;
  font-size: max(18px, min(6.5vw, 26px));
}

.result-score-block {
  background: #1a1a1a;
  border: 3px solid #000;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  width: 100%;
  padding: 16px 40px;
  display: flex;
  box-shadow: inset -4px -4px #0a0a0a, inset 4px 4px #3a3a3a;
}

.result-score-label {
  color: #666;
  letter-spacing: 2px;
  font-size: 10px;
}

.result-score-row {
  align-items: baseline;
  gap: 6px;
  display: flex;
}

.result-score-val {
  font-size: 78px;
  color: gold;
  text-shadow: 3px 3px #000;
  font-size: max(60px, min(19.5vw, 78px));
  line-height: 1;
}

.result-score-max {
  color: #555;
  font-size: 18px;
}

.new-record-badge {
  color: #fff;
  text-shadow: 2px 2px #000;
  text-align: center;
  background: #b88c10;
  border: 3px solid #000;
  width: 100%;
  padding: 10px 18px;
  font-size: 12px;
  animation: .6s ease-in-out infinite alternate badge-pulse;
  box-shadow: inset -3px -3px #6a4e06, inset 3px 3px #eaba28;
}

.new-record-badge.hidden {
  display: none;
}

@keyframes badge-pulse {
  from {
    transform: scale(1);
  }

  to {
    transform: scale(1.03);
  }
}

.result-stats {
  background: #1a1a1a;
  border: 3px solid #000;
  width: 100%;
  padding: 8px 16px;
  box-shadow: inset -3px -3px #0a0a0a, inset 3px 3px #2a2a2a;
}

.result-stat-row {
  color: #bbb;
  border-bottom: 1px solid #2a2a2a;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
  font-size: 12px;
  display: flex;
}

.result-stat-row:last-child {
  border-bottom: none;
}

.result-stat-row span:last-child {
  color: gold;
  text-align: right;
}

.result-btns {
  flex-direction: column;
  gap: 8px;
  width: 100%;
  display: flex;
}

.mc-btn {
  cursor: pointer;
  width: 100%;
  font-family: var(--font-game);
  color: #fff;
  text-shadow: 2px 2px #000;
  letter-spacing: 1px;
  text-align: center;
  border: 3px solid #000;
  padding: 14px 16px;
  font-size: 13px;
  transition: transform 50ms;
  display: block;
}

.mc-btn:active {
  transform: translate(2px, 2px);
}

.mc-btn-green {
  background: #3d8a2a;
  box-shadow: inset -4px -4px #1f4a12, inset 4px 4px #5dc048;
}

.mc-btn-green:active {
  box-shadow: inset 4px 4px #1f4a12, inset -4px -4px #5dc048;
}

.mc-btn-blue {
  background: #2a5cb8;
  box-shadow: inset -4px -4px #142e6a, inset 4px 4px #4880dc;
}

.mc-btn-blue:active {
  box-shadow: inset 4px 4px #142e6a, inset -4px -4px #4880dc;
}

.mc-btn-gray {
  background: #5a5a5a;
  box-shadow: inset -4px -4px #2a2a2a, inset 4px 4px #888;
}

.mc-btn-gray:active {
  box-shadow: inset 4px 4px #2a2a2a, inset -4px -4px #888;
}

.mc-btn-brown {
  background: #5c3a0a;
  box-shadow: inset -4px -4px #2e1c04, inset 4px 4px #9a6418;
}

.mc-btn-brown:active {
  box-shadow: inset 4px 4px #2e1c04, inset -4px -4px #9a6418;
}

.mc-btn-red {
  background: #9e2020;
  box-shadow: inset -4px -4px #560808, inset 4px 4px #cc4848;
}

.mc-btn-red:active {
  box-shadow: inset 4px 4px #560808, inset -4px -4px #cc4848;
}

.train-timeout-badge {
  color: #fff;
  text-shadow: 2px 2px #000;
  text-align: center;
  background: #9e2020;
  border: 3px solid #000;
  width: 100%;
  padding: 10px 18px;
  font-size: 12px;
  box-shadow: inset -3px -3px #560808, inset 3px 3px #cc4848;
}

.train-review {
  flex-direction: column;
  gap: 6px;
  width: 100%;
  display: flex;
}

.train-review-heading {
  color: #ffffffd9;
  text-shadow: 1px 1px #000;
  letter-spacing: 1px;
  font-size: 12px;
}

.train-review-list {
  -webkit-overflow-scrolling: touch;
  flex-direction: column;
  gap: 6px;
  max-height: 220px;
  display: flex;
  overflow-y: auto;
}

.train-review-row {
  text-align: center;
  background: #1a1a1a;
  border: 2px solid #000;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 3px;
  padding: 8px 10px;
  font-size: 11px;
  display: flex;
  box-shadow: inset -2px -2px #0a0a0a, inset 2px 2px #2a2a2a;
}

.train-review-problem {
  color: #fff;
  text-shadow: 1px 1px #000;
  font-size: 12px;
}

.train-review-given {
  color: #cc4848;
}

.train-review-correct {
  color: #5dc048;
}

.train-review-empty {
  color: #5dc048;
  text-align: center;
  letter-spacing: .5px;
  padding: 10px;
  font-size: 12px;
}

#screen-leaderboard {
  background: linear-gradient(#0a0a14 0%, #141428 40%, #0a0a14 100%);
  flex-direction: column;
  overflow: hidden;
}

.lb-header {
  background: #3d2a08;
  border-bottom: 4px solid #000;
  flex-shrink: 0;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  display: flex;
  box-shadow: inset -3px -3px #1e1204, inset 3px 3px #7a5a18;
}

.lb-back-btn {
  color: #fff;
  font-family: var(--font-game);
  cursor: pointer;
  white-space: nowrap;
  background: #7a5c14;
  border: 2px solid #000;
  flex-shrink: 0;
  padding: 8px 10px;
  font-size: 11px;
  box-shadow: inset -2px -2px #3e2c06, inset 2px 2px #aa8028;
}

.lb-back-btn:active {
  transform: translate(1px, 1px);
  box-shadow: inset 2px 2px #3e2c06, inset -2px -2px #aa8028;
}

.lb-title {
  font-size: 18px;
  color: gold;
  text-shadow: 2px 2px #000;
  text-align: center;
  flex: 1;
  font-size: max(13px, min(4.5vw, 18px));
}

.lb-refresh-btn {
  color: #fff;
  font-family: var(--font-game);
  cursor: pointer;
  background: #3d8a2a;
  border: 2px solid #000;
  flex-shrink: 0;
  justify-content: center;
  align-items: center;
  width: 36px;
  height: 36px;
  font-size: 18px;
  display: flex;
  box-shadow: inset -2px -2px #1f4a12, inset 2px 2px #5dc048;
}

.lb-refresh-btn:active {
  transform: translate(1px, 1px);
  box-shadow: inset 2px 2px #1f4a12, inset -2px -2px #5dc048;
}

.lb-tabs {
  border-bottom: 3px solid #000;
  flex-shrink: 0;
  display: flex;
}

.lb-tab {
  color: #666;
  font-family: var(--font-game);
  cursor: pointer;
  letter-spacing: .5px;
  background: #3a3a4a;
  border: none;
  border-right: 2px solid #000;
  flex: 1;
  padding: 10px 6px;
  font-size: 11px;
  transition: background .1s;
  box-shadow: inset -2px -2px #1e1e2e, inset 2px 2px #5a5a6a;
}

.lb-tab:last-child {
  border-right: none;
}

.lb-tab:active {
  background: #2e2e3e;
  box-shadow: inset 2px 2px #1e1e2e, inset -2px -2px #5a5a6a;
}

.lb-tab-active {
  color: gold;
  background: #1e1e30;
  box-shadow: inset 0 -3px gold, inset -2px 0 #1e1e2e, inset 2px 2px #3a3a5a;
}

.lb-content {
  -webkit-overflow-scrolling: touch;
  flex: 1;
  padding: 12px 14px 20px;
  overflow-y: auto;
}

.lb-loading, .lb-empty, .lb-error {
  text-align: center;
  letter-spacing: 1px;
  padding: 40px 20px;
  font-size: 12px;
}

.lb-loading {
  color: #666;
}

.lb-empty {
  color: #555;
}

.lb-error {
  color: #cc4848;
}

.lb-row {
  background: #22223a;
  border: 2px solid #000;
  align-items: center;
  gap: 10px;
  margin-bottom: 6px;
  padding: 10px 12px;
  display: flex;
  box-shadow: inset -2px -2px #0e0e1e, inset 2px 2px #38385a;
}

.lb-row-me {
  background: #0e2218;
  border-color: #3d8a2a;
  box-shadow: inset -2px -2px #061208, inset 2px 2px #1e4a28, 0 0 0 1px #3d8a2a;
}

.lb-row:first-child {
  background: #2a2000;
  border-color: gold;
  box-shadow: inset -2px -2px #141000, inset 2px 2px #4a3800;
}

.lb-row:nth-child(2) {
  background: #202028;
  border-color: #aaa;
  box-shadow: inset -2px -2px #101018, inset 2px 2px #383848;
}

.lb-row:nth-child(3) {
  background: #221408;
  border-color: #cd7f32;
  box-shadow: inset -2px -2px #110a04, inset 2px 2px #3e2410;
}

.lb-rank {
  color: #666;
  text-align: right;
  flex-shrink: 0;
  min-width: 24px;
  font-size: 13px;
}

.lb-row:first-child .lb-rank {
  color: gold;
  font-size: 15px;
}

.lb-row:nth-child(2) .lb-rank {
  color: #aaa;
}

.lb-row:nth-child(3) .lb-rank {
  color: #cd7f32;
}

.lb-name {
  color: #ccc;
  text-shadow: 1px 1px #000;
  text-overflow: ellipsis;
  white-space: nowrap;
  letter-spacing: 1px;
  flex: 1;
  font-size: 13px;
  overflow: hidden;
}

.lb-row-me .lb-name {
  color: #5dc048;
}

.lb-row:first-child .lb-name {
  color: gold;
}

.lb-score {
  color: gold;
  text-shadow: 2px 2px #000;
  flex-shrink: 0;
  font-size: 18px;
}

.lb-offline-hint {
  color: #444;
  text-align: center;
  letter-spacing: .5px;
  padding: 12px 20px 0;
  font-size: 10px;
  line-height: 2;
}

.login-inner {
  flex-direction: column;
  gap: 12px;
  width: 100%;
  max-width: 460px;
  margin: 0 auto;
  display: flex;
}

.login-form {
  flex-direction: column;
  gap: 8px;
  display: flex;
}

.profile-title {
  color: #fff;
  text-align: center;
  text-shadow: 2px 2px #000;
  font-size: 20px;
}

#profile-auth-panel {
  flex-direction: column;
  gap: 10px;
  display: flex;
}

.profile-help {
  color: #fff;
  text-align: center;
  background: #252535;
  padding: 10px 12px;
  font-size: 13px;
  line-height: 1.6;
}

.auth-mode-tabs {
  border: 3px solid #000;
  display: flex;
}

.auth-mode-btn {
  color: #ccc;
  min-height: 48px;
  font-family: var(--font-game);
  cursor: pointer;
  background: #3a3a4a;
  border: 0;
  border-right: 2px solid #000;
  flex: 1;
  padding: 8px 5px;
  font-size: 11px;
  box-shadow: inset -2px -2px #1e1e2e, inset 2px 2px #5a5a6a;
}

.auth-mode-btn:last-child {
  border-right: 0;
}

.auth-mode-btn:active {
  transform: translate(1px, 1px);
}

.auth-mode-active {
  color: gold;
  background: #1e1e30;
  box-shadow: inset 0 -3px gold, inset -2px 0 #1e1e2e, inset 2px 2px #3a3a5a;
}

.profile-signed-in {
  color: #aaa;
  text-align: center;
  background: #1e1e1e;
  border: 3px solid #000;
  flex-direction: column;
  gap: 14px;
  padding: 18px;
  display: flex;
  box-shadow: inset -3px -3px #0a0a0a, inset 3px 3px #3a3a3a;
}

.profile-signed-in strong {
  color: gold;
  overflow-wrap: anywhere;
  font-size: 20px;
}

.login-label {
  color: #ffffffe6;
  text-shadow: 1px 1px #000;
  letter-spacing: 1px;
  font-size: 12px;
}

.login-input-row {
  align-items: stretch;
  gap: 8px;
  display: flex;
}

.login-input {
  font-family: var(--font-game);
  color: gold;
  text-transform: uppercase;
  letter-spacing: 2px;
  background: #111;
  border: 3px solid #000;
  outline: none;
  flex: 1;
  min-width: 0;
  padding: 10px 12px;
  font-size: 17px;
  box-shadow: inset -3px -3px #0a0a0a, inset 3px 3px #3a3a3a;
}

.login-input:focus {
  border-color: gold;
  box-shadow: inset -3px -3px #0a0a0a, inset 3px 3px #3a3a3a, 0 0 0 2px #ffd70040;
}

.login-input::placeholder {
  color: #444;
  letter-spacing: 0;
  font-size: 12px;
}

.login-btn {
  font-family: var(--font-game);
  color: #fff;
  text-shadow: 1px 1px #000;
  cursor: pointer;
  white-space: nowrap;
  background: #3d8a2a;
  border: 3px solid #000;
  flex-shrink: 0;
  padding: 0 14px;
  font-size: 12px;
  box-shadow: inset -3px -3px #1f4a12, inset 3px 3px #5dc048;
}

.login-btn:active {
  transform: translate(1px, 1px);
  box-shadow: inset 3px 3px #1f4a12, inset -3px -3px #5dc048;
}

.login-btn:disabled {
  opacity: .5;
  cursor: default;
}

.login-error {
  color: #f66;
  text-shadow: 1px 1px #000;
  letter-spacing: .5px;
  min-height: 14px;
  font-size: 11px;
}

.login-anon-btn {
  font-family: var(--font-game);
  color: #888;
  cursor: pointer;
  text-align: center;
  letter-spacing: .5px;
  background: #1e1e1e;
  border: 3px solid #000;
  padding: 10px 14px;
  font-size: 11px;
  box-shadow: inset -3px -3px #0a0a0a, inset 3px 3px #3a3a3a;
}

.login-anon-btn:active {
  transform: translate(1px, 1px);
  box-shadow: inset 3px 3px #0a0a0a, inset -3px -3px #3a3a3a;
}

#screen-pin {
  background: linear-gradient(#0a0a14 0%, #141428 40%, #0a0a14 100%);
  justify-content: center;
  align-items: center;
  padding: 20px;
}

.pin-inner {
  flex-direction: column;
  align-items: center;
  gap: 18px;
  width: 100%;
  max-width: 340px;
  display: flex;
}

.pin-message {
  color: gold;
  text-align: center;
  text-shadow: 1px 1px #000;
  white-space: pre-line;
  letter-spacing: .5px;
  font-size: 20px;
  line-height: 2.2;
}

.pin-dots {
  gap: 14px;
  display: flex;
}

.pin-dot {
  background: #22223a;
  border: 3px solid #000;
  width: 22px;
  height: 22px;
  display: block;
  box-shadow: inset -2px -2px #0e0e1e, inset 2px 2px #38385a;
}

.pin-dot.filled {
  background: gold;
  box-shadow: inset -2px -2px #a89000, inset 2px 2px #ffe84d;
}

.pin-error {
  color: #f66;
  text-shadow: 1px 1px #000;
  text-align: center;
  letter-spacing: .5px;
  min-height: 14px;
  font-size: 11px;
}

.pin-back-btn {
  font-family: var(--font-game);
  color: #888;
  cursor: pointer;
  background: #22223a;
  border: 3px solid #000;
  padding: 8px 16px;
  font-size: 12px;
  box-shadow: inset -3px -3px #0e0e1e, inset 3px 3px #38385a;
}

.pin-back-btn:active {
  transform: translate(1px, 1px);
  box-shadow: inset 3px 3px #0e0e1e, inset -3px -3px #38385a;
}

.key-empty {
  height: 72px;
  box-shadow: none;
  pointer-events: none;
  background: none;
  border: none;
  flex: 1;
}

#keyboard-pin {
  background: #0e0e1e;
  border-top-color: #000;
  width: 100%;
}

#keyboard-pin .key {
  font-size: 26px;
}

#keyboard-pin .bksp-key {
  font-size: 28px;
}

.player-bar {
  color: #888;
  background: #1e1e1e;
  border: 3px solid #000;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  font-size: 12px;
  display: flex;
  box-shadow: inset -2px -2px #0a0a0a, inset 2px 2px #3a3a3a;
}

.player-bar-name {
  color: gold;
  text-shadow: 1px 1px #000;
  letter-spacing: 1px;
}

.profile-btn {
  font-family: var(--font-game);
  color: #aaa;
  cursor: pointer;
  white-space: nowrap;
  background: #3a2a0a;
  border: 2px solid #000;
  flex-shrink: 0;
  padding: 5px 8px;
  font-size: 10px;
  box-shadow: inset -2px -2px #1a1200, inset 2px 2px #5a4418;
}

.profile-btn:active {
  transform: translate(1px, 1px);
  box-shadow: inset 2px 2px #1a1200, inset -2px -2px #5a4418;
}

.guest-note {
  color: #fff;
  background: #3a2a0a;
  border: 3px solid #000;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  font-size: 12px;
  line-height: 1.5;
  display: flex;
}

.guest-note span {
  flex: 1;
}

.guest-note button {
  color: #fff;
  min-height: 40px;
  font-family: var(--font-game);
  cursor: pointer;
  background: #b88c10;
  border: 2px solid #000;
  padding: 6px 8px;
  font-size: 10px;
  box-shadow: inset -2px -2px #6a4e06, inset 2px 2px #eaba28;
}

.hidden {
  display: none !important;
}

html [class]:not(.logo-title) {
  letter-spacing: normal;
}

.quit-confirm-modal {
  z-index: 200;
  background: #0a0a0a;
  justify-content: center;
  align-items: center;
  padding: 20px;
  display: flex;
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  right: 0;
}

.quit-confirm-modal.hidden {
  display: none;
}

.quit-confirm-panel {
  background: #1a1a1a;
  border: 3px solid #000;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  width: 100%;
  max-width: 340px;
  padding: 20px 18px;
  display: flex;
  box-shadow: inset -4px -4px #0a0a0a, inset 4px 4px #3a3a3a;
}

.quit-confirm-icon {
  filter: drop-shadow(2px 2px #0009);
  font-size: 36px;
  line-height: 1;
}

.quit-confirm-text {
  color: #fff;
  text-align: center;
  text-shadow: 1px 1px #000;
  font-size: 14px;
  line-height: 1.6;
}

.quit-confirm-btns {
  flex-direction: column;
  gap: 8px;
  width: 100%;
  display: flex;
}

.no-flex-gap .start-inner > * + * {
  margin-top: 10px;
}

.no-flex-gap .hs-left > * + *, .no-flex-gap .lb-open-btn > * + *, .no-flex-gap .train-review-row > * + * {
  margin-top: 3px;
}

.no-flex-gap .diff-buttons > * + *, .no-flex-gap .result-btns > * + *, .no-flex-gap .login-form > * + *, .no-flex-gap .quit-confirm-btns > * + * {
  margin-top: 8px;
}

.no-flex-gap .diff-info > * + * {
  margin-top: 5px;
}

.no-flex-gap .train-config > * + *, .no-flex-gap .train-review > * + *, .no-flex-gap .train-review-list > * + * {
  margin-top: 6px;
}

.no-flex-gap .train-ops > * + *, .no-flex-gap .answer-section > * + *, .no-flex-gap .result-score-block > * + * {
  margin-top: 4px;
}

.no-flex-gap .keyboard-cmp > * + *, .no-flex-gap .quit-confirm-panel > * + * {
  margin-top: 14px;
}

.no-flex-gap .result-inner > * + *, .no-flex-gap .login-inner > * + * {
  margin-top: 12px;
}

.no-flex-gap #profile-auth-panel > * + * {
  margin-top: 10px;
}

.no-flex-gap .profile-signed-in > * + * {
  margin-top: 14px;
}

.no-flex-gap .pin-inner > * + * {
  margin-top: 18px;
}

.no-flex-gap .hs-panel > * + *, .no-flex-gap .lb-header > * + *, .no-flex-gap .lb-row > * + * {
  margin-left: 10px;
}

.no-flex-gap .train-custom-row > * + *, .no-flex-gap .train-op-chk > * + *, .no-flex-gap .train-toggle-row > * + *, .no-flex-gap .train-timer-row > * + *, .no-flex-gap .key-row > * + *, .no-flex-gap .result-stat-row > * + *, .no-flex-gap .login-input-row > * + *, .no-flex-gap .player-bar > * + * {
  margin-left: 8px;
}

.no-flex-gap .guest-note > * + * {
  margin-left: 10px;
}

.no-flex-gap .diff-btn > * + *, .no-flex-gap .cmp-keys > * + *, .no-flex-gap .pin-dots > * + * {
  margin-left: 14px;
}

.no-flex-gap .result-score-row > * + * {
  margin-left: 6px;
}

#screen-start .logo-icon {
  display: none;
}

#screen-start .logo-title {
  font-size: 28px;
}

#screen-start .logo-title br {
  display: none;
}

#screen-start .logo-tagline {
  margin: 8px 0;
}

.mode-help, .save-status {
  text-align: center;
  color: #fff;
  background: #252535;
  margin: 10px 0;
  padding: 12px;
  font-size: 14px;
  line-height: 1.6;
}

.quick-training {
  flex-direction: column;
  display: flex;
}

.quick-training > button {
  min-height: 72px;
  margin-bottom: 10px;
}

.quick-training small {
  margin-top: 8px;
  font-size: 12px;
  display: block;
}

.training-options {
  color: #fff;
  background: #252535;
  padding: 12px;
}

.training-options summary {
  cursor: pointer;
  padding: 10px 0;
  font-size: 14px;
}

.training-options .train-config {
  margin-top: 16px;
}

.version-label {
  overflow-wrap: break-word;
  color: #ddd;
  background: #252535;
  padding: 6px;
}

.mode-tab:not(.mode-tab-active) {
  color: #ccc;
}

.player-bar-label {
  overflow-wrap: anywhere;
  word-wrap: break-word;
  min-width: 0;
}

.player-bar {
  flex-wrap: wrap;
}

.profile-btn {
  white-space: normal;
  max-width: 100%;
  min-height: 36px;
  margin-left: auto;
}

.cmp-label {
  color: #c8c8c8;
}

.start-inner, .login-inner {
  z-index: 1;
  position: relative;
}

@media (max-width: 560px) {
  .mc-char {
    display: none;
  }

  #screen-start .logo-title {
    letter-spacing: normal;
    font-size: 22px;
  }

  .guest-note {
    flex-direction: column;
    align-items: stretch;
  }

  .no-flex-gap .guest-note > * + * {
    margin-top: 10px;
    margin-left: 0;
  }
}

.stat-label, .problem-label, .answer-label {
  color: #c8c8c8;
  font-size: 12px;
}

.game-header {
  flex-wrap: wrap;
}

.screen:focus {
  outline: none;
}

button:focus, summary:focus {
  outline-offset: 2px;
  outline: 3px solid #fff;
}

.feedback-continue {
  color: #fff;
  background: #202020;
  margin-top: 20px;
  animation: none;
}

#screen-game, #screen-game-training {
  overflow-y: auto;
}

.problem-section {
  flex-shrink: 0;
  min-height: 140px;
}

.problem-display {
  word-break: normal;
  overflow-wrap: break-word;
}

.train-feedback-solution {
  flex-wrap: wrap;
  max-width: 100%;
}

@media (max-height: 700px) {
  .game-header {
    padding: 6px 10px;
  }

  .problem-section {
    min-height: 100px;
    padding: 8px 12px;
  }

  .problem-label {
    margin-bottom: 6px;
  }

  .key {
    height: 48px;
  }

  .answer-box {
    padding: 4px 16px;
    font-size: 30px;
  }
}

@media (min-width: 560px) and (max-height: 600px) {
  #screen-game.active, #screen-game-training.active {
    grid-template-rows: auto 6px minmax(110px, 1fr) auto;
    grid-template-columns: minmax(0, 1fr) minmax(260px, 1fr);
    align-content: stretch;
    display: grid;
  }

  .game-header {
    grid-area: 1 / 1 / auto / 3;
  }

  .progress-track {
    grid-area: 2 / 1 / auto / 3;
    height: 6px;
  }

  .problem-section {
    grid-area: 3 / 1;
  }

  .answer-section {
    grid-area: 4 / 1;
    padding: 8px;
  }

  #screen-game .keyboard, #screen-game-training .keyboard {
    flex-direction: column;
    grid-area: 3 / 2 / 5;
    justify-content: center;
    display: flex;
  }

  .key-row {
    flex: 1;
  }

  .key {
    height: auto;
    min-height: 44px;
  }

  .problem-display {
    letter-spacing: 1px;
    font-size: 30px;
  }

  .cmp-keys {
    min-height: 72px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *, :before, :after {
    transition: none !important;
    animation: none !important;
  }
}
