:root {
    --teal-bg: #0b3d4f;
    --gold-text: #c4a35a;
    --beige-card: #f5f1e8;
    --light-bg: #ffffff;
    --dark-text: #333333;
    --border-gold: #c4a35a;
    --overlay-bg: rgba(245, 241, 232, 0.9);
    --input-bg: #e0dccc;
    --btn-hover-bg: #f0f0f0;
    --btn-active-transform: scale(0.98);
    --progress-bar-track: rgba(245, 241, 232, 0.3);
    --progress-bar-fill: var(--gold-text);
    --disabled-theme-bg: #e0e0e0;
    --disabled-theme-text: #a0a0a0;
    --sticky-header-bg: var(--beige-card); 
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Lato', sans-serif;
    background-color: var(--teal-bg);
    color: var(--gold-text);
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 95vh;
    overflow: hidden;
    position: relative;
    perspective: 1000px;
}

.screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 95%; 
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 20px;
    background-color: var(--teal-bg);
    opacity: 0;
    visibility: hidden;
    transform: scale(0.98);
    transition: opacity 0.5s ease-in-out, visibility 0s linear 0.5s, transform 0.5s ease-in-out;
    overflow-y: auto;
}
#title-screen, #theme-select-screen { 
    justify-content: center;
}
#rules-screen { 
    justify-content: center; 
    align-items: center; 
    /* --- UPDATED --- Add padding to prevent content from being hidden by the fixed footer */
    padding-bottom: 100px; 
}


.screen.active {
    opacity: 1;
    visibility: visible;
    transform: scale(1);
    transition: opacity 0.5s ease-in-out, visibility 0s linear 0s, transform 0.5s ease-in-out;
    z-index: 1;
}

.content-center {
    text-align: center;
}

.game-title {
    font-family: 'Playfair Display', serif;
    font-size: 3.5rem;
    line-height: 1.2;
    margin-bottom: 1rem;
    color: var(--gold-text);
}

.divider {
    height: 1px;
    background-color: var(--gold-text);
    width: 200px;
    margin: 1rem auto;
}

.card-divider {
     width: 100%;
     margin: 0.8rem 0;
}

.sub-title {
    font-size: 1rem;
    letter-spacing: 2px;
    margin-bottom: 1.5rem;
    color: var(--gold-text);
}

.landing-icon {
    font-size: 2.5rem;
    display: block;
    margin: 0 auto 2rem auto;
    color: var(--gold-text);
}

@keyframes pulse {
  0% { transform: scale(1); opacity: 0.6; }
  50% { transform: scale(1.25); opacity: 1; }
  100% { transform: scale(1); opacity: 0.6;}
}

@keyframes subtleBounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-3px); }
}

@keyframes moreBounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-5px); }
}

@keyframes downArrowHover {
    0%   { transform: translateX(-50%) translateY(0px) scale(1); }
    50%  { transform: translateX(-50%) translateY(5px) scale(1.1); }
    100% { transform: translateX(-50%) translateY(0px) scale(1); }
}


.btn {
    background-color: var(--light-bg);
    color: var(--dark-text);
    border: none;
    padding: 12px 30px;
    border-radius: 25px;
    font-size: 1rem;
    font-weight: bold;
    cursor: pointer;
    transition: background-color 0.3s ease, transform 0.2s ease-out;
    display: inline-block;
    flex-shrink: 0; 
}

.btn:hover {
    background-color: var(--btn-hover-bg);
}
.btn:active {
    transform: var(--btn-active-transform);
}

#play-button:hover {
    background-color: var(--btn-hover-bg);
    animation: subtleBounce 0.4s ease-out;
}

#rules-action-button:hover {
    color: var(--gold-text);
    background-color: var(--btn-hover-bg);
    animation: moreBounce 0.4s ease-out;
}

.btn-secondary {
    background-color: transparent;
    border: 1px solid var(--gold-text);
    color: var(--gold-text);
    padding: 8px 20px;
    border-radius: 25px;
    transition: background-color 0.3s ease, transform 0.1s ease, color 0.3s ease, border-color 0.3s ease;
}
.btn-secondary:hover {
     background-color: rgba(196, 163, 90, 0.1);
}
.btn-secondary:active {
    transform: var(--btn-active-transform);
}
.btn-secondary.btn-small {
    padding: 5px 15px;
    font-size: 0.8rem;
    border-radius: 25px;
}
.btn-secondary:disabled {
    opacity: 0.5;
    cursor: default;
    pointer-events: none;
    color: #aaa;
    border-color: #aaa;
    background-color: transparent;
}
.btn-secondary:disabled:hover {
    background-color: transparent;
}

.card.rules-card {
    max-width: 750px;
    width: 90%; 
    min-height: 450px; 
    max-height: calc(100vh - 150px); 
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    background-color: var(--beige-card);
    color: var(--dark-text);
    border: 2px solid var(--border-gold);
    border-radius: 15px;
    display: flex;
    flex-direction: column; 
    margin-bottom: 20px; 
    overflow: hidden; 
}

.rules-card-header-fixed {
    padding: 30px 50px 0 50px; 
    background-color: var(--sticky-header-bg); 
    z-index: 5; 
    flex-shrink: 0; 
}
#rules-card-dynamic-title.card-title { 
    font-family: 'Playfair Display', serif;
    color: var(--gold-text);
    text-align: center;
    font-size: 1.8rem;
    margin-bottom: 10px;
}
.rules-card-header-fixed .card-divider {
    margin-top: 0; 
}


.rules-content-area-scrollable {
    flex-grow: 1; 
    overflow-y: auto;
    padding: 0 35px 30px 50px; 
}
.rules-content-area-scrollable::-webkit-scrollbar { width: 8px; }
.rules-content-area-scrollable::-webkit-scrollbar-track { background: rgba(0,0,0,0.05); border-radius: 4px; }
.rules-content-area-scrollable::-webkit-scrollbar-thumb { background: #d0d0d0; border-radius: 4px; }
.rules-content-area-scrollable::-webkit-scrollbar-thumb:hover { background: #b0b0b0; }

.rules-content { 
    width: 100%;
    user-select: text;
    -webkit-user-select: text; 
    -moz-user-select: text;    
    -ms-user-select: text;     
}
.rules-content .card-title { display: none; } 

.rules-content p strong, .rules-content li strong {
    font-weight: 700; 
}
.rules-content p strong.game-name-emphasis { 
    font-weight: 700;
}
.rules-content p em, .rules-content li em {
    font-style: italic;
}
.rules-content.hidden { display: none !important; }
.rules-content ul { margin-top: 1.5rem; padding-left: 0; list-style: none;}
.rules-content li { margin-bottom: 1.2rem; line-height: 1.6; padding-left: 1.5em; position: relative; }
.rules-content li::before { content: '•'; color: var(--gold-text); font-weight: bold; display: inline-block; position: absolute; left: 0; top: 0; }
.rules-content p { margin-bottom: 1.2rem; line-height: 1.6; }

.quote {
    font-style: italic;
    text-align: center;
    margin: 1.5rem 0;
    padding: 1rem;
    border: 1px dashed var(--gold-text);
    border-radius: 5px;
    color: var(--dark-text);
    background-color: rgba(196, 163, 90, 0.1);
}

/* --- UPDATED --- Fixed Footer for Rules Screen */
.rules-navigation-footer {
    display: grid;
    grid-template-columns: 1fr 1fr;
    align-items: center;
    width: 100%;
    max-width: 700px;
    padding: 10px;
    position: fixed; /* Fix to viewport */
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 10;
    background-color: var(--teal-bg); /* Add background to prevent content showing through */
    /* Add safe area padding to lift it above mobile home bar */
    padding-bottom: calc(15px + env(safe-area-inset-bottom, 15px));
}
.nav-arrow {
    background: none;
    border: none;
    font-size: 2.5rem; 
    color: var(--gold-text);
    cursor: pointer;
    padding: 10px;
    z-index: 10;
    transition: transform 0.2s ease, opacity 0.2s ease, visibility 0s linear 0.2s;
}
.nav-arrow.prev {
    grid-column: 1 / 2;
    justify-self: start;
    text-align: left;
}
.nav-arrow.next {
    grid-column: 2 / 3;
    justify-self: end;
    text-align: right;
}

.nav-arrow.initial-guide-pulse {
    animation: pulse 1.5s infinite ease-in-out;
}
.nav-arrow:not(.initial-guide-pulse):hover {
    animation: pulse 1.2s infinite ease-in-out;
}
.nav-arrow.hidden { 
    visibility: hidden;
    opacity: 0;
    pointer-events: none; 
}


#theme-select-screen .screen-title {
    margin-bottom: 2rem;
}
#theme-grid-container.theme-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 280px));
    gap: 30px;
    width: 90%;
    max-width: 650px; 
    margin-bottom: 2rem;
    justify-content: center;
}
.theme-tile {
    background-color: var(--beige-card);
    color: var(--dark-text);
    border: 2px solid var(--border-gold);
    border-radius: 15px;
    padding: 25px;
    text-align: center;
    cursor: pointer;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    min-height: 200px; 
}
.theme-tile:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 20px rgba(0,0,0,0.1);
}
.theme-icon {
    font-size: 2.5rem; 
    margin-bottom: 10px;
    display: block;
}
.theme-tile h3 {
    font-family: 'Playfair Display', serif;
    color: var(--gold-text);
    margin-bottom: 10px;
    font-size: 1.5rem; 
}
.theme-tile p {
    font-size: 0.9rem;
    line-height: 1.5;
    margin-bottom: 15px;
    flex-grow: 1;
}
.theme-tile span:not(.theme-icon) {
    font-size: 0.8rem;
    font-style: italic;
    color: var(--disabled-theme-text);
    margin-top: auto;
}
.theme-tile.disabled {
    background-color: var(--disabled-theme-bg);
    border-color: #ccc;
    color: var(--disabled-theme-text);
    cursor: not-allowed;
}
.theme-tile.disabled:hover {
    transform: none;
    box-shadow: none;
}
.theme-tile.disabled h3 { color: #888; }
.theme-tile.disabled .theme-icon { opacity: 0.5; }
#back-to-rules-button { margin-top: 1rem; }

.top-nav {
    position: absolute;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    background-color: rgba(245, 241, 232, 0.15);
    padding: 8px 15px;
    border-radius: 8px;
    z-index: 20;
    display: flex;
    gap: 15px; 
    transition: opacity 0.4s ease, visibility 0.4s ease;
    align-items: center;
    justify-content: center;
}
.top-nav.hidden { opacity: 0; visibility: hidden; }

.nav-link {
    background: none;
    border: none;
    color: var(--beige-card);
    font-size: 0.85rem; 
    cursor: pointer;
    padding: 5px 8px; 
    transition: color 0.3s ease;
    font-weight: bold;
    white-space: nowrap;
}
.nav-link:hover { color: var(--gold-text); animation: pulse 1.2s infinite ease-in-out; }


.down-arrow { 
    width: 35px;
    height: 35px;
    background-color: var(--light-bg);
    border-radius: 50%;
    position: absolute;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 15;
    cursor: pointer;
    transition: opacity 0.4s ease, visibility 0.4s ease;
    /* --- UPDATED --- Add will-change to prevent animation flicker */
    will-change: transform;
}
.down-arrow.hidden { opacity: 0; visibility: hidden; }
.down-arrow:hover { 
    animation: downArrowHover 1s infinite ease-in-out;
}
.down-arrow::after { content: '▼'; font-size: 14px; color: var(--teal-bg); }

.current-theme-text {
    text-align: center;
    font-size: 1.3rem;
    color: var(--gold-text);
    margin-top: 0;
    margin-bottom: 1.5rem;
    font-weight: normal;
}

.screen-title {
    font-family: 'Playfair Display', serif;
    font-size: 2.5rem;
    margin-top: 80px; 
    margin-bottom: 1rem;
    text-align: center;
    color: var(--gold-text);
}
#theme-select-screen .screen-title {
    margin-top: 20px; 
    margin-bottom: 2.5rem;
}
#topic-select-theme-title.screen-title {
    margin-top: 70px;
    margin-bottom: 0.5rem;
}
.controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 90%; 
    max-width: 750px; 
    margin-bottom: 1rem;
    color: var(--gold-text);
    font-weight: bold;
}
.timer-setting {
    font-size: 0.9rem;
    font-weight: bold;
    color: var(--gold-text);
    display: flex;
    align-items: center;
    gap: 8px;
}
#timer-select {
    background-color: var(--input-bg);
    border: 1px solid var(--gold-text);
    color: var(--dark-text);
    padding: 4px 8px;
    border-radius: 4px;
    font-weight: bold;
    font-size: 0.9rem;
    cursor: pointer;
}
.instructions {
    font-size: 0.9rem;
    margin-bottom: 1.5rem;
    color: var(--gold-text);
    text-align: center; 
    width: 90%;
    max-width: 700px;
}
.topic-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 15px;
    width: 90%;
    max-width: 800px;
    margin-top: 20px; 
    margin-bottom: 20px; 
}
.topic-tile {
    background-color: transparent;
    min-height: 85px;
    border-radius: 10px;
    cursor: pointer;
    perspective: 1000px;
    border: 2px solid transparent;
}
.tile-inner {
    position: relative;
    width: 100%;
    height: 100%;
    text-align: center;
    transition: transform 0.6s;
    transform-style: preserve-3d;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
    border-radius: 8px;
}
.topic-tile.flipped .tile-inner,
.topic-tile.used .tile-inner {
    transform: rotateY(180deg);
}
.tile-front, .tile-back {
    position: absolute;
    width: 100%;
    height: 100%;
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
    border-radius: 8px;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 8px;
}
.tile-front {
    background-color: var(--beige-card);
    color: var(--dark-text);
}
.tile-back {
    background-color: transparent;
    color: var(--gold-text);
    transform: rotateY(180deg);
    border: 2px solid var(--gold-text);
    font-size: 0.8rem;
    word-break: break-word;
}
.topic-tile:not(.flipped):not(.used):hover .tile-inner {
    transform: translateY(-4px);
}
.topic-tile.used {
    cursor: default;
    opacity: 0.8; 
}
.topic-tile.used .tile-inner { 
    transform: rotateY(180deg);
}


.topic-card {
    border: 2px solid var(--gold-text);
    width: 90%;
    max-width: 800px;
    min-height: 250px;
    display: flex;
    justify-content: center;
    align-items: center;
    text-align: center;
    padding: 40px;
    margin-top: 70px; 
    margin-bottom: 2.5rem;
}
#topic-text {
    font-family: 'Playfair Display', serif;
    font-size: 2.2rem;
    color: var(--gold-text);
    line-height: 1.5;
}
#timer-display {
    text-align: center;
    color: var(--gold-text);
    font-size: 1.3rem;
    font-weight: bold;
    width: 100%;
    max-width: 350px;
    margin: 0 auto;
}
#timer-display.hidden { display: none; }
.timer-progress-bar {
    width: 100%;
    height: 8px;
    background-color: var(--progress-bar-track);
    border-radius: 4px;
    margin-bottom: 0.8rem;
    overflow: hidden;
}
.timer-progress-fill {
    height: 100%;
    width: 100%;
    background-color: var(--progress-bar-fill);
    border-radius: 4px;
    transition: width 0.5s linear;
}
#time-remaining { display: block; margin: 0.5rem 0; }
#end-discussion-button { margin-top: 10px; }

.modal-overlay {
    background-color: var(--overlay-bg);
    z-index: 100;
    justify-content: center;
    align-items: center;
    text-align: center;
    padding-bottom: calc(env(safe-area-inset-bottom, 0px));
}
#time-up-screen .modal-content.time-up-content {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    background-color: transparent; 
    padding: 20px;
    max-width: 600px;
    width: 90%;
}
.modal-content {
    background-color: transparent; 
    padding: 0; 
    border-radius: 15px;
    max-width: 500px; 
    width: 80%;
    position: relative;
    display: flex; 
    flex-direction: column;
    max-height: 85vh; 
}

.modal-content.card { 
    background-color: var(--beige-card);
    border: 2px solid var(--border-gold);
    color: var(--dark-text);
    max-width: 650px;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.15);
    padding: 0; 
}

#rules-popup-modal .modal-content.card {
    max-width: 750px;
    min-height: 450px;
    max-height: calc(100vh - 150px);
}

.modal-header-sticky {
    padding: 30px 40px 10px 40px; 
    background-color: var(--sticky-header-bg); 
    border-top-left-radius: 13px; 
    border-top-right-radius: 13px;
    position: sticky;
    top: 0;
    z-index: 1; 
    flex-shrink: 0;
}

.modal-title {
    font-family: 'Playfair Display', serif;
    font-size: 3rem; 
    margin-bottom: 1.5rem;
    color: var(--teal-bg); 
}
.modal-content.card .modal-title { 
    color: var(--gold-text);
    font-size: 1.8rem; 
    margin-bottom: 5px; 
}

.modal-scrollable-content {
    padding: 10px 40px 30px 40px; 
    overflow-y: auto;
    flex-grow: 1; 
    text-align: left;
    color: var(--dark-text);
}
.modal-scrollable-content::-webkit-scrollbar { width: 8px; }
.modal-scrollable-content::-webkit-scrollbar-track { background: rgba(0,0,0,0.05); border-radius: 4px; }
.modal-scrollable-content::-webkit-scrollbar-thumb { background: #d0d0d0; border-radius: 4px; }
.modal-scrollable-content::-webkit-scrollbar-thumb:hover { background: #b0b0b0; }

#rules-popup-modal .modal-scrollable-content {
    padding: 0 35px 30px 50px;
}

#rules-popup-content p, #rules-popup-content ul, #rules-popup-content li {
    color: var(--dark-text); 
    margin-bottom: 0.8rem;
    line-height: 1.6;
}
#rules-popup-content ul {
    padding-left: 0; list-style: none;
}
#rules-popup-content li {
    padding-left: 1.5em; position: relative;
}
#rules-popup-content li::before {
    content: '•'; color: var(--gold-text); position: absolute; left: 0; top: 0; font-weight: bold;
}
#resume-timer-button.btn-center {
    margin: 20px auto; 
    display: block; 
    flex-shrink: 0; 
}


.time-up-topic-card {
    border: 2px solid var(--gold-text);
    border-radius: 15px;
    padding: 30px;
    background-color: var(--beige-card);
    color: var(--dark-text);
    margin-bottom: 2rem;
    width: 100%;
    max-width: 450px;
    text-align: center;
}
#time-up-topic {
    color: var(--dark-text);
    opacity: 1;
    font-style: normal;
    font-size: 1.1rem;
    line-height: 1.5;
    margin: 0;
}

.close-btn {
    position: absolute;
    top: 15px;
    right: 20px;
    background: none;
    border: none;
    font-size: 2.2rem;
    color: var(--dark-text); 
    cursor: pointer;
    line-height: 1;
    padding: 5px;
    transition: transform 0.2s ease;
    z-index: 2; 
}
.close-btn:hover { transform: scale(1.1); }

.hidden { display: none !important; }

/* --- RESPONSIVE DESIGN MEDIA QUERIES --- */
@media (max-width: 992px) {
    .game-title { font-size: 3rem; }
    .screen-title { font-size: 2.2rem; }
    #topic-text { font-size: 2rem; }
    .modal-title { font-size: 2.5rem; }
    #rules-card-dynamic-title.card-title { font-size: 1.6rem; }
    .modal-content.card .modal-title { font-size: 1.6rem; }


    #theme-grid-container.theme-grid {
        grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
        gap: 20px;
        max-width: 90%;
    }
    .theme-tile { min-height: 180px; padding: 20px; }
    .theme-tile h3 { font-size: 1.3rem; }
    .theme-icon { font-size: 2.2rem; }

    .topic-grid {
        grid-template-columns: repeat(4, 1fr);
        gap: 12px;
        max-width: 95%;
    }
    .topic-tile { min-height: 75px; }

    .card.rules-card, #rules-popup-modal .modal-content.card {
        max-width: 90%;
    }

    .rules-card-header-fixed { padding: 25px 30px 0 30px; }
    .rules-content-area-scrollable { padding: 0 25px 25px 30px; }

    .modal-content.card {
        max-width: 90%;
    }
    .modal-header-sticky { padding: 25px 30px 10px 30px; }
    .modal-scrollable-content { padding: 10px 30px 25px 30px; }
    #rules-popup-modal .modal-scrollable-content {
        padding: 0 25px 25px 30px;
    }

    .controls { max-width: 90%; }
    .topic-card { max-width: 90%; padding: 30px; }
}

@media (max-width: 600px) {
    .game-title { font-size: 2.2rem; line-height: 1.3; }
    .sub-title { font-size: 0.9rem; margin-bottom: 1rem; }
    .landing-icon { font-size: 2rem; margin-bottom: 1.5rem; }

    .btn { padding: 12px 25px; font-size: 0.95rem; }
    .btn-secondary.btn-small { padding: 6px 12px; font-size: 0.75rem; }

    #rules-card-dynamic-title.card-title { font-size: 1.4rem; }
    .rules-card-header-fixed { padding: 20px 20px 0 20px; }
    .rules-content-area-scrollable { padding: 0 15px 20px 20px; }
    .rules-content p, .rules-content li { font-size: 0.9rem; margin-bottom: 1rem; }
    .card.rules-card, #rules-popup-modal .modal-content.card { 
        min-height: 380px; 
        max-height: calc(100vh - 120px); 
        width: 95%; 
    }

    .rules-navigation-footer {
        max-width: 100%;
        padding: 0 5px;
        padding-bottom: calc(10px + env(safe-area-inset-bottom, 10px));
    }
    .nav-arrow {
        font-size: 2rem;
        padding: 8px;
    }

    .screen-title { font-size: 1.8rem; margin-top: 60px; margin-bottom: 1.5rem; }
    #theme-select-screen .screen-title { margin-top: 15px; margin-bottom: 1.5rem; }
    .current-theme-text {
        font-size: 1.1rem;
    }
    #topic-select-theme-title.screen-title {
        margin-top: 60px;
        margin-bottom: 0.5rem;
    }

    #theme-grid-container.theme-grid {
        grid-template-columns: 1fr;
        gap: 15px;
        max-width: 95%;
    }
    .theme-tile { padding: 20px; min-height: auto; }
    .theme-tile h3 { font-size: 1.4rem; }
    .theme-icon { font-size: 2rem; }
    .theme-tile p { font-size: 0.85rem; }


    .controls {
        flex-direction: column;
        gap: 15px;
        margin-bottom: 1.5rem;
        max-width: 95%;
    }
    .timer-setting { font-size: 0.85rem; }
    #timer-select { font-size: 0.85rem; padding: 3px 6px;}

    .topic-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 10px;
        max-width: 100%;
        margin-top: 15px;
        margin-bottom: 15px;
    }
    .topic-tile { min-height: 70px; }
    .tile-back { font-size: 0.7rem; }


    .top-nav {
        padding: 6px 10px;
        gap: 8px;
        top: 10px;
    }
    .nav-link { font-size: 0.75rem; padding: 4px 6px; }
    .down-arrow { width: 30px; height: 30px; top: 10px; }
    .down-arrow::after { font-size: 12px; }


    .topic-card {
        padding: 20px;
        min-height: 200px;
        margin-top: 60px;
        margin-bottom: 1.5rem;
        width: 95%;
    }
    #topic-text { font-size: 1.6rem; line-height: 1.4; }

    #timer-display { font-size: 1.1rem; max-width: 90%; }
    .timer-progress-bar { height: 6px; }
    #time-remaining { margin: 0.4rem 0; }


    .modal-overlay { 
        padding: 10px;
        padding-bottom: calc(10px + env(safe-area-inset-bottom, 10px));
    }
    .modal-content.card {
        width: 95%;
        max-height: calc(90vh - 70px);
    }
    .modal-header-sticky { padding: 20px 20px 10px 20px; }
    .modal-scrollable-content { padding: 10px 20px 20px 20px; }
    #rules-popup-modal .modal-scrollable-content {
        padding: 0 15px 20px 20px;
    }
    .modal-content.card .modal-title { font-size: 1.5rem; }

    #time-up-screen .modal-content.time-up-content { width: 95%; }
    .modal-title { font-size: 2rem; }
    .time-up-topic-card { padding: 20px; }
    #time-up-topic { font-size: 1rem; }

    .close-btn { top: 10px; right: 15px; font-size: 2rem; }
}

@media (max-width: 420px) {
    .game-title { font-size: 1.9rem; }
    .screen-title { font-size: 1.6rem; }
    .current-theme-text {
        font-size: 1rem; 
    }
    #topic-select-theme-title.screen-title { 
        margin-top: 55px;
        margin-bottom: 0.5rem;
     }

    .topic-grid {
        grid-template-columns: repeat(2, 1fr); 
        gap: 8px;
    }
    .topic-tile { min-height: 65px; }
    .tile-back { font-size: 0.65rem; } 


    #topic-text { font-size: 1.4rem; }

    .rules-card-header-fixed { padding: 15px 15px 0 15px; }
    .rules-content-area-scrollable { padding: 0 10px 15px 15px; }
    .rules-content p, .rules-content li { font-size: 0.85rem; }

    .modal-header-sticky { padding: 15px 15px 5px 15px; }
    .modal-scrollable-content { padding: 5px 15px 15px 15px; }
    #rules-popup-modal .modal-scrollable-content {
        padding: 0 10px 15px 15px; 
    }
    .modal-content.card .modal-title { font-size: 1.3rem; }

    .nav-arrow { font-size: 1.8rem; }
    .btn {
        padding: 8px 12px; 
        font-size: 0.85rem;  
        min-width: auto; 
    }
}
