/* ========================================
   CODENAMES - CSS STYLES
   A complete styling for the Codenames game
   ======================================== */

/* CSS Variables */
:root {
    /* Team Colors */
    --red-primary: #dc3545;
    --red-dark: #a71d2a;
    --red-light: #f8d7da;
    --red-glow: rgba(220, 53, 69, 0.4);
    
    --blue-primary: #0d6efd;
    --blue-dark: #0a58ca;
    --blue-light: #cfe2ff;
    --blue-glow: rgba(13, 110, 253, 0.4);
    
    /* Card Colors */
    --neutral-color: #e9dcc9;
    --neutral-dark: #c4b8a5;
    --assassin-color: #1a1a2e;
    --assassin-dark: #0f0f1a;
    
    /* UI Colors */
    --bg-primary: #1a1a2e;
    --bg-secondary: #16213e;
    --bg-card: #f5f0e6;
    --text-primary: #ffffff;
    --text-secondary: #a0a0a0;
    --text-dark: #2c2c2c;
    --border-color: #333;
    
    /* Effects */
    --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.2);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.4);
    --transition-fast: 0.15s ease;
    --transition-normal: 0.3s ease;
    
    /* Sizing */
    --card-width: 140px;
    --card-height: 90px;
    --border-radius: 8px;
    --border-radius-lg: 12px;
}

/* Reset & Base Styles */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
}

body {
    font-family: 'Open Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: linear-gradient(135deg, var(--bg-primary) 0%, var(--bg-secondary) 100%);
    min-height: 100vh;
    color: var(--text-primary);
    line-height: 1.5;
    overflow-x: hidden;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 1rem;
    min-height: 100vh;
    position: relative;
}

/* Typography */
h1, h2, h3 {
    font-family: 'Russo One', sans-serif;
    letter-spacing: 0.05em;
}

/* Header */
.header {
    text-align: center;
    padding: 1.5rem 0;
    position: relative;
    left: 0;
    right: 0;
    margin: 0 auto;
}

.title {
    font-size: 3rem;
    background: linear-gradient(135deg, var(--red-primary), #ff6b6b, var(--blue-primary), #4dabf7);
    background-size: 300% 300%;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: gradientShift 8s ease infinite;
    text-shadow: none;
    margin-bottom: 0.25rem;
}

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

.subtitle {
    font-size: 1rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.3em;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
    font-weight: 600;
    border: none;
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: all var(--transition-fast);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.btn:active {
    transform: translateY(0);
}

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

.btn-primary {
    background: linear-gradient(135deg, var(--blue-primary), var(--blue-dark));
    color: white;
}

.btn-primary:hover {
    background: linear-gradient(135deg, #3d8bfd, var(--blue-primary));
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

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

.btn-warning {
    background: linear-gradient(135deg, #ffc107, #e0a800);
    color: #1a1a2e;
}

.btn-warning:hover {
    background: linear-gradient(135deg, #ffcd39, #ffc107);
}

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
    border: 1px dashed var(--text-secondary);
}

.btn-ghost:hover {
    color: var(--text-primary);
    border-color: var(--text-primary);
}

.btn-large {
    padding: 1rem 2rem;
    font-size: 1.125rem;
}

.btn-small {
    padding: 0.4rem 0.8rem;
    font-size: 0.75rem;
}

.btn-icon {
    font-size: 1.25em;
}

/* Modals */
.modal {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(4px);
    z-index: 1000;
    padding: 1rem;
}

.modal.hidden {
    display: none;
}

.modal-content {
    background: var(--bg-secondary);
    border-radius: var(--border-radius-lg);
    padding: 2rem;
    max-width: 500px;
    width: 100%;
    box-shadow: var(--shadow-lg);
    border: 1px solid rgba(255, 255, 255, 0.1);
    text-align: center;
}

.modal-content h2 {
    margin-bottom: 1.5rem;
    font-size: 1.75rem;
}

/* Setup Modal */
.setup-options {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.divider {
    display: flex;
    align-items: center;
    gap: 1rem;
    color: var(--text-secondary);
}

.divider::before,
.divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: rgba(255, 255, 255, 0.2);
}

.join-game {
    text-align: left;
}

.join-game label {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--text-secondary);
}

.input-group {
    display: flex;
    gap: 0.5rem;
}

.input-group input {
    flex: 1;
}

input[type="text"],
input[type="number"] {
    padding: 0.75rem 1rem;
    font-size: 1rem;
    border: 2px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--border-radius);
    background: rgba(0, 0, 0, 0.2);
    color: var(--text-primary);
    transition: border-color var(--transition-fast);
}

input[type="text"]:focus,
input[type="number"]:focus {
    outline: none;
    border-color: var(--blue-primary);
}

input[type="text"]::placeholder {
    color: var(--text-secondary);
}

/* Role Selection Modal */
.game-code-display {
    background: rgba(0, 0, 0, 0.2);
    padding: 0.75rem;
    border-radius: var(--border-radius);
    margin-bottom: 1.5rem;
    font-family: monospace;
    font-size: 1.125rem;
}

.game-code-display span {
    color: #ffc107;
    font-weight: bold;
}

/* Player Name Input */
.name-input-section {
    margin-bottom: 1.5rem;
}

.name-input-section label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    color: var(--text-primary);
}

.name-input-section input {
    width: 100%;
    padding: 0.75rem;
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: var(--border-radius);
    color: var(--text-primary);
    font-size: 1rem;
    transition: all var(--transition-fast);
}

.name-input-section input:focus {
    outline: none;
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.4);
}

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

.role-selection {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}

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

.team-column h3 {
    margin-bottom: 0.5rem;
}

.btn-role {
    padding: 1rem;
    flex-direction: column;
    gap: 0.25rem;
    position: relative;
}

.role-icon {
    font-size: 1.5rem;
}

.role-text {
    display: block;
}

.player-count {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    background: rgba(255, 255, 255, 0.9);
    color: #1a1a2e;
    font-size: 0.75rem;
    font-weight: bold;
    padding: 0.2rem 0.5rem;
    border-radius: 12px;
    min-width: 20px;
    text-align: center;
    display: none;
}

#spectator-btn {
    position: relative;
}

#spectator-btn .player-count {
    position: absolute;
    top: 50%;
    right: 1rem;
    transform: translateY(-50%);
}

/* Player Lists */
.player-list {
    display: none;
    flex-direction: column;
    gap: 0.25rem;
    margin-top: 0.25rem;
    padding: 0.5rem;
    background: rgba(0, 0, 0, 0.2);
    border-radius: var(--border-radius);
    max-height: 150px;
    overflow-y: auto;
}

.player-tag {
    padding: 0.4rem 0.6rem;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    font-size: 0.875rem;
    color: var(--text-primary);
    border-left: 3px solid rgba(255, 255, 255, 0.3);
}

.player-tag.current-player {
    background: rgba(255, 255, 255, 0.2);
    border-left-color: #ffc107;
    font-weight: 600;
}

.btn-red-spy {
    background: linear-gradient(135deg, var(--red-primary), var(--red-dark));
    color: white;
}

.btn-red-op {
    background: rgba(220, 53, 69, 0.2);
    color: var(--red-primary);
    border: 2px solid var(--red-primary);
}

.btn-blue-spy {
    background: linear-gradient(135deg, var(--blue-primary), var(--blue-dark));
    color: white;
}

.btn-blue-op {
    background: rgba(13, 110, 253, 0.2);
    color: var(--blue-primary);
    border: 2px solid var(--blue-primary);
}

/* Game Area */
.game-area {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    position: relative;
}

/* Body margin when sidebar is open */
body.sidebar-open .container {
    margin-right: 290px;
    transition: margin-right 0.3s ease;
}

.game-area.hidden {
    display: none;
}

/* Clue History Sidebar */
.clue-history-sidebar {
    position: fixed;
    right: -280px;
    top: 0;
    bottom: 0;
    width: 280px;
    background: linear-gradient(180deg, rgba(26, 26, 46, 0.95) 0%, rgba(22, 33, 62, 0.95) 100%);
    border-left: 2px solid rgba(255, 255, 255, 0.15);
    overflow: hidden;
    z-index: 100;
    backdrop-filter: blur(10px);
    box-shadow: -4px 0 20px rgba(0, 0, 0, 0.3);
    display: flex;
    flex-direction: column;
    transition: right 0.3s ease;
}

.clue-history-sidebar.open {
    right: 0;
}

.clue-history-toggle {
    position: fixed;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    background: linear-gradient(180deg, rgba(26, 26, 46, 0.95) 0%, rgba(22, 33, 62, 0.95) 100%);
    border: 2px solid rgba(255, 255, 255, 0.15);
    border-right: none;
    padding: 0.75rem 0.5rem;
    cursor: pointer;
    z-index: 101;
    border-radius: 8px 0 0 8px;
    color: var(--text-primary);
    font-size: 1.5rem;
    backdrop-filter: blur(10px);
    transition: all 0.3s ease;
    line-height: 1;
    box-shadow: -2px 0 8px rgba(0, 0, 0, 0.3);
}

.clue-history-toggle:hover {
    background: linear-gradient(180deg, rgba(26, 26, 46, 1) 0%, rgba(22, 33, 62, 1) 100%);
    transform: translateY(-50%) translateX(-3px);
}

.clue-history-sidebar.open ~ .clue-history-toggle {
    right: 280px;
}

.clue-history-header {
    background: rgba(0, 0, 0, 0.4);
    padding: 1.25rem;
    border-bottom: 2px solid rgba(255, 255, 255, 0.15);
    flex-shrink: 0;
}

.clue-history-header h3 {
    font-size: 1rem;
    margin: 0;
    color: var(--text-primary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.clue-history-list {
    padding: 1rem;
    overflow-y: auto;
    flex: 1;
}

.clue-history-list::-webkit-scrollbar {
    width: 8px;
}

.clue-history-list::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.3);
}

.clue-history-list::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.3);
    border-radius: 4px;
}

.clue-history-list::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.4);
}

.no-clues {
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.85rem;
    padding: 1rem;
}

.clue-history-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    margin-bottom: 0.75rem;
    border-radius: var(--border-radius);
    background: rgba(0, 0, 0, 0.3);
    transition: all var(--transition-fast);
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.clue-history-item.red-clue {
    border-left: 4px solid var(--red-primary);
    box-shadow: inset 0 0 10px rgba(220, 53, 69, 0.1);
}

.clue-history-item.blue-clue {
    border-left: 4px solid var(--blue-primary);
    box-shadow: inset 0 0 10px rgba(13, 110, 253, 0.1);
}

.clue-history-item.crossed-out .clue-history-word {
    text-decoration: line-through;
    opacity: 0.5;
}

.clue-history-content {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex: 1;
    min-width: 0;
}

.clue-history-team {
    font-size: 0.75rem;
}

.clue-history-word {
    font-weight: 700;
    font-size: 0.95rem;
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.clue-history-number {
    background: rgba(255, 255, 255, 0.15);
    padding: 0.1rem 0.4rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-primary);
}

/* Toggle Switch for Clue Applies */
.clue-toggle {
    position: relative;
    display: inline-block;
    width: 36px;
    height: 20px;
    flex-shrink: 0;
    margin-left: 0.5rem;
}

.clue-toggle input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(255, 255, 255, 0.2);
    transition: 0.3s;
    border-radius: 20px;
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 14px;
    width: 14px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: 0.3s;
    border-radius: 50%;
}

.clue-toggle input:checked + .toggle-slider {
    background-color: #28a745;
}

.clue-toggle input:checked + .toggle-slider:before {
    transform: translateX(16px);
}

/* Game Info Bar */
.game-info-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: linear-gradient(135deg, #f4ecd8 0%, #e8dcc4 50%, #f0e6d2 100%);
    border-radius: var(--border-radius-lg);
    padding: 1rem 1.5rem;
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.1), 0 4px 12px rgba(0, 0, 0, 0.3);
    border: 1px solid #d4c4a8;
}

.team-score {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 80px;
}

.team-label {
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.1em;
}

.score {
    font-family: 'Russo One', sans-serif;
    font-size: 2.5rem;
    line-height: 1;
}

.red-score .team-label,
.red-score .score {
    color: var(--red-primary);
}

.blue-score .team-label,
.blue-score .score {
    color: var(--blue-primary);
}

.game-status {
    text-align: center;
}

.turn-indicator {
    font-family: 'Russo One', sans-serif;
    font-size: 1.25rem;
    padding: 0.5rem 1rem;
    border-radius: var(--border-radius);
    margin-bottom: 0.5rem;
}

.turn-indicator.red-turn {
    background: var(--red-primary);
    color: white;
    box-shadow: 0 0 20px var(--red-glow);
}

.turn-indicator.blue-turn {
    background: var(--blue-primary);
    color: white;
    box-shadow: 0 0 20px var(--blue-glow);
}

.game-code-small {
    font-size: 0.875rem;
    color: #5a4a3a;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.game-code-small span {
    font-family: monospace;
    color: #d97706;
}

.btn-copy {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1rem;
    opacity: 0.7;
    transition: opacity var(--transition-fast);
}

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

/* Sync Status */
.sync-status {
    font-size: 0.75rem;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    margin-left: 0.5rem;
}

.sync-status.synced {
    background: rgba(40, 167, 69, 0.15);
    color: #1e7e34;
}

.sync-status.local {
    background: rgba(255, 193, 7, 0.25);
    color: #d97706;
}

/* Role Indicator */
.role-indicator {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1rem;
    padding: 0.5rem;
    background: rgba(255, 255, 255, 0.05);
    border-radius: var(--border-radius);
}

#current-role {
    font-weight: 600;
}

/* Game Board */
.game-board {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 0.75rem;
    padding: 1rem;
    background: linear-gradient(135deg, #f5e6d3 0%, #e0d4c0 50%, #f0e4d0 100%);
    border-radius: var(--border-radius-lg);
    max-width: 800px;
    margin: 0 auto;
    width: 100%;
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.1), 0 4px 12px rgba(0, 0, 0, 0.4);
    border: 2px solid #c9b89a;
}

/* Card Styles */
.card {
    aspect-ratio: 1.5;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem;
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: all var(--transition-normal);
    position: relative;
    overflow: hidden;
    background: var(--bg-card);
    border: 3px solid transparent;
    box-shadow: var(--shadow-sm);
}

.card:hover:not(.revealed):not(.spymaster-view) {
    transform: translateY(-4px) scale(1.02);
    box-shadow: var(--shadow-md);
}

.card-word {
    font-weight: 700;
    font-size: clamp(0.65rem, 1.5vw, 0.9rem);
    text-transform: uppercase;
    text-align: center;
    color: var(--text-dark);
    word-break: break-word;
    line-height: 1.2;
    z-index: 1;
}

/* Spymaster View - Border Colors */
.card.spymaster-view.team-red {
    border-color: var(--red-primary);
    box-shadow: inset 0 0 20px var(--red-glow);
}

.card.spymaster-view.team-blue {
    border-color: var(--blue-primary);
    box-shadow: inset 0 0 20px var(--blue-glow);
}

.card.spymaster-view.team-neutral {
    border-color: var(--neutral-dark);
}

.card.spymaster-view.team-assassin {
    border-color: var(--assassin-color);
    background: repeating-linear-gradient(
        45deg,
        var(--bg-card),
        var(--bg-card) 10px,
        #f0e6d6 10px,
        #f0e6d6 20px
    );
}

/* Revealed Cards */
.card.revealed {
    cursor: default;
    transform: none;
}

.card.revealed .card-word {
    color: white;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.3);
}

.card.revealed.team-red {
    background: linear-gradient(135deg, var(--red-primary), var(--red-dark));
}

.card.revealed.team-blue {
    background: linear-gradient(135deg, var(--blue-primary), var(--blue-dark));
}

.card.revealed.team-neutral {
    background: linear-gradient(135deg, #d4c4a8, #b8a67d);
    border: 2px solid #a08860;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.card.revealed.team-neutral .card-word {
    color: #3d3019;
    font-weight: 600;
    text-shadow: 0 1px 2px rgba(255, 255, 255, 0.3);
}

.card.revealed.team-assassin {
    background: #d8d8d8;
    border: 1px solid #c0c0c0;
    box-shadow: none;
}

.card.revealed.team-assassin .card-word {
    color: #888;
    text-shadow: none;
}

.card.revealed.team-assassin::after {
    content: '💀';
    position: absolute;
    font-size: 2rem;
    opacity: 0.1;
}

/* Card Count Badge (for Spymaster) */
.card-count {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.6rem;
    font-weight: bold;
    color: white;
}

.team-red .card-count {
    background: var(--red-primary);
}

.team-blue .card-count {
    background: var(--blue-primary);
}

/* Game Controls */
.game-controls {
    display: flex;
    justify-content: center;
    gap: 1rem;
    flex-wrap: wrap;
}

/* Clue Section */
.clue-section {
    background: rgba(0, 0, 0, 0.3);
    border-radius: var(--border-radius-lg);
    padding: 1.5rem;
    text-align: center;
}

.clue-section.hidden {
    display: none;
}

.clue-section h3 {
    margin-bottom: 1rem;
}

.clue-input-group {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.clue-input-group input[type="text"] {
    width: 200px;
}

.clue-input-group input[type="number"] {
    width: 60px;
    text-align: center;
}

/* Current Clue Display */
.current-clue {
    background: rgba(0, 0, 0, 0.3);
    border-radius: var(--border-radius-lg);
    padding: 1rem 1.5rem;
    text-align: center;
}

.current-clue.hidden {
    display: none;
}

.clue-display {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.clue-label {
    color: var(--text-secondary);
}

.clue-text {
    font-family: 'Russo One', sans-serif;
    font-size: 1.5rem;
    text-transform: uppercase;
}

.clue-count {
    background: rgba(255, 255, 255, 0.2);
    padding: 0.25rem 0.75rem;
    border-radius: var(--border-radius);
    font-weight: bold;
}

.guesses-remaining {
    margin-top: 0.5rem;
    color: var(--text-secondary);
    font-size: 0.875rem;
}

/* Game Over Modal */
.game-over-content h2 {
    font-size: 2rem;
}

.game-over-content h2.red-wins {
    color: var(--red-primary);
}

.game-over-content h2.blue-wins {
    color: var(--blue-primary);
}

.game-over-buttons {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-top: 1.5rem;
}

/* Toast Notifications */
.toast-container {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    z-index: 2000;
}

.toast {
    background: var(--bg-secondary);
    color: var(--text-primary);
    padding: 1rem 1.5rem;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-lg);
    border-left: 4px solid var(--blue-primary);
    animation: slideIn 0.3s ease, fadeOut 0.3s ease 2.7s forwards;
    max-width: 300px;
}

.toast.success {
    border-left-color: #28a745;
}

.toast.error {
    border-left-color: var(--red-primary);
}

.toast.warning {
    border-left-color: #ffc107;
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes fadeOut {
    to {
        opacity: 0;
        transform: translateX(50%);
    }
}

/* Responsive Design */
@media (max-width: 768px) {
    .container {
        padding: 0.5rem;
    }
    
    .title {
        font-size: 2rem;
    }
    
    .game-info-bar {
        flex-wrap: wrap;
        gap: 1rem;
        padding: 1rem;
    }
    
    .team-score {
        min-width: 60px;
    }
    
    .score {
        font-size: 2rem;
    }
    
    .turn-indicator {
        font-size: 1rem;
    }
    
    .game-board {
        gap: 0.4rem;
        padding: 0.5rem;
    }
    
    .card {
        border-width: 2px;
    }
    
    .card-word {
        font-size: clamp(0.5rem, 2.5vw, 0.75rem);
    }
    
    .role-selection {
        grid-template-columns: 1fr;
    }
    
    .modal-content {
        padding: 1.5rem;
    }
    
    .clue-input-group {
        flex-direction: column;
        align-items: stretch;
    }
    
    .clue-input-group input[type="text"] {
        width: 100%;
    }
    
    .clue-input-group input[type="number"] {
        width: 100%;
    }
    
    /* Container and body margin adjustments for mobile */
    body.sidebar-open .container {
        margin-right: 0;
        margin-bottom: 210px;
    }
    
    /* Clue History Toggle - Bottom right on mobile */
    .clue-history-toggle {
        position: fixed;
        right: 1rem;
        bottom: 1rem;
        top: auto;
        left: auto;
        transform: none;
        padding: 0.75rem 1rem;
        border-radius: 50%;
        border: 2px solid rgba(255, 255, 255, 0.15);
        font-size: 1.2rem;
        width: 56px;
        height: 56px;
        display: flex;
        align-items: center;
        justify-content: center;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
    }
    
    .clue-history-toggle:hover {
        transform: scale(1.05);
    }
    
    .clue-history-sidebar.open ~ .clue-history-toggle {
        bottom: 210px;
        right: 1rem;
    }
    
    /* Clue History Sidebar - Bottom on Mobile */
    .clue-history-sidebar {
        position: fixed;
        right: 0;
        left: 0;
        bottom: -200px;
        top: auto;
        width: 100%;
        max-height: 200px;
        border-left: none;
        border-top: 2px solid rgba(255, 255, 255, 0.15);
        box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.3);
        transition: bottom 0.3s ease;
    }
    
    .clue-history-sidebar.open {
        bottom: 0;
        right: 0;
    }
    
    .clue-history-header {
        padding: 0.75rem 1rem;
    }
    
    .clue-history-header h3 {
        font-size: 0.85rem;
    }
    
    .clue-history-list {
        padding: 0.75rem;
    }
}

@media (max-width: 480px) {
    .title {
        font-size: 1.5rem;
    }
    
    .subtitle {
        font-size: 0.75rem;
        letter-spacing: 0.15em;
    }
    
    .btn {
        padding: 0.5rem 1rem;
        font-size: 0.875rem;
    }
    
    .btn-large {
        padding: 0.75rem 1.5rem;
    }
    
    .game-board {
        gap: 0.25rem;
    }
    
    .card-word {
        font-size: clamp(0.45rem, 3vw, 0.65rem);
    }
}

/* Animations */
@keyframes pulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.05);
    }
}

.pulse {
    animation: pulse 1s infinite;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

.shake {
    animation: shake 0.3s ease-in-out;
}

/* Print Styles - for printing spymaster key */
@media print {
    body {
        background: white;
    }
    
    .header,
    .game-controls,
    .clue-section,
    .current-clue,
    .role-indicator,
    .modal {
        display: none !important;
    }
    
    .game-area {
        display: block !important;
    }
    
    .game-board {
        background: white;
    }
    
    .card {
        border: 2px solid #ccc;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }
}
/* Player Name Display */
.player-name-display {
    font-weight: 600;
    color: #ffc107;
    font-size: 1.1rem;
}

.info-left {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

/* Player Info and Role Actions */
.player-info {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.role-actions {
    display: flex;
    gap: 0.5rem;
}

.role-indicator {
    flex-wrap: wrap;
}

/* Left Sidebar (Teams + Chat) */
.teams-sidebar {
    position: fixed;
    left: -300px;
    top: 0;
    bottom: 0;
    width: 300px;
    background: linear-gradient(180deg, rgba(26, 26, 46, 0.97) 0%, rgba(22, 33, 62, 0.97) 100%);
    border-right: 2px solid rgba(255, 255, 255, 0.15);
    overflow: hidden;
    z-index: 100;
    backdrop-filter: blur(10px);
    box-shadow: 4px 0 20px rgba(0, 0, 0, 0.3);
    display: flex;
    flex-direction: column;
    transition: left 0.3s ease;
}

.teams-sidebar.open {
    left: 0;
}

.teams-toggle {
    position: fixed;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    background: linear-gradient(180deg, rgba(26, 26, 46, 0.95) 0%, rgba(22, 33, 62, 0.95) 100%);
    border: 2px solid rgba(255, 255, 255, 0.15);
    border-left: none;
    padding: 0.75rem 0.5rem;
    cursor: pointer;
    z-index: 101;
    border-radius: 0 8px 8px 0;
    color: var(--text-primary);
    font-size: 1.5rem;
    backdrop-filter: blur(10px);
    transition: all 0.3s ease;
    line-height: 1;
    box-shadow: 2px 0 8px rgba(0, 0, 0, 0.3);
}

.teams-toggle:hover {
    background: linear-gradient(180deg, rgba(26, 26, 46, 1) 0%, rgba(22, 33, 62, 1) 100%);
    transform: translateY(-50%) translateX(3px);
}

.teams-sidebar.open ~ .teams-toggle {
    left: 300px;
}

/* Left panel tab buttons */
.left-panel-tabs {
    display: flex;
    border-bottom: 2px solid rgba(255, 255, 255, 0.1);
    background: rgba(0, 0, 0, 0.25);
    flex-shrink: 0;
}

.left-tab-btn {
    flex: 1;
    padding: 0.85rem 0.5rem;
    background: transparent;
    border: none;
    border-bottom: 3px solid transparent;
    color: rgba(255, 255, 255, 0.55);
    font-family: 'Russo One', sans-serif;
    font-size: 0.8rem;
    letter-spacing: 0.03em;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
}

.left-tab-btn:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.05);
}

.left-tab-btn.active {
    color: var(--text-primary);
    border-bottom-color: #ffc107;
    background: rgba(255, 255, 255, 0.05);
}

/* Tab content areas */
.left-tab-content {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
}

.left-tab-content.hidden {
    display: none;
}

.teams-content {
    padding: 1rem;
}

.team-section {
    margin-bottom: 1.5rem;
    padding: 0.75rem;
    border-radius: var(--border-radius);
    background: rgba(0, 0, 0, 0.2);
}

.team-section h4 {
    margin: 0 0 0.75rem 0;
    font-size: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.red-team-section h4 {
    color: var(--red-primary);
}

.blue-team-section h4 {
    color: var(--blue-primary);
}

.spectator-section h4 {
    color: var(--text-secondary);
}

.role-group {
    margin-bottom: 0.75rem;
}

.role-group:last-child {
    margin-bottom: 0;
}

.role-label {
    font-size: 0.875rem;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.7);
    margin-bottom: 0.25rem;
}

.team-player-list {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.team-player-name {
    padding: 0.4rem 0.6rem;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 4px;
    font-size: 0.875rem;
    color: var(--text-primary);
    border-left: 3px solid rgba(255, 255, 255, 0.2);
}

.team-player-name.current-player {
    background: rgba(255, 255, 255, 0.15);
    border-left-color: #ffc107;
    font-weight: 600;
}

.no-players {
    padding: 0.4rem 0.6rem;
    font-size: 0.875rem;
    color: rgba(255, 255, 255, 0.4);
    font-style: italic;
}

/* Body margin when left sidebar is open */
body.teams-sidebar-open .container {
    margin-left: 310px;
    transition: margin-left 0.3s ease;
}

/* Both sidebars open */
body.teams-sidebar-open.sidebar-open .container {
    margin-left: 310px;
    margin-right: 290px;
}

/* Mobile Styles for Teams Sidebar */
@media (max-width: 768px) {
    /* Teams sidebar slides from bottom on mobile */
    .teams-sidebar {
        left: 0;
        right: 0;
        top: auto;
        bottom: -300px;
        width: 100%;
        height: 300px;
        transition: bottom 0.3s ease;
    }
    
    .teams-sidebar.open {
        bottom: 0;
        left: 0;
    }
    
    /* Teams toggle - Bottom left on mobile */
    .teams-toggle {
        position: fixed;
        left: 1rem;
        bottom: 1rem;
        top: auto;
        right: auto;
        transform: none;
        padding: 0.75rem 1rem;
        border-radius: 50%;
        border: 2px solid rgba(255, 255, 255, 0.15);
        font-size: 1.2rem;
        width: 56px;
        height: 56px;
        display: flex;
        align-items: center;
        justify-content: center;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
    }
    
    .teams-toggle:hover {
        transform: scale(1.05);
    }
    
    .teams-sidebar.open ~ .teams-toggle {
        bottom: 310px;
        left: 1rem;
    }
    
    /* Container and body margin adjustments for mobile */
    body.teams-sidebar-open .container {
        margin-left: 0;
        margin-bottom: 310px;
    }
    
    body.teams-sidebar-open.sidebar-open .container {
        margin-left: 0;
        margin-right: 0;
        margin-bottom: 520px;
    }
}

/* ==========================================
   CHAT PANEL STYLES
   ========================================== */

/* Chat content area */
.chat-content {
    display: flex;
    flex-direction: column;
    overflow: hidden; /* messages div handles its own scroll */
}

/* Channel selector */
.chat-channel-selector {
    display: flex;
    gap: 0.4rem;
    padding: 0.6rem 0.75rem;
    background: rgba(0, 0, 0, 0.2);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    flex-shrink: 0;
    flex-wrap: wrap;
}

.chat-channel-selector.hidden {
    display: none;
}

.chat-channel-btn {
    flex: 1;
    min-width: 0;
    padding: 0.35rem 0.5rem;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 20px;
    background: transparent;
    color: rgba(255, 255, 255, 0.6);
    font-size: 0.75rem;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
    text-align: center;
}

.chat-channel-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
}

.chat-channel-btn.active {
    background: rgba(255, 193, 7, 0.2);
    border-color: #ffc107;
    color: #ffc107;
    font-weight: 600;
}

.chat-channel-btn.hidden {
    display: none;
}

/* Messages area */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 0.6rem 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.chat-empty {
    text-align: center;
    color: rgba(255, 255, 255, 0.35);
    font-size: 0.85rem;
    font-style: italic;
    padding: 1.5rem 0;
    margin: auto 0;
}

/* Message bubble */
.chat-msg {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    animation: msgFadeIn 0.2s ease;
}

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

.chat-msg.own-msg .chat-bubble {
    background: rgba(255, 193, 7, 0.15);
    border-color: rgba(255, 193, 7, 0.3);
    align-self: flex-end;
}

.chat-msg-header {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.7rem;
    color: rgba(255, 255, 255, 0.45);
}

.chat-msg-sender {
    font-weight: 600;
    font-size: 0.75rem;
}

.chat-msg-sender.sender-red { color: var(--red-primary); }
.chat-msg-sender.sender-blue { color: var(--blue-primary); }
.chat-msg-sender.sender-neutral { color: rgba(255,255,255,0.7); }

.chat-msg-channel-tag {
    font-size: 0.65rem;
    padding: 0.1rem 0.4rem;
    border-radius: 10px;
    font-weight: 600;
    letter-spacing: 0.03em;
}

.channel-tag-all {
    background: rgba(255,255,255,0.12);
    color: rgba(255,255,255,0.6);
}

.channel-tag-spymasters {
    background: rgba(128, 0, 128, 0.25);
    color: #da8fff;
}

.chat-bubble {
    background: rgba(255, 255, 255, 0.07);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    padding: 0.45rem 0.65rem;
    font-size: 0.85rem;
    color: var(--text-primary);
    line-height: 1.4;
    word-break: break-word;
}

/* Chat input */
.chat-input-area {
    display: flex;
    gap: 0.4rem;
    padding: 0.6rem 0.75rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(0, 0, 0, 0.2);
    flex-shrink: 0;
}

.chat-input-area input {
    flex: 1;
    min-width: 0;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 6px;
    color: var(--text-primary);
    padding: 0.5rem 0.65rem;
    font-size: 0.85rem;
    font-family: inherit;
    outline: none;
    transition: border-color 0.2s ease;
}

.chat-input-area input:focus {
    border-color: rgba(255, 193, 7, 0.5);
}

.chat-input-area input::placeholder {
    color: rgba(255, 255, 255, 0.3);
}

.chat-send-btn {
    padding: 0.5rem 0.75rem;
    background: rgba(255, 193, 7, 0.2);
    border: 1px solid rgba(255, 193, 7, 0.4);
    border-radius: 6px;
    color: #ffc107;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
    font-family: 'Russo One', sans-serif;
    letter-spacing: 0.03em;
}

.chat-send-btn:hover {
    background: rgba(255, 193, 7, 0.35);
    border-color: #ffc107;
}

/* Unread badge */
.chat-unread-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--red-primary);
    color: white;
    border-radius: 10px;
    font-size: 0.65rem;
    font-weight: 700;
    min-width: 16px;
    height: 16px;
    padding: 0 4px;
    vertical-align: middle;
    margin-left: 2px;
    font-family: 'Open Sans', sans-serif;
}

.chat-unread-badge.hidden {
    display: none;
}
