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

body {
    font-family: 'Poppins', sans-serif;
    background-color: #00838f; /* Original background */
    color: white; /* Original text */
    line-height: 1.6;
}

#game-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

.screen {
    background-color: #00838f; /* Original background */
    border-radius: 10px;
    padding: 30px;
    margin-top: 10px;
}

.hidden {
    display: none !important;
}

h1, h2, h3 {
    text-align: center;
    margin-bottom: 20px;
}

h1 {
    font-size: 4rem;
    font-weight: 700;
    letter-spacing: 4px;
    font-weight: bold;
}

.form-group {
    margin-bottom: 20px;
    max-width: 500px;
    margin-left: auto;
    margin-right: auto;
}

label {
    display: block;
    margin-bottom: 5px;
    font-weight: bold;
}

input[type="text"] {
    width: 100%;
    padding: 12px;
    border: 1px solid #4A5568; /* Darker border */
    border-radius: 8px; /* Slightly more rounded */
    font-size: 16px;
    margin-bottom: 10px;
    background-color: rgba(255, 255, 255, 0.9); /* Original input background */
    color: #333; /* Original text */
    transition: border-color 0.3s, box-shadow 0.3s;
}

input[type="text"]:focus {
    outline: none;
    border-color: #4FD1C5;
    box-shadow: 0 0 0 3px rgba(79, 209, 197, 0.3);
}

input[type="text"]::placeholder {
    color: #555; /* Original placeholder text */
}

button {
    background-color: #ffeb3b; /* Original accent color */
    color: #333; /* Original text on button */
    border: none;
    border-radius: 8px; /* Slightly more rounded */
    padding: 12px 24px;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    transition: background-color 0.3s, transform 0.2s;
    display: block;
    margin: 0 auto;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

button:hover {
    background-color: #fff176; /* Original shade on hover */
    transform: translateY(-2px) scale(1.05);
}

button:disabled {
    background-color: #b2dfdb; /* Original, disabled state */
    color: #00838f;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.secondary-btn {
    background-color: #ef5350; /* Red for close/leave */
    color: white;
    margin-top: 10px;
}

.secondary-btn:hover {
    background-color: #e57373;
}

/* Player List */
#players-list {
    margin-top: 30px;
    text-align: center;
}

#players {
    list-style-type: none;
    margin-bottom: 20px;
    max-width: 500px;
    margin-left: auto;
    margin-right: auto;
}

#players li {
    padding: 10px;
    background-color: rgba(255, 255, 255, 0.1); /* Original list item */
    margin-bottom: 8px;
    border-radius: 5px;
}

/* Game Board */
.game-area {
    position: relative;
    margin: 0 auto 20px auto;
    max-width: 800px; /* Or adjust as needed */
}

#chat-container {
    position: absolute;
    top: 0;
    left: 100%;
    margin-left: 20px;
    width: 300px;
    flex-shrink: 0;
}

.game-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 10px;
}

.game-info {
    display: flex;
    justify-content: space-between;
    font-size: 16px;
    flex-wrap: wrap;
    text-align: center;
    flex-grow: 1;
    font-weight: bold;
    margin-bottom: 0; /* Removed margin-bottom as parent handles it */
}

.game-area {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 30px;
}

.piles {
    display: flex;
    justify-content: center;
    margin-bottom: 20px;
    width: 100%;
}

.pile {
    text-align: center;
    margin: 0 20px;
}

.pile-label {
    margin-top: 10px;
    font-weight: bold;
}

.card {
    width: 70px;
    height: 105px;
    border-radius: 4px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 24px;
    font-weight: bold;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
    transition: transform 0.2s, box-shadow 0.2s;
    position: relative;
    cursor: pointer;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.card:hover {
    transform: translateY(-5px) scale(1.05);
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.3);
}

.card.back {
    background-image: linear-gradient(45deg, #035951, #00838f);
    color: #00838f;
    border: 2px solid white; /* Original border */
}

.card.back::after {
    content: "Hilo";
    position: absolute;
    font-size: 14px;
    color: #ffffff; /* Original text */
}

.card.empty {
    border: 3px dashed rgba(255, 255, 255, 0.5); /* Dashed border for empty slots */
    background-color: transparent;
    box-shadow: none;
}

/* Grid */
#grid-container {
    display: grid;
    grid-template-columns: repeat(9, 80px);
    grid-template-rows: repeat(9, 120px);
    gap: 8px;
    margin: 0 auto;
    overflow: auto;
    max-width: 100%;
    height: 500px;
    padding: 20px;
    background-color: rgba(6, 96, 105, 0.8); /* Original grid background */
    border-radius: 10px;
    position: relative;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.grid-cell {
    display: flex;
    justify-content: center;
    align-items: center;
    border: 1px dashed rgba(255, 255, 255, 0.3); /* Original dashed border */
    border-radius: 5px;
    cursor: pointer;
    transition: background-color 0.2s;
}

.grid-cell:hover {
    background-color: rgba(255, 255, 255, 0.1); /* Original color on hover */
}

.grid-cell.occupied {
    border: none;
    cursor: default;
}

.grid-cell.occupied:hover {
    background-color: transparent;
}

/* Card Colors - Original Palette */
.card.red { background-color: #f44336; color: white; }
.card.blue { background-color: #2196f3; color: white; }
.card.green { background-color: #4caf50; color: white; }
.card.yellow { background-color: #ffeb3b; color: white; }
.card.purple { background-color: #9c27b0; color: white; }
.card.orange { background-color: #ff9800; color: white; }
.card.teal { background-color: #009688; color: white; }
.card.pink { background-color: #d077c7; color: white; }

/* Player Actions */
#player-message {
    width: 100%;
    text-align: center;
    margin-top: 15px;
    padding: 10px;
    font-weight: bold;
}

#round-scores, #final-scores {
    text-align: center;
    margin-bottom: 20px;
}

.score-item {
    padding: 10px;
    margin-bottom: 10px;
    background-color: rgba(255, 255, 255, 0.1); /* Original item background */
    border-radius: 5px;

}

.score-item:last-child {
    margin-bottom: 0;
}

.winner {
    background-color: rgba(255, 255, 0, 0.2); /* Original color for winner */
    font-weight: bold;
}

#next-round-countdown {
    text-align: center;
    margin-top: 20px;
    font-weight: bold;
}

#winner-announcement {
    text-align: center;
    font-size: 24px;
    margin: 20px 0;
    font-weight: bold;
    color: #ffeb3b; /* Original color */
}

#new-game-btn {
    margin-top: 20px;
}

/* Setup Phase */
#setup-phase-info {
    text-align: center;
    margin-bottom: 20px;
    background-color: rgba(255, 255, 255, 0.1); /* Original background */
    padding: 15px;
    border-radius: 10px;
    max-width: 800px;
    margin-left: auto;
    margin-right: auto;
    font-weight: bold;
}

.setup-grid {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 30px;
}

.setup-grid h3 {
    margin-bottom: 10px;
}

.setup-grid p {
    margin-bottom: 20px;
    text-align: center;
}

.cards-setup-grid {
    display: grid;
    grid-template-columns: repeat(3, 100px);
    grid-template-rows: repeat(3, 150px);
    gap: 12px;
    margin: 0 auto;
}

.setup-card {
    width: 100px;
    height: 150px;
}

.setup-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.3);
}

.setup-card.flipped {
    transform: rotateY(180deg);
}

@keyframes flip {
    from { transform: rotateY(0deg); }
    to { transform: rotateY(180deg); }
}

.player-status-setup {
    margin-top: 20px;
    text-align: center;
    background-color: rgba(255, 255, 255, 0.1);
    padding: 10px;
    border-radius: 10px;
    width: 100%;
    max-width: 400px;
}

.player-status-setup p {
    margin-bottom: 5px;
}

.player-status-setup .ready {
    color: #ffeb3b; /* Original color */
    font-weight: bold;
}

.player-progress {
    padding: 5px;
    margin-top: 5px;
    border-radius: 5px;
}

.player-progress.player-ready {
    background-color: rgba(255, 255, 0, 0.2); /* Original color */
}

/* Responsive Design */
@media (max-width: 1200px) {
    #grid-container {
        grid-template-columns: repeat(9, 70px);
        grid-template-rows: repeat(9, 105px);
        gap: 5px;
    }
    
    .card {
        width: 70px;
        height: 105px;
        font-size: 26px;
    }
    
    .game-info {
        font-size: 16px;
    }
}

@media (max-width: 768px) {
    .screen {
        padding: 15px;
    }
    
    #grid-container {
        grid-template-columns: repeat(9, 60px);
        grid-template-rows: repeat(9, 90px);
        gap: 4px;
        height: 400px;
    }
    
    .card {
        width: 65px;
        height: 97px;
        font-size: 24px;
    }
    
    .piles {
        margin-bottom: 20px;
    }
    
    .game-info {
        flex-direction: column;
        align-items: center;
    }
    
    .player-status {
        min-width: 140px;
    }
    
    h1 {
        font-size: 3rem;
    }
}

@media (max-width: 480px) {
    #grid-container {
        grid-template-columns: repeat(9, 50px);
        grid-template-rows: repeat(9, 75px);
        gap: 3px;
    }
    
    .card {
        width: 55px;
        height: 82px;
        font-size: 20px;
    }
    
    h1 {
        font-size: 2.5rem;
    }
}

/* Player Grids Display */
.all-player-grids {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
    margin-bottom: 20px;
}

/* Grid Table */
.grid-table {
    display: flex;
    flex-direction: column;
    width: 100%;
    align-items: center;
}

.player-labels-row {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 15px;
    margin-bottom: 8px;
    width: 100%;
    padding: 0 10px;
}

.player-label {
    font-size: 16px;
    font-weight: bold;
    padding: 6px 12px;
    border-radius: 4px;
    background-color: rgba(255, 255, 255, 0.1);
    text-align: center;
    min-width: 100px;
}

.player-label.current-player {
    background-color: rgba(255, 235, 59, 0.2); /* Original color */
    color: #fff;
    position: relative;
}

.player-label.current-player::after {
    content: "(You)";
    font-size: 14px;
    margin-left: 8px;
    color: #ffeb3b; /* Original color */
}

.grid-cells {
    display: flex;
    justify-content: center;
    gap: 20px;
    flex-wrap: wrap;
    width: 100%;
    padding: 0 10px;
}

.player-grid-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-top: 8px;
    min-width: 100px;
    position: relative;
    padding-top: 8px;
}

.current-player-grid {
    width: fit-content;
}

.current-player-grid::before {
    content: "Your Grid";
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    background-color: rgba(255, 235, 59, 0.8); /* Original color */
    color: #333; /* Original text */
    padding: 2px 8px;
    border-radius: 8px;
    font-size: 11px;
    font-weight: bold;
    z-index: 10;
    width: fit-content;
}

.mini-grid {
    display: grid;
    grid-template-columns: repeat(3, 70px);
    grid-template-rows: repeat(3, 105px);
    gap: 8px;
    margin: 0 auto;
    margin-top: 15px;
    margin-bottom: 8px;
    width: fit-content;
}

.mini-card {
    width: 70px;
    height: 105px;
    border-radius: 4px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 24px;
    font-weight: bold;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
    position: relative;
    z-index: 1;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.mini-card.back {
    background-image: linear-gradient(45deg, #035951, #00838f);
    color: #00838f;
    border: 2px solid white; /* Original border */
}

.mini-card.back::after {
    content: "Hilo";
    position: absolute;
    font-size: 14px;
    color: #ffffff; /* Original text */
}

.mini-card.interactive {
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

.mini-card.interactive:hover {
    transform: translateY(-5px);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.3);
}

.mini-card.empty {
    border: 2px dashed rgba(255, 255, 255, 0.3); /* Original dashed border */
    background-color: transparent;
}

.setup-message {
    text-align: center;
    margin: 20px;
    padding: 15px;
    background-color: rgba(255, 255, 255, 0.1); /* Original background */
    border-radius: 10px;
    font-size: 18px;
}

/* Responsive adjustments for the grid table */
@media (max-width: 768px) {
    .all-player-grids {
        padding: 10px;
        flex-direction: row;
        overflow-x: auto;
        align-items: flex-start;
        width: 100%;
        padding-bottom: 15px;
    }
    
    .grid-table {
        width: auto;
        align-items: stretch;
    }

    .grid-cells {
        flex-wrap: nowrap;
        justify-content: flex-start;
        align-items: flex-start;
    }
    
    .player-labels-row {
        gap: 10px;
        align-items: center;
        justify-content: flex-start;
    }
    
    .player-label, .player-grid-container {
        width: auto;
        max-width: 250px;
        min-width: 100px;
        flex-shrink: 0;
    }
    
    .mini-grid {
        grid-template-columns: repeat(3, 60px);
        grid-template-rows: repeat(3, 90px);
    }
    
    .mini-card {
        width: 60px;
        height: 90px;
        font-size: 22px;
    }
}

@media (max-width: 1200px) {
    #chat-container {
        position: static;
        margin: 20px auto 0 auto;
    }
}

/* Chat Container */
#chat-container {
    background-color: rgba(6, 96, 105, 0.8); /* Original background */
    border-radius: 10px;
    padding: 15px;
    display: flex;
    flex-direction: column;
    height: auto; /* Let it size naturally or set a max-height */
    max-height: 500px; /* Example max height */
    border: 1px solid rgba(255, 255, 255, 0.1);
}

#chat-container h3 {
    color: #ffeb3b; /* Original color */
    margin-bottom: 10px;
    font-size: 1em;
}

#chat-messages {
    flex-grow: 1;
    overflow-y: auto;
    margin-bottom: 10px;
    padding-right: 5px; /* for scrollbar */
}

.chat-message {
    margin-bottom: 8px;
    line-height: 1.4;
    font-size: 14px;
}

.chat-message .sender {
    font-weight: bold;
    color: #ffeb3b; /* Original color */
    margin-right: 5px;
}

#chat-form {
    display: flex;
    gap: 10px;
}

#chat-input {
    flex-grow: 1;
    border: 1px solid #004d40; /* Original border */
    background-color: #e0f2f1; /* Original background */
    color: #333; /* Original text */
    border-radius: 8px;
    padding: 10px;
}

#chat-input::placeholder {
    color: #555; /* Original placeholder */
}

#chat-form button {
    flex-shrink: 0;
    margin: 0;
}


/* Add corresponding color rules for mini-cards */
.mini-card.red { background-color: #f44336; color: white; }
.mini-card.blue { background-color: #2196f3; color: white; }
.mini-card.green { background-color: #4caf50; color: white; }
.mini-card.yellow { background-color: #ffeb3b; color: white; }
.mini-card.purple { background-color: #9c27b0; color: white; }
.mini-card.orange { background-color: #ff9800; color: white; }
.mini-card.teal { background-color: #009688; color: white; }
.mini-card.pink { background-color: #d077c7; color: white; }
.mini-card.default-card-color { background-color: #f0f0f0; color: #333333; }

/* Player Actions */
/* Removed duplicate .player-actions rule */

/* --- Shift Preview Arrows --- */

/* Add relative positioning to the mini-card to anchor the pseudo-element */
.mini-card {
  position: relative;
}

/* Base style for the preview arrow pseudo-element */
.mini-card.preview-shift-horizontal::after,
.mini-card.preview-shift-vertical::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 1.5em;
  font-weight: bold;
  color: yellow;
  text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.7);
  pointer-events: none;
  z-index: 10;
}

/* Specific arrow for horizontal shift (Left arrow) */
.mini-card.preview-shift-horizontal::after {
  content: '←';
}

/* Specific arrow for vertical shift (Up arrow - matches game logic) */
.mini-card.preview-shift-vertical::after {
  content: '↑';
}

/* Optional: Dim the card slightly when showing the arrow */
.mini-card.preview-shift-horizontal,
.mini-card.preview-shift-vertical {
  filter: brightness(85%);
}

/* --- End Shift Preview Arrows --- */

/* Style for the individual player score display */
.player-grid-score {
    text-align: center;
    font-weight: bold;
    margin-top: 4px;
    font-size: 14px;
    margin-left: 0;
    color: #ffeb3b; /* Original color */
}

/* --- Live Score Summary Table --- */
.score-summary-container {
    margin-top: 10px;
    padding: 15px;
    background-color: rgba(6, 96, 105, 0.8); /* Original background */
    border-radius: 10px;
    max-width: 800px;
    margin-left: auto;
    margin-right: auto;
}

.score-summary-container h3 {
    text-align: center;
    margin-bottom: 10px; /* Slightly reduced margin */
    color: #ffeb3b; /* Highlight title */
    font-size: 1em; /* Reduced font size */
}

#live-score-table-content {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.score-summary-item {
    display: flex;
    justify-content: space-between;
    padding: 5px 8px; /* Reduced padding */
    background-color: rgba(255, 255, 255, 0.1); /* Original item */
    border-radius: 4px; /* Slightly smaller radius */
    font-size: 12px; /* Reduced font size */
}

.score-summary-item .player-name {
    font-weight: bold;
}

.score-summary-item .player-score {
    font-weight: bold;
    color: #ffffff;
}

/* Style for the best score (lowest) */
.score-summary-item.best-score {
    background-color: rgba(255, 235, 59, 0.2); /* Subtle original highlight */
    border: 1px solid #ffeb3b; /* Original border */
}

/* --- End Live Score Summary Table --- */

/* Make cards in the draw/discard piles smaller */
#draw-pile .card, #discard-pile .card {
    width: 70px;
    height: 105px;
    font-size: 24px; /* Adjust font size for number */
}

#draw-pile .card.back::after {
    font-size: 20px; /* Adjust "Hilo" text size */
}

.card:hover {
    transform: translateY(-5px);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.3);
} 

/* Mode Buttons */
.mode-buttons {
    display: flex;
    gap: 10px;
    justify-content: center;
}

.mode-btn {
    padding: 10px 20px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-weight: bold;
    background-color: #b2dfdb;
    color: #00838f;
    transition: background-color 0.3s;
}

.mode-btn.active {
    background-color: #ffeb3b;
    color: #333;
}

.mode-btn:hover {
    background-color: #fff176;
}

/* Multicolor Cards */
.card.multicolor, .mini-card.multicolor {
    background: linear-gradient(45deg, #f44336, #ff9800, #ffeb3b, #4caf50, #2196f3, #9c27b0);
    background-size: 400% 400%;
    animation: gradientShift 3s ease infinite;
    color: white;
}

@keyframes gradientShift {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
} 

/* Fancy Special Mode Styles */
body.special-mode {
    background-color: #1a0a24;
    background-image: url('https://www.transparenttextures.com/patterns/stardust.png');
}

body.special-mode .screen {
    background-color: rgba(40, 20, 60, 0.7);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

body.special-mode .card.back, body.special-mode .mini-card.back {
    background-image: url('https://i.imgur.com/M1g413i.jpeg');
    background-color: #2c1e38; /* Fallback color */
    background-size: cover;
    background-position: center;
    /* Completely hide underlying text content */
    color: transparent !important;
    text-shadow: none !important;
    font-size: 0 !important;
    text-indent: -9999px !important; /* Move text completely off-screen */
    overflow: hidden !important; /* Clip anything outside */
}

body.special-mode .card.back::after, body.special-mode .mini-card.back::after {
    content: 'Hilo' !important; /* Ensure 'Hilo' is set */
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%); /* Center it properly */
    font-size: 16px !important; /* Slightly larger for visibility */
    color: white !important; /* White text */
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.9) !important; /* Stronger shadow */
    font-weight: bold !important;
    z-index: 5; /* Ensure it's on top */
    text-indent: 0 !important; /* Reset text indent for the pseudo-element */
    visibility: visible !important; /* Ensure visible even if parent has issues */
}

body.special-mode button {
    background-color: #be82ff;
    color: #1a0a24;
}

body.special-mode button:hover {
    background-color: #d8b5ff;
}

body.special-mode .player-label.current-player, body.special-mode .score-summary-item.best-score {
    background-color: rgba(190, 130, 255, 0.3);
    border-color: #be82ff;
}

/* Secondary button special mode */
body.special-mode .secondary-btn {
    background-color: #e91e63; /* Pinkish/red for special mode */
    color: white;
}

body.special-mode .secondary-btn:hover {
    background-color: #f06292;
}
