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

:root {
    --bg-dark: #1a1a2e;
    --bg-darker: #0f0f1e;
    --stone-light: #d4af8f;
    --stone-dark: #6b5d4f;
    --text-light: #f0f0f0;
    --text-muted: #a0a0a0;
    --accent-gold: #ffd700;
    --accent-red: #dc2626;
    --border-color: #4a4a5e;
}

body {
    background-color: var(--bg-dark);
    color: var(--text-light);
    font-family: 'Georgia', 'Times New Roman', serif;
    line-height: 1.6;
    background-image:
        repeating-linear-gradient(
            45deg,
            transparent,
            transparent 10px,
            rgba(107, 93, 79, 0.1) 10px,
            rgba(107, 93, 79, 0.1) 20px
        );
}

.container {
    max-width: 1000px;
    margin: 0 auto;
    padding: 20px;
    position: relative;
}

/* Language Selector */
.language-selector {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 0;
}

.lang-toggle {
    padding: 12px 16px;
    background-color: rgba(26, 26, 46, 0.9);
    color: var(--text-light);
    border: 2px solid var(--accent-gold);
    border-radius: 4px;
    cursor: pointer;
    font-size: 1.2rem;
    font-weight: bold;
    transition: all 0.3s ease;
    min-width: 50px;
    text-align: center;
}

.lang-toggle:hover {
    background-color: var(--accent-gold);
    color: var(--bg-dark);
    transform: scale(1.05);
}

.lang-panel {
    display: none;
    flex-direction: column;
    gap: 0;
    background-color: rgba(26, 26, 46, 0.95);
    border: 2px solid var(--accent-gold);
    border-top: none;
    border-radius: 0 0 4px 4px;
    overflow-y: auto;
    max-height: 400px;
}

.lang-panel.open {
    display: flex;
}

.lang-btn {
    padding: 12px 16px;
    background-color: transparent;
    color: var(--text-light);
    border: none;
    border-bottom: 1px solid rgba(255, 215, 0, 0.2);
    border-radius: 0;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: bold;
    transition: all 0.3s ease;
    text-align: center;
}

.lang-btn:last-child {
    border-bottom: none;
}

.lang-btn:hover {
    background-color: rgba(255, 215, 0, 0.2);
    color: var(--accent-gold);
}

header {
    text-align: center;
    margin-bottom: 40px;
    padding: 40px 20px;
    border-bottom: 3px solid var(--stone-dark);
}

header h1 {
    font-size: 3rem;
    color: var(--accent-gold);
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
    margin-bottom: 10px;
    font-weight: normal;
    letter-spacing: 2px;
}

.subtitle {
    color: var(--text-muted);
    font-size: 1.2rem;
    font-style: italic;
    margin-bottom: 20px;
}

/* Game Mode Selector */
.game-mode-selector {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-top: 20px;
    flex-wrap: wrap;
}

.mode-btn {
    padding: 10px 20px;
    background-color: var(--stone-dark);
    color: var(--text-light);
    border: 2px solid var(--accent-gold);
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.95rem;
    font-family: inherit;
    transition: all 0.3s ease;
    font-weight: bold;
}

.mode-btn:hover {
    background-color: var(--accent-gold);
    color: var(--bg-dark);
    transform: scale(1.05);
}

.mode-btn.active {
    background-color: var(--accent-gold);
    color: var(--bg-dark);
    box-shadow: 0 0 10px rgba(255, 215, 0, 0.5);
}

.mode-dev-btn {
    padding: 10px 16px;
    background-color: transparent;
    color: var(--text-muted);
    border: 2px solid var(--text-muted);
    border-radius: 4px;
    cursor: pointer;
    font-size: 1.2rem;
    transition: all 0.3s ease;
}

.controls {
    display: flex;
    justify-content: center;
    gap: 30px;
    margin-bottom: 40px;
    align-items: center;
}

.btn-refresh {
    padding: 10px 20px;
    background-color: var(--stone-dark);
    color: var(--text-light);
    border: 2px solid var(--accent-gold);
    border-radius: 4px;
    cursor: pointer;
    font-size: 1rem;
    font-family: inherit;
    transition: all 0.3s ease;
}

.btn-refresh:hover {
    background-color: var(--accent-gold);
    color: var(--bg-dark);
    transform: scale(1.05);
}

.auto-refresh-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
}

.auto-refresh-toggle input {
    cursor: pointer;
    width: 18px;
    height: 18px;
}

.auto-refresh-toggle label {
    cursor: pointer;
    color: var(--text-muted);
}

.loading {
    text-align: center;
    padding: 40px;
    font-size: 1.2rem;
    color: var(--text-muted);
}

.error-message {
    display: none;
    padding: 20px;
    margin-bottom: 20px;
    background-color: rgba(220, 38, 38, 0.1);
    border-left: 4px solid var(--accent-red);
    color: var(--accent-red);
    text-align: center;
}

.error-message.show {
    display: block;
}

.ranking-grid {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-bottom: 40px;
}

.gravestone {
    background: rgba(26, 26, 46, 0.6);
    border: 2px solid var(--accent-red);
    border-radius: 8px;
    padding: 16px;
    position: relative;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.4);
    transition: all 0.3s ease;
    overflow: hidden;
}

.gravestone::before {
    display: none;
}

.gravestone:hover {
    transform: translateY(-3px);
    box-shadow: 0 12px 30px rgba(220, 38, 38, 0.3);
    background: rgba(26, 26, 46, 0.8);
}

.gravestone-content {
    position: relative;
    z-index: 1;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 15px;
    text-align: left;
}

/* Section 1: Rank, Player, Score, Cause */
.info-section {
    flex: 0 0 auto;
    width: 420px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.top-row {
    display: flex;
    gap: 12px;
    align-items: center;
}

.rank-cell {
    font-size: 1.25rem;
    color: #ffd700;
    font-weight: bold;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.3);
    width: 70px;
    text-align: center;
    flex-shrink: 0;
}

.player-cell {
    flex: 0 0 260px;
    min-width: 0;
}

.player-name {
    color: var(--accent-gold);
    font-weight: bold;
    font-size: 1rem;
    word-wrap: break-word;
    overflow-wrap: break-word;
    word-break: break-all;
    line-height: 1.3;
    max-height: 2.6em;
    overflow: hidden;
}

.score-cell {
    color: var(--accent-gold);
    font-weight: bold;
    font-size: 1rem;
}

.bottom-row {
    display: flex;
    align-items: center;
}

.cause-cell {
    color: #ff6b6b;
    font-weight: bold;
    font-size: 0.9rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Section 2: Icons (Class, Equipment, Skills) */
.icons-section {
    flex: 0 0 385px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    align-items: flex-start;
    justify-content: flex-start;
}

.equipment-and-class {
    display: flex;
    gap: 20px;
    align-items: center;
}

.class-cell {
    flex-shrink: 0;
    display: flex;
    align-items: center;
}

.equipment-cell {
    color: var(--text-muted);
    font-size: 0.85rem;
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}

.equipment-icon {
    font-size: 1.3rem;
    display: inline-block;
    cursor: pointer;
    transition: transform 0.2s ease;
}

.equipment-icon:hover {
    transform: scale(1.2);
}

.equipment-icon-empty {
    color: var(--text-muted);
    font-size: 0.9rem;
}

.skills-cell {
    color: var(--text-light);
    font-size: 0.85rem;
    display: flex;
    gap: 5px;
    align-items: center;
    flex-wrap: wrap;
    margin-left: 60px;
}

.skill-icon {
    font-size: 1.3rem;
    display: inline-block;
    cursor: pointer;
    transition: transform 0.2s ease;
}

.skill-icon:hover {
    transform: scale(1.2);
}

.skill-icon-empty {
    color: var(--text-muted);
    font-size: 0.9rem;
}

/* Section 3: Details Button */
.details-cell {
    flex: 0 0 auto;
    display: flex;
    justify-content: center;
}

footer {
    text-align: center;
    padding: 30px 20px;
    border-top: 3px solid var(--stone-dark);
    color: var(--text-muted);
    margin-top: 60px;
}

#lastUpdate {
    color: var(--accent-gold);
    font-weight: bold;
}

.credits {
    font-size: 0.9rem;
    margin-top: 10px;
}

/* Responsive */
@media (max-width: 1024px) {
    .gravestone-content {
        flex-wrap: wrap;
    }

    .player-cell,
    .depth-cell,
    .cause-cell,
    .score-cell,
    .equipment-cell,
    .skills-cell {
        min-width: 100px;
    }
}

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

    .controls {
        flex-direction: column;
        gap: 15px;
    }

    .language-selector {
        top: 10px;
        right: 10px;
        flex-direction: row;
        gap: 5px;
    }

    .lang-btn {
        padding: 8px 12px;
        font-size: 0.8rem;
        min-width: 40px;
    }

    .gravestone-content {
        gap: 10px;
    }

    .player-cell,
    .depth-cell,
    .cause-cell,
    .score-cell,
    .equipment-cell,
    .skills-cell,
    .details-cell {
        width: 100%;
        min-width: auto;
    }

    .rank-cell {
        min-width: auto;
    }

    .equipment-cell,
    .skills-cell {
        flex-wrap: wrap;
        gap: 6px;
    }

    .class-cell {
        flex: 0 0 auto;
    }

    .skills-cell {
        margin-left: 60px;
    }

    .equipment-icon,
    .skill-icon {
        font-size: 1.1rem;
    }

    .details-cell {
        justify-content: flex-start;
    }

    .details-button {
        width: 100%;
    }

    .modal-content {
        max-width: 95%;
        border-radius: 8px;
    }

    .modal-header h2 {
        font-size: 1.4rem;
    }

    .modal-body {
        padding: 15px;
    }

    .player-info-row {
        justify-content: space-between;
        align-items: center;
    }

    .info-label {
        margin-bottom: 0;
    }

    .info-value {
        text-align: right;
    }

    .equipment-list,
    .skills-list {
        grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
        gap: 10px;
    }

    .bag-items-list {
        grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
        gap: 10px;
    }

    .bag-item {
        min-width: 0;
    }

    .equipment-item,
    .skill-item,
    .bag-item {
        padding: 8px;
    }

    .equipment-item img,
    .skill-item img,
    .bag-item img {
        width: 40px;
        height: 40px;
    }

    .item-name {
        font-size: 0.75rem;
    }
}

/* Responsive - Mobile Small (600px and below) */
@media (max-width: 600px) {
    .gravestone-content {
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
    }

    .info-section {
        width: 100%;
        gap: 0;
    }

    .top-row {
        flex-direction: column;
        gap: 0;
    }

    .rank-cell,
    .player-cell,
    .score-cell {
        margin-bottom: 8px;
    }

    .player-cell {
        flex: 1 1 auto;
    }

    .player-name {
        max-height: 1.3em;
        line-height: 1.3;
    }

    .bottom-row {
        margin-bottom: 8px;
    }

    .icons-section {
        flex: 1 1 auto;
        width: 100%;
        gap: 8px;
        align-items: flex-start;
    }

    .equipment-and-class {
        flex-direction: column;
        gap: 8px;
        width: 100%;
        align-items: flex-start;
    }

    .class-cell {
        margin-bottom: 0;
        justify-content: flex-start;
    }

    .equipment-cell {
        width: 100%;
        margin-left: 0 !important;
    }

    .skills-cell {
        margin-left: 0;
        width: 100%;
    }

    .details-cell {
        width: 100%;
        justify-content: center;
        margin-top: 8px;
    }

    .details-button {
        width: 100%;
    }
}

/* Responsive - Mobile Extra Small (480px and below) */
@media (max-width: 480px) {
    .gravestone {
        padding: 10px;
    }

    .skills-cell {
        gap: 3px;
    }
}

/* Animation */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.gravestone {
    animation: fadeIn 0.5s ease forwards;
}

.gravestone:nth-child(1) {
    animation-delay: 0s;
}

.gravestone:nth-child(2) {
    animation-delay: 0.1s;
}

.gravestone:nth-child(3) {
    animation-delay: 0.2s;
}

.gravestone:nth-child(n+4) {
    animation-delay: 0.3s;
}

/* Icon Styles */
.icon {
    display: inline-block;
    width: 32px;
    height: 32px;
    margin: 0 4px;
    object-fit: contain;
    image-rendering: crisp-edges;
    cursor: pointer;
    transition: transform 0.2s ease, filter 0.2s ease;
}

.icon:hover {
    transform: scale(1.15);
    filter: brightness(1.2);
}

.icon-character {
    width: 40px;
    height: 40px;
    margin: 0 0px 0 0;
}

.icon-item {
    width: 32px;
    height: 32px;
}

.icon-skill {
    width: 28px;
    height: 28px;
}

/* Tooltip icon - click/tap to show details */
.tooltip-icon {
    cursor: pointer;
}

.details-button {
    padding: 8px 8px;
    background-color: var(--stone-dark);
    color: var(--text-light);
    border: 2px solid var(--accent-gold);
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.85rem;
    font-family: inherit;
    transition: all 0.3s ease;
    white-space: nowrap;
}

.details-button:hover {
    background-color: var(--accent-gold);
    color: var(--bg-dark);
    transform: scale(1.05);
}

/* Modal Styles */
.modal {
    display: none;
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.8);
    animation: fadeIn 0.3s ease;
}

.modal.show {
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background-color: var(--bg-darker);
    border: 3px solid var(--accent-gold);
    border-radius: 8px;
    width: 850px;
    max-width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 0 30px rgba(255, 215, 0, 0.3);
    animation: slideUp 0.3s ease;
}

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

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 2px solid var(--stone-dark);
    background-color: rgba(26, 26, 46, 0.9);
}

.modal-header h2 {
    color: var(--accent-gold);
    font-size: 1.8rem;
    margin: 0;
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-light);
    font-size: 2rem;
    cursor: pointer;
    padding: 0;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.modal-close:hover {
    color: var(--accent-red);
    transform: scale(1.2);
}

.modal-body {
    padding: 30px;
    color: var(--text-light);
}

.player-info-section {
    margin-bottom: 30px;
}

.player-info-section h3 {
    color: var(--accent-gold);
    font-size: 1.3rem;
    margin-bottom: 15px;
    border-bottom: 2px solid var(--stone-dark);
    padding-bottom: 10px;
}

.player-info-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid rgba(255, 215, 0, 0.1);
}

.player-info-row:last-child {
    border-bottom: none;
}

.info-label {
    color: var(--text-muted);
    font-weight: bold;
    min-width: 150px;
}

.info-value {
    color: var(--text-light);
    text-align: right;
}

.equipment-list,
.skills-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 15px;
    margin-top: 15px;
}

.bag-items-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 15px;
    margin-top: 15px;
}

.bag-item {
    min-width: 0;
    word-break: break-word;
    overflow-wrap: break-word;
}

.equipment-item,
.skill-item,
.bag-item {
    background-color: rgba(107, 93, 79, 0.3);
    border: 1px solid var(--stone-dark);
    border-radius: 4px;
    padding: 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.equipment-item img,
.skill-item img,
.bag-item img {
    width: 48px;
    height: 48px;
    object-fit: contain;
}

.item-name {
    font-size: 0.85rem;
    text-align: center;
    word-wrap: break-word;
    color: var(--text-light);
}

.item-grade {
    font-size: 0.8rem;
    color: var(--accent-gold);
}

.item-enchants {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-align: center;
    margin-top: 4px;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.empty-message {
    color: var(--text-muted);
    font-style: italic;
    text-align: center;
    padding: 20px;
}
