body {
  overflow-x: hidden;
  margin: 0;
}

.wrapper {
  overflow-x: auto;
  width: 100%;
}

#game-ui {
  display: flex;
  flex-direction: column;
  height: 100vh;
  width: 100vw;
}

#game-container {
  width: 100vw;
  height: 100vh;
  pointer-events: none;
  z-index: 9999;
}

.category-hint {
  text-align: center;
  margin-bottom: 12px;
  color: #0b5285;
  font-size: 1.12rem;
  letter-spacing: 1px;
  font-family: 'Original Surfer', Arial, sans-serif;
}
html.dark-mode .category-hint {
  color: #ffff00 !important;
}

.timer-display {
  font-size: 1.1rem;
  background: #0b74bf;
  color: #fff;
  padding: 6px 16px;
  margin-bottom: 10px;
  border-radius: 20px;
  display: inline-block;
}

html.dark-mode .timer-display {
    background: #055285;
    border: 2px solid #bada55;
}

/* ---- Puzzle Board Layout ---- */
.puzzle-board {
  display: flex;
  flex-wrap: wrap;
  gap: 14px 12px;
  align-items: flex-start;
  justify-content: flex-start;
  width: 100%;
  box-sizing: border-box;
  padding: 0 8px 16px 8px;
}

/* Word grouping */
.puzzle-word {
  display: flex;
  background: rgba(186,218,85,0.08);
  border-radius: 10px;
  border: 1px solid rgba(186,218,85,0.16);
  padding: 6px 8px;
  gap: var(--word-gap, 10px);
  margin-bottom: 0;
}

html.dark-mode .puzzle-word {
  background: rgba(11,82,133,0.10);
  border: 1px solid rgba(186,218,85,0.08);
}

/* ---- Puzzle Tiles ---- */
.puzzle-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: var(--tile-size, 48px);
  min-width: 0;
}

.puzzle-tile input {
  width: var(--tile-size, 48px);
  height: var(--tile-size, 48px);
  font-size: var(--tile-font, 1.5rem);
  text-align: center;
  border: 2px solid #bada55;
  border-radius: 8px;
  background: #ffffffaa;
  color: #1a1a1a;
  text-transform: uppercase;
  margin-bottom: 4px;
  outline: none;
  transition: border 0.15s, box-shadow 0.15s;
  font-weight: bold;
  cursor: pointer;
  caret-color: transparent;
  -webkit-user-select: none;
  user-select: none;
  box-sizing: border-box;
}

/* Active tile */
.puzzle-tile input.active {
  border-color: #ff8c00 !important;
  box-shadow: 0 0 0 3px rgba(255, 140, 0, 0.45) !important;
}

/* Highlighted */
.puzzle-tile input.highlight {
  border-color: #f39c12 !important;
  box-shadow: 0 0 0 2px #f39c1260;
}

.puzzle-tile input.correct {
  background: #27ae60;
  color: #fff;
  border-color: #27ae60;
}
.puzzle-tile input.wrong {
  background: #e74c3c;
  color: #fff;
  border-color: #e74c3c;
  animation: shake 0.3s;
}

html.dark-mode .puzzle-tile input {
  background: #191919;
  color: #ffff00;
  border-color: #bada55;
}
html.dark-mode .puzzle-tile input.active {
  border-color: #ff8c00 !important;
  box-shadow: 0 0 0 3px rgba(255,140,0,0.5) !important;
}
html.dark-mode .puzzle-tile input.highlight {
  border-color: #f39c12 !important;
  box-shadow: 0 0 0 2px #f39c1260;
}
html.dark-mode .puzzle-tile input.correct {
  background: green !important;
  color: yellow !important;
}
html.dark-mode .puzzle-tile input.wrong {
  background: red !important;
  color: yellow !important;
  animation: shake 0.3s !important;
}

/* ---- Cipher Letters & Static Characters ---- */
.cipher-letter {
  font-size: var(--cipher-font, 0.95rem);
  font-weight: bold;
  color: #444;
  letter-spacing: 2px;
  background: #eef;
  border-radius: 5px;
  padding: 1px 8px;
  margin-top: 1px;
  min-width: 22px;
  text-align: center;
  border: 1px solid #e9ecef;
  white-space: nowrap;
}
html.dark-mode .cipher-letter {
  background: #222;
  color: #ffff00;
  border-color: #333;
}

.static-char {
  width: var(--tile-size, 48px);
  height: var(--tile-size, 48px);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--tile-font, 1.5rem);
  color: #bbb;
  font-weight: bold;
  margin-bottom: 4px;
}
html.dark-mode .static-char {
  color: #888;
}

/* ---- Shake Animation ---- */
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-4px); }
  40%, 80% { transform: translateX(4px); }
}

/* ---- Mobile Layout ---- */
@media (max-width: 768px) {
  .puzzle-board {
    flex-direction: column;
    gap: 6px 0;
    align-items: flex-start;
    overflow-x: auto;
  }
  .puzzle-word {
    margin-bottom: 0;
  }
}

@media (max-width: 500px) {
  .puzzle-word {
    padding: 3px 3px;
    gap: 3px;
    margin: 0 2px 0 0;
  }
  .cipher-letter {
    padding: 0 3px;
  }
}

/* ============================================
   VIRTUAL KEYBOARD
   ============================================ */
.crypto-keyboard {
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: 8px 4px 10px;
  align-items: center;
  margin-top: 10px;
  border-top: 2px solid rgba(186,218,85,0.3);
  background: rgba(255,255,255,0.6);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  border-radius: 0 0 12px 12px;
}

html.dark-mode .crypto-keyboard {
  background: rgba(10,30,60,0.7);
  border-top-color: rgba(186,218,85,0.25);
}

/* Sticky keyboard on mobile */
@media (max-width: 768px) {
  .crypto-keyboard {
    position: sticky;
    bottom: 0;
    z-index: 50;
    border-radius: 0;
    border-top: 2px solid #bada55;
    box-shadow: 0 -3px 12px rgba(0,0,0,0.15);
    background: rgba(255,255,255,0.95);
    margin-top: 0;
  }
  html.dark-mode .crypto-keyboard {
    background: rgba(8,20,48,0.97);
  }
  /* Give puzzle board bottom breathing room for the sticky keyboard */
  .puzzle-board {
    padding-bottom: 8px;
  }
}

.crypto-keyboard-row {
  display: flex;
  gap: 1px;
  justify-content: center;
  width: 100%;
}

.crypto-key {
  padding: 7px;
  font-size: 18px;
  font-weight: bold;
  box-shadow: 2px 2px 5px rgba(2, 32, 75, 0.4);
  background-color: #0b74bfaa;
  color: #EAEAEA;
  border: 2px solid #555;
  border-radius: 5px;
  cursor: pointer;
  margin: 2px;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
  transition: background-color 0.3s ease;
  font-family: 'Original Surfer', Arial, sans-serif;
}

.crypto-key:active {
  background-color: #5BC0BE !important;
  color: #181818 !important;
}

.crypto-key--wide {
  font-size: 16px;
}

html.dark-mode .crypto-key {
  background-color: #0b5285;
  color: #ffff00;
  border-color: #bada55;
}
html.dark-mode .crypto-key:active {
  background-color: #bada55 !important;
  color: #111 !important;
}

/* Key state feedback */
.crypto-key.key-correct {
  background-color: #4ad71c !important;
  color: #181818 !important;
  border-color: #4ad71c !important;
}

@media (max-width: 380px) {
  .crypto-key {
    padding: 5px;
    font-size: 15px;
    margin: 1px;
  }
}

/* ---- Leaderboard ---- */
.dashed {
  margin-top: 20px;
  padding: 20px 5px 20px 5px;
  border: 2px dashed #888;
  text-align: center;
  max-width: 600px;
  margin-left: auto;
  margin-right: auto;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.85);
}

html.dark-mode .dashed {
  background: rgba(0, 0, 0, 0.45);
}
