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

body {
  font-family: 'Fredoka', 'Segoe UI', sans-serif;
  min-height: 100vh;
  color: #2c3e50;
}

a { text-decoration: none; }

.top-nav {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  padding: 12px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: 0 4px 15px rgba(0,0,0,0.15);
  position: relative;
  z-index: 10;
}

.nav-home, .nav-ranking, .nav-game {
  color: white;
  font-size: 18px;
  font-weight: 500;
  padding: 8px 16px;
  border-radius: 20px;
  transition: background 0.3s;
}

.nav-home:hover, .nav-ranking:hover, .nav-game:hover {
  background: rgba(255,255,255,0.2);
}

.nav-title {
  color: white;
  font-size: 22px;
  font-weight: 600;
}

/* LANDING PAGE */
.admin-trigger {
  position: fixed;
  top: 16px;
  right: 16px;
  font-size: 28px;
  cursor: pointer;
  opacity: 0.5;
  transition: all 0.3s;
  z-index: 50;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: rgba(255,255,255,0.15);
  backdrop-filter: blur(4px);
}

.admin-trigger:hover {
  opacity: 1;
  transform: scale(1.15);
  background: rgba(255,255,255,0.25);
}

.pass-error {
  color: #ff6b6b;
  font-size: 14px;
  font-weight: 500;
  text-align: center;
  min-height: 20px;
}

.btn-cancel {
  background: transparent;
  color: #888;
  border: 2px solid #ddd;
  padding: 10px 24px;
  border-radius: 12px;
  font-size: 16px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.3s;
}

.btn-cancel:hover {
  background: #f5f5f5;
  border-color: #bbb;
}

.landing {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.landing-container {
  text-align: center;
  position: relative;
  z-index: 1;
}

.title {
  font-size: 64px;
  font-weight: 700;
  margin-bottom: 16px;
  letter-spacing: 4px;
}

.letter {
  display: inline-block;
  animation: bounce 2s ease-in-out infinite;
}

.title-break { display: none; }

.letter-space { display: inline-block; width: 16px; }

.l1 { color: #FF6B6B; animation-delay: 0s; }
.l2 { color: #FFE66D; animation-delay: 0.1s; }
.l3 { color: #4ECDC4; animation-delay: 0.2s; }
.l4 { color: #FF6B6B; animation-delay: 0.3s; }
.l5 { color: #FFE66D; animation-delay: 0.4s; }
.l6 { color: #4ECDC4; animation-delay: 0.5s; }
.l7 { color: #FF6B6B; animation-delay: 0.6s; }
.l8 { color: #FFE66D; animation-delay: 0.7s; }
.l9 { color: #4ECDC4; animation-delay: 0.8s; }
.l10 { color: #FF6B6B; animation-delay: 0.9s; }
.l11 { color: #FFE66D; animation-delay: 1.0s; }
.l12 { color: #4ECDC4; animation-delay: 1.1s; }
.l13 { color: #FF6B6B; animation-delay: 1.2s; }

@keyframes bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-15px); }
}

.subtitle {
  font-size: 24px;
  color: rgba(255,255,255,0.9);
  margin-bottom: 48px;
}

.credits {
  margin-top: 40px;
  text-align: center;
  color: #fff;
  font-size: 22px;
  font-weight: 600;
  line-height: 1.8;
  text-shadow: 0 2px 8px rgba(0,0,0,0.25);
}

.credits p {
  margin: 2px 0;
}

.school-logo {
  max-width: 120px;
  height: auto;
  margin-top: -24px;
  margin-bottom: 8px;
  filter: drop-shadow(0 4px 8px rgba(0,0,0,0.2));
}

.landing-buttons {
  display: flex;
  gap: 24px;
  justify-content: center;
  flex-wrap: wrap;
}

.btn-big {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 180px;
  height: 180px;
  border-radius: 24px;
  font-weight: 600;
  transition: all 0.3s;
  box-shadow: 0 8px 25px rgba(0,0,0,0.2);
}

.btn-big:hover {
  transform: translateY(-8px) scale(1.05);
  box-shadow: 0 12px 35px rgba(0,0,0,0.3);
}

.btn-play { background: linear-gradient(135deg, #FF6B6B, #ee5a24); color: white; }
.btn-ranking { background: linear-gradient(135deg, #FFE66D, #f9ca24); color: #2c3e50; }
.btn-admin { background: linear-gradient(135deg, #4ECDC4, #00b894); color: white; }

.btn-icon { font-size: 48px; margin-bottom: 8px; }
.btn-text { font-size: 24px; letter-spacing: 2px; }

.floating-letters {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 0;
}

.floating-letters span {
  position: absolute;
  font-size: 28px;
  font-weight: 700;
  opacity: 0.12;
  color: white;
  animation: floatLetter 20s linear infinite;
}

.floating-letters span:nth-child(1) { left: 5%; animation-delay: 0s; }
.floating-letters span:nth-child(2) { left: 15%; animation-delay: 2s; }
.floating-letters span:nth-child(3) { left: 25%; animation-delay: 4s; }
.floating-letters span:nth-child(4) { left: 35%; animation-delay: 6s; }
.floating-letters span:nth-child(5) { left: 45%; animation-delay: 8s; }
.floating-letters span:nth-child(6) { left: 55%; animation-delay: 10s; }
.floating-letters span:nth-child(7) { left: 65%; animation-delay: 12s; }
.floating-letters span:nth-child(8) { left: 75%; animation-delay: 14s; }
.floating-letters span:nth-child(9) { left: 85%; animation-delay: 16s; }
.floating-letters span:nth-child(10) { left: 10%; top: 60%; animation-delay: 1s; }
.floating-letters span:nth-child(11) { left: 20%; top: 70%; animation-delay: 3s; }
.floating-letters span:nth-child(12) { left: 30%; top: 80%; animation-delay: 5s; }
.floating-letters span:nth-child(13) { left: 40%; top: 50%; animation-delay: 7s; }
.floating-letters span:nth-child(14) { left: 50%; top: 65%; animation-delay: 9s; }
.floating-letters span:nth-child(15) { left: 60%; top: 75%; animation-delay: 11s; }
.floating-letters span:nth-child(16) { left: 70%; top: 55%; animation-delay: 13s; }
.floating-letters span:nth-child(17) { left: 80%; top: 85%; animation-delay: 15s; }
.floating-letters span:nth-child(18) { left: 90%; top: 45%; animation-delay: 17s; }
.floating-letters span:nth-child(19) { left: 3%; top: 30%; animation-delay: 19s; }
.floating-letters span:nth-child(20) { left: 95%; top: 20%; animation-delay: 3s; }
.floating-letters span:nth-child(21) { left: 8%; top: 90%; animation-delay: 7s; }
.floating-letters span:nth-child(22) { left: 48%; top: 35%; animation-delay: 11s; }
.floating-letters span:nth-child(23) { left: 92%; top: 70%; animation-delay: 5s; }
.floating-letters span:nth-child(24) { left: 72%; top: 15%; animation-delay: 9s; }
.floating-letters span:nth-child(25) { left: 38%; top: 10%; animation-delay: 13s; }
.floating-letters span:nth-child(26) { left: 18%; top: 40%; animation-delay: 17s; }

@keyframes floatLetter {
  0% { transform: translateY(100vh) rotate(0deg); opacity: 0; }
  10% { opacity: 0.12; }
  90% { opacity: 0.12; }
  100% { transform: translateY(-100vh) rotate(720deg); opacity: 0; }
}

/* ADMIN PAGE */
.admin-page { background: #f0f2f5; }

.admin-container {
  max-width: 900px;
  margin: 0 auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.admin-card {
  background: white;
  border-radius: 20px;
  padding: 24px;
  box-shadow: 0 4px 15px rgba(0,0,0,0.08);
}

.admin-card h2 {
  font-size: 22px;
  margin-bottom: 16px;
  color: #2c3e50;
}

.add-word-form {
  display: flex;
  gap: 12px;
}

.add-word-form input {
  flex: 1;
  padding: 12px 16px;
  border: 3px solid #e0e0e0;
  border-radius: 12px;
  font-size: 18px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.3s;
}

.add-word-form input:focus {
  border-color: #667eea;
}

.btn {
  padding: 10px 24px;
  border: none;
  border-radius: 12px;
  font-size: 16px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.3s;
}

.btn:hover { transform: translateY(-2px); box-shadow: 0 4px 12px rgba(0,0,0,0.15); }
.btn:active { transform: translateY(0); }

.btn-primary { background: linear-gradient(135deg, #667eea, #764ba2); color: white; }
.btn-success { background: linear-gradient(135deg, #4ECDC4, #00b894); color: white; }
.btn-secondary { background: linear-gradient(135deg, #a29bfe, #6c5ce7); color: white; }
.btn-large { padding: 14px 36px; font-size: 20px; }
.btn-delete {
  background: #ff6b6b;
  color: white;
  border: none;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 14px;
  transition: background 0.3s;
  display: flex;
  align-items: center;
  justify-content: center;
}
.btn-delete:hover { background: #ee5a24; }

.message {
  margin-top: 12px;
  padding: 10px 16px;
  border-radius: 10px;
  font-size: 15px;
  display: none;
}

.message.success { display: block; background: #d4edda; color: #155724; }
.message.error { display: block; background: #f8d7da; color: #721c24; }

.word-count {
  font-size: 14px;
  color: #666;
  margin-bottom: 12px;
}

.words-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.word-item {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #f8f9fa;
  padding: 8px 12px;
  border-radius: 10px;
  border: 2px solid #e0e0e0;
  transition: all 0.2s;
}

.word-item:hover { border-color: #667eea; }

.word-check {
  width: 18px;
  height: 18px;
  cursor: pointer;
  accent-color: #667eea;
}

.word-text {
  font-size: 18px;
  font-weight: 500;
  letter-spacing: 1px;
}

.empty-msg {
  color: #999;
  font-size: 16px;
  padding: 12px 0;
}

.generate-form {
  display: flex;
  align-items: flex-end;
  gap: 16px;
  flex-wrap: wrap;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-group label {
  font-size: 14px;
  font-weight: 500;
  color: #666;
}

.form-group select {
  padding: 10px 16px;
  border: 3px solid #e0e0e0;
  border-radius: 12px;
  font-size: 16px;
  font-family: inherit;
  outline: none;
  background: white;
  cursor: pointer;
}

.form-group select:focus { border-color: #4ECDC4; }

.hint {
  font-size: 14px;
  color: #888;
  margin-bottom: 12px;
}

.puzzles-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.puzzle-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  background: #f8f9fa;
  border-radius: 10px;
  border: 2px solid #e0e0e0;
}

.puzzle-item.active {
  border-color: #4ECDC4;
  background: #e8faf8;
}

.puzzle-info { font-weight: 500; }
.puzzle-date { font-size: 13px; color: #888; }

.qr-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.qr-input-row {
  display: flex;
  gap: 12px;
  align-items: stretch;
}

.qr-input {
  flex: 1;
  padding: 12px 16px;
  border: 3px solid #e0e0e0;
  border-radius: 12px;
  font-size: 16px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.3s;
}

.qr-input:focus {
  border-color: #667eea;
}

.qr-output {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 20px;
  background: #f8f9fa;
  border-radius: 16px;
  min-height: 200px;
  justify-content: center;
}

.qr-image {
  max-width: 250px;
  border-radius: 12px;
  box-shadow: 0 4px 15px rgba(0,0,0,0.1);
}

.qr-hint {
  font-size: 14px;
  color: #888;
  text-align: center;
}

.qr-placeholder {
  color: #aaa;
  font-size: 15px;
  text-align: center;
}

/* GAME PAGE */
.game-page { background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); }

.no-puzzle {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 80vh;
}

.no-puzzle-card {
  background: white;
  border-radius: 24px;
  padding: 48px;
  text-align: center;
  box-shadow: 0 8px 30px rgba(0,0,0,0.15);
}

.no-puzzle-icon { font-size: 64px; display: block; margin-bottom: 16px; }
.no-puzzle-card h2 { font-size: 28px; margin-bottom: 8px; }
.no-puzzle-card p { color: #666; margin-bottom: 24px; }

.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: 100;
  backdrop-filter: blur(4px);
}

.modal {
  background: white;
  border-radius: 24px;
  padding: 40px;
  text-align: center;
  max-width: 400px;
  width: 90%;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
  animation: modalIn 0.4s ease;
}

@keyframes modalIn {
  from { transform: scale(0.8) translateY(20px); opacity: 0; }
  to { transform: scale(1) translateY(0); opacity: 1; }
}

.modal-icon { font-size: 56px; display: block; margin-bottom: 12px; }

.modal-logo {
  max-width: 100px;
  height: auto;
  margin-bottom: 12px;
  filter: drop-shadow(0 4px 8px rgba(0,0,0,0.15));
}

.modal h2 { font-size: 28px; margin-bottom: 8px; }
.modal p { color: #666; margin-bottom: 24px; }
.modal-desc { font-size: 15px; line-height: 1.5; }

.modal form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.modal input {
  padding: 14px 18px;
  border: 3px solid #e0e0e0;
  border-radius: 14px;
  font-size: 20px;
  font-family: inherit;
  text-align: center;
  outline: none;
  transition: border-color 0.3s;
}

.modal input:focus { border-color: #667eea; }

.game-container {
  max-width: 920px;
  margin: 0 auto;
  padding: 16px;
}

.game-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.player-info {
  background: rgba(255,255,255,0.2);
  color: white;
  padding: 8px 20px;
  border-radius: 20px;
  font-size: 18px;
  font-weight: 500;
  backdrop-filter: blur(4px);
}

.timer {
  background: rgba(255,255,255,0.2);
  color: white;
  padding: 8px 24px;
  border-radius: 20px;
  font-size: 26px;
  font-weight: 700;
  backdrop-filter: blur(4px);
  font-variant-numeric: tabular-nums;
}

.game-area {
  display: flex;
  gap: 20px;
  align-items: flex-start;
}

.grid-wrapper {
  flex: 1;
  display: flex;
  justify-content: center;
}

.grid-container {
  background: white;
  border-radius: 20px;
  padding: 12px;
  box-shadow: 0 8px 30px rgba(0,0,0,0.15);
  display: inline-block;
}

.word-grid {
  border-collapse: collapse;
  user-select: none;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
}

.word-grid td {
  width: 44px;
  height: 44px;
  text-align: center;
  font-size: 20px;
  font-weight: 600;
  color: #2c3e50;
  cursor: pointer;
  border: 1px solid #e8e8e8;
  transition: all 0.15s;
  border-radius: 4px;
}

.word-grid td:hover {
  background: #e8f0fe;
}

.word-grid td.selecting {
  background: #ffe66d !important;
  color: #2c3e50 !important;
  transform: scale(1.05);
  z-index: 2;
  position: relative;
  box-shadow: 0 0 8px rgba(255, 230, 109, 0.5);
}

.word-grid td.found {
  background: #4ECDC4 !important;
  color: white !important;
  font-weight: 700;
}

.word-grid td.found-word-start {
  background: #00b894 !important;
  color: white !important;
  font-weight: 700;
}

.words-panel {
  background: white;
  border-radius: 20px;
  padding: 20px;
  min-width: 220px;
  box-shadow: 0 8px 30px rgba(0,0,0,0.15);
  position: sticky;
  top: 20px;
}

.words-panel h3 {
  font-size: 18px;
  margin-bottom: 12px;
  color: #2c3e50;
}

.word-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 16px;
}

.word-list-item {
  padding: 8px 14px;
  background: #f8f9fa;
  border-radius: 10px;
  font-size: 16px;
  font-weight: 500;
  letter-spacing: 1px;
  border: 2px solid #e0e0e0;
  transition: all 0.3s;
}

.word-list-item.found {
  background: #d4edda;
  border-color: #4ECDC4;
  color: #155724;
  text-decoration: line-through;
  opacity: 0.7;
}

.progress-bar-container {
  width: 100%;
  height: 10px;
  background: #e0e0e0;
  border-radius: 5px;
  overflow: hidden;
  margin-bottom: 4px;
}

.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, #4ECDC4, #00b894);
  border-radius: 5px;
  transition: width 0.5s ease;
  width: 0%;
}

.progress-text {
  font-size: 14px;
  color: #666;
  text-align: center;
}

.game-footer {
  margin-top: 16px;
  text-align: center;
}

.game-hint {
  background: rgba(255,255,255,0.15);
  color: white;
  padding: 10px 20px;
  border-radius: 16px;
  display: inline-block;
  font-size: 16px;
  backdrop-filter: blur(4px);
}

.complete-modal .score-display {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin: 20px 0;
}

.score-item {
  background: #f8f9fa;
  border-radius: 14px;
  padding: 12px;
  text-align: center;
}

.score-item.star {
  grid-column: 1 / -1;
  background: linear-gradient(135deg, #FFE66D, #f9ca24);
}

.score-label {
  display: block;
  font-size: 14px;
  color: #666;
  margin-bottom: 4px;
}

.score-item.star .score-label { color: #2c3e50; }

.score-value {
  display: block;
  font-size: 24px;
  font-weight: 700;
  color: #2c3e50;
}

.complete-buttons {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 12px;
}

/* RANKING PAGE */
.ranking-page { background: #f0f2f5; }

.ranking-container {
  max-width: 800px;
  margin: 24px auto;
  padding: 0 16px;
}

.ranking-card {
  background: white;
  border-radius: 24px;
  overflow: hidden;
  box-shadow: 0 8px 30px rgba(0,0,0,0.1);
}

.ranking-header {
  background: linear-gradient(135deg, #667eea, #764ba2);
  color: white;
  padding: 32px;
  text-align: center;
}

.ranking-header h2 { font-size: 28px; margin-bottom: 4px; }
.ranking-header p { opacity: 0.85; font-size: 16px; }

.ranking-table-wrapper {
  overflow-x: auto;
}

.ranking-table {
  width: 100%;
  border-collapse: collapse;
}

.ranking-table th {
  background: #f8f9fa;
  padding: 14px 16px;
  text-align: left;
  font-size: 14px;
  color: #666;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.ranking-table td {
  padding: 14px 16px;
  border-bottom: 1px solid #f0f0f0;
  font-size: 16px;
}

.ranking-table tr:hover td {
  background: #f8f9fa;
}

.ranking-table tr.top-three td {
  font-weight: 600;
}

.rank-cell { font-size: 20px; width: 50px; }
.name-cell { font-weight: 600; }
.score-cell {
  font-weight: 700;
  color: #667eea;
  font-size: 18px;
}
.time-cell { color: #666; }
.words-cell { color: #666; }
.date-cell { color: #999; font-size: 14px; }

.loading-msg {
  text-align: center;
  color: #999;
  padding: 40px !important;
  font-size: 16px;
}

/* Responsive */
@media (max-width: 585px) {
  .title-break { display: block; }
  .title { font-size: 44px; }
  .school-logo { max-width: 90px; margin-top: -16px; }
}

@media (max-width: 768px) {
  .title { font-size: 40px; }
  .subtitle { font-size: 18px; }
  .btn-big { width: 140px; height: 140px; }
  .btn-icon { font-size: 36px; }
  .btn-text { font-size: 18px; }

  .game-area {
    flex-direction: column;
    align-items: center;
  }

  .words-panel {
    width: 100%;
    position: static;
  }

  .word-grid td {
    width: 32px;
    height: 32px;
    font-size: 15px;
  }

  .grid-container { padding: 8px; }

  .landing-buttons { gap: 16px; }

  .nav-title { font-size: 16px; }
  .timer { font-size: 20px; }
}

@media (max-width: 480px) {
  .word-grid td {
    width: 26px;
    height: 26px;
    font-size: 12px;
  }
}
