html {
    scroll-behavior: auto;
}

body {
    font-family: Arial, sans-serif;
    max-width: 800px;
    margin: 0 auto;
    padding: 20px;
    line-height: 1.6;
    -webkit-overflow-scrolling: touch;
}

.container {
    background-color: #f9f9f9;
    border-radius: 8px;
    padding: 20px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

/* Landscape/Horizontal Layout Optimizations */
@media screen and (orientation: landscape) and (max-height: 600px) {
    html {
        scroll-behavior: auto;
    }
    
    body {
        padding: 10px;
        max-width: none;
        margin: 0;
        -webkit-overflow-scrolling: touch;
    }
    
    .container {
        padding: 15px;
        border-radius: 6px;
    }
    
    .header-controls {
        margin-bottom: 15px;
    }
    
    .header-controls h1 {
        font-size: 1.1em;
    }
    
    .form-group {
        margin-bottom: 12px;
    }
    
    .comment {
        padding: 8px;
        margin-bottom: 8px;
    }
    
    .controls {
        margin: 15px 0;
    }
    
    .speech-settings {
        padding: 8px;
        margin: 8px 0;
    }
    
    .video-title {
        padding: 8px 12px;
        margin: 8px 0 15px 0;
    }
    
    .video-title p {
        font-size: 0.85em;
    }
    
    /* Make install prompt smaller in landscape */
    .install-prompt-bottom {
        bottom: 10px;
        padding: 6px 16px;
        height: 35px;
        min-width: 180px;
    }
    
    .install-btn-bottom {
        font-size: 13px !important;
    }
    
    .dismiss-btn {
        width: 20px !important;
        height: 20px !important;
        font-size: 12px !important;
    }
}

/* Very short landscape screens - aggressive space optimization */
@media (max-width: 768px) and (orientation: landscape) and (max-height: 400px) {
    body {
        padding: 3px;
        font-size: 14px;
    }
    
    .container {
        padding: 5px;
    }
    
    .controls {
        margin: 5px 0;
        gap: 5px;
    }
    
    .playback-controls button {
        padding: 4px 8px;
        font-size: 12px;
        min-width: 60px;
    }
    
    .navigation-controls button {
        width: 30px;
        height: 30px;
        font-size: 14px;
    }
    
    .speech-settings {
        padding: 5px;
        margin: 5px 0;
    }
    
    .form-group {
        margin-bottom: 8px;
    }
}

/* Ultra-wide landscape (like when videos are shared horizontally) */
@media screen and (orientation: landscape) and (min-aspect-ratio: 16/9) and (max-height: 500px) {
    body {
        padding: 8px;
    }
    
    .container {
        padding: 12px;
        border-radius: 6px;
    }
    
    .header-controls h1 {
        font-size: 1em;
    }
    
    .settings-btn {
        width: 28px;
        height: 28px;
        font-size: 12px;
    }
    
    .form-group {
        margin-bottom: 10px;
    }
    
    .controls {
        margin: 10px 0;
    }
    
    .speech-settings {
        padding: 8px;
        margin: 8px 0;
    }
    
    .video-title {
        padding: 6px 10px;
        margin: 8px 0 10px 0;
    }
    
    .comment {
        padding: 6px 8px;
        margin-bottom: 6px;
    }
    
    .comment-author {
        font-size: 0.9em;
    }
    
    .comment-text {
        font-size: 0.9em;
        margin-top: 3px;
    }
}

h1 {
    color: #cc0000;
    text-align: center;
    font-size: 1.5em;
    margin: 10px 0;
}

.logo {
    text-decoration: none;
    color: inherit;
}

.logo:hover {
    text-decoration: none;
    color: #990000;
}

.form-group {
    margin-bottom: 15px;
}

label {
    display: block;
    margin-bottom: 5px;
    font-weight: bold;
}

input[type="text"], input[type="number"] {
    width: 100%;
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    box-sizing: border-box;
}

button {
    background-color: #cc0000;
    color: white;
    border: none;
    padding: 10px 15px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 16px;
    white-space: nowrap;
    max-width: 100%;
    box-sizing: border-box;
}

button:hover {
    background-color: #990000;
}

button:disabled {
    background-color: #cccccc;
    cursor: not-allowed;
}

.controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    margin: 20px 0;
}

.playback-controls {
    display: flex;
    gap: 10px;
}

.playback-controls button {
    flex: 0 1 auto;
    min-width: 100px;
    max-width: 150px;
    height: 40px;
}

.navigation-controls {
    display: flex;
    gap: 5px;
}

.navigation-controls button {
    background-color: #2196F3;
    color: white;
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 18px;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
}

.navigation-controls button:hover {
    background-color: #1976D2;
}

.navigation-controls button:disabled {
    background-color: #cccccc !important;
    cursor: not-allowed;
    opacity: 0.6;
}

/* Video Title */
.video-title {
    background-color: white;
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 10px 15px;
    margin: 10px 0 20px 0;
    text-align: center;
}

.video-title p {
    color: #555;
    font-size: 0.9em;
    font-style: italic;
    line-height: 1.3;
    margin: 0;
    padding: 0;
    text-align: center;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

@media (max-width: 480px) and (orientation: portrait) {
    .video-title {
        padding: 8px 12px;
        margin: 8px 0 16px 0;
    }
    
    .video-title p {
        font-size: 0.85em;
    }
}

.speech-settings {
    background-color: white;
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 10px;
    margin: 10px 0;
}

.speed-voice-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 5px;
    flex-wrap: nowrap;
}

.speed-voice-row label {
    margin: 0;
    font-weight: bold;
    font-size: 0.9em;
    white-space: nowrap;
}

.voice-info {
    font-size: 0.9em;
    color: #666;
    font-weight: normal;
    white-space: nowrap;
    flex-shrink: 0;
}

.setting-group {
    margin-bottom: 8px;
}

.setting-group label {
    display: block;
    margin-bottom: 3px;
    font-weight: bold;
    font-size: 0.9em;
}

.language-info {
    margin-top: 8px;
}

.language-info p {
    margin: 2px 0;
    font-size: 0.9em;
}

.rate-value {
    display: inline-block;
    width: 40px;
    text-align: center;
}

select, input[type="range"] {
    width: 100%;
    padding: 5px;
    border: 1px solid #ddd;
    border-radius: 4px;
}

/* Segmented control for Theme (mobile-friendly) */
.segmented-control {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
    width: 100%;
}

.segmented-input {
    /* hide but keep accessible for forms */
    position: absolute;
    opacity: 0;
    pointer-events: none;
    width: 0; height: 0;
}

.segmented-option {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 28px; /* compact buttons (~2x smaller) */
    padding: 6px 8px;
    border: 1px solid var(--border-color, #ddd);
    border-radius: 8px;
    background: var(--bg-input, #fff);
    color: var(--text-primary, #222);
    font-weight: 600;
    font-size: 0.85em;
    user-select: none;
    cursor: pointer;
    transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

.segmented-option:active {
    transform: translateY(0.5px);
}

.segmented-option.active {
    background: var(--secondary-color, #2196F3);
    color: #fff;
    border-color: var(--secondary-color, #2196F3);
}

.segmented-option:not(.active):hover {
    background: var(--comment-hover, #f0f0f0);
}

.segmented-option:focus-visible {
    outline: 3px solid rgba(33,150,243,0.4);
    outline-offset: 2px;
}

@media (max-width: 480px) {
    .segmented-option {
        padding: 6px 6px;
        font-size: 0.85em;
    }
}

.comment {
    background-color: white;
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 10px;
    margin-bottom: 10px;
    cursor: pointer;
    position: relative;
}

.comment:hover {
    background-color: #f0f0f0;
}

.comment.active {
    border: 2px solid #cc0000;
    background-color: #fff8f8;
    cursor: pointer;
}

.comment.active:hover {
    background-color: #ffe8e8;
    box-shadow: 0 2px 4px rgba(204, 0, 0, 0.2);
}

.comment.paused {
    border: 2px solid #ff9500;
    background-color: #fff9f0;
}

.comment.paused:hover {
    background-color: #fff3e0;
    box-shadow: 0 2px 4px rgba(255, 149, 0, 0.2);
}

.pause-indicator {
    position: absolute;
    top: 8px;
    right: 8px;
    background-color: #ff9500;
    color: white;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: bold;
    z-index: 10;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    transition: all 0.2s ease;
}

.pause-indicator:hover {
    background-color: #e6850e;
    transform: scale(1.1);
}

/* Mobile adjustments for pause indicator */
@media (max-width: 480px) and (orientation: portrait) {
    .pause-indicator {
        width: 22px;
        height: 22px;
        font-size: 11px;
        top: 6px;
        right: 6px;
    }
}

/* Landscape mobile adjustments */
@media (max-width: 768px) and (orientation: landscape) and (max-height: 500px) {
    .pause-indicator {
        width: 20px;
        height: 20px;
        font-size: 10px;
        top: 5px;
        right: 5px;
    }
}

.comment.squashed {
    padding: 5px 10px;
    opacity: 0.7;
    background-color: #f8f8f8;
}

.comment.squashed .comment-text {
    display: none;
}

.comment.squashed .comment-author {
    font-size: 0.9em;
    color: #666;
}

.comment.squashed:hover {
    opacity: 1;
    background-color: #f0f0f0;
}

/* New comments highlighting */
.comment[id^="new-comment-"] {
    border-left: 3px solid #cc0000;
    transition: background-color 2s ease-out;
}

.comment[id^="new-comment-"]:first-of-type {
    margin-top: 15px;
    position: relative;
}

.comment[id^="new-comment-"]:first-of-type::before {
    content: "New Comments";
    position: absolute;
    top: -25px;
    left: 0;
    font-size: 0.8em;
    color: #cc0000;
    font-weight: bold;
    text-transform: uppercase;
}

.comment-author {
    font-weight: bold;
    color: #333;
}

.comment-text {
    margin-top: 5px;
}

.error {
    color: #cc0000;
    font-weight: bold;
}

.back-link {
    display: block;
    text-align: center;
    margin-top: 20px;
    text-decoration: none;
    color: #cc0000;
}

.back-link:hover {
    text-decoration: underline;
}

small {
    color: #666;
    font-size: 0.9em;
}

/* Comment Count Controls */
.comment-controls-row {
    display: flex;
    align-items: center;
    gap: 10px;
    justify-content: space-between;
}

.comment-count-controls {
    display: flex;
    align-items: center;
    gap: 0;
    flex-shrink: 0;
}

.count-btn {
    background-color: #2196F3;
    color: white;
    border: none;
    width: 35px;
    height: 35px;
    font-size: 18px;
    font-weight: bold;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}

.count-btn:hover {
    background-color: #1976D2;
}

.count-btn:active {
    background-color: #0D47A1;
    transform: scale(0.95);
}

.count-btn:first-child {
    border-radius: 4px 0 0 4px;
}

.count-btn:last-child {
    border-radius: 0 4px 4px 0;
}

#commentCount {
    width: 50px;
    text-align: center;
    font-size: 14px;
    font-weight: bold;
    border-radius: 0;
    border-left: none;
    border-right: none;
    background-color: white;
    margin: 0;
    height: 35px;
    box-sizing: border-box;
}

.fetch-btn {
    background-color: #cc0000;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    font-weight: bold;
    height: 35px;
    flex-grow: 1;
    margin-left: 10px;
    min-width: 120px;
}

/* Mobile optimizations - Portrait */
@media (max-width: 480px) and (orientation: portrait) {
    .comment-controls-row {
        gap: 8px;
    }
    
    .count-btn {
        width: 32px;
        height: 32px;
        font-size: 16px;
    }
    
    #commentCount {
        width: 45px;
        height: 32px;
        font-size: 12px;
    }
    
    .fetch-btn {
        height: 32px;
        font-size: 13px;
        padding: 6px 12px;
        min-width: 100px;
    }
}

/* Mobile landscape optimizations */
@media (max-width: 768px) and (orientation: landscape) and (max-height: 500px) {
    body {
        padding: 5px;
    }
    
    .container {
        padding: 8px;
    }
    
    .controls {
        margin: 8px 0;
        gap: 8px;
    }
    
    .playback-controls button, .navigation-controls button {
        padding: 6px 10px;
        font-size: 13px;
    }
    .comment-controls-row {
        gap: 6px;
    }
    
    .count-btn {
        width: 30px;
        height: 30px;
        font-size: 14px;
    }
    
    #commentCount {
        width: 40px;
        height: 30px;
        font-size: 11px;
    }
    
    .fetch-btn {
        height: 30px;
        font-size: 12px;
        padding: 5px 10px;
        min-width: 90px;
    }
    
    label {
        font-size: 0.9em;
        margin-bottom: 3px;
    }
    
    input[type="text"] {
        padding: 6px;
        font-size: 14px;
    }
}

/* Install button at bottom */
.install-prompt-bottom {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(33, 150, 243, 0.95);
    border-radius: 25px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 1000;
    backdrop-filter: blur(10px);
    padding: 8px 20px;
    min-width: 200px;
    height: 40px;
    box-sizing: border-box;
    display: flex;
    align-items: center;
    justify-content: space-between;
    white-space: nowrap;
}

.install-btn-bottom {
    background: none !important;
    border: none !important;
    color: white !important;
    font-size: 14px !important;
    font-weight: bold !important;
    cursor: pointer !important;
    padding: 0 !important;
    border-radius: 0 !important;
    white-space: nowrap !important;
    overflow: hidden !important;
}

.dismiss-btn {
    background: rgba(255, 255, 255, 0.2) !important;
    border: none !important;
    color: white !important;
    font-size: 14px !important;
    width: 24px !important;
    height: 24px !important;
    border-radius: 50% !important;
    cursor: pointer !important;
    padding: 0 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    flex-shrink: 0 !important;
    margin-left: 10px !important;
}

.dismiss-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* Header controls */
.header-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    gap: 10px;
}

.header-controls h1 {
    margin: 0;
    font-size: 1.4em;
    color: #cc0000;
    flex-shrink: 1;
    min-width: 0;
}

.header-controls h1 a {
    text-decoration: none;
    color: inherit;
}

.header-controls h1 a:hover {
    text-decoration: none;
    color: #990000;
    transition: color 0.2s;
}

.settings-btn {
    background: #2196F3;
    color: white;
    border: none;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.settings-btn:hover {
    background: #1976D2;
}

/* Mobile adjustments */
@media (max-width: 480px) and (orientation: portrait) {
    .header-controls h1 {
        font-size: 1.2em;
        line-height: 1.2;
    }
    
    .settings-btn {
        width: 32px;
        height: 32px;
        font-size: 14px;
    }
    
    .playback-controls button {
        font-size: 14px;
        padding: 10px 12px;
        white-space: nowrap;
        min-width: 90px;
        max-width: 120px;
        flex: 0 1 auto;
        height: 38px;
    }
}

/* Mobile landscape adjustments */
@media (max-width: 768px) and (orientation: landscape) and (max-height: 500px) {
    .header-controls {
        margin-bottom: 10px;
        gap: 8px;
    }
    
    .header-controls h1 {
        font-size: 1em;
        line-height: 1.1;
    }
    
    .settings-btn {
        width: 28px;
        height: 28px;
        font-size: 12px;
    }
}

/* Settings Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
    backdrop-filter: blur(3px);
}

.modal-content {
    background-color: white;
    margin: 10% auto;
    padding: 0;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.3);
    width: 90%;
    max-width: 500px;
    max-height: 80vh;
    overflow-y: auto;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 1px solid #eee;
    background-color: #f8f9fa;
    border-radius: 8px 8px 0 0;
}

.modal-header h2 {
    margin: 0;
    color: #333;
    font-size: 1.3em;
}

.close {
    color: #aaa;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s;
}

.close:hover {
    color: #000;
    background-color: #f0f0f0;
}

.modal-body {
    padding: 20px;
}

.setting-group {
    margin-bottom: 20px;
}

.setting-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: bold;
    color: #333;
}

.setting-input-row {
    display: flex;
    align-items: center;
    gap: 0;
    margin-bottom: 8px;
}

.setting-input-row .count-btn {
    background-color: #2196F3;
    color: white;
    border: none;
    width: 35px;
    height: 35px;
    font-size: 18px;
    font-weight: bold;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.setting-input-row .count-btn:hover {
    background-color: #1976D2;
}

.setting-input-row .count-btn:first-child {
    border-radius: 4px 0 0 4px;
}

.setting-input-row .count-btn:last-child {
    border-radius: 0 4px 4px 0;
}

.setting-input-row input[type="number"] {
    width: 60px;
    text-align: center;
    font-size: 14px;
    font-weight: bold;
    border-radius: 0;
    border-left: none;
    border-right: none;
    background-color: white;
    margin: 0;
    height: 35px;
    box-sizing: border-box;
}

.setting-group input[type="checkbox"] {
    margin-right: 4px;
    transform: scale(1.2);
}

.setting-group small {
    display: block;
    color: #666;
    font-size: 0.85em;
    margin-top: 4px;
    line-height: 1.3;
}

.setting-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 25px;
    padding-top: 15px;
    border-top: 1px solid #eee;
}

.save-btn {
    background-color: #4CAF50;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    font-weight: bold;
}

.save-btn:hover {
    background-color: #45a049;
}

.cancel-btn {
    background-color: #f44336;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    font-weight: bold;
}

.cancel-btn:hover {
    background-color: #da190b;
}

/* Mobile adjustments for modal */
@media (max-width: 480px) and (orientation: portrait) {
    .modal-content {
        width: 95%;
        margin: 5% auto;
        max-height: 90vh;
    }
    
    .modal-header {
        padding: 15px;
    }
    
    .modal-body {
        padding: 15px;
    }
    
    .setting-actions {
        flex-direction: column;
        gap: 8px;
    }
    
    .save-btn, .cancel-btn {
        width: 100%;
        padding: 12px;
    }
}

/* Landscape modal adjustments */
@media screen and (orientation: landscape) and (max-height: 600px) {
    .modal {
        padding: 20px;
        box-sizing: border-box;
    }
    
    .modal-content {
        margin: 0 auto;
        max-height: calc(100vh - 40px);
        width: 90%;
        max-width: 600px;
    }
    
    .modal-header {
        padding: 12px 20px;
    }
    
    .modal-header h2 {
        font-size: 1.1em;
    }
    
    .modal-body {
        padding: 15px 20px;
    }
    
    .setting-group {
        margin-bottom: 15px;
    }
    
    .setting-actions {
        margin-top: 15px;
        padding-top: 10px;
    }
}

/* Very short landscape mode */
@media screen and (orientation: landscape) and (max-height: 400px) {
    .modal-content {
        max-height: calc(100vh - 20px);
        width: 95%;
        max-width: 800px;
    }
    
    .modal-header {
        padding: 8px 15px;
    }
    
    .modal-body {
        padding: 10px 15px;
    }
    
    .setting-group {
        margin-bottom: 10px;
    }
    
    .setting-actions {
        margin-top: 10px;
        padding-top: 8px;
        flex-direction: row;
        justify-content: center;
        gap: 10px;
    }
    
    .save-btn, .cancel-btn {
        width: auto;
        padding: 8px 16px;
    }
}

/* PWA Install Components */
.modal-overlay {
    display: none;
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    align-items: center;
    justify-content: center;
}

.pwa-install-modal {
    background-color: white;
    padding: 0;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    width: 90%;
    max-width: 480px;
    max-height: 85vh;
    overflow: hidden;
    margin: 0;
}

.pwa-install-modal .modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    border-bottom: 1px solid #eee;
    background: linear-gradient(135deg, #2196F3 0%, #1976D2 100%);
    color: white;
    border-radius: 12px 12px 0 0;
}

.pwa-install-modal .modal-header h3 {
    margin: 0;
    font-size: 1.3em;
    font-weight: 600;
}

.close-btn {
    color: rgba(255, 255, 255, 0.8);
    font-size: 24px;
    font-weight: bold;
    cursor: pointer;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: none;
    border: none;
    transition: all 0.2s;
}

.close-btn:hover {
    color: white;
    background-color: rgba(255, 255, 255, 0.1);
}

.pwa-install-content {
    padding: 24px;
}

.qr-code-section {
    text-align: center;
    margin-bottom: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.qr-code-placeholder {
    width: 160px;
    height: 160px;
    background: #f5f5f5;
    border: 2px dashed #ddd;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 16px;
    position: relative;
}

.qr-code-text {
    text-align: center;
    color: #666;
    width: 100%;
}

.qr-code-text p {
    margin: 4px 0;
    font-size: 0.9em;
    text-align: center;
}

.app-url {
    font-family: monospace;
    font-size: 0.8em !important;
    color: #2196F3;
    font-weight: bold;
    text-align: center;
    display: block;
    margin-top: 8px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.install-message {
    margin-bottom: 20px;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.install-message p {
    color: #555;
    line-height: 1.5;
    margin: 0;
    text-align: center;
}

.install-steps {
    margin-top: 16px;
}

.step {
    display: flex;
    align-items: flex-start;
    margin-bottom: 12px;
    padding: 8px 0;
}

.step-number {
    background: #2196F3;
    color: white;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8em;
    font-weight: bold;
    flex-shrink: 0;
    margin-right: 12px;
}

.step-text {
    color: #333;
    line-height: 1.4;
    font-size: 0.9em;
}

.step-text .icon {
    font-size: 1.1em;
    vertical-align: middle;
}

.modal-footer {
    padding: 16px 24px 24px;
    display: flex;
    gap: 10px;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
}

.btn {
    border: none;
    padding: 12px 20px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s;
    text-decoration: none;
    display: inline-block;
    text-align: center;
    min-width: 80px;
}

.btn-primary {
    background: linear-gradient(135deg, #2196F3 0%, #1976D2 100%);
    color: white;
}

.btn-primary:hover {
    background: linear-gradient(135deg, #1976D2 0%, #1565C0 100%);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(33, 150, 243, 0.3);
}

.btn-secondary {
    background: #f5f5f5;
    color: #333;
    border: 1px solid #ddd;
}

.btn-secondary:hover {
    background: #e9e9e9;
    border-color: #ccc;
}

.btn-tertiary {
    background: transparent;
    color: #666;
    border: none;
}

.btn-tertiary:hover {
    color: #333;
    background: #f5f5f5;
}

/* PWA Install Prompt at bottom */
.pwa-install-prompt {
    position: fixed;
    bottom: 20px;
    left: 20px;
    right: 20px;
    background: linear-gradient(135deg, #2196F3 0%, #1976D2 100%);
    border-radius: 24px;
    box-shadow: 0 6px 20px rgba(33, 150, 243, 0.4);
    z-index: 1500;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    animation: slideUp 0.3s ease-out;
    width: auto;
    max-width: 400px;
    margin: 0 auto;
}

@keyframes slideUp {
    from {
        transform: translateY(100px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.pwa-prompt-content {
    display: flex;
    align-items: center;
    padding: 12px 14px;
    gap: 10px;
    min-width: 260px;
    max-width: 100%;
    box-sizing: border-box;
}

.pwa-prompt-icon {
    font-size: 20px;
    flex-shrink: 0;
}

.pwa-prompt-text {
    flex: 1;
    min-width: 0;
    margin-right: 4px;
}

.pwa-prompt-title {
    color: white;
    font-weight: 600;
    font-size: 14px;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.pwa-prompt-subtitle {
    color: rgba(255, 255, 255, 0.8);
    font-size: 12px;
    line-height: 1.2;
    margin-top: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.pwa-prompt-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

.pwa-install-btn {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.3);
    padding: 8px 14px;
    border-radius: 18px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 500;
    transition: all 0.2s;
    white-space: nowrap;
    min-width: 75px;
    flex-shrink: 0;
}

.pwa-install-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    border-color: rgba(255, 255, 255, 0.4);
    transform: translateY(-1px);
}

.pwa-dismiss-btn {
    background: rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.8);
    border: none;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.pwa-dismiss-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    color: white;
}

/* Mobile adjustments for PWA components */
@media (max-width: 480px) {
    .pwa-install-modal {
        width: 95%;
        max-height: 90vh;
    }
    
    .pwa-install-content {
        padding: 20px;
    }
    
    .qr-code-placeholder {
        width: 140px;
        height: 140px;
    }
    
    .modal-footer {
        flex-direction: column;
        gap: 8px;
    }
    
    .btn {
        width: 100%;
        padding: 14px 20px;
    }
    
    .pwa-prompt-content {
        min-width: 250px;
        padding: 10px 14px;
        gap: 10px;
        max-width: 100%;
    }
    
    .pwa-install-prompt {
        left: 15px;
        right: 15px;
        max-width: none;
    }
    
    .pwa-prompt-text {
        margin-right: 4px;
    }
    
    .pwa-prompt-title {
        font-size: 13px;
    }
    
    .pwa-prompt-subtitle {
        font-size: 11px;
    }
    
    .pwa-install-btn {
        padding: 6px 12px;
        font-size: 11px;
        min-width: 70px;
    }
}

/* Landscape adjustments for PWA components */
@media screen and (orientation: landscape) and (max-height: 600px) {
    .pwa-install-modal {
        max-height: 94vh;
        width: 90%;
        max-width: 600px;
    }
    
    .pwa-install-content {
        padding: 16px 20px;
    }
    
    .qr-code-placeholder {
        width: 120px;
        height: 120px;
    }
    
    .install-steps {
        margin-top: 12px;
    }
    
    .step {
        margin-bottom: 8px;
        padding: 4px 0;
    }
    
    .pwa-install-prompt {
        bottom: 12px;
        left: 15px;
        right: 15px;
        max-width: none;
    }
    
    .pwa-prompt-content {
        padding: 8px 14px;
        min-width: 260px;
        max-width: 100%;
        gap: 10px;
    }
    
    .pwa-prompt-text {
        margin-right: 4px;
    }
}

/* Reset section */
.reset-section {
    text-align: center;
    margin: 10px 0 15px 0;
}

.reset-btn {
    background-color: #f44336;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    font-weight: bold;
}

.reset-btn:hover {
    background-color: #da190b;
}

/* More Comments section */
.more-comments-section {
    text-align: center;
    margin: 30px 0 20px 0;
    padding: 20px;
    background-color: #f9f9f9;
    border-radius: 8px;
    border: 1px solid #e0e0e0;
}

.more-comments-btn {
    background-color: #2196F3;
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 16px;
    font-weight: bold;
    margin-bottom: 10px;
    transition: all 0.2s ease;
}

.more-comments-btn:hover {
    background-color: #1976D2;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(33, 150, 243, 0.3);
}

.more-comments-btn:disabled {
    background-color: #cccccc;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.more-comments-info {
    color: #666;
    font-size: 0.9em;
    margin: 0 0 8px 0;
    line-height: 1.4;
}

.hard-limit-info {
    color: #888;
    font-size: 0.8em;
    margin: 0;
    line-height: 1.3;
    font-style: italic;
}

/* Mobile adjustments for More Comments and Reset */
@media (max-width: 480px) and (orientation: portrait) {
    .more-comments-section {
        margin: 20px 0 15px 0;
        padding: 15px;
    }
    
    .more-comments-btn {
        width: 100%;
        padding: 14px 20px;
        font-size: 15px;
    }
    
    .more-comments-info {
        font-size: 0.85em;
    }
    
    .hard-limit-info {
        font-size: 0.75em;
    }
    
    .reset-section {
        margin: 8px 0 12px 0;
    }
    
    .reset-btn {
        padding: 6px 12px;
        font-size: 13px;
    }
}

/* Landscape adjustments for More Comments and Reset */
@media (max-width: 768px) and (orientation: landscape) and (max-height: 500px) {
    .more-comments-section {
        margin: 15px 0 10px 0;
        padding: 12px;
    }
    
    .more-comments-btn {
        padding: 8px 16px;
        font-size: 14px;
    }
    
    .more-comments-info {
        font-size: 0.8em;
    }
    
    .hard-limit-info {
        font-size: 0.7em;
    }
    
    .reset-section {
        margin: 5px 0 8px 0;
    }
    
    .reset-btn {
        padding: 6px 12px;
        font-size: 12px;
    }
}


/* PWA standalone and safe-area adjustments */
@media (display-mode: standalone) {
  .modal {
    padding-top: max(12px, env(safe-area-inset-top));
    padding-right: max(12px, env(safe-area-inset-right));
    padding-bottom: max(12px, env(safe-area-inset-bottom));
    padding-left: max(12px, env(safe-area-inset-left));
    box-sizing: border-box;
  }
  .modal-content {
    margin: 0 auto;
    width: clamp(280px, 94vw, 640px);
    max-height: calc(100svh - env(safe-area-inset-top) - env(safe-area-inset-bottom) - 24px);
    overflow: hidden;
  }
  .modal-body {
    overflow: auto;
    -webkit-overflow-scrolling: touch;
  }
}

/* Use dynamic viewport units when supported */
@supports (height: 100svh) {
  .modal-content {
    max-height: min(90svh, calc(100svh - 24px));
  }
}

/* Landscape short-height tuning for PWA and browsers */
@media (orientation: landscape) and (max-height: 600px) {
  .segmented-option {
    min-height: 26px;
    padding: 4px 6px;
    font-size: 0.82em;
  }
  .save-btn, .cancel-btn, .count-btn, .navigation-controls button {
    padding: 8px 14px;
    font-size: 13px;
  }
}

@media (orientation: landscape) and (max-height: 480px) {
  .segmented-option {
    min-height: 24px;
    padding: 4px 6px;
    font-size: 0.8em;
  }
  .save-btn, .cancel-btn, .count-btn, .navigation-controls button {
    padding: 6px 12px;
    font-size: 12.5px;
  }
  .modal-content {
    width: 96vw;
    max-width: 720px;
    max-height: calc(100svh - 16px);
  }
}
