* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  background-image: url('https://i.imgur.com/KmoYNRI.png');
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  background-attachment: fixed;
  background-blend-mode: multiply;
  background-color: rgba(30, 27, 51, 0.75);
  color: #f0e9e0;
  font-family: 'Unica One', cursive, Arial, sans-serif;
  user-select: none;
  min-height: 100vh;
}

#main-content {
  padding: 25px;
  padding-bottom: 150px; /* Space for admin panel */
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  width: 100%;
}

.hidden {
  display: none !important;
}

/* Portal styles */
#portal-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 3000;
    overflow: hidden;
}

.portal-door {
    position: absolute;
    top: 0;
    width: 50vw;
    height: 100vh;
    background-image: url('https://i.imgur.com/1yKb2hP.png');
    background-size: cover;
    background-blend-mode: multiply;
    background-color: rgba(10, 8, 18, 0.85);
    transition: transform 1.2s cubic-bezier(0.77, 0, 0.175, 1);
    z-index: 3001;
}

#portal-left { left: 0; background-position: left center; }
#portal-right { right: 0; background-position: right center; }
#portal-container.opened #portal-left { transform: translateX(-100%); }
#portal-container.opened #portal-right { transform: translateX(100%); }

#portal-content {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 3002;
    text-align: center;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    transition: opacity 0.5s ease;
}

#portal-container.opened #portal-content { opacity: 0; pointer-events: none; }
#portal-eye { 
    width: 180px; /* Adjusted for the lock icon */
    height: 180px; /* Adjusted for the lock icon */
    filter: drop-shadow(0 0 15px #ffc107); 
    transition: transform 0.4s, filter 0.4s; 
}
#portal-content:hover #portal-eye { 
    transform: scale(1.1); 
    filter: drop-shadow(0 0 25px #ffeb3b); 
}
#portal-text { margin-top: 20px; font-size: 1.3rem; font-style: italic; color: #f7e9a1; text-shadow: 1px 1px 5px #000; max-width: 300px; }

/* Admin Access Icon */
#admin-access-container {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    z-index: 1000;
    transition: transform 0.3s, filter 0.3s, opacity 0.3s, top 0.5s, left 0.5s;
}

#admin-access-icon {
    width: 160px;
    cursor: pointer;
    filter: drop-shadow(0 0 12px #f7c94888);
    transition: transform 0.3s;
}

#admin-access-container.centered {
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    bottom: auto;
}

#admin-access-icon:hover {
    transform: scale(1.15);
    filter: drop-shadow(0 0 18px #f7c948);
}

#end-game-message {
    margin-top: 20px;
    font-size: 1.3rem;
    font-style: italic;
    color: #f7e9a1;
    text-shadow: 1px 1px 5px #000;
}

/* Title and Countdown */
.title-image { width: clamp(300px, 90vw, 600px); margin-bottom: 15px; filter: drop-shadow(3px 3px 6px #9a6a00cc); }

#countdown-container {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    margin-bottom: 20px;
}

.time-segment { display: flex; flex-direction: column; align-items: center; }
.time-segment span { font-family: 'Orbitron', sans-serif; font-size: clamp(2.5rem, 8vw, 4rem); color: #f7e9a1; text-shadow: 0 0 10px #f7c948, 0 0 20px #f7c948a0; line-height: 1; }
.time-segment label { font-size: 0.8rem; color: #d1a523; text-transform: uppercase; }
.separator { font-family: 'Orbitron', sans-serif; font-size: clamp(2rem, 6vw, 3rem); color: #f7c948; text-shadow: 0 0 10px #f7c948; padding-bottom: 20px; }

/* Main Content Layout */
.main-container { display: flex; flex-direction: column; justify-content: center; align-items: center; width: 100%; gap: 40px; }

/* Enigma and Leaderboard */
#enigma-area { display: flex; flex-direction: column; align-items: center; order: 1; }
#leaderboard { order: 2; background-color: rgba(240, 233, 224, 0.9); padding: 20px; color: #3e2900; width: min(400px, 90vw); border-radius: 8px; box-shadow: 0 4px 15px rgba(0,0,0,0.3); border: 1px solid #d1a523; }
#leaderboard h2 { font-size: 1.8rem; margin-top: 0; color: #5a3d00; }
#leaderboard ol { padding-left: 20px; }
#leaderboard li { font-size: 1.2rem; margin-bottom: 8px; text-align: left; }
#leaderboard li .detective-name { font-weight: bold; color: #a5801b; }
#leaderboard li.top-1 .detective-name { color: #f7b733; text-shadow: 0 0 4px #f7b733; }

/* Interactive Elements */
#envelopeImg { width: 100%; max-width: 280px; cursor: pointer; transition: transform 0.3s ease, filter 0.3s ease; filter: drop-shadow(0 8px 12px rgba(247, 201, 72, 0.4)); user-select: none; }
#envelopeImg:hover, #envelopeImg:focus { transform: scale(1.08); filter: drop-shadow(0 12px 20px rgba(255, 211, 71, 0.6)); outline: none; }

#senhaArea { margin-top: 25px; display: none; flex-direction: row; align-items: center; justify-content: center; gap: 10px; width: clamp(300px, 90vw, 450px); }
.password-wrapper { position: relative; flex-grow: 1; }
#senhaInput { padding-right: 12px; }
#toggle-password { position: static; transform: none; cursor: pointer; color: #f7c948; font-size: 1.8rem; margin-top: 15px; }
.challenge-text { margin-top: 15px; font-style: italic; color: #d1a523; text-shadow: 1px 1px 2px #000; }

/* Secret Content and Forms */
#conteudoSecreto { display: none; width: 100vw; height: 100vh; position: fixed; top: 0; left: 0; background-color: #000; z-index: 2000; padding: 0; }
#videoSecreto { width: 100%; height: 100%; object-fit: contain; }
#registroArea { width: clamp(300px, 90vw, 500px); background-color: rgba(20, 15, 30, 0.85); padding: 25px; border-radius: 10px; border: 1px solid #f7c948; box-shadow: 0 0 20px #f7c94833; margin-top: 20px; }

/* Inputs and Buttons */
input[type="text"], input[type="password"] { width: 100%; padding: 12px; font-size: 1.1rem; border-radius: 10px; border: 1px solid transparent; outline: none; box-shadow: inset 0 0 10px #f7c948aa; background-color: #2a221a; color: #f7e9a1; font-family: 'Unica One', cursive; transition: box-shadow 0.3s, border-color 0.3s; }
input[type="text"]:focus, input[type="password"]:focus { box-shadow: inset 0 0 12px #ffed4b, 0 0 10px #f7c94888; border-color: #f7c948; }

button { margin-top: 15px; width: 100%; padding: 12px 0; border-radius: 15px; border: none; font-family: 'Unica One', cursive; font-weight: 900; font-size: 1.2rem; color: #3e2900; background: linear-gradient(90deg, #ffed4b 0%, #d1a523 100%); box-shadow: 0 4px 12px #b38700bb; cursor: pointer; transition: all 0.3s ease; }
button:hover, button:focus { transform: scale(1.03); box-shadow: 0 6px 16px #b38700dd; filter: brightness(1.1); }
.cancel-btn { background: linear-gradient(90deg, #6c757d 0%, #495057 100%); box-shadow: 0 4px 12px #212529bb; color: #fff; }


.codex-entry-point {
    margin-top: 30px;
    display: flex;
    justify-content: center;
}

.codex-entry-button {
    padding: 15px 30px;
    font-family: 'Unica One', cursive;
    font-size: 1.5rem;
    color: #fff;
    background: linear-gradient(45deg, #00ffff, #ff00ff);
    border: none;
    border-radius: 10px;
    text-decoration: none;
    text-shadow: 0 0 5px #fff;
    box-shadow: 0 0 15px #00ffff, 0 0 25px #ff00ff;
    transition: all 0.3s ease;
}

.codex-entry-button:hover {
    transform: scale(1.1);
    box-shadow: 0 0 25px #00ffff, 0 0 40px #ff00ff, inset 0 0 10px #fff;
}

/* --- ADMIN FOOTER (NEW & RESPONSIVE) --- */
#secret-footer {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    background: rgba(10, 5, 2, 0.95);
    padding: 15px;
    box-shadow: 0 -5px 15px rgba(0,0,0,0.6);
    border-top: 2px solid #f7c948;
    z-index: 1500;
    display: flex;
    justify-content: center; /* Center the content */
    align-items: center;
}

.admin-controls {
    display: flex;
    flex-wrap: wrap; /* Allow items to wrap on smaller screens */
    justify-content: center;
    align-items: center;
    gap: 20px;
    width: 100%;
    max-width: 800px; /* Max width for the controls */
}

.time-controls, .audio-controls {
    display: flex;
    align-items: center;
    gap: 10px;
    border: 1px solid #f7c94833;
    padding: 10px;
    border-radius: 8px;
    background-color: rgba(0,0,0,0.2);
}

#secret-footer p {
    margin: 0;
    color: #f7c948;
    font-style: italic;
    font-size: 0.9rem;
    white-space: nowrap;
}

#secret-footer select, #secret-footer button {
    width: auto;
    padding: 8px 15px;
    margin-top: 0;
    font-size: 0.9rem;
}

#secret-footer #volume-toggle-btn {
    background: none;
    border: none;
    color: #f0e9e0;
    font-size: 24px;
    cursor: pointer;
    padding: 0;
    margin: 0;
    width: auto; 
    box-shadow: none;
}

#secret-footer #volume-toggle-btn:hover { 
    color: #ffed4b; 
    transform: scale(1.1);
    box-shadow: none;
    filter: none;
}

#close-secret-footer {
    position: absolute;
    top: -35px;
    right: 20px;
    background: none;
    border: none;
    color: #f7c948;
    font-size: 2rem;
    cursor: pointer;
    padding: 0;
    box-shadow: none;
    text-shadow: 0 0 5px #000;
}

/* --- MATERIALS PAGE --- */
.materials-header {
    text-align: center;
    padding: 40px 20px;
    background-color: rgba(10, 8, 18, 0.6);
    margin-bottom: 30px;
}

.materials-header h1 {
    margin: 0;
    font-size: 2.8rem;
    color: #f7e9a1;
    text-shadow: 0 0 15px #f7c948;
}

.materials-header p {
    margin: 5px 0 0;
    font-size: 1.2rem;
    color: #d1a523;
    font-style: italic;
}

.materials-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

.materials-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 30px;
    padding-bottom: 50px;
}

.material-card {
    background: rgba(20, 15, 30, 0.7);
    border: 1px solid #f7c948;
    border-radius: 10px;
    padding: 25px;
    display: flex;
    flex-direction: column;
    box-shadow: 0 5px 20px rgba(0,0,0,0.4), inset 0 0 10px #f7c94833;
    transition: transform 0.3s, box-shadow 0.3s;
}

.material-card:hover {
    transform: translateY(-10px);
    box-shadow: 0 15px 30px rgba(0,0,0,0.6), inset 0 0 15px #f7c94855;
}

.material-card h2 {
    font-size: 1.6rem;
    color: #f7e9a1;
    margin: 0 0 15px;
    border-bottom: 1px solid #f7c948;
    padding-bottom: 10px;
}

.material-card p {
    font-family: 'Roboto', sans-serif;
    font-size: 1rem;
    line-height: 1.6;
    color: #e0d8cc;
    flex-grow: 1;
}

.read-more-btn {
    display: inline-block;
    margin-top: 20px;
    padding: 10px 20px;
    background: #d1a523;
    color: #140f1e;
    text-decoration: none;
    border-radius: 5px;
    font-weight: bold;
    text-align: center;
    transition: background-color 0.3s, transform 0.3s;
}

.read-more-btn:hover {
    background-color: #f7c948;
    transform: scale(1.05);
}

.page-footer {
    text-align: center;
    padding: 30px 20px;
    margin-top: 40px;
    background-color: rgba(10, 8, 18, 0.8);
}

.navigation-buttons {
    display: flex;
    justify-content: center;
    gap: 1rem;
}

.navigation-buttons button {
    margin: 0;
    width: auto;
    padding: 12px 25px;
}

/* --- SUPER CODEX (WORD SEARCH) STYLES --- */
@keyframes animated-gradient {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

@keyframes neon-pulse {
  0%, 100% {
    text-shadow: 0 0 5px #ff00ff, 0 0 10px #ff00ff, 0 0 20px #ff00ff, 0 0 40px #ff00ff, 0 0 70px #ff00ff;
  }
  50% {
    text-shadow: 0 0 10px #00ffff, 0 0 20px #00ffff, 0 0 40px #00ffff, 0 0 80px #00ffff, 0 0 120px #00ffff;
  }
}

@keyframes found-word-blast {
  0% {
    transform: scale(1);
    box-shadow: 0 0 5px #ff00ff, 0 0 10px #ff00ff;
  }
  50% {
    transform: scale(1.2);
    box-shadow: 0 0 20px #00ffff, 0 0 40px #00ffff, 0 0 60px #ff00ff;
  }
  100% {
    transform: scale(1);
    box-shadow: 0 0 5px #ff00ff, 0 0 10px #ff00ff;
  }
}

body.super-codex {
    background-image: none; /* Prevents main background from showing */
    background-color: #0d0c15; /* Fallback color */
    background: linear-gradient(45deg, #2c004e, #4a007a, #0d0c15, #4a007a);
    background-size: 400% 400%;
    animation: animated-gradient 15s ease infinite;
}

.ws-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    width: 100vw;
    padding: 10px; /* Reduced padding for smaller screens */
    background: transparent;
}

.ws-header {
    text-align: center;
    padding-bottom: 15px;
}

.ws-title {
    font-family: 'Orbitron', sans-serif;
    font-size: clamp(2rem, 8vw, 3.5rem); /* Responsive font size */
    color: #fff;
    animation: neon-pulse 4s ease-in-out infinite;
    margin: 0;
}

.ws-main {
    flex-grow: 1;
    display: flex;
    gap: 20px;
    width: 100%;
    margin: 0 auto;
    overflow: hidden; /* Prevents inner content from overflowing */
}

.ws-game-panel {
    flex: 1.5; /* 60% of the space */
    display: flex;
    justify-content: center;
    align-items: center;
    background: rgba(0,0,0,0.3);
    border-radius: 15px;
    padding: 10px; /* Adjusted padding */
    border: 2px solid #ff00ff;
    box-shadow: 0 0 20px #ff00ff88;
}

.ws-puzzle {
    display: grid;
    grid-template-columns: repeat(20, 1fr);
    gap: 2px; /* Reduced gap */
    background-color: transparent;
    max-width: 100%;
}

.ws-puzzle .puzzle-cell {
    width: clamp(12px, 4.5vw, 35px);   /* Aggressive scaling for mobile */
    height: clamp(12px, 4.5vw, 35px);  /* Aggressive scaling for mobile */
    background-color: rgba(14, 1, 31, 0.5);
    color: #b39ddb;
    display: flex;
    justify-content: center;
    align-items: center;
    font-family: 'Orbitron', sans-serif;
    font-size: clamp(0.5rem, 2.5vw, 1.2rem); /* Aggressive font scaling */
    cursor: pointer;
    user-select: none;
    transition: all 0.2s ease;
    border-radius: 3px;
    border: 1px solid transparent;
}

.ws-puzzle .puzzle-cell:hover {
    border-color: #00ffff;
    box-shadow: 0 0 10px #00ffff;
    color: #00ffff;
}

.ws-puzzle .puzzle-cell.selected {
    background-color: #ff00ff;
    color: #fff;
    transform: scale(1.1);
    box-shadow: 0 0 15px #ff00ff, 0 0 25px #ff00ff;
}

.ws-puzzle .puzzle-cell.found {
    background-color: #7b1fa2;
    color: #fff;
    animation: found-word-blast 0.6s ease-in-out;
}

.ws-sidebar {
    flex: 1; /* 40% of the space */
    display: flex;
    flex-direction: column;
    background: rgba(0,0,0,0.3);
    border-radius: 15px;
    padding: 20px;
    border: 2px solid #00ffff;
    box-shadow: 0 0 20px #00ffff88;
}

.ws-sidebar-title {
    font-family: 'Unica One', cursive;
    font-size: clamp(1.8rem, 6vw, 2.5rem); /* Responsive font size */
    color: #fff;
    text-align: center;
    margin: 0 0 15px;
    text-shadow: 0 0 10px #00ffff;
}

.ws-word-list-wrapper {
    flex-grow: 1;
    overflow-y: auto; 
    padding-right: 10px;
}

.ws-word-list {
    list-style-type: none;
    padding: 0;
    margin: 0;
    font-size: clamp(1rem, 3.5vw, 1.4rem);
    column-count: 2;
    column-gap: 20px;
}

.ws-word-list li {
    margin-bottom: 10px;
    color: #b39ddb;
    transition: all 0.3s ease;
    text-shadow: 1px 1px 2px #000;
}

.ws-word-list li.found {
    text-decoration: line-through;
    color: #00ffff;
    font-weight: bold;
    text-shadow: 0 0 8px #00ffff;
}

.ws-controls {
    margin-top: 15px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.ws-controls button {
    margin-top: 0;
    padding: 12px;
    font-size: 1.1rem;
    background: linear-gradient(45deg, #6a00c9, #ff00ff);
    box-shadow: 0 4px 15px #00000088;
    border: 1px solid #ff00ff;
    transition: all 0.3s ease;
}

.ws-controls button:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 20px #000000cc, 0 0 15px #ff00ff;
    filter: brightness(1.2);
}

/* --- Responsive for Super Codex --- */
@media (max-width: 900px) {
    .ws-main {
        flex-direction: column;
        gap: 15px;
    }
    .ws-game-panel, .ws-sidebar {
        flex: none;
        width: 100%;
        max-height: 50vh;
    }
    .ws-sidebar {
        max-height: 40vh; /* Adjust height for word list on mobile */
    }
    .ws-puzzle {
        max-height: 100%;
    }
}

@media (max-width: 600px) {
    .ws-word-list {
        column-count: 2; /* Keep two columns for better space usage */
    }
}

/* Responsive adjustments */
@media (max-width: 600px) {
    .admin-controls {
        flex-direction: column;
        gap: 15px;
    }
    .time-controls, .audio-controls {
        width: 100%;
        justify-content: space-between;
    }
    #secret-footer {
        padding: 10px;
    }

    .navigation-buttons {
        flex-direction: column;
        align-items: center;
    }

    .navigation-buttons button {
        width: 80%;
        margin-bottom: 10px;
    }

    .page-footer {
        bottom: 120px; /* Adjust space for stacked buttons and admin icon */
    }
}

.video-card {
    padding: 0;
    overflow: hidden;
}

.video-card iframe {
    width: 100%;
    height: 100%;
    border: 0;
    aspect-ratio: 16 / 9;
}
