:root { --tms-blue: #1a5276; --tms-green: #27ae60; --sq-size: min(11vw, 54px); }
* { margin: 0; padding: 0; box-sizing: border-box; }
body { background: linear-gradient(135deg, #e8f8f5 0%, #a8e6cf 30%, #ffd3b6 60%, #ffaaa5 100%); font-family: 'Segoe UI', 'Fredoka', 'Comic Sans MS', sans-serif; min-height: 100vh; display: flex; justify-content: center; align-items: center; padding: 10px; }
.app-container { width: 100%; max-width: 1100px; background: rgba(255,255,255,0.95); border-radius: 35px; padding: 20px; box-shadow: 0 15px 50px rgba(0,0,0,0.2); border: 4px solid #ff6b6b; display: flex; flex-direction: column; min-height: 95vh; max-height: 98vh; overflow-y: auto; }
.app-header { background: linear-gradient(135deg, #ff6b6b, #ffd93d, #6bcb77, #4d96ff); border-radius: 25px; padding: 15px 25px; text-align: center; margin-bottom: 15px; border: 3px solid #fff; }
.header-school { font-size: 1.3rem; font-weight: 800; animation: rainbow-text 3s infinite; }
@keyframes rainbow-text { 0%{color:#ff6b6b} 25%{color:#ffd93d} 50%{color:#6bcb77} 75%{color:#4d96ff} 100%{color:#ff6b6b} }
.header-title { font-size: 1.8rem; font-weight: 900; color: #1a5276; }
.app-footer { background: linear-gradient(135deg, #4d96ff, #6bcb77); border-radius: 15px; padding: 10px; text-align: center; margin-top: auto; color: white; font-size: 0.85rem; font-weight: 600; }
.login-screen { display: flex; flex-direction: column; align-items: center; gap: 20px; padding: 10px; flex: 1; justify-content: center; }
.home-screen { display: none; flex-direction: column; align-items: center; gap: 18px; flex: 1; justify-content: center; }
.level-selection,.chapter-selection { display: none; flex-direction: column; align-items: center; gap: 16px; width: 100%; flex: 1; }
.chapter-screen { display: none; flex-direction: column; align-items: center; gap: 10px; width: 100%; flex: 1; }
.login-title { font-size: 2.5rem; font-weight: 900; color: #ff6b6b; text-shadow: 3px 3px 0 #ffd93d; }
.login-input { width: 100%; max-width: 380px; padding: 16px 25px; font-size: 1.3rem; border: 4px solid #4d96ff; border-radius: 50px; background: #fff; text-align: center; outline: none; font-weight: 600; }
.btn-login { background: linear-gradient(135deg, #ff6b6b, #ffd93d); border: none; font-size: 1.8rem; font-weight: 900; color: white; padding: 16px 50px; border-radius: 100px; cursor: pointer; box-shadow: 0 8px 0 #c0392b; border: 3px solid #fff; animation: bounce-btn 1s infinite; }
@keyframes bounce-btn { 0%,100%{transform:translateY(0)} 50%{transform:translateY(-5px)} }
.student-name { font-size: 1.4rem; color: #4d96ff; background: #fff; padding: 10px 30px; border-radius: 30px; font-weight: 800; border: 3px solid #ffd93d; }
.btn-start { background: linear-gradient(135deg, #6bcb77, #ffd93d); border: none; font-size: 1.6rem; font-weight: 900; color: white; padding: 16px 40px; border-radius: 100px; cursor: pointer; box-shadow: 0 8px 0 #27ae60; border: 3px solid #fff; }
.level-list,.chapter-list { display: flex; flex-direction: column; gap: 14px; width: 100%; max-width: 500px; }
.level-card { background: linear-gradient(135deg, #fff, #f0f8ff); padding: 20px; border-radius: 22px; cursor: pointer; box-shadow: 0 5px 0 #4d96ff; text-align: center; font-size: 1.3rem; font-weight: 800; color: #1a5276; border: 3px solid #ffd93d; }
.level-card:hover { transform: scale(1.03); }
.level-card.locked { background: #e8e8e8; cursor: not-allowed; opacity: 0.65; }
.level-card.completed { background: linear-gradient(135deg, #d4edda, #a8e6cf); border-color: #27ae60; }
.level-card.coming-soon {
  opacity: 0.6;
  cursor: default;
  background: linear-gradient(135deg, #f0f0f0, #e0e0e0);
  border-color: #999;
  font-style: italic;
  color: #888;
}
.level-card.coming-soon:hover {
  transform: none;
}
.chapter-card { background: linear-gradient(135deg, #fff, #f0f0ff); padding: 16px; border-radius: 22px; cursor: pointer; box-shadow: 0 5px 0 #4d96ff; text-align: center; font-size: 1.1rem; font-weight: 800; color: #1a5276; border: 3px solid #ffd93d; }
.chapter-card:hover { transform: scale(1.03); }
.chapter-card.completed { background: linear-gradient(135deg, #d4edda, #a8e6cf); border-color: #27ae60; }
.chapter-card.locked { background: #e8e8e8; cursor: not-allowed; opacity: 0.65; border-color: #bbb; }
.chapter-card.coming-soon { background: linear-gradient(135deg, #f0f0f0, #e0e0e0); cursor: default; opacity: 0.5; border-color: #999; font-style: italic; }
.chapter-card.coming-soon:hover { transform: none; }
.chapter-content-wrapper { display: flex; flex-direction: column; gap: 15px; width: 100%; flex: 1; }
.chapter-left-panel { display: flex; flex-direction: column; gap: 10px; align-items: center; }
.chapter-right-panel { display: flex; flex-direction: column; gap: 10px; align-items: center; flex: 1; justify-content: center; }
.chapter-info-header { display: flex; align-items: center; justify-content: space-between; width: 100%; background: linear-gradient(135deg, #ff6b6b, #ffd93d, #6bcb77); border-radius: 30px; padding: 12px 22px; font-weight: 900; font-size: 1.1rem; color: white; flex-wrap: wrap; gap: 8px; }
.stars-display { display: flex; align-items: center; gap: 5px; background: rgba(255,255,255,0.3); padding: 8px 18px; border-radius: 25px; font-size: 1.5rem; }
.progress-text { background: rgba(255,255,255,0.9); border-radius: 25px; padding: 8px 20px; font-size: 1.1rem; font-weight: 800; color: #ff6b6b; }
.puzzle-selector { display: flex; flex-wrap: wrap; gap: 7px; justify-content: center; max-height: 120px; overflow-y: auto; }
.puzzle-dot { width: 34px; height: 34px; border-radius: 50%; background: #eee; display: flex; align-items: center; justify-content: center; cursor: pointer; font-weight: 800; font-size: 0.8rem; border: 3px solid #bbb; }
.puzzle-dot.completed { background: #6bcb77; border-color: #27ae60; color: white; }
.puzzle-dot.current { background: #ffd93d; border-color: #ff6b6b; }
.board-container { display: flex; align-items: stretch; }
.rank-labels { display: flex; flex-direction: column; justify-content: space-around; padding-right: 5px; }
.rank-labels span { font-size: 0.8rem; font-weight: 800; color: #ff6b6b; height: var(--sq-size); display: flex; align-items: center; justify-content: center; width: 18px; }
.board-and-files { display: flex; flex-direction: column; }
.chessboard { display: grid; grid-template-columns: repeat(8, var(--sq-size)); grid-template-rows: repeat(8, var(--sq-size)); width: calc(var(--sq-size)*8); height: calc(var(--sq-size)*8); border: 4px solid #ff6b6b; border-radius: 12px; overflow: hidden; box-shadow: 0 10px 30px rgba(0,0,0,0.3); position: relative; }
.square { display: flex; align-items: center; justify-content: center; cursor: pointer; position: relative; width: var(--sq-size); height: var(--sq-size); min-width: var(--sq-size); min-height: var(--sq-size); }

/* Softer board colors for better piece visibility */
.square.light { background-color: #f0d9b5; } 
.square.dark { background-color: #b58863; }

.square.selected { background-color: #7cff6b !important; }
.square.legal-move { background-color: rgba(144,255,144,0.7) !important; cursor: pointer; }
.square.red-target { background-color: #FF1744 !important; animation: pulse-target 0.8s infinite; box-shadow: inset 0 0 25px rgba(255,23,68,0.8); }
@keyframes pulse-target { 0%,100%{box-shadow:inset 0 0 15px rgba(255,23,68,0.6)} 50%{box-shadow:inset 0 0 40px rgba(255,23,68,1)} }
.square.white-to-move { background-color: #2196F3 !important; animation: glow-white 1.2s infinite; box-shadow: inset 0 0 30px rgba(33, 150, 243, 0.9); }
.square.attacked-highlight { background-color: #FF6D00 !important; animation: pulse-attacker 1.2s infinite; box-shadow: inset 0 0 20px rgba(255, 109, 0, 0.7); }
.square.attacked-highlight2 { background-color: #FF9800 !important; animation: pulse-attacker 1.2s infinite; box-shadow: inset 0 0 20px rgba(255, 152, 0, 0.7); }
@keyframes glow-white { 0%,100%{box-shadow:inset 0 0 15px rgba(33,150,243,0.6)} 50%{box-shadow:inset 0 0 35px rgba(33,150,243,1)} }
@keyframes pulse-attacker { 0%,100%{box-shadow:inset 0 0 12px rgba(255,109,0,0.5)} 50%{box-shadow:inset 0 0 30px rgba(255,109,0,1)} }
.square.black-move-from { background-color: #9C27B0 !important; animation: glow-from 1.5s infinite; box-shadow: inset 0 0 25px rgba(156, 39, 176, 0.8); }
@keyframes glow-from { 0%,100%{box-shadow:inset 0 0 15px rgba(156,39,176,0.6)} 50%{box-shadow:inset 0 0 35px rgba(156,39,176,1)} }
.square.black-move-to { background-color: #E040FB !important; animation: glow-to 1.5s infinite; box-shadow: inset 0 0 25px rgba(224, 64, 251, 0.8); }
@keyframes glow-to { 0%,100%{box-shadow:inset 0 0 15px rgba(224,64,251,0.6)} 50%{box-shadow:inset 0 0 35px rgba(224,64,251,1)} }
.square.unsafe-square { background-color: #FF1744 !important; animation: pulse-check 0.8s infinite; }
@keyframes pulse-check { 0%,100%{box-shadow:inset 0 0 15px rgba(255,23,68,0.7)} 50%{box-shadow:inset 0 0 40px rgba(255,23,68,1)} }
@keyframes pulse-gold { 0%,100%{box-shadow:inset 0 0 20px rgba(255,215,0,0.7)} 50%{box-shadow:inset 0 0 35px rgba(255,215,0,1)} }

.piece { font-size: clamp(2rem, 6vw, 2.8rem); line-height: 1; user-select: none; pointer-events: none; z-index: 4; position: relative; }

/* White pieces - bright white with strong dark outline for visibility */
.piece.wp { 
  color: #ffffff; 
  text-shadow: 1px 1px 0 #000, -1px -1px 0 #000, 1px -1px 0 #000, -1px 1px 0 #000, 0 0 4px #000; 
}

/* Black pieces - dark brown with light outline */
.piece.bp { 
  color: #3c3c3c; 
  text-shadow: 1px 1px 0 #fff, -1px -1px 0 #fff, 1px -1px 0 #fff, -1px 1px 0 #fff, 0 0 2px #fff; 
}

.file-labels { display: flex; justify-content: space-around; padding-top: 3px; }
.file-labels span { font-size: 0.8rem; font-weight: 800; color: #ff6b6b; width: var(--sq-size); text-align: center; }
.message-box { min-height: 45px; font-size: 1rem; font-weight: 800; text-align: center; color: #1a5276; padding: 8px; background: rgba(255,255,255,0.8); border-radius: 15px; }
.instruction-tip { background: linear-gradient(135deg, #fff3cd, #ffeaa7); border: 3px solid #ffd93d; border-radius: 18px; padding: 10px 18px; font-size: 0.95rem; font-weight: 800; color: #e67e22; text-align: center; }
.turn-indicator { 
  background: linear-gradient(135deg, #4d96ff, #6bcb77); 
  border: 3px solid #fff; 
  border-radius: 20px; 
  padding: 8px 20px; 
  font-size: 0.9rem; 
  font-weight: 800; 
  color: white; 
  text-align: center; 
  margin-bottom: 5px; 
  min-height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
}
.turn-indicator.white-turn { 
  background: linear-gradient(135deg, #fff, #e3f2fd); 
  color: #1a5276; 
  border-color: #4FC3F7; 
}
.turn-indicator.computer-turn { 
  background: linear-gradient(135deg, #9C27B0, #7B1FA2); 
  color: white; 
  border-color: #E1BEE7; 
  animation: pulse-computer 1s infinite; 
}

@keyframes pulse-computer { 0%,100%{opacity:1} 50%{opacity:0.7} }
.retry-message { background: linear-gradient(135deg, #ff6b6b, #ff4444); color: white; padding: 8px 15px; border-radius: 12px; font-size: 0.9rem; font-weight: 800; text-align: center; display: none; }
.button-group { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; align-items: center; }
.game-btn { background: linear-gradient(135deg, #4d96ff, #6bcb77); border: none; font-size: 1rem; font-weight: 800; padding: 10px 20px; border-radius: 40px; cursor: pointer; box-shadow: 0 5px 0 #1a5276; color: white; border: 2px solid #fff; }
.game-btn:active { transform: translateY(3px); }
.game-btn.try-again-btn { background: linear-gradient(135deg, #ff6b6b, #ff4444); box-shadow: 0 5px 0 #c0392b; display: none; }
.puzzle-info { background: rgba(255,255,255,0.9); padding: 10px 18px; border-radius: 20px; font-size: 1rem; font-weight: 800; color: #4d96ff; text-align: center; border: 2px solid #ffd93d; }
.move-counter { background: #fff; padding: 6px 15px; border-radius: 15px; font-size: 0.9rem; font-weight: 800; color: #ff6b6b; border: 2px solid #ffd93d; }
.btn-next-chapter { background: linear-gradient(135deg, #ffd93d, #ff6b6b); box-shadow: 0 6px 0 #e67e22; display: none; font-size: 1.2rem; padding: 12px 28px; animation: bounce 0.6s infinite alternate; border: none; font-weight: 900; color: white; border-radius: 100px; cursor: pointer; border: 3px solid #fff; }
@keyframes bounce { from{transform:translateY(0)} to{transform:translateY(-10px)} }
.promotion-popup { display: none; position: fixed; top: 50%; left: 50%; transform: translate(-50%,-50%); background: #fff; border: 5px solid #ffd93d; border-radius: 25px; padding: 25px; z-index: 100; text-align: center; box-shadow: 0 15px 50px rgba(0,0,0,0.5); }
.promotion-popup h3 { color: #ff6b6b; margin-bottom: 15px; font-size: 1.5rem; font-weight: 900; }
.promo-options { display: flex; gap: 15px; justify-content: center; flex-wrap: wrap; }
.promo-btn { font-size: 3rem; padding: 12px 18px; border-radius: 18px; cursor: pointer; border: 3px solid #ffd93d; background: #fff; }
.promo-btn:hover { background: #ffd93d; color: white; transform: scale(1.2); }
.overlay { display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.6); z-index: 99; }
.badge-popup { display: none; position: fixed; top: 50%; left: 50%; transform: translate(-50%,-50%); background: #fff; border: 5px solid #ffd93d; border-radius: 25px; padding: 30px; z-index: 100; text-align: center; box-shadow: 0 15px 50px rgba(0,0,0,0.5); max-width: 500px; width: 90%; }
.badge-icon { font-size: 5rem; animation: bounce 0.5s infinite alternate; }
.badge-name { font-size: 1.5rem; font-weight: 900; color: #4d96ff; }
.checkmate-btn { background: linear-gradient(135deg, #8B0000, #FF4444) !important; box-shadow: 0 5px 0 #4B0000 !important; font-size: 1.1rem !important; animation: pulse-checkmate 1.5s infinite !important; border: 3px solid #ffd93d !important; }
@keyframes pulse-checkmate { 0%,100%{box-shadow:0 5px 0 #4B0000} 50%{box-shadow:0 5px 20px rgba(255,0,0,0.7)} }
.certificate-popup { display: none; position: fixed; top: 50%; left: 50%; transform: translate(-50%,-50%); background: linear-gradient(135deg, #fffde7, #fff9c4); border: 6px solid #ffd93d; border-radius: 25px; padding: 30px; z-index: 100; text-align: center; box-shadow: 0 15px 50px rgba(0,0,0,0.5); max-width: 550px; width: 90%; }
.certificate-icon { font-size: 6rem; }
.certificate-title { font-size: 1.8rem; font-weight: 900; color: #1a5276; }
.certificate-subtitle { font-size: 1.1rem; font-weight: 700; color: #27ae60; margin: 10px 0; }
.hint-text { color: #e67e22; font-style: italic; margin-top: 5px; font-size: 0.85rem; }
.achievements-screen { display: none; flex-direction: column; align-items: center; gap: 16px; width: 100%; flex: 1; }
.achievement-card { background: #fff; border: 2px solid #ffd93d; border-radius: 20px; padding: 20px; text-align: center; width: 200px; box-shadow: 0 5px 15px rgba(0,0,0,0.1); }
.achievement-card .title { font-weight: bold; color: #1a5276; margin: 10px 0 5px; }
.achievement-card .desc { font-size: 0.85rem; color: #555; margin-bottom: 10px; }
.achievement-card .download-btn { background: #ffd93d; border: none; padding: 6px 12px; border-radius: 10px; font-weight: bold; cursor: pointer; }
.about-screen { display: none; flex-direction: column; align-items: center; gap: 16px; width: 100%; flex: 1; }
@media (min-width: 768px) { .chapter-content-wrapper { flex-direction: row; align-items: flex-start; } .chapter-left-panel { flex: 0 0 450px; position: sticky; top: 0; } .chapter-right-panel { flex: 1; min-width: 260px; padding-left: 20px; } }