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

:root {
    --bg-color: #f5f5f5;
    --text-color: #333;
    --header-bg: #4a90e2;
    --header-text: white;
    --card-bg: white;
    --border-color: #ddd;
    --btn-primary: #4a90e2;
    --btn-primary-hover: #357abd;
    --btn-secondary: #6c757d;
    --btn-secondary-hover: #5a6268;
    --btn-success: #10b981;
    --btn-success-hover: #059669;
    --message-sent: #4a90e2;
    --message-received: #e9ecef;
    --chat-header-male: #5b9bd5;
    --chat-header-female: #ff7bac;
    --chat-header-other: #a5a5a5;
}

body.dark-mode {
    --bg-color: #1a1a1a;
    --text-color: #e0e0e0;
    --header-bg: #2d3748;
    --header-text: #e0e0e0;
    --card-bg: #2d3748;
    --border-color: #4a5568;
    --btn-primary: #3182ce;
    --btn-primary-hover: #2b6cb0;
    --btn-secondary: #4a5568;
    --btn-secondary-hover: #2d3748;
    --btn-success: #059669;
    --btn-success-hover: #047857;
    --message-sent: #3182ce;
    --message-received: #4a5568;
    --chat-header-male: #3d7ab8;
    --chat-header-female: #c45c8a;
    --chat-header-other: #5a5a5a;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    min-height: 100vh;
    min-height: 100dvh;
    transition: background-color 0.3s, color 0.3s;
}

body.keyboard-open {
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
}

#app {
    max-width: 800px;
    margin: 0 auto;
    padding: 15px;
}

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px;
    background-color: var(--header-bg);
    color: var(--header-text);
    border-radius: 10px;
    margin-bottom: 15px;
}

header h1 {
    font-size: 1.6rem;
}

.title-container {
    display: flex;
    align-items: center;
    gap: 10px;
}

.version {
    font-size: 0.7rem;
    font-weight: 700;
    border: none;
    padding: 2px 6px;
    border-radius: 3px;
    background: var(--header-text);
    color: var(--header-bg);
    opacity: 0.7;
    align-self: flex-end;
    line-height: 1;
    margin-bottom: 2px;
}

#darkModeToggle {
    padding: 8px 12px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    background-color: rgba(255, 255, 255, 0.2);
    color: var(--header-text);
    font-size: 0.95rem;
    transition: background-color 0.3s;
}

#darkModeToggle:hover {
    background-color: rgba(255, 255, 255, 0.3);
}

.form-container {
    background-color: var(--card-bg);
    padding: 14px;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.form-group {
    margin-bottom: 10px;
    text-align: center;
    padding: 8px;
    background-color: var(--bg-color);
    border-radius: 6px;
    transition: all 0.3s;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.05);
    border: 1px solid rgba(0, 0, 0, 0.03);
}

.form-group:hover {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    transform: translateY(-1px);
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 600;
    font-size: 0.88rem;
    color: var(--btn-primary);
    text-transform: uppercase;
    letter-spacing: 0.4px;
}

.nickname-row {
    display: flex;
    gap: 8px;
    max-width: 100%;
    align-items: center;
}

.nickname-row input[type="text"] {
    flex: 1;
    padding: 8px;
    border: 2px solid var(--border-color);
    border-radius: 5px;
    font-size: 0.9rem;
    background-color: var(--bg-color);
    color: var(--text-color);
    text-align: center;
    transition: border-color 0.3s;
}

.nickname-row input[type="text"]:focus {
    outline: none;
    border-color: var(--btn-primary);
}

.form-group input[type="text"],
.form-group input[type="number"] {
    width: 100%;
    padding: 8px;
    border: 2px solid var(--border-color);
    border-radius: 5px;
    font-size: 0.9rem;
    background-color: var(--bg-color);
    color: var(--text-color);
    transition: border-color 0.3s;
}

.form-group input[type="text"]:focus,
.form-group input[type="number"]:focus {
    outline: none;
    border-color: var(--btn-primary);
}

.city-group {
    display: flex;
    flex-direction: row;
    justify-content: center;
    align-items: center;
    gap: 20px;
    padding: 12px 16px !important;
}

.city-label {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 6px;
    font-size: 0.95rem;
    font-weight: 500;
}

.city-label span:first-child {
    color: var(--btn-primary);
    font-weight: 600;
}

.city-text {
    transition: all 0.3s;
    min-width: 60px;
    font-weight: 500;
}

.city-unknown {
    color: #999;
}

.city-known {
    color: var(--text-color);
}

.city-toggle {
    display: flex;
    justify-content: center;
    align-items: center;
}

.custom-switch {
    position: relative;
    display: inline-block;
    width: 48px;
    height: 28px;
}

.custom-switch input {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
    visibility: hidden;
    pointer-events: none;
    -webkit-appearance: none;
    appearance: none;
    border: none;
    background: transparent;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #adb5bd;
    transition: 0.3s;
    border-radius: 28px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 22px;
    width: 22px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: 0.3s;
    border-radius: 50%;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.custom-switch input:checked + .slider {
    background-color: var(--btn-primary);
}

.custom-switch input:checked + .slider:before {
    transform: translateX(20px);
}

#randomNickname {
    padding: 8px 14px;
    background-color: var(--btn-secondary) !important;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    white-space: nowrap;
    font-weight: 500;
    font-size: 0.9rem;
    transition: all 0.3s;
}

#randomNickname:hover {
    background-color: var(--btn-secondary-hover) !important;
    transform: translateY(-2px);
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

#ageValue {
    color: var(--text-color);
}

.age-slider-container {
    display: flex;
    align-items: center;
    gap: 10px;
}

.age-slider {
    flex: 1;
    -webkit-appearance: none;
    height: 8px;
    border-radius: 5px;
    background: linear-gradient(to right, #87ceeb, #4169e1);
    outline: none;
}

.age-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: white;
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}

.age-slider::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: white;
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
    border: none;
}

.age-label-left,
.age-label-right {
    font-weight: 500;
    white-space: nowrap;
    font-size: 0.95rem;
}

.gender-options {
    display: flex;
    gap: 12px;
    justify-content: center;
}

.gender-options label {
    display: flex;
    align-items: center;
    gap: 5px;
    cursor: pointer;
    font-weight: normal;
    font-size: 0.9rem;
}

.btn-primary {
    width: 100%;
    padding: 10px;
    background-color: var(--btn-primary);
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 1rem;
    cursor: pointer;
    margin-bottom: 10px;
    transition: background-color 0.3s;
}

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

.btn-secondary {
    width: 100%;
    padding: 10px;
    background-color: var(--btn-secondary);
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 1rem;
    cursor: pointer;
    transition: background-color 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

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

.hidden {
    display: none !important;
}

.chat-container {
    background-color: var(--card-bg);
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
    height: calc(100vh - 150px);
    position: relative;
}

.chat-header {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    padding: 5px 10px;
    border-bottom: 1px solid var(--border-color);
    gap: 8px;
    transition: background-color 0.3s;
    min-height: auto;
    height: auto;
    box-sizing: border-box;
}

.chat-header.male {
    background-color: var(--chat-header-male);
    color: white;
}

.chat-header.female {
    background-color: var(--chat-header-female);
    color: white;
}

.chat-header.other {
    background-color: var(--chat-header-other);
    color: white;
}

.back-btn-chat {
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 50%;
    background-color: rgba(255, 255, 255, 0.2);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s;
    color: inherit;
    flex-shrink: 0;
}

.back-btn-chat:hover {
    background-color: rgba(255, 255, 255, 0.3);
    transform: scale(1.05);
}

#partnerInfo {
    font-weight: 600;
    font-size: 0.9rem;
    flex: 1;
    min-width: 0;
    line-height: 1.2;
}

.block-btn {
    padding: 4px 8px;
    border: 1px solid rgba(255, 255, 255, 0.4);
    border-radius: 4px;
    background-color: rgba(255, 255, 255, 0.15);
    color: white;
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    line-height: 1.2;
}

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

.block-btn.blocked {
    background-color: #dc3545;
    border-color: #dc3545;
}

.status-notice {
    padding: 8px 15px;
    font-size: 0.85rem;
    color: #666;
    text-align: center;
    background-color: #fff3cd;
    border-top: 1px solid var(--border-color);
    transition: all 0.3s;
}

.status-notice.hidden {
    display: none;
}

.status-notice.error {
    background-color: #f8d7da;
    color: #721c24;
}

.status-notice.success {
    background-color: #d4edda;
    color: #155724;
}

body.dark-mode .status-notice {
    background-color: #3d3d2f;
    color: #e0e0e0;
}

body.dark-mode .status-notice.error {
    background-color: #4a2428;
    color: #ffc9ce;
}

body.dark-mode .status-notice.success {
    background-color: #1e4620;
    color: #b5f7c6;
}

.inline-status-notice {
    padding: 8px 16px;
    font-size: 0.85rem;
    color: #666;
    text-align: center;
    background-color: #fff3cd;
    border-radius: 20px;
    margin: 8px auto;
    max-width: 80%;
    animation: fadeIn 0.3s ease;
}

.inline-status-notice.error {
    background-color: #f8d7da;
    color: #721c24;
}

.inline-status-notice.success {
    background-color: #d4edda;
    color: #155724;
}

body.dark-mode .inline-status-notice {
    background-color: #3d3d2f;
    color: #e0e0e0;
}

body.dark-mode .inline-status-notice.error {
    background-color: #4a2428;
    color: #ffc9ce;
}

body.dark-mode .inline-status-notice.success {
    background-color: #1e4620;
    color: #b5f7c6;
}

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

.messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
}

.message {
    margin-bottom: 15px;
    max-width: 70%;
    width: fit-content;
    padding: 12px 16px;
    border-radius: 18px;
    word-wrap: break-word;
    white-space: pre-wrap;
}

.message.sent {
    margin-left: auto;
    margin-right: 0;
    background-color: var(--message-sent);
    color: white;
    border-bottom-right-radius: 4px;
}

.message.received {
    margin-right: auto;
    margin-left: 0;
    background-color: var(--message-received);
    color: var(--text-color);
    border-bottom-left-radius: 4px;
}

.message-content {
    margin-bottom: 4px;
}

.message-time {
    font-size: 0.7rem;
    opacity: 0.6;
    text-align: right;
    line-height: 1;
}

.message.sent .message-time {
    text-align: right;
}

.message.received .message-time {
    text-align: left;
}

.message img {
    max-width: 200px;
    max-height: 200px;
    border-radius: 10px;
    display: block;
    cursor: pointer;
    transition: transform 0.2s;
}

.message img:hover {
    transform: scale(1.02);
}

.image-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    cursor: pointer;
}

.image-modal.hidden {
    display: none;
}

.image-modal img {
    max-width: 90%;
    max-height: 90%;
    border-radius: 8px;
    cursor: default;
}

.input-area {
    display: flex;
    padding: 15px 20px;
    border-top: 1px solid var(--border-color);
    gap: 10px;
    align-items: center;
    flex-wrap: nowrap;
    max-width: 100%;
    box-sizing: border-box;
    position: relative;
    z-index: 100;
    flex-shrink: 0;
}

.input-tools {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}

.tool-btn {
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 50%;
    background-color: var(--bg-color);
    cursor: pointer;
    font-size: 1.2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s;
}

.tool-btn:hover {
    background-color: var(--border-color);
}

#messageInput {
    flex: 1;
    min-width: 0;
    padding: 12px 15px;
    border: 1px solid var(--border-color);
    border-radius: 20px;
    font-size: 1rem;
    background-color: var(--bg-color);
    color: var(--text-color);
}

#sendMessage {
    padding: 12px 20px;
    background-color: var(--btn-primary);
    color: white;
    border: none;
    border-radius: 20px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 600;
    transition: all 0.3s;
    min-width: 70px;
    flex-shrink: 0;
}

#sendMessage:hover {
    background-color: var(--btn-primary-hover);
    transform: translateY(-2px);
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

#driftMessageInput {
    flex: 1;
    min-width: 0;
    padding: 12px 15px;
    border: 1px solid var(--border-color);
    border-radius: 20px;
    font-size: 1rem;
    background-color: var(--bg-color);
    color: var(--text-color);
}

#sendDriftMessage {
    padding: 12px 20px;
    background-color: var(--btn-primary);
    color: white;
    border: none;
    border-radius: 20px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 600;
    transition: all 0.3s;
    min-width: 70px;
    flex-shrink: 0;
}

#sendDriftMessage:hover {
    background-color: var(--btn-primary-hover);
    transform: translateY(-2px);
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

.emoji-panel {
    position: absolute;
    bottom: 100px;
    left: 20px;
    background-color: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 15px;
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
    z-index: 100;
}

.emoji-panel span {
    font-size: 1.5rem;
    cursor: pointer;
    padding: 5px;
    border-radius: 5px;
    text-align: center;
    transition: background-color 0.2s;
}

.emoji-panel span:hover {
    background-color: var(--border-color);
}

.history-container {
    background-color: var(--card-bg);
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    padding: 20px;
}

.history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 1px solid var(--border-color);
}

#backToHome {
    padding: 8px 15px;
    background-color: var(--btn-secondary);
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
}

#backToHome:hover {
    background-color: var(--btn-secondary-hover);
}

.upload-progress-container {
    padding: 10px 15px;
    background-color: var(--card-bg);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.upload-progress-text {
    font-size: 0.85rem;
    color: var(--text-color);
    opacity: 0.8;
}

.upload-progress-bar {
    width: 100%;
    height: 8px;
    background-color: var(--border-color);
    border-radius: 4px;
    overflow: hidden;
}

.upload-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary-color), #66a3ff);
    border-radius: 4px;
    width: 0%;
    transition: width 0.1s ease-out;
    position: relative;
    overflow: hidden;
}

.upload-progress-fill::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(90deg, 
        transparent 0%, 
        rgba(255, 255, 255, 0.3) 50%, 
        transparent 100%);
    animation: shimmer 1.5s infinite;
}

@keyframes shimmer {
    0% {
        transform: translateX(-100%);
    }
    100% {
        transform: translateX(100%);
    }
}

.upload-progress-percent {
    font-size: 0.75rem;
    color: var(--text-color);
    opacity: 0.7;
    text-align: right;
}

.image-modal-loading-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 15px;
}

.image-modal-progress-bar {
    width: 200px;
    height: 6px;
    background-color: rgba(255, 255, 255, 0.2);
    border-radius: 3px;
    overflow: hidden;
}

.image-modal-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #4a90e2, #66a3ff);
    border-radius: 3px;
    width: 0%;
    transition: width 0.3s ease;
}

.image-modal-progress-text {
    color: white;
    font-size: 14px;
}

.history-list {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.history-item {
    padding: 15px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s;
    border-left: 4px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 10px;
}

.history-item.male {
    border-left-color: #4a90e2;
    background-color: rgba(74, 144, 226, 0.05);
}

.history-item.female {
    border-left-color: #e91e8c;
    background-color: rgba(233, 30, 140, 0.05);
}

.history-item.other {
    border-left-color: #6c757d;
    background-color: rgba(108, 117, 125, 0.05);
}

.history-item:hover {
    background-color: var(--bg-color);
}

.history-item-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
}

.history-item-partner {
    font-weight: 600;
}

.history-item-date {
    font-size: 0.9rem;
    color: var(--text-color);
    opacity: 0.7;
}

.history-item-preview {
    font-size: 0.9rem;
    opacity: 0.8;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.drift-bottle-actions {
    display: flex;
    gap: 15px;
    margin-bottom: 20px;
    justify-content: center;
}

.drift-bottle-actions .btn-primary {
    flex: 1;
    max-width: 200px;
}

.throw-bottle-info {
    background: var(--card-bg);
    padding: 20px;
    border-radius: 10px;
    margin-bottom: 20px;
}

.user-info-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.user-info-nickname {
    font-size: 1.3rem;
    font-weight: 600;
    color: var(--text-color);
}

.user-info-details {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.95rem;
    color: var(--text-color);
    opacity: 0.85;
}

.user-info-details .separator {
    opacity: 0.5;
}

.throw-bottle-info p {
    margin: 10px 0;
    color: var(--text-color);
}

#throwBottleContent {
    width: 100%;
    min-height: 120px;
    padding: 15px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 1rem;
    background: var(--bg-color);
    color: var(--text-color);
    resize: vertical;
    margin-bottom: 20px;
}

#throwBottleContent:focus {
    outline: none;
    border-color: var(--btn-primary);
}

.throw-status,
.pick-status {
    text-align: center;
    padding: 40px 20px;
    font-size: 1.2rem;
    color: var(--text-color);
}

.picked-bottle-info {
    background: var(--card-bg);
    padding: 20px;
    border-radius: 10px;
    margin-bottom: 20px;
}

.picked-bottle-info .user-info-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.picked-bottle-info .user-info-nickname {
    font-size: 1.3rem;
    font-weight: 600;
    color: var(--text-color);
}

.picked-bottle-info .user-info-details {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.95rem;
    color: var(--text-color);
    opacity: 0.85;
}

.picked-bottle-info .user-info-details .separator {
    opacity: 0.5;
}

.picked-bottle-info p {
    margin: 10px 0;
    color: var(--text-color);
}

.picked-bottle-content {
    background: var(--bg-color);
    padding: 20px;
    border-radius: 10px;
    margin-bottom: 20px;
    border-left: 4px solid var(--btn-primary);
}

.picked-bottle-content p {
    margin: 0;
    color: var(--text-color);
    line-height: 1.6;
}

.picked-bottle-image {
    margin-bottom: 20px;
    border-radius: 10px;
    overflow: hidden;
    border: 2px solid var(--border-color);
}

.picked-bottle-image img {
    width: 100%;
    max-height: 300px;
    object-fit: contain;
    display: block;
}

.drift-bottle-item {
    padding: 15px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s;
    border-left: 4px solid #ff9800;
    background-color: rgba(255, 152, 0, 0.05);
    display: flex;
    align-items: center;
    gap: 10px;
}

.drift-bottle-item:hover {
    background-color: var(--bg-color);
    transform: translateY(-2px);
}

.drift-bottle-item-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
}

.drift-bottle-item-partner {
    font-weight: 600;
}

.drift-bottle-item-date {
    font-size: 0.9rem;
    color: var(--text-color);
    opacity: 0.7;
}

.drift-bottle-item-preview {
    font-size: 0.9rem;
    opacity: 0.8;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.drift-bottle-item-content {
    flex: 1;
    min-width: 0;
}

.history-item-content {
    flex: 1;
    min-width: 0;
}

.history-delete-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    transition: all 0.3s;
    opacity: 1;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #dc3545;
    width: 36px;
    height: 36px;
}

.history-delete-btn:hover {
    background-color: rgba(220, 53, 69, 0.1);
    transform: scale(1.1);
}

.no-history {
    text-align: center;
    padding: 40px;
    color: var(--text-color);
    opacity: 0.7;
}

@media (max-width: 600px) {
    #app {
        padding: 0;
        min-height: 100vh;
    }

    #homePage {
        padding: 10px;
        padding-top: calc(10px + env(safe-area-inset-top));
        padding-bottom: calc(10px + env(safe-area-inset-bottom));
    }

    header {
        padding: 15px;
        border-radius: 10px;
    }

    header h1 {
        font-size: 1.4rem;
    }

    #darkModeToggle {
        padding: 8px 12px;
        font-size: 0.9rem;
    }

    .form-container {
        padding: 20px;
        border-radius: 10px;
    }

    .chat-container {
        height: 100%;
        border-radius: 0;
        margin: 0;
        padding: 0;
        display: flex;
        flex-direction: column;
    }
    
    #chatPage {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 100;
    }
    
    #driftChatPage {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 100;
    }

    #historyPage {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 100;
        overflow-y: auto;
        background-color: var(--bg-color);
    }

    #historyPage .history-container {
        border-radius: 0;
        min-height: 100vh;
        padding: 15px;
        padding-top: calc(15px + env(safe-area-inset-top));
        padding-bottom: calc(15px + env(safe-area-inset-bottom));
        box-shadow: none;
    }

    .chat-header {
        padding: 4px 8px;
        padding-top: calc(4px + env(safe-area-inset-top));
        min-height: auto;
        height: auto;
        box-sizing: border-box;
    }

    .messages {
        padding: 15px;
        flex: 1;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    .message {
        max-width: 85%;
    }

    .input-area {
        padding: 12px 15px;
        padding-bottom: calc(12px + env(safe-area-inset-bottom));
        gap: 8px;
        flex-shrink: 0;
    }

    .input-tools {
        gap: 6px;
    }

    .tool-btn {
        width: 36px;
        height: 36px;
        font-size: 1.1rem;
    }

    #messageInput {
        padding: 10px 15px;
    }

    #sendMessage {
        padding: 10px 18px;
        font-size: 0.95rem;
        min-width: 70px;
    }

    .nickname-row {
        gap: 8px;
    }

    .nickname-row input[type="text"] {
        padding: 10px;
        font-size: 0.95rem;
    }

    #randomNickname {
        padding: 10px 15px;
        font-size: 0.95rem;
    }

    .emoji-panel {
        grid-template-columns: repeat(6, 1fr);
        left: 10px;
        right: 10px;
        bottom: 90px;
        max-height: 40vh;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        padding: 10px;
        gap: 5px;
    }
    
    .emoji-panel span {
        font-size: 1.2rem;
        padding: 3px;
    }

    .age-slider-container {
        gap: 10px;
    }

    .age-label-left,
    .age-label-right {
        font-size: 0.9rem;
    }

    .gender-options {
        gap: 15px;
        flex-wrap: wrap;
    }
}

@media (max-width: 400px) {
    header h1 {
        font-size: 1.2rem;
    }

    .emoji-panel {
        grid-template-columns: repeat(5, 1fr);
        max-height: 35vh;
        padding: 8px;
        gap: 4px;
    }
    
    .emoji-panel span {
        font-size: 1.1rem;
        padding: 2px;
    }
}

footer {
    margin-top: 30px;
    text-align: center;
}

.online-count {
    font-size: 0.95rem;
    color: var(--btn-primary);
    font-weight: 600;
    padding: 8px 0;
    opacity: 0.9;
}

.copyright {
    font-size: 0.9rem;
    color: var(--text-color);
    opacity: 0.6;
    padding: 10px 0;
}

.history-notice {
    text-align: center;
    padding: 12px 16px;
    background-color: #fff3cd;
    color: #856404;
    border-radius: 8px;
    margin-bottom: 15px;
    font-size: 0.9rem;
    line-height: 1.4;
}

body.dark-mode .history-notice {
    background-color: #533f03;
    color: #ffc107;
}

.form-switch {
    padding-left: 0 !important;
    padding-right: 0 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    min-height: auto !important;
}

.form-check.form-switch {
    padding-left: 0 !important;
    margin-bottom: 0 !important;
}

.form-check-input {
    width: 2.8em !important;
    height: 1.6em !important;
    margin: 0 !important;
    padding: 0 !important;
    cursor: pointer !important;
    transition: all 0.3s ease !important;
    border: none !important;
    background-image: none !important;
    background-color: #adb5bd !important;
    -webkit-appearance: none !important;
    appearance: none !important;
    position: relative !important;
    border-radius: 1.6em !important;
}

.form-check-input::before {
    content: '' !important;
    position: absolute !important;
    top: 0.12em !important;
    left: 0.12em !important;
    width: 1.36em !important;
    height: 1.36em !important;
    background-color: white !important;
    border-radius: 50% !important;
    transition: transform 0.3s ease !important;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2) !important;
}

.form-check-input:focus {
    box-shadow: none !important;
    outline: none !important;
}

.form-check-input:checked {
    background-color: #0d6efd !important;
}

.form-check-input:checked::before {
    transform: translateX(1.2em) !important;
}

body.dark-mode .form-check-input:not(:checked) {
    background-color: #4a5568 !important;
}

body.dark-mode .form-check-input:checked {
    background-color: #0b5ed7 !important;
}

@media (max-width: 600px) {
    .form-check-input {
        width: 2.8em !important;
        height: 1.6em !important;
    }
    
    .form-check-input::before {
        width: 1.36em !important;
        height: 1.36em !important;
        top: 0.12em !important;
        left: 0.12em !important;
    }
    
    .form-check-input:checked::before {
        transform: translateX(1.2em) !important;
    }
}

footer {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 20px;
    margin-top: 30px;
    padding: 0 10px;
    flex-wrap: wrap;
}

.guestbook-btn {
    padding: 6px 12px;
    font-size: 0.85rem;
    background-color: var(--bg-color);
    color: var(--text-color);
    border: 1px solid var(--border-color);
    border-radius: 15px;
    cursor: pointer;
    opacity: 0.7;
    transition: all 0.3s;
}

.guestbook-btn:hover {
    opacity: 1;
    background-color: var(--card-bg);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    animation: fadeIn 0.2s ease;
}

.modal {
    background-color: var(--card-bg);
    padding: 25px;
    border-radius: 12px;
    max-width: 450px;
    width: 90%;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    animation: slideUp 0.3s ease;
}

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

.modal h2 {
    margin-bottom: 15px;
    color: var(--text-color);
    font-size: 1.3rem;
}

.modal textarea {
    width: 100%;
    height: 120px;
    padding: 12px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 0.95rem;
    background-color: var(--bg-color);
    color: var(--text-color);
    resize: vertical;
    margin-bottom: 10px;
    font-family: inherit;
}

.modal textarea:focus {
    outline: none;
    border-color: var(--btn-primary);
}

.modal-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    align-items: center;
}

.modal-actions .tool-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    background: var(--bg-color);
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-actions .tool-btn:hover {
    background: var(--border-color);
    transform: scale(1.1);
}

.throw-image-preview {
    position: relative;
    margin-bottom: 15px;
    border-radius: 8px;
    overflow: hidden;
    border: 2px solid var(--border-color);
}

.throw-image-preview img {
    width: 100%;
    max-height: 300px;
    object-fit: contain;
    display: block;
}

.remove-image-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    border: none;
    background: rgba(220, 53, 69, 0.9);
    color: white;
    font-size: 24px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    transition: all 0.3s;
}

.remove-image-btn:hover {
    background: #dc3545;
    transform: scale(1.1);
}

.cancel-btn,
.confirm-btn {
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.95rem;
    transition: background-color 0.3s;
}

.cancel-btn {
    background-color: var(--btn-secondary);
    color: white;
}

.cancel-btn:hover {
    background-color: var(--btn-secondary-hover);
}

.confirm-btn {
    background-color: var(--btn-primary);
    color: white;
}

.confirm-btn:hover {
    background-color: var(--btn-primary-hover);
}

.login-error {
    color: #dc3545;
    font-size: 0.9rem;
    margin-bottom: 10px;
    padding: 8px;
    background-color: #f8d7da;
    border-radius: 4px;
}

body.dark-mode .login-error {
    background-color: #4a2428;
    color: #ffc9ce;
}

.unread-badge {
    position: static;
    background-color: #dc3545;
    color: white;
    font-size: 0.7rem;
    font-weight: 600;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.unread-badge.hidden {
    display: none;
}

.typing-indicator {
    position: absolute;
    top: -24px;
    right: 0;
    font-size: 0.75rem;
    color: #28a745;
    font-style: italic;
    font-weight: 400;
    white-space: nowrap;
}

.typing-indicator.hidden {
    display: none;
}

.history-item-unread {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background-color: #dc3545;
    color: white;
    font-size: 0.75rem;
    font-weight: 600;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    margin-left: 8px;
}

.typing-text {
    color: var(--text-color);
    font-style: italic;
    font-weight: 400;
    font-size: 0.9rem;
    margin-left: 6px;
    opacity: 0.7;
}

.pagination-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border: 2px solid var(--border-color);
    border-radius: 50%;
    background-color: var(--card-bg);
    color: var(--text-color);
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 1rem;
}

.pagination-btn:hover:not(:disabled) {
    background-color: var(--btn-primary);
    border-color: var(--btn-primary);
    color: white;
    transform: scale(1.1);
    box-shadow: 0 2px 8px rgba(74, 144, 226, 0.3);
}

.pagination-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none;
}

.pagination-info {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-color);
    padding: 0 12px;
    min-width: 60px;
    text-align: center;
}

body.dark-mode .pagination-btn {
    border-color: #4a5568;
}

body.dark-mode .pagination-btn:hover:not(:disabled) {
    background-color: var(--btn-primary);
    border-color: var(--btn-primary);
}
