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

:root {
    --left-color: #e74c3c;
    --right-color: #3498db;
    --bg-dark: #0f0f1a;
    --bg-card: #1a1a2e;
    --text-light: #eee;
    --text-dim: #666;
    --rope-color: #c9a050;
}

body {
    font-family: 'Segoe UI', system-ui, sans-serif;
    background: var(--bg-dark);
    background-image:
        radial-gradient(ellipse at 20% 20%, rgba(231,76,60,0.08) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 80%, rgba(52,152,219,0.08) 0%, transparent 50%);
    color: var(--text-light);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 2rem;
}

.game-wrapper {
    width: 100%;
    max-width: 1200px;
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

header {
    text-align: center;
}

.card-header {
    display: none;
}

header h1 {
    font-size: 2.5rem;
    font-weight: 300;
    letter-spacing: 0.5em;
    text-transform: uppercase;
    background: linear-gradient(90deg, var(--left-color), #fff, var(--right-color));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.game-card {
    background: var(--bg-card);
    border-radius: 24px;
    padding: 3rem;
    border: 1px solid rgba(255,255,255,0.05);
    box-shadow: 0 25px 50px -12px rgba(0,0,0,0.5);
}

.stats-row {
    display: flex;
    justify-content: space-between;
    align-items: stretch;
    gap: 2rem;
    margin-bottom: 3rem;
}

.stat-box {
    flex: 1;
    background: rgba(0,0,0,0.3);
    border-radius: 16px;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    border: 1px solid rgba(255,255,255,0.03);
}

.stat-box.wins {
    flex-direction: row;
    justify-content: space-around;
}

.team-stats {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
    padding: 0.75rem 1.5rem;
    border-radius: 12px;
    border: 2px solid transparent;
    transition: all 0.2s ease;
}

.team-stats.left { color: var(--left-color); }
.team-stats.right { color: var(--right-color); }

.team-stats[data-team="left"] {
    border-color: var(--left-color);
    background: rgba(231,76,60,0.15);
    box-shadow: 0 0 20px rgba(231,76,60,0.2);
}

.team-stats[data-team="right"] {
    border-color: var(--right-color);
    background: rgba(52,152,219,0.15);
    box-shadow: 0 0 20px rgba(52,152,219,0.2);
}

.team-badge {
    position: absolute;
    top: -10px;
    left: 50%;
    transform: translateX(-50%);
    padding: 2px 10px;
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    border-radius: 4px;
    white-space: nowrap;
}

.team-stats.left .team-badge {
    background: var(--left-color);
    color: white;
}

.team-stats.right .team-badge {
    background: var(--right-color);
    color: white;
}

.stat-value {
    font-size: 3rem;
    font-weight: 700;
    line-height: 1;
}

.stat-label {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.2em;
    color: var(--text-dim);
}

.stat-divider {
    width: 1px;
    background: linear-gradient(to bottom, transparent, rgba(255,255,255,0.2), transparent);
    margin: 0 1rem;
}

.battle-area {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 3rem;
    padding: 2rem 0;
}

.side-indicator {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    min-width: 120px;
}

.side-indicator .team-name {
    font-size: 1.2rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.15em;
}

.side-indicator.left .team-name { color: var(--left-color); }
.side-indicator.right .team-name { color: var(--right-color); }

.side-indicator .click-count {
    font-size: 4rem;
    font-weight: 800;
    line-height: 1;
}

.side-indicator.left .click-count { color: var(--left-color); }
.side-indicator.right .click-count { color: var(--right-color); }

.side-indicator .player-count {
    font-size: 0.9rem;
    color: var(--text-dim);
}

.side-indicator .player-count span {
    color: #fff;
    font-weight: 600;
}

.rope-section {
    flex: 1;
    max-width: 700px;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.rope-track-wrapper {
    position: relative;
    padding: 0.5rem 0;
}

.rope-track {
    height: 40px;
    background: linear-gradient(90deg,
        rgba(231,76,60,0.4) 0%,
        rgba(231,76,60,0.15) 20%,
        rgba(255,255,255,0.05) 45%,
        rgba(255,255,255,0.05) 55%,
        rgba(52,152,219,0.15) 80%,
        rgba(52,152,219,0.4) 100%
    );
    border-radius: 20px;
    position: relative;
    border: 1px solid rgba(255,255,255,0.1);
    box-shadow: inset 0 2px 10px rgba(0,0,0,0.3);
}

.rope-track-bg {
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg,
        rgba(231,76,60,0.2) 0%,
        rgba(52,152,219,0.2) 100%
    );
    border-radius: 20px;
}

.team-zone {
    position: absolute;
    top: 0;
    height: 100%;
}

.left-zone {
    left: 0;
    width: 20%;
    background: linear-gradient(90deg, rgba(231,76,60,0.3), transparent);
    border-radius: 20px 0 0 20px;
}

.right-zone {
    right: 0;
    width: 20%;
    background: linear-gradient(-90deg, rgba(52,152,219,0.3), transparent);
    border-radius: 0 20px 20px 0;
}

.center-line {
    position: absolute;
    left: 50%;
    top: -20px;
    bottom: -20px;
    width: 2px;
    background: rgba(255,255,255,0.3);
    transform: translateX(-50%);
    border-radius: 1px;
}

.rope {
    position: absolute;
    top: 50%;
    width: 60px;
    height: 50px;
    background: linear-gradient(180deg,
        #d4af37 0%,
        var(--rope-color) 20%,
        #8b7355 80%,
        #c9a050 100%
    );
    transform: translate(-50%, -50%);
    border-radius: 8px;
    box-shadow:
        0 4px 15px rgba(0,0,0,0.5),
        0 0 30px rgba(201,160,80,0.3),
        inset 0 2px 4px rgba(255,255,255,0.3);
    transition: left 0.15s ease-out;
    z-index: 10;
}

.rope::before,
.rope::after {
    content: '';
    position: absolute;
    top: 50%;
    width: 20px;
    height: 20px;
    background: radial-gradient(circle at 30% 30%, #666, #222);
    border-radius: 50%;
    transform: translateY(-50%);
    border: 2px solid #444;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.5);
}

.rope::before { left: -10px; }
.rope::after { right: -10px; }

.rope-markers {
    display: flex;
    justify-content: space-between;
    padding: 0 30px;
    font-size: 0.7rem;
    color: var(--text-dim);
    letter-spacing: 0.1em;
}

.rope-marker-left { color: var(--left-color); }
.rope-marker-right { color: var(--right-color); }

.bottom-section {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 2rem;
    margin-top: 2rem;
}

.total-stats {
    display: flex;
    gap: 3rem;
}

.total-stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
}

.total-stat .value {
    font-size: 2rem;
    font-weight: 700;
    color: #fff;
}

.total-stat .label {
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.15em;
    color: var(--text-dim);
}

.team-indicator {
    text-align: center;
    min-width: 200px;
}

.team-indicator .player-team {
    font-size: 1rem;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    color: var(--text-dim);
    padding: 0.5rem 1rem;
    border-radius: 8px;
    background: rgba(0,0,0,0.3);
    border: 2px solid transparent;
}

.team-indicator .player-team strong {
    font-weight: 700;
}

.team-indicator .player-team[data-player-team="left"] {
    color: var(--left-color);
    border-color: var(--left-color);
    background: rgba(231,76,60,0.1);
}

.team-indicator .player-team[data-player-team="right"] {
    color: var(--right-color);
    border-color: var(--right-color);
    background: rgba(52,152,219,0.1);
}

.click-button {
    padding: 2rem 5rem;
    font-size: 2rem;
    font-weight: 700;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    color: #fff;
    background: linear-gradient(180deg, #444 0%, #2a2a2a 50%, #1a1a1a 100%);
    border: 3px solid #555;
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.1s ease;
    box-shadow:
        0 8px 0 #111,
        0 12px 30px rgba(0,0,0,0.5);
    position: relative;
    overflow: hidden;
}

.click-button::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.1), transparent);
    transition: left 0.5s ease;
}

.click-button:hover::before {
    left: 100%;
}

.click-button:hover {
    transform: translateY(3px);
    box-shadow:
        0 5px 0 #111,
        0 8px 20px rgba(0,0,0,0.5);
}

.click-button:active,
.click-button.active {
    transform: translateY(6px);
    box-shadow:
        0 2px 0 #111,
        0 4px 10px rgba(0,0,0,0.5);
}

.btn-hint {
    display: block;
    font-size: 0.6rem;
    font-weight: 400;
    letter-spacing: 0.1em;
    margin-top: 0.5rem;
    color: #666;
}

.left-winner .rope,
.right-winner .rope {
    animation: pulse-glow 0.5s ease-in-out infinite alternate;
}

@keyframes pulse-glow {
    from { box-shadow: 0 4px 15px rgba(0,0,0,0.5), 0 0 30px rgba(201,160,80,0.3); }
    to { box-shadow: 0 4px 15px rgba(0,0,0,0.5), 0 0 50px rgba(201,160,80,0.6); }
}

.left-winner .rope {
    background: linear-gradient(180deg,
        #c0392b 0%,
        var(--left-color) 20%,
        #922B21 80%,
        #e74c3c 100%
    );
}

.right-winner .rope {
    background: linear-gradient(180deg,
        #2980b9 0%,
        var(--right-color) 20%,
        #1F618D 80%,
        #3498db 100%
    );
}

.username-section {
    margin-top: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.username-input-row {
    display: flex;
    gap: 0.25rem;
}

.username-input-row[hidden] {
    display: none;
}

#username-input {
    padding: 0.5rem 0.75rem;
    font-size: 0.85rem;
    border: 2px solid #333;
    border-radius: 6px;
    background: #1a1a1a;
    color: #eee;
    width: 140px;
    outline: none;
    transition: border-color 0.2s;
}

#username-input:focus {
    border-color: #888;
}

#username-input::placeholder {
    color: #666;
}

.username-btn {
    padding: 0.5rem 0.75rem;
    font-size: 0.85rem;
    font-weight: 600;
    border: none;
    border-radius: 6px;
    background: #444;
    color: #eee;
    cursor: pointer;
    transition: background 0.2s;
}

.username-btn:hover {
    background: #555;
}

.username-display {
    font-size: 0.9rem;
    font-weight: 500;
    color: #ccc;
    min-height: 1.2rem;
}

#username-change-section {
    margin-top: 0.25rem;
    font-size: 0.75rem;
}

#username-change-section a {
    color: #888;
    text-decoration: underline;
    cursor: pointer;
}

#username-change-section a:hover {
    color: #aaa;
}

.username-change-timer {
    color: #555;
}

.username-change-link {
    color: #888;
    text-decoration: underline;
    cursor: pointer;
}

.username-change-link:hover {
    color: #aaa;
}

.clickers-container {
    position: fixed;
    bottom: 1rem;
    right: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    align-items: flex-end;
    max-height: 400px;
    overflow: hidden;
    pointer-events: none;
    padding: 0.5rem;
}

.clicker-badge {
    font-size: 0.9rem;
    font-weight: 700;
    padding: 0.6rem 1.2rem;
    border-radius: 50px;
    color: #fff;
    text-shadow: 0 2px 4px rgba(0,0,0,0.4);
    box-shadow: 0 4px 20px rgba(0,0,0,0.4), 0 0 15px var(--badge-glow);
    animation-fill-mode: both;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.clicker-badge.enter {
    animation: popIn 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.5);
}

@keyframes popIn {
    0% {
        opacity: 0;
        transform: translateX(120px) scale(0.2) rotate(20deg);
    }
    60% {
        opacity: 1;
        transform: translateX(-10px) scale(1.1) rotate(-5deg);
    }
    80% {
        transform: translateX(5px) scale(0.95) rotate(2deg);
    }
    100% {
        opacity: 1;
        transform: translateX(0) scale(1) rotate(0deg);
    }
}

.rotate-message {
    display: none;
    position: fixed;
    inset: 0;
    background: var(--bg-dark);
    z-index: 9999;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1.5rem;
    text-align: center;
    padding: 2rem;
}

.rotate-message svg {
    width: 80px;
    height: 80px;
    fill: var(--text-dim);
    animation: rotate-hint 2s ease-in-out infinite;
}

@keyframes rotate-hint {
    0%, 100% { transform: rotate(-30deg); }
    50% { transform: rotate(30deg); }
}

.rotate-message h2 {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-light);
}

.rotate-message p {
    color: var(--text-dim);
    font-size: 0.9rem;
}

@media (orientation: portrait) {
    .rotate-message {
        display: flex;
    }
    .game-wrapper {
        display: none;
    }
}

@media (max-width: 768px) and (max-height: 500px) and (orientation: landscape) {
    body {
        padding: 0.25rem;
        align-items: flex-start;
        overflow: hidden;
    }

    header {
        display: none;
    }

    .game-wrapper {
        height: calc(100vh - 0.5rem);
        max-width: 100%;
    }

    .game-card {
        padding: 0.5rem;
        height: 100%;
        display: flex;
        flex-direction: column;
    }

    .card-header {
        display: block;
        text-align: center;
        flex-shrink: 0;
    }

    .card-header h1 {
        font-size: 1rem;
        font-weight: 300;
        letter-spacing: 0.3em;
        text-transform: uppercase;
        background: linear-gradient(90deg, var(--left-color), #fff, var(--right-color));
        -webkit-background-clip: text;
        -webkit-text-fill-color: transparent;
        background-clip: text;
    }

    .clickers-container {
        position: static;
        flex-direction: row;
        justify-content: center;
        overflow: hidden;
        height: 1.5rem;
        flex-shrink: 0;
        margin-top: auto;
    }

    .clicker-badge {
        font-size: 0.6rem;
        padding: 0.15rem 0.5rem;
        margin: 0 0.15rem;
        opacity: 0.7;
        animation: none;
    }

    .clicker-badge.enter {
        animation: scrollIn 0.3s ease-out;
    }

    @keyframes scrollIn {
        from { transform: translateX(20px); opacity: 0; }
        to { transform: translateX(0); opacity: 0.7; }
    }

    .game-container {
        flex: 1;
        display: flex;
        flex-direction: column;
        justify-content: space-between;
        min-height: 0;
    }

    .stats-row {
        flex-shrink: 0;
    }

    .stat-box {
        padding: 0.3rem;
    }

    .stat-value {
        font-size: 1.3rem;
    }

    .stat-label {
        font-size: 0.45rem;
    }

    .team-stats {
        padding: 0.3rem 0.5rem;
    }

    .team-badge {
        font-size: 0.45rem;
        padding: 1px 5px;
        top: -6px;
    }

    .battle-area {
        flex: 1;
        min-height: 0;
        display: flex;
        align-items: center;
        gap: 0.5rem;
    }

    .side-indicator {
        min-width: 50px;
    }

    .side-indicator .team-name {
        font-size: 0.6rem;
    }

    .side-indicator .click-count {
        font-size: 1.5rem;
    }

    .side-indicator .player-count {
        font-size: 0.55rem;
    }

    .rope-section {
        max-width: 350px;
        flex: 1;
    }

    .rope {
        width: 25px;
        height: 25px;
    }

    .rope-track {
        height: 20px;
    }

    .rope-markers {
        font-size: 0.5rem;
        padding: 0 15px;
    }

    .bottom-section {
        flex-shrink: 0;
        gap: 0.5rem;
        margin-top: 0.25rem;
    }

    .total-stats {
        gap: 0.75rem;
    }

    .total-stat .value {
        font-size: 1rem;
    }

    .total-stat .label {
        font-size: 0.45rem;
    }

    .team-indicator {
        min-width: auto;
    }

    .team-indicator .player-team {
        font-size: 0.6rem;
        padding: 0.25rem 0.4rem;
    }

    .click-button {
        padding: 0.5rem 1.2rem;
        font-size: 0.85rem;
        border-radius: 8px;
        box-shadow:
            0 2px 0 #111,
            0 4px 10px rgba(0,0,0,0.5);
    }

    .click-button:active,
    .click-button.active {
        transform: translateY(1px);
        box-shadow:
            0 1px 0 #111,
            0 2px 5px rgba(0,0,0,0.5);
    }

    .btn-hint {
        font-size: 0.45rem;
        margin-top: 0.15rem;
    }

    .username-section {
        margin-top: 0.15rem;
    }

    #username-input,
    .username-btn {
        font-size: 0.6rem;
        padding: 0.2rem 0.4rem;
    }

    .username-display {
        font-size: 0.6rem;
    }

    #username-change-section {
        font-size: 0.5rem;
    }
}
