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

body {
    font-family: system-ui, -apple-system, sans-serif;
    background-color: #1a472a;
    color: #fff;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
}

main {
    text-align: center;
}

h1 {
    font-size: 3rem;
    margin-bottom: 1rem;
}

p {
    font-size: 1.25rem;
    opacity: 0.8;
}


/* Top-right icon buttons */
.icon-btn {
    position: fixed;
    top: 1rem;
    right: 1rem;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: #fff;
    font-size: 1.5rem;
    width: 3rem;
    height: 3rem;
    border-radius: 50%;
    cursor: pointer;
    transition: background 0.2s;
    z-index: 100;
}

.icon-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

.icon-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

#settings-btn {
    right: 4.5rem;
}

#health-check-btn {
    right: 8rem;
}

#refresh-btn {
    right: 11.5rem;
}

#new-game-btn {
    right: 15rem;
}

#invite-links-btn {
    right: 18.5rem;
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal.hidden {
    display: none;
}

.modal-content {
    background: #2d5a3d;
    border-radius: 8px;
    min-width: 300px;
    max-width: 90%;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.modal-header h2 {
    font-size: 1.25rem;
    margin: 0;
}

.close-btn {
    background: none;
    border: none;
    color: #fff;
    font-size: 1.5rem;
    cursor: pointer;
    opacity: 0.7;
}

.close-btn:hover {
    opacity: 1;
}

.modal-body {
    padding: 1.5rem;
}

.modal-body label {
    display: block;
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
    font-weight: 500;
}

.modal-body select,
.modal-body input[type="text"],
.modal-body input[type="password"] {
    width: 100%;
    padding: 0.6rem 0.75rem;
    border-radius: 4px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    background: #1a472a;
    color: #fff;
    font-size: 1rem;
    margin-bottom: 1rem;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.modal-body select:focus,
.modal-body input[type="text"]:focus,
.modal-body input[type="password"]:focus {
    outline: none;
    border-color: #4a7c59;
    box-shadow: 0 0 0 2px rgba(74, 124, 89, 0.3);
}

.modal-body input::placeholder {
    color: rgba(255, 255, 255, 0.4);
}

.modal-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    justify-content: flex-end;
}

.modal-footer .primary-btn {
    margin-top: 0;
    padding: 0.6rem 1.5rem;
    font-size: 1rem;
}

/* Hidden class */
.hidden {
    display: none !important;
}

/* Primary Button */
.primary-btn {
    background: #4a7c59;
    color: #fff;
    border: none;
    padding: 1rem 2rem;
    font-size: 1.25rem;
    border-radius: 8px;
    cursor: pointer;
    margin-top: 1.5rem;
    transition: background 0.2s;
}

.primary-btn:hover {
    background: #5a8c69;
}

.primary-btn:disabled {
    background: #3a5c49;
    cursor: not-allowed;
    opacity: 0.7;
}

/* Game View */
#game-view {
    width: 100%;
    max-width: 1000px;
    padding: 1rem;
    margin: 0 auto;
}

.game-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 1rem;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 8px;
    margin-bottom: 0.75rem;
}

.game-id {
    font-size: 0.9rem;
    opacity: 0.8;
}

.turn-indicator {
    font-weight: bold;
    color: #ffd700;
}

/* Your turn highlight in header */
.game-header.your-turn {
    background: rgba(74, 124, 89, 0.5);
    border: 2px solid #90ee90;
}

.game-header.your-turn .turn-indicator {
    color: #90ee90;
    font-size: 1rem;
}

/* Must give card - warning state */
.game-header.must-give-card {
    background: rgba(198, 40, 40, 0.4);
    border: 2px solid #ff6b6b;
}

.game-header.must-give-card .turn-indicator {
    color: #ff6b6b;
    font-size: 1rem;
}

.game-board {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}

.other-players {
    display: flex;
    justify-content: space-around;
    gap: 1rem;
}

.other-player {
    background: rgba(0, 0, 0, 0.2);
    padding: 0.5rem 0.75rem;
    border-radius: 8px;
    text-align: center;
    min-width: 100px;
}

.other-player.active {
    border: 2px solid #ffd700;
}

.player-label {
    font-weight: bold;
    margin-bottom: 0.5rem;
}

.card-count {
    font-size: 0.9rem;
    opacity: 0.8;
}

.played-cards {
    background: rgba(0, 0, 0, 0.3);
    padding: 0.75rem 1rem;
    border-radius: 8px;
    display: flex;
    align-items: center;
    gap: 1rem;
}

.played-cards-label {
    font-size: 0.9rem;
    opacity: 0.7;
    white-space: nowrap;
}

.board-display {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    flex: 1;
    justify-content: center;
}

/* Your Hand */
.your-hand {
    background: rgba(0, 0, 0, 0.2);
    padding: 0.75rem 1rem;
    border-radius: 8px;
    display: flex;
    align-items: center;
    gap: 1rem;
    position: relative;
    border: 2px solid transparent;
}

/* Your turn - green border */
.your-hand.your-turn {
    border-color: #90ee90;
    background: rgba(46, 125, 50, 0.2);
    padding-top: 1.5rem;
}

/* Must give card - red/orange warning */
.your-hand.must-give-card {
    border-color: #ff6b6b;
    background: rgba(198, 40, 40, 0.3);
    padding-top: 1.5rem;
}

.hand-sidebar {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    min-width: 90px;
}

.hand-label {
    font-size: 0.9rem;
    opacity: 0.7;
}

.your-hand.must-give-card .hand-label {
    color: #ff6b6b;
    font-weight: bold;
    opacity: 1;
}

.hand-display {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    flex: 1;
    justify-content: center;
}

/* Action indicator banner */
.action-indicator {
    position: absolute;
    top: -12px;
    left: 50%;
    transform: translateX(-50%);
    padding: 0.25rem 1rem;
    border-radius: 4px;
    font-weight: bold;
    font-size: 0.85rem;
    white-space: nowrap;
    z-index: 10;
}

.action-indicator.play-mode {
    background: #2e7d32;
    color: #fff;
    border: 1px solid #90ee90;
}

.action-indicator.give-mode {
    background: #c62828;
    color: #fff;
    border: 1px solid #ff6b6b;
    animation: pulse-warning 1s infinite;
}

@keyframes pulse-warning {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

/* Card Styles */
.card {
    width: 50px;
    height: 70px;
    background: #fff;
    border-radius: 6px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    font-weight: bold;
    font-size: 1rem;
    cursor: pointer;
    transition: transform 0.1s;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.card:hover {
    transform: translateY(-5px);
}

.card.red {
    color: #c41e3a;
}

.card.black {
    color: #000;
}

.card .rank {
    font-size: 1rem;
}

.card .suit {
    font-size: 1.25rem;
}

.card.playing {
    opacity: 0.5;
    pointer-events: none;
}

.card.card-received {
    animation: card-received-glow 2.5s ease-out;
}

@keyframes card-received-glow {
    0% {
        box-shadow: 0 0 20px 8px rgba(255, 215, 0, 0.9),
                    0 0 40px 15px rgba(255, 215, 0, 0.6);
        transform: scale(1.1);
    }
    30% {
        box-shadow: 0 0 15px 5px rgba(255, 215, 0, 0.7),
                    0 0 30px 10px rgba(255, 215, 0, 0.4);
        transform: scale(1.05);
    }
    100% {
        box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
        transform: scale(1);
    }
}

.game-status {
    font-size: 0.9rem;
    opacity: 0.8;
}

/* Current player highlight */
.other-player.current-player {
    background: rgba(74, 124, 89, 0.5);
}

.other-player.current-player .player-label::after {
    content: " (You)";
    font-size: 0.8rem;
    opacity: 0.7;
}

/* Board suit stacks */
.suit-stack {
    position: relative;
    width: 50px;
    min-height: 35px;
}

.suit-stack:empty {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    border: 2px dashed rgba(255, 255, 255, 0.3);
}

/* Board cards - overlapping display (half-height) */
.board-card {
    position: absolute;
    left: 0;
    width: 50px;
    height: 35px;
    background: #fff;
    border: 1px solid #000;
    border-radius: 4px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
    display: flex;
    flex-direction: row;
    align-items: flex-start;
    justify-content: center;
    gap: 2px;
    padding-top: 2px;
    font-weight: bold;
    font-size: 0.85rem;
    box-sizing: border-box;
}

.board-card.red {
    color: #c41e3a;
}

.board-card.black {
    color: #000;
}

.board-card .rank {
    font-size: 0.85rem;
}

.board-card .suit {
    font-size: 0.85rem;
}

.board-card.full .suit {
    font-size: 1rem;
}

/* Message display */
.message-display {
    margin-top: 1rem;
    padding: 0.75rem 1rem;
    border-radius: 4px;
    text-align: center;
    background: rgba(0, 0, 0, 0.2);
}

.message-display.info {
    background: rgba(100, 149, 237, 0.3);
    color: #a0c4ff;
}

.message-display.success {
    background: rgba(46, 125, 50, 0.3);
    color: #90ee90;
}

.message-display.error {
    background: rgba(198, 40, 40, 0.3);
    color: #ff8a80;
}

/* Request Card Button */
.request-card-btn {
    background: #8b5a2b;
    color: #fff;
    border: none;
    padding: 0.5rem 0.75rem;
    font-size: 0.85rem;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.2s;
    white-space: nowrap;
}

.request-card-btn:hover {
    background: #a0673a;
}

.request-card-btn:disabled {
    background: #5a3d1e;
    cursor: not-allowed;
    opacity: 0.7;
}

/* Player Score */
.player-score {
    font-size: 0.85rem;
    color: #ffd700;
    margin-top: 0.25rem;
    font-weight: bold;
}

/* Round Summary Modal */
.round-summary-content {
    min-width: 400px;
}

.round-winner {
    font-size: 1.1rem;
    text-align: center;
    margin-bottom: 1rem;
    color: #90ee90;
}

.round-scores-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 1rem;
}

.round-scores-table th,
.round-scores-table td {
    padding: 0.5rem;
    text-align: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.round-scores-table th {
    background: rgba(0, 0, 0, 0.2);
    font-weight: bold;
}

.round-scores-table tr.winner {
    background: rgba(144, 238, 144, 0.2);
}

.round-scores-table tr.game-winner {
    background: rgba(255, 215, 0, 0.3);
}

.round-winner.game-winner {
    color: #ffd700;
    font-size: 1.3rem;
}

.round-scores-table .points-earned {
    color: #ff8a80;
}

.round-scores-table .points-earned.zero {
    color: #90ee90;
}

#close-round-summary {
    display: block;
    margin: 0 auto;
}

/* How to Play Screen */
.help-screen {
    max-width: 600px;
    margin: 0 auto;
    padding: 2rem 1.5rem;
}

.help-screen h1 {
    text-align: center;
    font-size: 2rem;
    margin-bottom: 1.5rem;
}

.help-section {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 8px;
    padding: 1rem 1.25rem;
    margin-bottom: 0.75rem;
}

.help-section h2 {
    font-size: 1.1rem;
    color: #ffd700;
    margin-bottom: 0.5rem;
}

.help-section p {
    font-size: 1rem;
    opacity: 0.9;
    line-height: 1.5;
    margin-bottom: 0.5rem;
}

.help-section p:last-child {
    margin-bottom: 0;
}

.help-section ul {
    margin: 0.5rem 0;
    padding-left: 1.5rem;
}

.help-section li {
    font-size: 1rem;
    opacity: 0.9;
    line-height: 1.5;
    margin-bottom: 0.25rem;
}

.help-screen > .primary-btn {
    display: block;
    margin: 1.5rem auto 0;
}

/* Name Input on Landing Page */
.name-input-container {
    margin: 1.5rem 0;
}

.name-input-container label {
    display: block;
    margin-bottom: 0.5rem;
    font-size: 1rem;
}

.name-input-container input {
    padding: 0.75rem 1rem;
    border-radius: 6px;
    border: 1px solid rgba(255, 255, 255, 0.3);
    background: rgba(0, 0, 0, 0.2);
    color: #fff;
    font-size: 1rem;
    width: 200px;
    text-align: center;
}

.name-input-container input::placeholder {
    color: rgba(255, 255, 255, 0.4);
}

.name-input-container input:focus {
    outline: none;
    border-color: #4a7c59;
    box-shadow: 0 0 0 2px rgba(74, 124, 89, 0.3);
}

/* Friend Count Selector */
.friend-count-container {
    margin: 1.5rem 0 0.5rem;
}

.friend-count-container label {
    display: block;
    margin-bottom: 0.5rem;
    font-size: 1rem;
}

.friend-count-options {
    display: flex;
    gap: 0.5rem;
    justify-content: center;
}

.friend-count-btn {
    width: 48px;
    height: 48px;
    border-radius: 8px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    background: rgba(0, 0, 0, 0.2);
    color: #fff;
    font-size: 1.25rem;
    font-weight: bold;
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s;
}

.friend-count-btn:hover {
    background: rgba(74, 124, 89, 0.3);
    border-color: rgba(255, 255, 255, 0.5);
}

.friend-count-btn.selected {
    background: #4a7c59;
    border-color: #90ee90;
    color: #fff;
}

/* Join Modal Styles */
.join-description {
    margin-bottom: 1rem;
    text-align: center;
    opacity: 0.9;
}

.error-text {
    color: #ff8a80;
    font-size: 0.9rem;
    margin-top: 0.5rem;
}

/* Player Name Display */
.player-name {
    font-weight: bold;
    font-size: 1rem;
    margin-bottom: 0.25rem;
    color: #fff;
}

.other-player.not-joined .player-name {
    color: rgba(255, 255, 255, 0.5);
    font-style: italic;
}

/* Invite Modal */
.invite-modal-content {
    min-width: 350px;
}

.invite-description {
    text-align: center;
    margin-bottom: 1.5rem;
    opacity: 0.9;
}

.invite-buttons {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.invite-btn {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 6px;
    color: #fff;
    font-size: 1rem;
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s;
}

.invite-btn:hover {
    background: rgba(74, 124, 89, 0.3);
    border-color: #4a7c59;
}

.invite-btn.copied {
    background: rgba(46, 125, 50, 0.4);
    border-color: #90ee90;
}

.invite-btn .seat-label {
    font-weight: bold;
}

.invite-btn .copy-label {
    font-size: 0.85rem;
    opacity: 0.8;
}

.invite-btn.copied .copy-label {
    color: #90ee90;
    opacity: 1;
}

/* Invite Row (new layout with bot toggle) */
.invite-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 6px;
}

.invite-row .seat-label {
    font-weight: bold;
    min-width: 60px;
}

.invite-row .bot-name {
    flex: 1;
    color: #ffd700;
    font-style: italic;
}

.invite-row .human-label {
    flex: 1;
    color: rgba(255, 255, 255, 0.6);
    font-style: italic;
}

.invite-row .copy-btn {
    flex: 1;
    background: rgba(74, 124, 89, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 4px;
    color: #fff;
    padding: 0.5rem 0.75rem;
    cursor: pointer;
    font-size: 0.9rem;
    transition: background 0.2s, border-color 0.2s;
}

.invite-row .copy-btn:hover {
    background: rgba(74, 124, 89, 0.5);
    border-color: #4a7c59;
}

.invite-row .copy-btn.copied {
    background: rgba(46, 125, 50, 0.4);
    border-color: #90ee90;
    color: #90ee90;
}

.invite-row .toggle-btn {
    background: rgba(100, 100, 100, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 4px;
    color: #fff;
    padding: 0.5rem 0.75rem;
    cursor: pointer;
    font-size: 0.85rem;
    min-width: 70px;
    transition: background 0.2s, border-color 0.2s;
}

.invite-row .toggle-btn:hover {
    background: rgba(100, 100, 100, 0.5);
}

.invite-row .toggle-btn.bot-active {
    background: rgba(139, 90, 43, 0.5);
    border-color: #8b5a2b;
    color: #ffd700;
}

/* Refresh Button spin on click */
#refresh-btn:active {
    transform: rotate(180deg);
}

/* Inactivity Modal */
.inactivity-modal-content {
    max-width: 350px;
    text-align: center;
}

.inactivity-modal-content .modal-header h2 {
    margin-bottom: 0.5rem;
}

.inactivity-description {
    color: rgba(255, 255, 255, 0.8);
    margin-bottom: 1.5rem;
}

.inactivity-modal-content .primary-btn {
    margin-top: 0.5rem;
}

/* Confirm Leave Modal */
.confirm-leave-modal-content {
    max-width: 350px;
    text-align: center;
}

.confirm-leave-description {
    color: rgba(255, 255, 255, 0.8);
    margin-bottom: 1.5rem;
}

.confirm-leave-buttons {
    display: flex;
    gap: 1rem;
    justify-content: center;
}

.confirm-leave-buttons .primary-btn {
    margin-top: 0;
    padding: 0.6rem 1.5rem;
    font-size: 1rem;
}

.danger-btn {
    background: #c62828 !important;
}

.danger-btn:hover {
    background: #d32f2f !important;
}

/* Give Card Alert Modal */
.give-card-alert-modal-content {
    max-width: 380px;
    text-align: center;
}

.give-card-alert-description {
    color: rgba(255, 255, 255, 0.8);
    margin-bottom: 1.5rem;
}

#give-card-requester {
    font-weight: bold;
    color: #ffeb3b;
}

.give-card-alert-modal-content .primary-btn {
    margin-top: 0;
}

/* Game Abandoned Modal */
.game-abandoned-modal-content {
    max-width: 350px;
    text-align: center;
}

.abandoned-description {
    color: rgba(255, 255, 255, 0.8);
    margin-bottom: 1.5rem;
}

.game-abandoned-modal-content .primary-btn {
    margin-top: 0.5rem;
}

/* Health Check Modal */
.health-modal-content {
    min-width: 280px;
    max-width: 320px;
}

.health-status {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    font-size: 1.1rem;
    padding: 0.5rem 0;
}

.health-status i {
    font-size: 1.3rem;
}

.health-status.online i {
    color: #90ee90;
}

.health-status.online span {
    color: #90ee90;
}

.health-status.offline i {
    color: #ff6b6b;
}

.health-status.offline span {
    color: #ff6b6b;
}
