/* ===================================================
   MatiKraft – Minecraft-themed math game
   Mobile-first, Press Start 2P font
   =================================================== */

:root {
  /* Čitateľný font je predvolený (deti sa ešte učia čítať) */
  --font-game: 'Playpen Sans', cursive;
}

/* Pôvodný pixel-art Minecraft font - teraz voliteľný opt-in (viz .font-toggle-btn) */
html.font-pixel {
  --font-game: 'Press Start 2P', monospace;
}

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

/* Textový vstup potrebuje user-select */
input {
  user-select: text;
  touch-action: auto;
  -webkit-user-select: text;
}

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

/* ===================================================
   SCREEN SYSTEM
   =================================================== */

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

.screen.active {
  display: flex;
}

/* ===================================================
   START SCREEN
   =================================================== */

#screen-login,
#screen-start {
  background:
    linear-gradient(to bottom,
      #87CEEB 0%,
      #87CEEB 50%,
      #5A8A36 50%,
      #5A8A36 58%,
      #8B6914 58%,
      #8B6914 76%,
      #B34A00 76%
    );
  align-items: center;
  justify-content: flex-start;
  padding: 10px 14px 18px;
}

/* Dekoratívne postavičky - vidiet aj na mobile, kde hraju deti najviac */
.mc-char {
  position: absolute;
  bottom: 42%;
  pointer-events: none;
  display: block;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  filter: drop-shadow(2px 2px 0 rgba(0,0,0,0.5));
}

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

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

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

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

.logo-title {
  font-size: 36px;
  font-size: clamp(26px, 8.5vw, 36px);
  color: #fff;
  text-shadow:
    3px 3px 0 #000,
    -1px -1px 0 #000,
     1px -1px 0 #000,
    -1px  1px 0 #000;
  line-height: 1.4;
  letter-spacing: 6px;
}

.logo-tagline {
  font-size: 12px;
  color: rgba(255,255,255,0.85);
  text-shadow: 1px 1px 0 #000;
  margin-top: 5px;
  letter-spacing: 1px;
}

/* High score + leaderboard panel */
.hs-panel {
  background: #1E1E1E;
  border: 3px solid #000;
  box-shadow:
    inset -3px -3px 0 #0A0A0A,
    inset  3px  3px 0 #3A3A3A;
  padding: 8px 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

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

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

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

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

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

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

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

/* ===================================================
   NAME SECTION
   =================================================== */

.name-section {
  /* container bez vlastného pozadia */
}

.name-input-area {
  background: #1E1E1E;
  border: 3px solid #000;
  box-shadow:
    inset -3px -3px 0 #0A0A0A,
    inset  3px  3px 0 #3A3A3A;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.name-input-area.hidden,
.name-display-area.hidden {
  display: none;
}

.name-label {
  font-size: 9px;
  color: #aaa;
  letter-spacing: 1px;
}

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

.name-input {
  flex: 1;
  background: #111;
  border: 2px solid #444;
  color: #FFD700;
  font-family: var(--font-game);
  font-size: 18px;
  padding: 8px 10px;
  outline: none;
  letter-spacing: 2px;
  min-width: 0;
}

.name-input:focus {
  border-color: #FFD700;
  box-shadow: 0 0 0 2px rgba(255, 215, 0, 0.25);
}

.name-input::placeholder {
  color: #444;
  font-size: 12px;
}

.name-ok-btn {
  background: #3D8A2A;
  border: 2px solid #000;
  box-shadow: inset -3px -3px 0 #1F4A12, inset 3px 3px 0 #5DC048;
  color: #fff;
  font-family: var(--font-game);
  font-size: 14px;
  padding: 8px 14px;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
}

.name-ok-btn:active {
  box-shadow: inset 3px 3px 0 #1F4A12, inset -3px -3px 0 #5DC048;
  transform: translate(1px, 1px);
}

/* Name display (keď už je zadané) */
.name-display-area {
  background: #1E1E1E;
  border: 3px solid #000;
  box-shadow:
    inset -3px -3px 0 #0A0A0A,
    inset  3px  3px 0 #3A3A3A;
  padding: 10px 12px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.name-display-label {
  font-size: 9px;
  color: #aaa;
  flex-shrink: 0;
}

.name-display-value {
  font-size: 18px;
  color: #FFD700;
  text-shadow: 2px 2px 0 #000;
  letter-spacing: 2px;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.name-edit-btn {
  background: #5A5A5A;
  border: 2px solid #000;
  box-shadow: inset -2px -2px 0 #2A2A2A, inset 2px 2px 0 #888;
  color: #fff;
  font-size: 18px;
  width: 36px;
  height: 36px;
  cursor: pointer;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.name-edit-btn:active {
  box-shadow: inset 2px 2px 0 #2A2A2A, inset -2px -2px 0 #888;
  transform: translate(1px, 1px);
}

.version-label {
  font-size: 10px;
  color: rgba(0,0,0,0.3);
  text-align: center;
  letter-spacing: 2px;
  padding-top: 2px;
}

/* Difficulty section */
.diff-heading {
  font-size: 10px;
  color: #1A1A1A;
  text-shadow: 1px 1px 0 rgba(255,255,255,0.25);
  text-align: center;
  letter-spacing: 1px;
}

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

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

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

.diff-easy {
  background: #3D8A2A;
  box-shadow: inset -4px -4px 0 #1F4A12, inset 4px 4px 0 #5DC048;
}
.diff-easy:active {
  box-shadow: inset 4px 4px 0 #1F4A12, inset -4px -4px 0 #5DC048;
}

.diff-medium {
  background: #B88C10;
  box-shadow: inset -4px -4px 0 #6A4E06, inset 4px 4px 0 #EABA28;
}
.diff-medium:active {
  box-shadow: inset 4px 4px 0 #6A4E06, inset -4px -4px 0 #EABA28;
}

.diff-hard {
  background: #9E2020;
  box-shadow: inset -4px -4px 0 #560808, inset 4px 4px 0 #CC4848;
}
.diff-hard:active {
  box-shadow: inset 4px 4px 0 #560808, inset -4px -4px 0 #CC4848;
}

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

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

.diff-name {
  font-size: 17px;
  font-size: clamp(13px, 4.5vw, 17px);
  text-shadow: 2px 2px 0 rgba(0,0,0,0.6);
  display: block;
}

.diff-desc {
  font-size: 11px;
  color: rgba(255,255,255,0.8);
  line-height: 1.8;
  display: block;
  text-shadow: 1px 1px 0 rgba(0,0,0,0.5);
}

/* ===================================================
   MODE TABS (Súťaž / Tréning)
   =================================================== */

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

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

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

.mode-tab:active {
  background: #2E2E3E;
  box-shadow: inset 2px 2px 0 #1E1E2E, inset -2px -2px 0 #5A5A6A;
}

.mode-tab-active {
  background: #1E1E30;
  color: #FFD700;
  box-shadow: inset 0 -3px 0 #FFD700, inset -2px 0 0 #1E1E2E, inset 2px 2px 0 #3A3A5A;
}

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

/* ===================================================
   TRAINING CONFIG FORM
   =================================================== */

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

.train-heading {
  font-size: 12px;
  color: rgba(255,255,255,0.85);
  text-shadow: 1px 1px 0 #000;
  letter-spacing: 1px;
  margin-top: 6px;
}

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

.train-preset-btn,
.train-errmode-btn {
  font-family: var(--font-game);
  font-size: 11px;
  color: #999;
  background: #2E2E3E;
  border: 3px solid #000;
  box-shadow: inset -3px -3px 0 #16161E, inset 3px 3px 0 #46465A;
  padding: 10px 4px;
  cursor: pointer;
  letter-spacing: 0.5px;
  transition: transform 0.05s;
}

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

.train-preset-active,
.train-errmode-active {
  background: #2A5CB8;
  color: #fff;
  box-shadow: inset -3px -3px 0 #142E6A, inset 3px 3px 0 #4880DC;
}

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

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

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

.train-custom-input:focus,
.train-timer-input:focus {
  border-color: #FFD700;
  box-shadow: inset -3px -3px 0 #0A0A0A, inset 3px 3px 0 #3A3A3A, 0 0 0 2px rgba(255,215,0,0.25);
}

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

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

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

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

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

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

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

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

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

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

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

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

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

/* ===================================================
   GAME SCREEN
   =================================================== */

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

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

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

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

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

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

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

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

.progress-bar {
  height: 100%;
  background: #3D8A2A;
  box-shadow: inset 0 3px 0 #5DC048, inset 0 -2px 0 #1F4A12;
  width: 0%;
  transition: width 0.4s ease;
}

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

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

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

/* CSS box namiesto □ znaku (font ho nemá) */
.cmp-placeholder {
  display: inline-block;
  width: 0.75em;
  height: 0.75em;
  border: 3px solid #fff;
  vertical-align: middle;
  box-shadow: 2px 2px 0 #000;
  margin: 0 4px;
}

/* Feedback overlay */
/* Fixed namiesto absolute - prekryje CELU obrazovku vratane hlavicky a
   klavesnice, nie len stred s prikladom (inak klavesnica pod nou vyzera
   stale "aktivne", hoci vstup je zamknuty) */
.feedback-overlay {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 50;
  padding: 20px;
  cursor: pointer;
}

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

.feedback-overlay.correct {
  background: rgb(40, 120, 20);
}

.feedback-overlay.wrong {
  background: rgb(160, 30, 30);
}

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

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

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

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

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

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

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

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

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

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

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

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

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

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

/* ===================================================
   KEYBOARDS
   =================================================== */

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

.keyboard.hidden {
  display: none;
}

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

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

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

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

/* Number keys – stone grey */
.num-key {
  background: #6E6E6E;
  color: #fff;
  box-shadow: inset -3px -3px 0 #3A3A3A, inset 3px 3px 0 #9A9A9A;
  text-shadow: 2px 2px 0 #000;
}

.num-key:active {
  box-shadow: inset 3px 3px 0 #3A3A3A, inset -3px -3px 0 #9A9A9A;
}

/* Backspace – dirt brown */
.bksp-key {
  background: #7A5C14;
  color: #fff;
  box-shadow: inset -3px -3px 0 #3E2C06, inset 3px 3px 0 #AA8028;
  font-size: 22px;
}

.bksp-key:active {
  box-shadow: inset 3px 3px 0 #3E2C06, inset -3px -3px 0 #AA8028;
}

/* Check – grass green */
.check-key {
  background: #3D8A2A;
  color: #fff;
  box-shadow: inset -3px -3px 0 #1F4A12, inset 3px 3px 0 #5DC048;
  font-size: 24px;
}

.check-key:active {
  box-shadow: inset 3px 3px 0 #1F4A12, inset -3px -3px 0 #5DC048;
}

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

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

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

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

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

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

/* ===================================================
   RESULT SCREEN
   =================================================== */

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

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

.result-emoji {
  font-size: 72px;
  line-height: 1;
  filter: drop-shadow(3px 3px 0 rgba(0,0,0,0.5));
}

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

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

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

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

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

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

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

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

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

/* Stats */
.result-stats {
  background: #1A1A1A;
  border: 3px solid #000;
  box-shadow: inset -3px -3px 0 #0A0A0A, inset 3px 3px 0 #2A2A2A;
  padding: 8px 16px;
  width: 100%;
}

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

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

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

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

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

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

.mc-btn-green {
  background: #3D8A2A;
  box-shadow: inset -4px -4px 0 #1F4A12, inset 4px 4px 0 #5DC048;
}
.mc-btn-green:active {
  box-shadow: inset 4px 4px 0 #1F4A12, inset -4px -4px 0 #5DC048;
}

.mc-btn-blue {
  background: #2A5CB8;
  box-shadow: inset -4px -4px 0 #142E6A, inset 4px 4px 0 #4880DC;
}
.mc-btn-blue:active {
  box-shadow: inset 4px 4px 0 #142E6A, inset -4px -4px 0 #4880DC;
}

.mc-btn-gray {
  background: #5A5A5A;
  box-shadow: inset -4px -4px 0 #2A2A2A, inset 4px 4px 0 #888888;
}
.mc-btn-gray:active {
  box-shadow: inset 4px 4px 0 #2A2A2A, inset -4px -4px 0 #888888;
}

.mc-btn-brown {
  background: #5C3A0A;
  box-shadow: inset -4px -4px 0 #2E1C04, inset 4px 4px 0 #9A6418;
}
.mc-btn-brown:active {
  box-shadow: inset 4px 4px 0 #2E1C04, inset -4px -4px 0 #9A6418;
}

.mc-btn-red {
  background: #9E2020;
  box-shadow: inset -4px -4px 0 #560808, inset 4px 4px 0 #CC4848;
}
.mc-btn-red:active {
  box-shadow: inset 4px 4px 0 #560808, inset -4px -4px 0 #CC4848;
}

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

/* Training – review list */
.train-review {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.train-review-heading {
  font-size: 12px;
  color: rgba(255,255,255,0.85);
  text-shadow: 1px 1px 0 #000;
  letter-spacing: 1px;
}

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

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

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

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

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

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

/* ===================================================
   LEADERBOARD SCREEN
   =================================================== */

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

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

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

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

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

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

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

/* Tabs – kamenné bloky */
.lb-tabs {
  display: flex;
  border-bottom: 3px solid #000;
  flex-shrink: 0;
}

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

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

.lb-tab:active {
  background: #2E2E3E;
  box-shadow: inset 2px 2px 0 #1E1E2E, inset -2px -2px 0 #5A5A6A;
}

.lb-tab-active {
  background: #1E1E30;
  color: #FFD700;
  box-shadow: inset 0 -3px 0 #FFD700, inset -2px 0 0 #1E1E2E, inset 2px 2px 0 #3A3A5A;
}

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

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

.lb-loading { color: #666; }
.lb-empty   { color: #555; }
.lb-error   { color: #CC4848; }

/* Leaderboard rows – kamenné tehly */
.lb-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  margin-bottom: 6px;
  background: #22223A;
  border: 2px solid #000;
  box-shadow: inset -2px -2px 0 #0E0E1E, inset 2px 2px 0 #38385A;
}

/* Zvýrazni aktuálneho hráča */
.lb-row-me {
  background: #0E2218;
  border-color: #3D8A2A;
  box-shadow: inset -2px -2px 0 #061208, inset 2px 2px 0 #1E4A28, 0 0 0 1px #3D8A2A;
}

/* Top 3 – zlato, striebro, bronz */
.lb-row:nth-child(1) {
  background: #2A2000;
  border-color: #FFD700;
  box-shadow: inset -2px -2px 0 #141000, inset 2px 2px 0 #4A3800;
}
.lb-row:nth-child(2) {
  background: #202028;
  border-color: #AAAAAA;
  box-shadow: inset -2px -2px 0 #101018, inset 2px 2px 0 #383848;
}
.lb-row:nth-child(3) {
  background: #221408;
  border-color: #CD7F32;
  box-shadow: inset -2px -2px 0 #110A04, inset 2px 2px 0 #3E2410;
}

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

.lb-row:nth-child(1) .lb-rank { color: #FFD700; font-size: 15px; }
.lb-row:nth-child(2) .lb-rank { color: #AAAAAA; }
.lb-row:nth-child(3) .lb-rank { color: #CD7F32; }

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

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

.lb-row:nth-child(1) .lb-name { color: #FFD700; }

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

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

/* ===================================================
   LOGIN SCREEN
   =================================================== */

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

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

.login-label {
  font-size: 12px;
  color: rgba(255,255,255,0.9);
  text-shadow: 1px 1px 0 #000;
  letter-spacing: 1px;
}

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

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

.login-input:focus {
  border-color: #FFD700;
  box-shadow: inset -3px -3px 0 #0A0A0A, inset 3px 3px 0 #3A3A3A, 0 0 0 2px rgba(255,215,0,0.25);
}

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

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

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

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

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

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

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

/* ===================================================
   PIN SCREEN
   =================================================== */

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

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

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

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

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

.pin-dot.filled {
  background: #FFD700;
  box-shadow: inset -2px -2px 0 #A89000, inset 2px 2px 0 #FFE84D;
}

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

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

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

/* Prazdna bunka v klavesnici (PIN – miesto check tlacidla) */
.key-empty {
  flex: 1;
  height: 72px;
  background: transparent;
  border: none;
  box-shadow: none;
  pointer-events: none;
}

/* PIN klávesnica – tmavé pozadie na pin okno */
#keyboard-pin {
  background: #0E0E1E;
  border-top-color: #000;
  width: 100%;
}

/* PIN obrazovka nie je herná obrazovka - zdieľané .key triedy tu zväčšíme */
#keyboard-pin .key {
  font-size: 26px;
}

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

/* ===================================================
   PLAYER BAR (menu po prihlaseni)
   =================================================== */

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

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

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

.logout-btn:active {
  box-shadow: inset 2px 2px 0 #1A1200, inset -2px -2px 0 #5A4418;
  transform: translate(1px, 1px);
}

/* ===================================================
   UTILITIES
   =================================================== */

.hidden { display: none !important; }

@keyframes bounce-in {
  0%   { transform: scale(0.5); opacity: 0; }
  70%  { transform: scale(1.05); }
  100% { transform: scale(1); opacity: 1; }
}

.bounce-in {
  animation: bounce-in 0.3s ease-out;
}

/* ===================================================
   PREPÍNAČ PÍSMA (Minecraft vs. čitateľný)
   =================================================== */

.font-toggle-btn {
  font-family: var(--font-game);
  font-size: 11px;
  color: #ccc;
  background: #2E2E3E;
  border: 2px solid #000;
  box-shadow: inset -2px -2px 0 #16161E, inset 2px 2px 0 #46465A;
  padding: 8px 10px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  align-self: center;
  letter-spacing: 0.5px;
}

.font-toggle-btn:active {
  box-shadow: inset 2px 2px 0 #16161E, inset -2px -2px 0 #46465A;
  transform: translate(1px, 1px);
}

.font-toggle-icon {
  font-size: 14px;
  line-height: 1;
}

/* V čitateľnom (predvolenom) režime sú pixel-art rozostupy písma príliš široké.
   V pixel režime ostávajú pôvodné (širšie) hodnoty z jednotlivých tried. */
html:not(.font-pixel) [class] {
  letter-spacing: normal;
}

/* ===================================================
   POTVRDENIE UKONCENIA (nahradza window.confirm)
   =================================================== */

.quit-confirm-modal {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 200;
  /* Plne nepriehladne - inak cez tmave pozadie klavesnice/hlavicky
     presvitaju "aktivne" vyzerajuce tlacidla, na ktore sa neda tuknut */
  background: #0A0A0A;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

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

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

.quit-confirm-icon {
  font-size: 36px;
  line-height: 1;
  filter: drop-shadow(2px 2px 0 rgba(0,0,0,0.6));
}

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

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

/* iOS 12 Safari ignores gap on flex containers. Keep the same spacing with margins. */
.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 .name-input-area > * + *,
.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 .pin-inner > * + * { margin-top: 18px; }

.no-flex-gap .hs-panel > * + *,
.no-flex-gap .name-display-area > * + *,
.no-flex-gap .lb-header > * + *,
.no-flex-gap .lb-row > * + * { margin-left: 10px; }
.no-flex-gap .name-input-row > * + *,
.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 .diff-btn > * + *,
.no-flex-gap .cmp-keys > * + *,
.no-flex-gap .pin-dots > * + * { margin-left: 14px; }
.no-flex-gap .result-score-row > * + *,
.no-flex-gap .font-toggle-btn > * + * { margin-left: 6px; }
