/* Dialogs */
.modal-overlay {
    display: none;
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.3);
    z-index: 2000;
    justify-content: center;
    align-items: center;
    backdrop-filter: blur(2px);
}

.modal-overlay.active {
    display: flex;
}

.dialog-content {
    background: rgba(255, 255, 255, 0.98);
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
    width: 320px;
    max-width: 90%;
    text-align: center;
}

.residence-region-dialog {
    width: 380px;
}

.residence-region-dialog h2 {
    margin: 0 0 10px;
}

.residence-region-dialog h3 {
    margin: 20px 0 6px;
    text-align: left;
}

.residence-region-dialog > p {
    margin: 0;
    color: #475569;
    line-height: 1.5;
}

.initial-profile-username {
    margin-top: 18px;
    text-align: left;
}

.initial-profile-username label {
    display: block;
    margin-bottom: 6px;
    font-weight: 700;
}

.initial-profile-username input {
    width: 100%;
    height: 40px;
    padding: 8px 10px;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    box-sizing: border-box;
    font-size: 16px;
}

.initial-profile-username input:focus {
    border-color: var(--accent);
    outline: 2px solid rgba(59, 130, 246, 0.18);
}

.initial-profile-username p {
    margin: 6px 0 0;
    color: #64748b;
    font-size: 12px;
    line-height: 1.45;
}

.residence-region-options {
    display: grid;
    gap: 10px;
    margin: 12px 0;
    text-align: left;
}

.residence-region-option {
    display: flex;
    gap: 10px;
    align-items: center;
    padding: 12px;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    cursor: pointer;
}

.residence-region-option:has(input:checked) {
    border-color: var(--accent);
    background: rgba(59, 130, 246, 0.08);
}

.residence-region-option:has(input:disabled) {
    cursor: default;
}

.residence-region-note {
    font-size: 12px;
}

#residence-region-confirm {
    width: 100%;
    margin-top: 8px;
}

.delete-environment-warning {
    margin: 12px 0;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 6px;
    background: #f8fafc;
    color: #333;
    font-size: 12px;
    line-height: 1.45;
    text-align: left;
}

.delete-environment-warning strong {
    display: block;
    margin-bottom: 4px;
    color: #14532d;
}

.delete-environment-warning strong.is-production {
    color: #b91c1c;
}

.delete-production-guard {
    margin: 12px 0;
    text-align: left;
}

.delete-production-guard label {
    display: block;
    margin-bottom: 6px;
    color: #b91c1c;
    font-size: 12px;
    font-weight: 700;
}

.delete-production-guard input {
    width: 100%;
    height: 36px;
    padding: 6px 8px;
    border: 1px solid #fca5a5;
    border-radius: 4px;
    box-sizing: border-box;
    font-family: 'JetBrains Mono', monospace;
    font-size: 14px;
}

/* Controls (Bottom Left) - REMOVED */


/* Tooltip */
#tooltip {
    position: absolute;
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 8px 12px;
    border-radius: 4px;
    font-size: 12px;
    pointer-events: none;
    /* Default none, auto when pinned */
    display: none;
    z-index: 150;
}

.tooltip-link {
    cursor: pointer;
}

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

/* Mobile */
@media (max-width: 600px) {
    .header-bar {
        padding: 0 8px;
    }

    .user-dropdown-menu {
        min-width: 200px;
    }

    .user-menu-name,
    .user-menu-email {
        max-width: 140px;
    }
}

.lang-flag {
    width: 20px;
    height: 15px;
    object-fit: cover;
    border: 1px solid #eee;
}

/* ===== User Dropdown ===== */
.settings-dropdown,
.user-dropdown {
    position: relative;
    display: inline-block;
}

.user-dropdown-btn {
    background: white;
    border: 1px solid #ccc;
    border-radius: 4px;
    padding: 3px 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    height: 32px;
    box-sizing: border-box;
    transition: background 0.2s;
}

.user-dropdown-btn:hover {
    background-color: #f9f9f9;
}

.user-avatar {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    object-fit: cover;
}

.user-avatar-fallback {
    font-size: 22px;
    color: #666;
}

.user-dropdown-menu {
    display: none;
    position: absolute;
    top: 100%;
    right: 0;
    background: white;
    border: 1px solid #ccc;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
    z-index: 200;
    min-width: 260px;
    max-width: min(340px, calc(100vw - 16px));
    margin-top: 4px;
    padding: 8px 0;
}

.settings-dropdown-menu {
    display: none;
    position: absolute;
    top: 100%;
    right: 0;
    background: white;
    border: 1px solid #ccc;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
    z-index: 200;
    min-width: 260px;
    max-width: min(340px, calc(100vw - 16px));
    margin-top: 4px;
    padding: 8px 0;
}

.settings-dropdown-menu.show,
.user-dropdown-menu.show {
    display: block;
}

.user-dropdown-info {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
}

.user-menu-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}

.user-menu-avatar-fallback {
    font-size: 32px;
    color: #999;
    flex-shrink: 0;
}

.user-menu-details {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.user-menu-name {
    font-size: 13px;
    font-weight: 600;
    color: #333;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-menu-email {
    font-size: 11px;
    color: #999;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-dropdown-divider {
    height: 1px;
    background: #eee;
    margin: 4px 0;
}

.user-dropdown-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 8px 14px;
    border: none;
    background: none;
    cursor: pointer;
    font-size: 13px;
    color: #333;
    text-align: left;
    font-family: 'DM Sans', 'Noto Sans JP', sans-serif;
    transition: background 0.15s;
}

.user-dropdown-item:hover {
    background-color: #f5f5f5;
}

.user-dropdown-item i {
    width: 16px;
    text-align: center;
    color: #666;
    font-size: 14px;
}

/* Profile settings inline in dropdown */
.user-dropdown-profile {
    padding: 8px 14px;
}

.user-dropdown-section-title {
    font-size: 11px;
    font-weight: 700;
    color: #666;
    margin: 4px 0 6px;
}

.user-language-options {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 6px;
    margin-bottom: 10px;
}

.user-language-option {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 30px;
    padding: 5px 6px;
    border: 1px solid #ddd;
    border-radius: 4px;
    background: #fff;
    color: #333;
    cursor: pointer;
    font-size: 12px;
    font-family: 'DM Sans', 'Noto Sans JP', sans-serif;
    box-sizing: border-box;
}

.user-language-option:hover {
    background-color: #f7f7f7;
}

.user-language-option.active {
    border-color: #333;
    background: #333;
    color: #fff;
}

.user-dropdown-profile-row {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 4px;
    font-size: 12px;
    color: #333;
}

.user-dropdown-profile-row input[type="radio"] {
    margin: 0;
    width: 14px;
    height: 14px;
}

.user-dropdown-profile-row label {
    font-size: 12px;
    cursor: pointer;
}

.user-dropdown-profile-preview {
    font-size: 11px;
    color: #999;
    margin-left: 20px;
    margin-bottom: 6px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-dropdown-profile-input {
    width: 100%;
    box-sizing: border-box;
    padding: 5px 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 12px;
    margin-top: 2px;
    margin-bottom: 8px;
    font-family: 'DM Sans', 'Noto Sans JP', sans-serif;
    transition: border-color 0.2s;
}

.user-dropdown-profile-input:focus {
    outline: none;
    border-color: #999;
}

.user-dropdown-profile-input:disabled {
    background: #f5f5f5;
    color: #999;
}

.user-dropdown-profile-save {
    width: 100%;
    padding: 6px 0;
    background: #333;
    color: white;
    border: none;
    border-radius: 4px;
    font-size: 12px;
    cursor: pointer;
    font-family: 'DM Sans', 'Noto Sans JP', sans-serif;
    transition: background 0.2s;
}

.user-dropdown-profile-save:hover {
    background: #555;
}

.purchase-history-panel {
    padding: 8px 14px;
}

.purchase-history-title {
    font-size: 12px;
    font-weight: 700;
    color: #333;
    margin-bottom: 6px;
}

.purchase-history-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    max-height: 180px;
    overflow-y: auto;
}

.purchase-history-row {
    padding: 7px 8px;
    border: 1px solid #eee;
    border-radius: 6px;
    background: #fafafa;
}

.purchase-history-main {
    font-size: 12px;
    font-weight: 700;
    color: #222;
    line-height: 1.35;
}

.purchase-history-meta {
    margin-top: 2px;
    font-size: 11px;
    color: #666;
    line-height: 1.35;
}

.purchase-history-empty {
    font-size: 11px;
    color: #777;
    line-height: 1.45;
}

.purchase-history-error {
    color: #b3261e;
}

.user-dropdown-logout {
    color: #d32f2f;
}

.user-dropdown-logout i {
    color: #d32f2f;
}

.user-dropdown-logout:hover {
    background-color: #fef2f2;
}

/* (Old footer styles removed - see Footer v3 section above) */

/* Info Dialog */
#info-dialog ul {
    padding-left: 20px;
    margin: 10px 0;
}

#info-dialog li {
    margin-bottom: 5px;
}

#info-dialog a {
    color: #333;
    text-decoration: underline;
}

#info-dialog a:hover {
    color: #000;
}

/* Info Dialog Tabs */
.info-dialog-content {
    max-height: 80vh;
    overflow-y: auto;
}

.info-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 20px;
    background: #f0f0f0;
    padding: 4px;
    border-radius: 8px;
}

.info-tab {
    flex: 1;
    padding: 10px 16px;
    border: none;
    background: transparent;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    color: #666;
    transition: all 0.2s ease;
    font-family: 'DM Sans', 'Noto Sans JP', sans-serif;
}

.info-tab:hover {
    background: rgba(255, 255, 255, 0.5);
    color: #333;
}

.info-tab.active {
    background: white;
    color: #333;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* Info Tab Content */
.info-tab-content {
    display: none;
}

.info-tab-content.active {
    display: block;
    animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-5px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Rule Sections */
.rule-section {
    margin-bottom: 16px;
    padding-bottom: 16px;
    border-bottom: 1px solid #eee;
}

.rule-section:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.rule-section h4 {
    margin: 0 0 8px 0;
    font-size: 15px;
    color: #333;
}

.rule-section p {
    margin: 0;
    font-size: 14px;
    color: #555;
    line-height: 1.6;
}

.rule-section ul {
    margin: 8px 0 0 0;
    padding-left: 20px;
}

.rule-section li {
    font-size: 14px;
    color: #555;
    margin-bottom: 4px;
}

/* Influence Table */
.influence-table {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-top: 12px;
    background: #f8f9fa;
    border-radius: 8px;
    padding: 12px;
}

.influence-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 10px;
    background: white;
    border-radius: 4px;
    font-size: 13px;
}

.influence-price {
    font-weight: 600;
    color: #333;
}

.influence-radius {
    color: #666;
    background: #eee;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 12px;
}

/* King Tier Table */
.king-tier-table {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 12px;
}

.king-tier-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    background: #f8f9fa;
    border-radius: 8px;
}

.king-tier-row .king-crown-mark {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: #fff8d6;
    border: 1px solid #ffd700;
    color: #8a6d1f;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.king-tier-desc {
    font-size: 13px;
    color: #555;
}
