* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family:  system-ui;
}
html, body {
  height: 100%;
}
body {
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  text-align: center;
  background: white;
  overflow: hidden;
  touch-action: none;
}

.container {
  height: 100dvh;
  max-width: 560px;
  padding: 20px;
  margin: auto;
  display: flex;
  flex-direction: column;
  padding-top: 0px;
}

.header {
  background: white;
  position: relative;
  width: 100%;
  height: 9dvh;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 10px;
}

.header-left {
  display: flex;
  align-items: center;
  width: 60px;
  justify-content: flex-start;
}

.hints-button {
  position: relative;
  cursor: pointer;
  --color-tone-1: #2a2a2a;
  display: flex;
  align-items: center;
  justify-content: center;
}

.hints-button svg {
  display: block;
}

.hints-badge {
  position: absolute;
  top: -2px;
  right: -2px;
  background: #ff4444;
  color: white;
  border-radius: 50%;
  width: 18px;
  height: 18px;
  font-size: 12px;
  font-weight: bold;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
}

.header-center {
  flex: 1;
  display: flex;
  justify-content: center;
  align-items: center;
}

.header-right {
  display: flex;
  align-items: center;
  width: 60px;
  justify-content: flex-end;
}

.header-title {
  text-align: center;
  color: #2a2a2a;
  font-size: 22px;
  font-weight: bold;
  cursor: pointer;
  display: none;
}

.words-wrap { 
  height: 41dvh;
  display: flex; 
  flex-direction: column; 
  min-height: 0;
  padding-top: 20px;
}
.words { 
  flex: 1; 
  overflow-y: auto; 
  scrollbar-width: none; /* Firefox */
  -ms-overflow-style: none; /* Internet Explorer 10+ */
}

.words::-webkit-scrollbar { /* WebKit */
  display: none;
}

.word { 
  display: inline-flex; 
  margin: 12px 10px 24px; 
  border-bottom: 3px solid #2a2a2a;
  color: white;
  padding: 0 3px; 
  background: transparent;
  font-weight: bold;
  font-size: 22px;
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
  align-items: center;
}
.word.bonus { 
  display: none;
}
.word.found { 
  color: #2a2a2a;;
  cursor: pointer;
}
.word.bonus.found {
  display: inline-flex;
  color: green;
  border-bottom-color: green;
  cursor: pointer;
}

/* Word letter styles */
.word-letter {
  display: inline-block;
}

.word-letter.first-letter {
  text-transform: capitalize;
}

.word-letter.revealed {
  color: #999;
}

.word.bonus .word-letter.revealed {
  color: #7a9e7e;
}

.word-letter.given-up {
  color: #999;
}

.word.bonus .word-letter.given-up {
  color: #7a9e7e;
}

.word-letter.hidden {
  color: transparent;
}

.word-letter.visible {
  color: inherit;
}

.letters-wrap {
  position: relative;
  height: 50dvh;
  padding: 10px 12px 34px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.letters-wrap.completed {
  justify-content: center;
  align-items: center;
}

.completion-screen {
  display: none;
  text-align: center;
  max-width: 400px;
  padding: 20px;
}

.completion-screen.show {
  display: block;
}

.completion-header {
  font-size: 28px;
  font-weight: bold;
  color: #4caf50;
  margin-bottom: 16px;
  line-height: 1.2;
}

.completion-message {
  font-size: 18px;
  color: #666;
  margin-bottom: 16px;
  line-height: 1.4;
}

.countdown-container {
  background: #f8f8f8;
  border: 2px solid #e0e0e0;
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 24px;
}

.countdown-label {
  font-size: 16px;
  color: #555;
  margin-bottom: 8px;
  font-weight: 600;
}

.countdown-timer {
  font-family: 'Courier New', monospace;
  font-size: 32px;
  font-weight: bold;
  color: #4caf50;
  letter-spacing: 2px;
}

.completion-button {
  background: linear-gradient(135deg, #4caf50, #45a049);
  border: none;
  color: white;
  padding: 16px 32px;
  border-radius: 12px;
  font-size: 18px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 4px 12px rgba(76, 175, 80, 0.3);
}

.completion-button:hover {
  background: linear-gradient(135deg, #45a049, #3d8b40);
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(76, 175, 80, 0.4);
}

.completion-button:active {
  transform: translateY(0);
}

.current-wrap { 
  min-height: 32px; 
  font-size: calc(var(--tile, 80px) * 0.35); 
  letter-spacing: 0.05em; 
  font-weight: 800;
  margin-bottom: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.current-wrap.shake,
.word.shake {
  animation: shake 0.5s ease-in-out;
}
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  10%, 30%, 50%, 70%, 90% { transform: translateX(-3px); }
  20%, 40%, 60%, 80% { transform: translateX(3px); }
}

.letters-grid-wrap {
  flex: 1;
  position: relative;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}
.snake-svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 3;
}
#snake-poly {
  transition: all 0.1s ease-out;
}
.letters {
  --gap: 8px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--gap);
  justify-content: center;
  align-content: center;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  position: relative;
  z-index: 2;
}
.letter {
  width: var(--tile, 80px);
  height: var(--tile, 80px);
  font-size: calc(var(--tile, 80px) * 0.35);
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #d3d7db;
  border-radius: 10px;
  transition: all 0.15s ease-out;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
  color: #2a2a2a;
}
.letter.selected {
  background: #c8e6c9;
  box-shadow: 0 4px 8px rgba(0,0,0,0.15);
  border: 2px solid #4caf50;
}

.letter.highlighted {
  background: #fff3e0;
  border: 2px solid #ff9800;
  box-shadow: 0 4px 8px rgba(255, 152, 0, 0.15);
}

/* Visual indicator for removable letters in tap mode - REMOVED */

/* Loader styles */
.loader-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(255, 255, 255, 0.9);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.loader-overlay.show {
  opacity: 1;
  visibility: visible;
}

.loader-spinner {
  width: 50px;
  height: 50px;
  border: 4px solid #f0f0f0;
  border-top: 4px solid #4caf50;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin-bottom: 20px;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.loader-text {
  font-size: 18px;
  font-weight: 600;
  color: #333;
  margin-bottom: 8px;
}

.loader-subtext {
  font-size: 14px;
  color: #666;
}

/* Modal styles */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
}

.modal-overlay.show {
  opacity: 1;
  visibility: visible;
}

.modal {
  background: white;
  border-radius: 12px;
  padding: 24px;
  max-width: 90%;
  width: 400px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
  transform: scale(0.8);
  transition: transform 0.3s ease;
  text-align: left;
  position: relative;
  overflow: auto;
  max-height: 80vh;
}

.modal-overlay.show .modal {
  transform: scale(1);
}

.modal-header {
  margin-bottom: 16px;
  border-bottom: 2px solid #f0f0f0;
  padding-bottom: 12px;
}

.modal-word {
  font-size: 24px;
  font-weight: bold;
  text-transform: capitalize;
  color: #333;
}

.modal-word.bonus {
  color: #4caf50;
}

.modal-close-x {
  position: sticky;
  top: 8px;
  float: right;
  width: 32px;
  height: 32px;
  border: none;
  background: transparent;
  color: #666;
  font-size: 22px;
  font-weight: bold;
  line-height: 32px;
  text-align: center;
  cursor: pointer;
  border-radius: 6px;
  z-index: 3;
}

.menu-modal .modal-close-x {
  position: absolute;
  top: 12px;
  right: 12px;
  float: none;
}

.modal-close-x:hover { background: #f3f3f3; color: #333; }

.modal-close {
  background: linear-gradient(135deg, #4caf50, #45a049);
  border: none;
  color: white;
  padding: 12px 24px;
  border-radius: 8px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 2px 8px rgba(76, 175, 80, 0.3);
  width: 100%;
  margin-top: 20px;
}

.modal-close:hover {
  background: linear-gradient(135deg, #45a049, #3d8b40);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(76, 175, 80, 0.4);
}

.modal-close:active {
  transform: translateY(0);
}

.modal-definition {
  font-size: 16px;
  line-height: 1.5;
  margin-bottom: 16px;
  color: #444;
}

.modal-example {
  font-size: 14px;
  font-style: italic;
  color: #666;
  padding: 12px;
  background: #f8f8f8;
  border-radius: 8px;
}

.modal-example strong {
  font-style: normal;
  color: #333;
}

/* Menu Modal Styles */
.menu-modal {
  max-width: 90%;
  width: 400px;
  text-align: center;
}

.menu-title {
  font-size: 28px;
  font-weight: bold;
  color: #333;
  margin-bottom: 24px;
  text-align: center;
}

.menu-buttons {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 20px;
}

.menu-button {
  background: linear-gradient(135deg, #4caf50, #45a049);
  border: none;
  color: white;
  padding: 16px 24px;
  border-radius: 8px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 2px 8px rgba(76, 175, 80, 0.3);
  text-align: center;
}

.menu-button:hover {
  background: linear-gradient(135deg, #45a049, #3d8b40);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(76, 175, 80, 0.4);
}

.menu-button:active {
  transform: translateY(0);
}

/* Info Modal Styles */
.info-modal {
  max-width: 90%;
  width: 500px;
  max-height: 80vh;
  overflow-y: auto;
}

.info-title {
  font-size: 24px;
  font-weight: bold;
  color: #333;
  margin-bottom: 20px;
  text-align: center;
}

.info-content {
  font-size: 16px;
  line-height: 1.6;
  color: #444;
  text-align: left;
}

.info-content h3 {
  font-size: 18px;
  font-weight: bold;
  color: #333;
  margin: 20px 0 10px 0;
}

.info-content p {
  margin-bottom: 12px;
}

.info-content ul {
  margin: 12px 0;
  padding-left: 20px;
}

.info-content li {
  margin-bottom: 8px;
}

.info-highlight {
  background: #f0f8f0;
  padding: 12px;
  border-radius: 8px;
  border-left: 4px solid #4caf50;
  margin: 16px 0;
  font-weight: 500;
}

/* Puzzle List Modal Styles */
.puzzle-list-modal {
  max-width: 90%;
  width: 500px;
  max-height: 80vh;
}

.puzzle-list-title {
  font-size: 24px;
  font-weight: bold;
  color: #333;
  margin-bottom: 16px;
}

.puzzle-list {
  max-height: 400px;
  overflow-y: auto;
  margin-bottom: 20px;
}

.puzzle-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  margin-bottom: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
  background: white;
}

.puzzle-item.current {
  background: #e8f5e8;
  border-color: #4caf50;
  border-width: 2px;
}

.puzzle-info {
  display: flex;
  flex-direction: column;
  flex: 1;
}

.puzzle-number {
  font-weight: bold;
  font-size: 16px;
  color: #333;
}

.puzzle-details {
  font-size: 14px;
  color: #666;
  margin-top: 2px;
}

.puzzle-status {
  font-weight: bold;
  font-size: 14px;
  padding: 4px 8px;
  border-radius: 4px;
}

.puzzle-status.solved {
  background: #c8e6c9;
  color: #2e7d32;
}

.puzzle-status.partial {
  background: #fff3e0;
  color: #f57c00;
}

.puzzle-status.unsolved {
  background: #ffebee;
  color: #c62828;
}

.word.found.reveal-animation {
  animation: flip 0.8s forwards;
  transform-style: preserve-3d;
  perspective: 1000px;
}
.word.bonus.found.reveal-animation {
  animation: bonusFlip 0.8s forwards;
  transform-style: preserve-3d;
  perspective: 1000px;
}

@keyframes flip {
  0% {
    transform: rotateX(180deg);
  }
  100% {
    transform: rotateX(0deg);
  }
}

@keyframes bonusFlip {
  0% {
    transform: rotateX(180deg);
  }
  100% {
    transform: rotateX(0deg);
  }
}

/* Bonus Tutorial Modal Styles */
.bonus-tutorial-modal {
  max-width: 90%;
  width: 450px;
  text-align: center;
}

.bonus-tutorial-header {
  text-align: center;
  margin-bottom: 20px;
}

.bonus-tutorial-title {
  font-size: 28px;
  font-weight: bold;
  color: #4caf50;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.bonus-tutorial-subtitle {
  font-size: 16px;
  color: #666;
  font-weight: normal;
}

.bonus-tutorial-content {
  font-size: 16px;
  line-height: 1.6;
  color: #444;
  margin-bottom: 20px;
  text-align: left;
}

.bonus-tutorial-highlight {
  background: #f0f8f0;
  padding: 16px;
  border-radius: 8px;
  border-left: 4px solid #4caf50;
  margin: 16px 0;
  font-weight: 500;
}

/* No Hints Modal Styles */
.no-hints-modal {
  max-width: 90%;
  width: 400px;
  text-align: center;
}

.no-hints-header {
  text-align: center;
  margin-bottom: 20px;
}

.no-hints-title {
  font-size: 24px;
  font-weight: bold;
  color: #f44336;
  margin-bottom: 8px;
}

.give-up-button {
  background: linear-gradient(135deg, #f44336, #d32f2f) !important;
  box-shadow: 0 2px 8px rgba(244, 67, 54, 0.3) !important;
}

.give-up-button:hover {
  background: linear-gradient(135deg, #d32f2f, #b71c1c) !important;
  box-shadow: 0 4px 12px rgba(244, 67, 54, 0.4) !important;
}

.bonus-star {
  font-size: 24px;
  color: #4caf50;
}

#menu {
  font-size: 30px;
  font-weight: bold;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
