* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  background: #1a1a2e;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  min-height: 100vh;
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  color: #e8eaed;
  user-select: none;
  -webkit-user-select: none;
  overflow-x: hidden;
}

#back-btn {
  position: fixed;
  top: 16px;
  right: 16px;
  color: #fff;
  text-decoration: none;
  font-size: 22px;
  font-weight: 700;
  z-index: 20;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  background: rgba(255,255,255,0.1);
  transition: background 0.2s;
  line-height: 1;
}

#back-btn:hover {
  background: rgba(255,255,255,0.2);
}

#game-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  max-width: 600px;
  min-height: 100vh;
  padding: 16px 12px 24px;
  gap: 10px;
  position: relative;
}

#header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  padding: 0 4px;
}

#level-label {
  font-size: 20px;
  font-weight: 700;
  color: #e8eaed;
}

#bonus-label {
  font-size: 14px;
  color: #9aa0a6;
  font-weight: 600;
}

#crossword-wrapper {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 180px;
}

#crossword {
  display: grid;
  gap: 5px;
  justify-content: center;
}

.cross-cell {
  width: 44px;
  height: 44px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  font-weight: 700;
  text-transform: uppercase;
}

.cross-cell.empty {
  background: rgba(255,255,255,0.08);
  border: 2px solid rgba(255,255,255,0.12);
}

.cross-cell.revealed {
  background: #2e7d32;
  color: #fff;
  border: 2px solid #43a047;
  animation: cell-reveal 0.35s ease-out;
}

.cross-cell.spacer {
  visibility: hidden;
}

@keyframes cell-reveal {
  0% { transform: scale(0.5); opacity: 0; }
  60% { transform: scale(1.1); }
  100% { transform: scale(1); opacity: 1; }
}

#current-word {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: 4px;
  min-height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  transition: color 0.15s;
}

#message {
  font-size: 15px;
  font-weight: 600;
  min-height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.3s;
}

#message.correct {
  color: #66bb6a;
}

#message.already {
  color: #ffa726;
}

#message.invalid {
  color: #ef5350;
}

#message.bonus {
  color: #42a5f5;
}

#message.win {
  color: #ffd54f;
  font-size: 20px;
  animation: pop-in 0.4s ease-out;
}

@keyframes pop-in {
  0% { transform: scale(0); opacity: 0; }
  60% { transform: scale(1.15); }
  100% { transform: scale(1); opacity: 1; }
}

#wheel-wrapper {
  position: relative;
  width: 360px;
  height: 360px;
  flex-shrink: 0;
}

canvas#wheel {
  display: block;
  width: 360px;
  height: 360px;
  cursor: pointer;
  touch-action: none;
}

#shuffle-btn {
  background: rgba(255,255,255,0.08);
  color: #9aa0a6;
  border: none;
  width: 44px;
  height: 44px;
  font-size: 24px;
  border-radius: 50%;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: -4px;
}

#shuffle-btn:hover {
  background: rgba(255,255,255,0.15);
  color: #e8eaed;
}

.shake {
  animation: shake 0.4s ease-in-out;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-8px); }
  40% { transform: translateX(8px); }
  60% { transform: translateX(-6px); }
  80% { transform: translateX(6px); }
}

@media (max-width: 420px) {
  .cross-cell {
    width: 32px;
    height: 32px;
    font-size: 15px;
  }

  #crossword {
    gap: 3px;
  }

  #wheel-wrapper {
    width: 280px;
    height: 280px;
  }

  canvas#wheel {
    width: 280px;
    height: 280px;
  }

  #current-word {
    font-size: 22px;
  }
}

@media (min-height: 800px) {
  #crossword-wrapper {
    min-height: 240px;
  }
}
