/* Game Styling - Professional & Clean */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: #006064;
    color: #ffffff;
    min-height: 100vh;
    line-height: 1.6;
}

/* Header */
header {
    text-align: center;
    padding: 20px 0;
    background: rgba(240, 98, 146, 0.1);
    border-bottom: 2px solid #f06292;
}

header h1 {
    font-size: 2.5rem;
    color: #f06292;
    text-shadow: 0 0 10px rgba(240, 98, 146, 0.5);
    margin-bottom: 10px;
    font-weight: bold;
}

.tagline {
    font-size: 1.1rem;
    color: #ffffff;
    font-style: italic;
}

/* Ad Spaces - Clean & Non-Intrusive */
.ad-space {
    background: rgba(0, 0, 0, 0.18);
    border: none;
    margin: 6px 0;
}

#topAdSpace {
    height: 90px;
    width: 100%;
}

.side-ad {
    height: 600px;
    width: 160px;
    margin-left: 20px;
}

.left-side-ad {
    margin-left: 0;
    margin-right: 20px;
}

#bottomAdSpace {
    height: 90px;
    width: 100%;
}

.ad-placeholder {
    color: #4dd0e1;
    font-size: 0.9rem;
    text-align: center;
}

/* Main Game Container */
.game-container {
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding: 20px;
    gap: 20px;
}

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

/* Game UI */
.game-ui {
    display: flex;
    justify-content: center;
    width: 800px;
    margin-bottom: 10px;
}

.ui-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
}

.ui-item {
    background: rgba(0, 0, 0, 0.7);
    padding: 8px 12px;
    border-radius: 8px;
    border: 1px solid rgba(240, 98, 146, 0.5);
    backdrop-filter: blur(5px);
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 5px;
}

.ui-label {
    color: #ffffff;
    font-weight: bold;
}

.score-display {
    font-size: 1.2rem;
    background: rgba(240, 98, 146, 0.2);
    border-color: #f06292;
}

.score-display #score {
    color: #f06292;
    font-weight: bold;
    font-size: 1.3rem;
}

/* Lives Display */
.lives-container {
    display: flex;
    gap: 3px;
}

.heart {
    color: #ff8a65;
    font-size: 1.1rem;
    text-shadow: 0 0 5px rgba(255, 138, 101, 0.5);
}

/* Canvas Wrapper */
.canvas-wrapper {
    position: relative;
}

/* Canvas */
#gameCanvas {
    border: 3px solid #f06292;
    background: #263238;
    box-shadow: 
        0 0 30px rgba(240, 98, 146, 0.3),
        inset 0 0 50px rgba(0, 0, 0, 0.3);
    border-radius: 8px;
}

/* Power-up Display */
.powerup-display {
    position: absolute;
    top: 15px;
    right: 15px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
}

.powerup-item {
    background: rgba(255, 138, 101, 0.9);
    color: #000;
    padding: 8px 12px;
    border-radius: 20px;
    font-weight: bold;
    font-size: 0.85rem;
    box-shadow: 0 2px 10px rgba(255, 138, 101, 0.4);
    animation: powerupPulse 2s infinite ease-in-out;
}

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

/* Controls Info */
.controls-info {
    text-align: center;
    margin: 20px auto;
    max-width: 600px;
    background: rgba(255, 255, 255, 0.05);
    padding: 20px;
    border-radius: 10px;
    border: 1px solid rgba(240, 98, 146, 0.3);
}

.controls-info h3 {
    color: #f06292;
    margin-bottom: 15px;
    font-size: 1.3rem;
}

.controls-info p {
    margin-bottom: 10px;
}

.controls-info strong {
    color: #ffffff;
    background: rgba(240, 98, 146, 0.2);
    padding: 2px 6px;
    border-radius: 4px;
}

/* Modal always covers viewport */
.modal {
    position: fixed;
    top: 0;
    left: 0;
  width: 100vw;
  height: 100vh;
  z-index: 1000;
    display: flex;
  align-items: center;
    justify-content: center;
}

/* Modal Styles */
.modal-content {
    background: #006064;
    padding: 30px;
    border-radius: 15px;
    border: 2px solid #f06292;
    text-align: center;
    max-width: 500px;
    width: 90%;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    max-height: 90vh;
    overflow-y: auto;
}

.modal-content h2 {
    color: #f06292;
    margin-bottom: 20px;
    font-size: 1.8rem;
}

.final-stats, .wave-stats {
    background: rgba(255, 255, 255, 0.05);
    padding: 15px;
    border-radius: 8px;
    margin: 20px 0;
}

.final-stats p, .wave-stats p {
    margin: 8px 0;
    font-size: 1.1rem;
}

.final-stats h3 {
    color: #f06292;
    margin: 20px 0 10px 0;
    font-size: 1.2rem;
    border-bottom: 1px solid rgba(240, 98, 146, 0.3);
    padding-bottom: 5px;
}

.final-stats h3:first-child {
    margin-top: 0;
}

.final-stats p:last-child {
    margin-bottom: 0;
}

.modal-buttons {
    display: flex;
    flex-direction: column;
    gap: 15px;
    justify-content: center;
    margin-top: 20px;
}

/* Buttons */
.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.btn-primary {
    background: linear-gradient(45deg, #f06292, #ff8a65);
    color: white;
    box-shadow: 0 4px 15px rgba(240, 98, 146, 0.3);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(240, 98, 146, 0.4);
}

.btn-secondary {
    background: linear-gradient(45deg, #4dd0e1, #80deea);
    color: white;
    box-shadow: 0 4px 15px rgba(77, 208, 225, 0.3);
}

.btn-secondary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(77, 208, 225, 0.4);
}

/* Button size variants */
.btn-large {
    padding: 14px 28px;
    font-size: 1.05rem;
    width: 100%;
}
.btn-small {
    padding: 9px 14px;
    font-size: 0.85rem;
    flex: 1;
    text-transform: none;
    font-weight: 600;
}

/* Main menu layout helpers */
.menu-tagline {
    font-size: 0.92em;
    color: #bbb;
    margin: -6px 0 4px 0;
    text-align: center;
}
.chapter-btn-row,
.menu-util-row {
    display: flex;
    flex-direction: row;
    gap: 8px;
    width: 100%;
}

.share-text {
    margin-top: 15px;
    font-size: 0.9rem;
    color: #ffffff;
    font-style: italic;
}

/* Footer */
footer {
    text-align: center;
    padding: 30px 20px;
    background: rgba(0, 0, 0, 0.3);
    border-top: 1px solid rgba(240, 98, 146, 0.3);
    margin-top: 40px;
}

footer a {
    color: #f06292;
    text-decoration: none;
    font-weight: bold;
}

footer a:hover {
    text-decoration: underline;
}

.disclaimer {
    font-size: 0.9rem;
    color: #ffffff;
    margin-top: 10px;
}

/* Responsive Design */
@media (max-width: 1024px) {
    .game-container {
        flex-direction: column;
        align-items: center;
    }
    
    .side-ad {
        width: 100%;
        height: 90px;
        margin-left: 0;
        margin-top: 20px;
    }
}

@media (max-width: 768px) {
    header h1 {
        font-size: 2rem;
    }
    
    #gameCanvas {
        width: 100%;
        max-width: 600px;
        height: auto;
    }
    
    .game-ui {
        width: 100%;
        max-width: 600px;
    }
    
    .controls-info {
        margin: 20px;
    }
    
    .modal-content {
        margin: 20px;
        padding: 20px;
    }
    
    .modal-buttons {
        flex-direction: column;
    }
    
    .ui-item {
        font-size: 0.8rem;
        padding: 6px 10px;
    }
}

/* Game Visual Effects */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-20px); }
    to { opacity: 1; transform: translateY(0); }
}

.fade-in {
    animation: fadeIn 0.5s ease-out;
}

/* Loading/Transition Effects */
.wave-transition {
    position: absolute;
    top: 10%;
    left: 50%;
    transform: translate(-50%, 0);
    background: rgba(240, 98, 146, 0.92);
    backdrop-filter: blur(8px);
    color: white;
    padding: 16px 36px;
    border-radius: 12px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    font-size: 1.5rem;
    font-weight: bold;
    text-align: center;
    line-height: 1.6;
    z-index: 100;
    box-shadow: 0 4px 24px rgba(240, 98, 146, 0.5);
    animation: waveAnnounce 2.5s ease-in-out;
    pointer-events: none;
}

@keyframes waveAnnounce {
    0% { opacity: 0; transform: translate(-50%, 0) scale(0.5); }
    15% { opacity: 1; transform: translate(-50%, 0) scale(1.08); }
    75% { opacity: 1; transform: translate(-50%, 0) scale(1); }
    100% { opacity: 0; transform: translate(-50%, -10px) scale(0.95); }
}

/* Codex Modal Styles */
#codexModal.modal {
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}
#codexModal .codex-content {
  background: #263238;
  border: 3px solid #4dd0e1;
  border-radius: 16px;
  padding: 32px 32px 24px 32px;
  min-width: 350px;
  min-height: 400px;
  max-width: 600px;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: 0 0 40px #4dd0e1aa;
}
#codexModal h2 {
  color: #4dd0e1;
  text-align: center;
  margin-bottom: 18px;
}
#codexEntries {
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.codex-entry {
  display: flex;
  align-items: flex-start;
  gap: 18px;
  background: rgba(77, 208, 225, 0.08);
  border: 1.5px solid #4dd0e1;
  border-radius: 12px;
  padding: 14px 16px;
  box-shadow: 0 2px 8px #4dd0e133;
}
.codex-icon {
  width: 48px;
  height: 48px;
  background: #fffde7;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.1rem;
  box-shadow: 0 0 8px #4dd0e1aa;
  border: 2px solid #ffb300;
}
.codex-info {
  flex: 1;
}
.codex-title {
  font-size: 1.15rem;
  color: #ffb300;
  font-weight: bold;
  margin-bottom: 2px;
}
.codex-desc {
  font-size: 0.98rem;
  color: #fffde7;
  margin-bottom: 4px;
}
.codex-link {
  font-size: 0.92rem;
  color: #4dd0e1;
  text-decoration: underline;
}
.codex-link:hover {
  color: #f06292;
}

/* Ensure hidden modals are never visible or interactive */
.modal.hidden { display: none !important; }

.stat-sep {
  color: #aaa;
  margin: 0 6px;
}
.stat-label {
  color: #bbb;
  font-size: 0.97em;
}

.compact-stats {
  font-size: 0.98em;
  padding: 10px 8px;
  margin: 10px 0;
}
.compact-stats p {
  margin: 4px 0 2px 0;
  line-height: 1.2;
}
.lifetime-line {
  margin-top: 10px;
  font-size: 0.92em;
  color: #bbb;
  border-top: 1px solid #f06292;
  padding-top: 8px;
  text-align: center;
}

/* Stats table for end screens */
.stats-table {
  width: 100%;
  border-collapse: collapse;
  margin: 12px 0 8px 0;
  font-size: 0.95em;
}
.stats-table thead th {
  color: #4dd0e1;
  font-size: 0.78em;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 4px 8px 6px 8px;
  text-align: center;
  border-bottom: 1px solid #f06292;
}
.stats-table thead th:first-child {
  text-align: left;
}
.stats-table tbody td {
  padding: 5px 8px;
  text-align: center;
  color: #fff;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}
.stats-table tbody tr:last-child td {
  border-bottom: none;
}
.stats-table tbody tr:nth-child(even) {
  background: rgba(255,255,255,0.04);
}
.stats-table td.stat-label {
  text-align: left;
  color: #bbb;
  font-size: 0.92em;
}

/* New personal best highlight */
.new-best {
  color: #ffd600 !important;
  font-weight: bold;
}

/* Bonus breakdown line on chapter complete */
.bonus-breakdown {
  font-size: 0.88em;
  color: #ffd600;
  margin: 2px 0 8px 0;
  text-align: center;
}

/* Victory screen links */
.victory-links {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 16px 0;
}
.victory-links a {
  color: #4dd0e1;
  text-decoration: none;
  font-size: 0.95em;
}
.victory-links a:hover {
  color: #ffffff;
  text-decoration: underline;
}

/* Share score card panel */
#sharePanel {
  background: #004d40;
  border: 2px solid #4dd0e1;
  border-radius: 10px;
  padding: 16px;
  margin-top: 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}
#sharePanel img {
  max-width: 100%;
  border-radius: 6px;
  display: block;
}
.share-btn-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
}