* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
    min-height: 100vh;
    color: #ffffff;
    display: flex;
    flex-direction: column;
}

/* Background canvas full-screen */
#bg-canvas {
    position: fixed;
    inset: 0;
    width: 100vw;
    height: 100vh;
    z-index: 0;
    pointer-events: none;
}

.container {
    max-width: 800px;
    margin: 0 auto;
    padding: 20px;
    flex: 1 0 auto;
}

/* Acrylic panel look: used for game-area, tip-section, guess-items, and table */
.acrylic {
    background: linear-gradient(135deg, rgba(255,255,255,0.03), rgba(255,255,255,0.015));
    backdrop-filter: blur(8px) saturate(120%);
    -webkit-backdrop-filter: blur(8px) saturate(120%);
    border: 1px solid rgba(255,255,255,0.04);
    box-shadow: 0 8px 30px rgba(2,6,23,0.6);
    border-radius: 12px;
}

.container.wide {
    max-width: 1200px;
}

footer {
    margin-top: auto;
    padding: 10px 0;
}

header {
    text-align: center;
    margin-bottom: 30px;
    color: #ffffff;
}

.mode-toggle {
    position: relative;
    display: inline-grid;
    grid-template-columns: 1fr 1fr;
    gap: 0;
    margin: 8px 0 12px;
    border: 2px solid #4ecdc4;
    border-radius: 10px;
    overflow: hidden;
    background: rgba(78,205,196,0.08);
}

.mode-btn {
    padding: 10px 14px;
    background: transparent;
    color: #4ecdc4;
    border: none;
    cursor: pointer;
    font-weight: 700;
    position: relative;
    z-index: 2;
    transition: color 0.25s ease, transform 0.15s ease;
    text-shadow: 0 0 6px rgba(78,205,196,0.5);
}

.mode-btn.active {
    color: #1a1a2e;
    text-shadow: none;
}

.mode-btn:hover {
    transform: translateY(-1px);
}

.mode-indicator {
    position: absolute;
    top: 0;
    left: 0;
    width: 50%;
    height: 100%;
    background: linear-gradient(135deg, #4ecdc4, #45b7d1);
    box-shadow: 0 0 18px rgba(78,205,196,0.6), 0 0 36px rgba(69,183,209,0.4);
    border-radius: 8px;
    transform: translateX(0%);
    transition: transform 0.25s ease;
    z-index: 1;
}

.mode-toggle.shift-daily .mode-indicator {
    transform: translateX(100%);
}

.mode-description {
    margin-top: 8px;
    color: #b0f7ef;
    font-weight: 600;
}

.mode-info {
    margin-top: 6px;
    color: #b0f7ef;
    font-weight: 600;
}

/* Default (desktop/tablet): keep the control in the top-right */
.exercise-list-link {
    position: absolute;
    top: 16px;
    right: 24px;
    color: #4ecdc4;
    text-decoration: none;
    font-weight: 700;
    background: rgba(78,205,196,0.12);
    border: 1px solid #4ecdc4;
    padding: 8px 12px;
    border-radius: 6px;
    transition: background 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
}

.exercise-list-link:hover {
    background: rgba(78,205,196,0.25);
    transform: translateY(-1px);
    box-shadow: 0 4px 10px rgba(78,205,196,0.25);
}

/* Table styles for list.html */
.table-wrapper {
    overflow-x: auto;
}

table.exercise-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 20px;
    background: linear-gradient(145deg, #1a1a2e, #2a2a3e);
    border: 1px solid #4a4a6a;
    border-radius: 8px;
}

table.exercise-table thead th {
    position: sticky;
    top: 0;
    background: #2d2d44;
    color: #4ecdc4;
    text-align: left;
    padding: 12px;
    border-bottom: 1px solid #4a4a6a;
}

table.exercise-table td {
    padding: 12px;
    border-bottom: 1px solid #4a4a6a;
    color: #ffffff;
}

table.exercise-table td a {
    color: #4ecdc4;
    text-decoration: underline;
}

table.exercise-table tr:hover {
    background: rgba(78,205,196,0.07);
}

header h1 {
    font-size: 3rem;
    margin-bottom: 10px;
    background: linear-gradient(45deg, #4ecdc4, #1df3e4, #07cdc0, #4ecdc4);
    background-size: 300% 300%;
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    text-shadow: 0 0 10px rgba(78,205,196,0.45), 0 0 20px rgba(69,183,209,0.35);
    animation: gradientShift 3s ease infinite, titleGlow 2.6s ease-in-out infinite alternate;
}

@keyframes gradientShift {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

@keyframes titleGlow {
    0%   { text-shadow: 0 0 8px rgba(78,205,196,0.35), 0 0 16px rgba(69,183,209,0.25); }
    100% { text-shadow: 0 0 14px rgba(78,205,196,0.6), 0 0 28px rgba(69,183,209,0.45); }
}

header p {
    font-size: 1.1rem;
    opacity: 0.9;
    color: #b0b0b0;
}

.game-area {
    background: linear-gradient(145deg, rgba(20,26,40,0.6), rgba(30,36,56,0.45));
    border-radius: 15px;
    padding: 30px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.4);
    border: 1px solid rgba(255,255,255,0.04);
    /* Allow smooth size transitions using max-height (slower for a smooth expand) */
    transition: padding 700ms cubic-bezier(.22,.9,.32,1), max-height 780ms cubic-bezier(.22,.9,.32,1), box-shadow 300ms ease;
}

/* After expansion, allow the panel to grow naturally with content */
.game-area:not(.compact) {
    max-height: none;
}

.game-area, .tip-section, .guess-item, table.exercise-table {
    /* add acrylic visuals */
    background: linear-gradient(145deg, rgba(255,255,255,0.03), rgba(255,255,255,0.015));
    backdrop-filter: blur(8px) saturate(120%);
    -webkit-backdrop-filter: blur(8px) saturate(120%);
    border: 1px solid rgba(255,255,255,0.04);
/* end block above */

/* Compact layout for when no guesses are present: smaller box and vertical centering */
.game-area.compact {
    /* Compact: small max-height so collapsed state animates from/to this size */
    padding-top: 20px;
    padding-bottom: 20px;
    padding-left: 20px;
    padding-right: 20px;
    max-height: 120px; /* small value to create ~20px spacing above/below input */
    /* allow dropdowns to overflow the compact container so suggestions aren't clipped */
    overflow: visible;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

/* Remove extra spacing inside compact mode so top and bottom distances match */
.game-area.compact .input-section {
    margin: 0; /* override default bottom margin */
}

.game-area.compact .input-group label {
    margin-bottom: 0; /* reduce label spacing for visual balance */
}

.game-area.compact #exercise-input {
    padding-top: 10px;
    padding-bottom: 10px;
}

/* Animate input padding so the input visually moves smoothly */
#exercise-input {
    transition: padding 300ms ease, box-shadow 200ms ease, border-color 200ms ease;
}

/* Controls for list page */
.list-controls {
    margin-bottom: 15px;
}

.search-bar {
    display: flex;
    gap: 8px;
}

#list-search-input {
    flex: 1;
    padding: 10px 12px;
    border: 2px solid #4a4a6a;
    border-radius: 8px;
    background: #1a1a2e;
    color: #ffffff;
    font-size: 14px;
}

.search-options {
    position: relative;
}

#search-options-btn {
    padding: 10px 12px;
    background: #1a1a2e;
    color: #4ecdc4;
    border: 2px solid #4ecdc4;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
}

.search-options-menu {
    position: absolute;
    right: 0;
    top: calc(100% + 6px);
    background: #1a1a2e;
    border: 1px solid #4a4a6a;
    border-radius: 8px;
    box-shadow: 0 10px 20px rgba(0,0,0,0.4);
    padding: 8px 10px;
    min-width: 200px;
    display: none;
    z-index: 10;
}

.search-options-menu .option-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 4px;
    color: #ffffff;
}

.search-options-menu .filter-title {
    font-weight: 700;
    color: #4ecdc4;
    margin: 6px 0;
}

.search-options-menu .divider {
    height: 1px;
    background: #4a4a6a;
    margin: 8px 0;
}

.search-options-menu .filter-group {
    margin-bottom: 8px;
}

.search-options-menu .checkboxes {
    display: grid;
    grid-template-columns: repeat(2, minmax(120px, 1fr));
    gap: 6px 12px;
}

.checkbox-item {
    display: flex;
    align-items: center;
    gap: 6px;
    color: #ffffff;
    font-size: 0.95rem;
}

.filters-actions {
    margin-top: 10px;
    display: flex;
    justify-content: flex-end;
}

.clear-filters-btn {
    padding: 8px 10px;
    background: transparent;
    color: #ffd93d;
    border: 1px solid #ffd93d;
    border-radius: 6px;
    cursor: pointer;
}

.clear-filters-btn:hover {
    background: rgba(255, 217, 61, 0.15);
}

#list-search-input:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.input-section {
    margin-bottom: 30px;
}

.input-group {
    margin-bottom: 15px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.input-group label {
    font-weight: 600;
    color: #ffffff;
    margin-bottom: 5px;
    display: block;
}

#exercise-input {
    padding: 12px 15px;
    border: 2px solid #4a4a6a;
    border-radius: 8px;
    font-size: 16px;
    background: #1a1a2e;
    color: #ffffff;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

#exercise-input:focus {
    outline: none;
    border-color: #4ecdc4;
    box-shadow: 0 0 0 3px rgba(78, 205, 196, 0.2);
}

.autocomplete-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: #1a1a2e;
    border: 2px solid #4a4a6a;
    border-top: none;
    border-radius: 0 0 8px 8px;
    max-height: 200px;
    overflow-y: auto;
    z-index: 9999; /* ensure suggestions render above the game box */
    box-shadow: 0 10px 30px rgba(0,0,0,0.6);
    display: none;
}

.autocomplete-item {
    padding: 12px 15px;
    color: #ffffff;
    cursor: pointer;
    border-bottom: 1px solid #4a4a6a;
    transition: background-color 0.2s ease;
}

.autocomplete-item:hover,
.autocomplete-item.highlighted {
    background: #4ecdc4;
    color: #1a1a2e;
}

.autocomplete-item:last-child {
    border-bottom: none;
}

.input-container {
    position: relative;
    flex: 1;
}

#guess-btn {
    padding: 12px 25px;
    background: linear-gradient(135deg, #4ecdc4, #45b7d1);
    color: #1a1a2e;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

#guess-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(78, 205, 196, 0.4);
}

#guess-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.attempts-counter {
    text-align: center;
    font-weight: 600;
    color: #ffffff;
}

.feedback-section h3 {
    margin-bottom: 20px;
    color: #ffffff;
    border-bottom: 2px solid #4a4a6a;
    padding-bottom: 10px;
}

.guess-item {
    background: linear-gradient(145deg, #2a2a3e, #3a3a4e);
    border-radius: 10px;
    padding: 20px;
    margin-bottom: 15px;
    border-left: 4px solid #4ecdc4;
    transition: transform 0.2s ease;
    border: 1px solid #4a4a6a;
}

.guesses-container {
    transition: opacity 520ms ease, transform 620ms cubic-bezier(.22,.9,.32,1);
}

.guess-item:hover {
    transform: translateX(5px);
    box-shadow: 0 5px 15px rgba(0,0,0,0.3);
}

.guess-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.exercise-name {
    font-size: 1.3rem;
    font-weight: 700;
    color: #ffffff;
}

.correct {
    color: #4ecdc4;
    font-weight: 600;
}

.feedback-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
}

.feedback-item {
    background: linear-gradient(145deg, #1a1a2e, #2a2a3e);
    padding: 15px;
    border-radius: 8px;
    border: 1px solid #4a4a6a;
}

.feedback-label {
    font-weight: 600;
    margin-bottom: 8px;
    color: #ffffff;
}

.feedback-bar {
    height: 8px;
    background: #1b1b1b;
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 5px;
}

.feedback-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 0.5s ease;
}

.feedback-fill.excellent {
    background: linear-gradient(90deg, #4ecdc4, #45b7d1);
}

.feedback-fill.good {
    background: linear-gradient(90deg, #ffd93d, #ff6b6b);
}

.feedback-fill.poor {
    background: linear-gradient(90deg, #ff6b6b, #ee5a52);
}

.feedback-text {
    font-size: 0.9rem;
    color: #ffffff;
}

.tip-section {
    background: linear-gradient(135deg, #2d2d44, #3a3a5c);
    border-radius: 10px;
    padding: 20px;
    margin-top: 20px;
    border-left: 4px solid #4ecdc4;
    border: 1px solid #4a4a6a;
}

.tip-section h3 {
    margin-bottom: 10px;
    color: #4ecdc4;
}

#tip-text {
    font-size: 1.1rem;
    color: #ffffff;
    line-height: 1.5;
}

.game-over {
    text-align: center;
    padding: 30px;
    background: linear-gradient(135deg, #4ecdc4, #45b7d1);
    border-radius: 10px;
    color: #1a1a2e;
    margin-top: 20px;
}

.game-over h3 {
    font-size: 1.5rem;
    margin-bottom: 20px;
}

.daily-countdown {
    font-weight: 700;
    margin-bottom: 16px;
    color: #1a1a2e;
}

#new-game-btn {
    padding: 12px 30px;
    background: #1a1a2e;
    color: #4ecdc4;
    border: 2px solid #4ecdc4;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s ease, background-color 0.2s ease;
}

#new-game-btn:hover {
    transform: translateY(-2px);
    background: #4ecdc4;
    color: #1a1a2e;
}

.hint-icon {
    display: inline-block;
    width: 20px;
    height: 20px;
    margin-right: 8px;
    border-radius: 50%;
    text-align: center;
    line-height: 20px;
    font-size: 12px;
    font-weight: bold;
}

.hint-icon.correct {
    background: #4ecdc4;
    color: #1a1a2e;
}

.hint-icon.partial {
    background: #ffd93d;
    color: #1a1a2e;
}

.hint-icon.incorrect {
    background: #ff6b6b;
    color: #ffffff;
}

@media (max-width: 600px) {
    .container {
        padding: 10px;
    }
    
    header h1 {
        font-size: 2rem;
    }
    
    /* Ensure header has room for the link under the title */
    header {
        padding-top: 8px;
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 8px;
        position: relative;
    }
    
    .input-group {
        flex-direction: column;
        align-items: stretch;
    }
    
    .feedback-grid {
        grid-template-columns: 1fr;
    }

    /* Make the back/exercise list link more prominent and easier to tap on mobile */
    .exercise-list-link {
        position: static !important;
        display: block;
        width: auto;
        margin: 0 auto 12px auto;
        padding: 12px 16px;
        font-size: 16px;
        border-radius: 8px;
        transform: none !important;
        box-shadow: none;
        z-index: 2;
        text-align: center;
    }

    /* place title first, mode-toggle next, then the link below the title */
    header h1 { order: 1; }
    .mode-toggle { order: 2; }
    .exercise-list-link { order: 3; }

    /* Ensure hover/active transforms don't move the link on small screens */
    .exercise-list-link:hover {
        transform: none !important;
        box-shadow: none !important;
    }

    /* Make table responsive: allow horizontal scroll and slightly reduce font size for fitting */
    .table-wrapper {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    table.exercise-table td, table.exercise-table th {
        padding: 8px;
        font-size: 13px;
    }

    /* Responsive stacked table rows for narrow screens: show data-labels */
    table.exercise-table thead { display: none; }
    table.exercise-table, table.exercise-table tbody, table.exercise-table tr, table.exercise-table td { display: block; width: 100%; }
    table.exercise-table tr { margin-bottom: 12px; border-bottom: 1px solid rgba(255,255,255,0.03); padding-bottom: 8px; }
    table.exercise-table td { padding: 6px 8px; text-align: left; }
    table.exercise-table td::before { content: attr(data-label) ": "; font-weight: 700; color: #4ecdc4; display: inline-block; width: 120px; }

    /* Increase tap target for buttons */
    #search-options-btn, #new-game-btn, #guess-btn {
        padding: 12px 18px;
        font-size: 16px;
    }
}
