/* Reset and Base Styles */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Arial, sans-serif;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  min-height: 100vh;
  color: #333;
  overflow-x: hidden;
}

/* App Container */
.app-container {
  max-width: 100vw;
  margin: 0 auto;
  background: white;
  min-height: 100vh;
  position: relative;
}

/* Top Header */
.top-header {
  background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
  color: white;
  padding: 15px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
  position: relative;
  z-index: 100;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 15px;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 15px;
}

.header-btn {
  background: rgba(255, 255, 255, 0.2);
  border: none;
  color: white;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.3s ease;
  font-size: 18px;
}

.header-btn:hover {
  background: rgba(255, 255, 255, 0.3);
  transform: scale(1.1);
}

.level-info {
  display: flex;
  flex-direction: column;
}

.level-number {
  font-weight: 600;
  font-size: 16px;
}

.difficulty-stars {
  display: flex;
  gap: 2px;
  font-size: 12px;
}

.app-title {
  font-size: 20px;
  font-weight: 700;
  text-align: center;
  flex: 1;
}

.coins-display {
  display: flex;
  align-items: center;
  gap: 5px;
  background: rgba(255, 255, 255, 0.2);
  padding: 8px 12px;
  border-radius: 20px;
  font-weight: 600;
}

.hints-btn {
  position: relative;
}

.hint-count {
  position: absolute;
  top: -5px;
  right: -5px;
  background: #ff6b6b;
  color: white;
  border-radius: 50%;
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 600;
}

/* Progress Bar */
.progress-container {
  background: #f8f9fa;
  padding: 15px 20px;
  display: flex;
  align-items: center;
  gap: 15px;
  border-bottom: 1px solid #e9ecef;
}

.progress-bar {
  flex: 1;
  height: 8px;
  background: #e9ecef;
  border-radius: 4px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #48bb78, #38a169);
  width: 0%;
  transition: width 0.3s ease;
}

.progress-text {
  font-size: 14px;
  font-weight: 600;
  color: #4a5568;
  min-width: 80px;
}

/* Main Game Area */
.game-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 20px;
  gap: 20px;
}

.puzzle-section {
  flex: 1;
  display: flex;
  justify-content: center;
  align-items: center;
  background: white;
  border-radius: 15px;
  padding: 20px;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
  overflow: hidden;
  position: relative;
}

@media (max-width: 768px) {
  .game-main {
    padding: 10px;
    gap: 10px;
  }

  .puzzle-section {
    padding: 5px;
    border-radius: 10px;
    overflow: hidden;
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
  }
}

/* Crossword Grid */
.grid-container {
  display: grid;
  gap: 2px;
  background: #cbd5e0;
  padding: 10px;
  border-radius: 10px;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.1);
  margin: 0 auto;
  width: fit-content;
  max-width: 100%;
}

@media (max-width: 768px) {
  .grid-container {
    padding: 5px;
    gap: 1px;
    width: fit-content;
    margin: 0 auto;
    display: grid;
    place-items: center;
  }
}

.grid-cell {
  width: 45px;
  height: 45px;
  background: white;
  border: 2px solid #e2e8f0;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  cursor: pointer;
  transition: all 0.2s ease;
}

.grid-cell:hover:not(.clue-cell):not(.blocked-cell) {
  background: #f7fafc;
  border-color: #4299e1;
}

.grid-cell.active {
  background: #ebf8ff;
  border-color: #3182ce;
  box-shadow: 0 0 0 3px rgba(66, 153, 225, 0.3);
}

.grid-cell.correct {
  background: #c6f6d5;
  border-color: #48bb78;
}

.grid-cell.incorrect {
  background: #fed7d7;
  border-color: #f56565;
}

/* Clue Cell Styles */
.clue-cell {
  background: linear-gradient(135deg, #4a5568, #2d3748);
  color: white;
  font-size: 9px;
  font-weight: 600;
  text-align: center;
  padding: 2px;
  line-height: 1.2;
  flex-direction: column;
  justify-content: flex-start;
  align-items: flex-start;
  position: relative;
  cursor: default;
  pointer-events: none;
}

.clue-cell.horizontal {
  border-right: 3px solid #4299e1;
}

.clue-cell.vertical {
  border-bottom: 3px solid #4299e1;
}

.clue-text {
  font-size: 8px;
  line-height: 1.1;
  word-wrap: break-word;
  text-align: left;
  width: 100%;
}

.arrow {
  position: absolute;
  font-size: 14px;
  color: #4299e1;
  font-weight: bold;
}

.arrow-right {
  right: 1px;
  top: 50%;
  transform: translateY(-50%);
}

.arrow-down {
  bottom: 1px;
  left: 50%;
  transform: translateX(-50%);
}

/* Input Cell Styles */
.input-cell {
  background: white;
  border: 2px solid #cbd5e0;
}

.input-cell input {
  width: 100%;
  height: 100%;
  border: none;
  background: transparent;
  text-align: center;
  font-weight: bold;
  font-size: 20px;
  color: #2d3748;
  text-transform: uppercase;
}

.input-cell input:focus {
  outline: none;
  background: #ebf8ff;
}

/* Blocked Cell */
.blocked-cell {
  background: #2d3748;
  border: 2px solid #2d3748;
}

/* Bottom Controls */
.bottom-controls {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  padding: 0;
}

.control-btn {
  background: linear-gradient(135deg, #667eea, #764ba2);
  color: white;
  border: none;
  border-radius: 12px;
  padding: 15px 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  cursor: pointer;
  transition: all 0.3s ease;
  font-weight: 600;
  font-size: 12px;
}

.control-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
}

.control-btn:active {
  transform: translateY(0);
}

.control-btn i {
  font-size: 20px;
}

.hint-btn {
  background: linear-gradient(135deg, #ed8936, #dd6b20);
}

/* Side Menu */
.side-menu {
  position: fixed;
  top: 0;
  left: -300px;
  width: 300px;
  height: 100vh;
  background: white;
  box-shadow: 2px 0 10px rgba(0, 0, 0, 0.1);
  transition: left 0.3s ease;
  z-index: 200;
}

.side-menu.active {
  left: 0;
}

.menu-header {
  background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
  color: white;
  padding: 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.close-menu {
  background: none;
  border: none;
  color: white;
  font-size: 24px;
  cursor: pointer;
}

.menu-items {
  padding: 20px 0;
}

.menu-item {
  display: flex;
  align-items: center;
  gap: 15px;
  padding: 15px 20px;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  cursor: pointer;
  transition: background 0.2s ease;
  font-size: 16px;
}

.menu-item:hover {
  background: #f8f9fa;
}

.menu-item i {
  width: 20px;
  color: #4facfe;
}

.bonus-indicator {
  background: #48bb78;
  color: white;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 12px;
  font-weight: 600;
  margin-left: auto;
}

/* Modals */
.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  z-index: 300;
  justify-content: center;
  align-items: center;
}

.modal.active {
  display: flex;
}

.modal-content {
  background: white;
  border-radius: 20px;
  padding: 30px;
  text-align: center;
  max-width: 400px;
  width: 90%;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

.success-icon {
  font-size: 60px;
  color: #48bb78;
  margin-bottom: 20px;
}

.success-modal h2 {
  color: #2d3748;
  margin-bottom: 10px;
}

.reward-info {
  display: flex;
  justify-content: space-around;
  margin: 20px 0;
}

.reward-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  color: #4a5568;
}

.modal-buttons {
  display: flex;
  gap: 10px;
  margin-top: 20px;
}

.btn {
  padding: 12px 24px;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 600;
  transition: all 0.3s ease;
}

.btn-primary {
  background: linear-gradient(135deg, #48bb78, #38a169);
  color: white;
  flex: 1;
}

.btn-secondary {
  background: #e2e8f0;
  color: #4a5568;
}

.hint-cost {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin: 15px 0;
  color: #4a5568;
}

/* Responsive Design */
@media (max-width: 768px) {
  .app-title {
    font-size: 18px;
  }

  /* Grid cell sizes are now set dynamically by JavaScript */

  .input-cell input {
    font-size: 16px;
  }

  .clue-text {
    font-size: 7px;
  }

  .control-btn {
    padding: 12px 8px;
    font-size: 11px;
  }

  .control-btn i {
    font-size: 18px;
  }
}

/* Animations */
@keyframes bounce {
  0%, 20%, 50%, 80%, 100% { transform: translateY(0); }
  40% { transform: translateY(-10px); }
  60% { transform: translateY(-5px); }
}

@keyframes pulse {
  0% { transform: scale(1); }
  50% { transform: scale(1.05); }
  100% { transform: scale(1); }
}

.success-icon {
  animation: bounce 1s ease;
}

.control-btn:hover {
  animation: pulse 0.3s ease;
}
