/* --- Global Styles & Variables --- */
:root {
    --background-color: #f4f7f9;
    --text-color: #333;
    --primary-color: #007aff;
    --secondary-color: #6c757d;
    --header-bg: linear-gradient(135deg, #007aff, #0056b3);
    --card-bg: #ffffff;
    --shadow-light: rgba(0, 0, 0, 0.08);
    --shadow-medium: rgba(0, 0, 0, 0.15);
    --success-color: #28a745;
    --danger-color: #dc3545;
    --font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

.dark-mode {
    --background-color: #1c1c1e;
    --text-color: #f5f5f7;
    --primary-color: #0a84ff;
    --secondary-color: #8e8e93;
    --header-bg: linear-gradient(135deg, #0a84ff, #004c99);
    --card-bg: #2c2c2e;
    --shadow-light: rgba(0, 0, 0, 0.25);
    --shadow-medium: rgba(0, 0, 0, 0.4);
}

/* --- Base & Layout --- */
body {
    font-family: var(--font-family);
    background-color: var(--background-color);
    color: var(--text-color);
    margin: 0;
    padding-bottom: 80px; /* Space for the dock */
    transition: background-color 0.3s, color 0.3s;
}

header {
    background: var(--header-bg);
    color: white;
    text-align: center;
    padding: 1.5rem 1rem;
    box-shadow: 0 2px 4px var(--shadow-light);
    position: relative;
}

header h1 {
    margin: 0;
    font-size: 2.5rem;
    font-weight: 600;
}

.controls {
    position: absolute;
    top: 50%;
    right: 20px;
    transform: translateY(-50%);
    display: flex;
    align-items: center;
    gap: 15px;
}

#theme-switcher, .language-switcher button {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    cursor: pointer;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    font-size: 1.2rem;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: background-color 0.2s;
}

#theme-switcher:hover, .language-switcher button:hover {
    background: rgba(255, 255, 255, 0.3);
}

.language-switcher {
    display: flex;
    align-items: center;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 20px;
    padding: 2px;
}

.language-switcher button {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: transparent;
}

.language-switcher button.active {
    background: var(--primary-color);
}

.language-switcher span {
    color: rgba(255, 255, 255, 0.5);
}

main {
    position: relative;
    width: 100%;
    height: calc(100vh - 100px - 80px); /* Full height minus header and footer/dock */
    overflow: hidden;
}

footer {
    background: var(--card-bg);
    border-top: 1px solid var(--shadow-light);
    text-align: center;
    padding: 1rem 0;
    position: fixed;
    bottom: 60px; /* Above the dock */
    width: 100%;
    font-size: 0.9rem;
    color: var(--secondary-color);
    display: none; /* Initially hidden, shown when no apps are open */
}

/* --- App Dock --- */
#app-dock {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    background-color: var(--card-bg);
    box-shadow: 0 -2px 10px var(--shadow-light);
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 5px 0;
    z-index: 1000;
}

.dock-icon {
    background: none;
    border: none;
    text-align: center;
    cursor: pointer;
    padding: 10px 15px;
    border-radius: 8px;
    transition: background-color 0.2s;
}

.dock-icon:hover {
    background-color: var(--background-color);
}

.dock-icon i {
    font-size: 2rem;
    color: var(--primary-color);
}

.dock-icon span {
    display: block;
    font-size: 0.75rem;
    margin-top: 5px;
    color: var(--text-color);
}

/* --- App Windows --- */
.app-window {
    position: absolute;
    top: 5%;
    left: 10%;
    width: 80%;
    max-width: 800px;
    height: 80vh;
    background: var(--card-bg);
    border-radius: 12px;
    box-shadow: 0 10px 30px var(--shadow-medium);
    display: flex;
    flex-direction: column;
    z-index: 100;
    resize: both;
    overflow: auto;
    min-width: 320px;
    min-height: 250px;
}

.window-header {
    background: var(--header-bg);
    color: white;
    padding: 10px 15px;
    cursor: move;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-top-left-radius: 12px;
    border-top-right-radius: 12px;
}

.window-title {
    font-weight: 600;
}

.close-btn {
    background: var(--danger-color);
    color: white;
    border: none;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1rem;
    line-height: 24px;
    text-align: center;
}

.window-body {
    flex-grow: 1;
    padding: 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

/* --- General UI Elements --- */
.btn {
    background-color: var(--primary-color);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    transition: background-color 0.2s, transform 0.1s;
}

.btn:hover {
    opacity: 0.9;
}

.btn:active {
    transform: scale(0.98);
}

.btn.hide, .hide {
    display: none;
}

/* --- Tic-Tac-Toe --- */
.tictactoe-board {
    display: grid;
    grid-template-columns: repeat(3, 100px);
    grid-template-rows: repeat(3, 100px);
    gap: 10px;
    margin-bottom: 20px;
}

.tictactoe-cell {
    width: 100px;
    height: 100px;
    background-color: var(--background-color);
    border-radius: 8px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 3rem;
    font-weight: bold;
    cursor: pointer;
}

.tictactoe-status {
    margin-bottom: 15px;
    font-size: 1.2rem;
    font-weight: 500;
}

/* --- Memory Game --- */
.memory-game-board {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
    width: 100%;
    max-width: 400px;
    aspect-ratio: 1/1;
}

.memory-card {
    background-color: transparent;
    perspective: 1000px;
    cursor: pointer;
}

.memory-card .card-face {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    transition: transform 0.6s;
    border-radius: 8px;
    display: flex;
    justify-content: center;
    align-items: center;
}

.memory-card .card-front {
    background-color: var(--primary-color);
    transform: rotateY(0deg);
}

.memory-card .card-back {
    background-color: var(--secondary-color);
    color: white;
    font-size: 2rem;
    transform: rotateY(180deg);
}

.memory-card.flipped .card-front {
    transform: rotateY(-180deg);
}

.memory-card.flipped .card-back {
    transform: rotateY(0deg);
}

.memory-card.matched .card-back {
    background-color: var(--success-color);
}

.memory-game-controls {
    margin-bottom: 20px;
    font-size: 1.2rem;
    display: flex;
    gap: 20px;
    align-items: center;
}

/* --- Typing Test --- */
.typing-test-container {
    width: 100%;
    max-width: 700px;
    font-size: 1.2rem;
}

.quote {
    margin-bottom: 20px;
    background-color: var(--background-color);
    padding: 20px;
    border-radius: 8px;
    line-height: 1.8;
    letter-spacing: 1px;
}

.quote span.correct {
    color: var(--success-color);
}

.quote span.incorrect {
    color: var(--danger-color);
    text-decoration: underline;
}

.input-field {
    width: 100%;
    padding: 15px;
    border: 2px solid var(--secondary-color);
    border-radius: 8px;
    font-size: 1.2rem;
    resize: none;
}

.typing-test-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 15px;
}

/* --- Personality Test --- */
#question-container, #result-container {
    width: 100%;
}

#question-header {
    margin-bottom: 30px;
}

.options-container {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.option {
    padding: 15px;
    border: 1px solid var(--secondary-color);
    border-radius: 8px;
    cursor: pointer;
    transition: background-color 0.2s;
}

.option:hover {
    background-color: var(--background-color);
}

.option input[type="radio"] {
    margin-right: 10px;
}

.result-bar-container {
    margin-bottom: 15px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.trait-name {
    width: 100px;
}

.result-bar {
    flex-grow: 1;
    height: 25px;
    background-color: var(--background-color);
    border-radius: 5px;
}

.result-bar-fill {
    height: 100%;
    background-color: var(--primary-color);
    border-radius: 5px;
    transition: width 0.5s ease-in-out;
}

/* --- Reaction Test --- */
.reaction-test-container {
    text-align: center;
}

.reaction-box {
    width: 100%;
    height: 200px;
    margin-top: 20px;
    border-radius: 12px;
    color: white;
    font-size: 2rem;
    font-weight: bold;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    transition: background-color 0.2s;
}

.reaction-box.waiting {
    background-color: var(--danger-color);
}

.reaction-box.ready {
    background-color: var(--success-color);
}

.reaction-box.too-soon, .reaction-box.round-end {
    background-color: var(--secondary-color);
}

/* --- Simon Says --- */
.simon-says-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
}

.simon-grid {
    display: grid;
    grid-template-columns: 150px 150px;
    grid-template-rows: 150px 150px;
    gap: 20px;
}

.simon-button {
    border-radius: 15px;
    cursor: pointer;
    transition: filter 0.2s;
    opacity: 0.6;
}

.simon-button.green { background-color: #28a745; }
.simon-button.red { background-color: #dc3545; }
.simon-button.yellow { background-color: #ffc107; }
.simon-button.blue { background-color: #007bff; }

.simon-button.active {
    opacity: 1;
    transform: scale(1.05);
    box-shadow: 0 0 20px currentColor;
}

/* --- Trivia Quiz --- */
#quiz-container, #start-screen, #results-container {
    width: 100%;
    text-align: center;
}

#progress-container {
    width: 100%;
    height: 10px;
    background-color: var(--background-color);
    border-radius: 5px;
    margin-bottom: 20px;
}

#progress-bar {
    height: 100%;
    width: 0%;
    background-color: var(--primary-color);
    border-radius: 5px;
    transition: width 0.3s ease;
}

#score-container {
    text-align: right;
    margin-bottom: 10px;
    font-weight: bold;
}

.btn-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    margin-top: 20px;
}

.btn.correct {
    background-color: var(--success-color);
}

.btn.wrong {
    background-color: var(--danger-color);
}

/* --- Responsive Design --- */
@media (max-width: 768px) {
    header h1 { font-size: 2rem; }
    .controls { gap: 10px; }
    .app-window {
        top: 0; left: 0; width: 100%; height: 100%; border-radius: 0;
    }
    .btn-grid { grid-template-columns: 1fr; }
    .tictactoe-board { grid-template-columns: repeat(3, 80px); grid-template-rows: repeat(3, 80px); }
    .tictactoe-cell { width: 80px; height: 80px; }
    .simon-grid { grid-template-columns: 100px 100px; grid-template-rows: 100px 100px; }
}
