/**
 * Air Hockey - Styles
 * 2-4 Player multiplayer air hockey game
 */

/* ============================================
   BASE STYLES
   ============================================ */

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    color: #fff;
    overflow: hidden;
    height: 100vh;
}

.hidden {
    display: none !important;
}

/* ============================================
   GAME CONTAINER
   ============================================ */

#gameContainer {
    display: grid;
    grid-template-rows: auto 1fr;
    grid-template-columns: 1fr 280px;
    height: 100vh;
    gap: 0;
}

#gameContainer.hidden {
    display: none;
}

/* ============================================
   TOP BAR
   ============================================ */

.top-bar {
    grid-column: 1 / -1;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1.5rem;
    background: rgba(0, 0, 0, 0.6);
    border-bottom: 2px solid #00d4ff;
    min-height: 70px;
    overflow: visible;
    flex-wrap: wrap;
    gap: 1rem;
}

.game-info {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.game-info h1 {
    font-size: 1.5rem;
    background: linear-gradient(135deg, #00d4ff 0%, #0099cc 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.room-badge {
    background: rgba(0, 212, 255, 0.2);
    color: #00d4ff;
    padding: 0.25rem 0.75rem;
    border-radius: 12px;
    font-size: 0.875rem;
    border: 1px solid rgba(0, 212, 255, 0.3);
}

.score-display {
    display: flex;
    gap: 2rem;
}

.score-board {
    display: flex;
    gap: 1.5rem;
    align-items: center;
}

.score-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 8px;
}

.score-color {
    width: 16px;
    height: 16px;
    border-radius: 50%;
}

.score-name {
    font-weight: 600;
    font-size: 0.9rem;
}

.score-value {
    font-size: 1.5rem;
    font-weight: bold;
    color: #00d4ff;
    min-width: 30px;
    text-align: center;
}

/* Indicator styles */
.indicator {
    font-size: 1.25rem;
}

.indicator.connected {
    color: #10b981;
}

.indicator.disconnected {
    color: #ef4444;
}

/* ============================================
   GAME ARENA
   ============================================ */

.game-arena {
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    background: linear-gradient(180deg, #0a1628 0%, #162447 100%);
    overflow: hidden;
    min-height: 300px;
    padding: 10px;
}

#gameCanvas {
    border: 4px solid #00d4ff;
    border-radius: 12px;
    box-shadow: 0 0 30px rgba(0, 212, 255, 0.3),
                inset 0 0 60px rgba(0, 0, 0, 0.5);
    /* Don't use max-width/max-height as they interfere with transform scaling */
    display: block;
}

/* Portrait mode container adjustments */
.game-arena.portrait-mode {
    min-height: 50vh;
}

#gameCanvas.rotated {
    /* Canvas is rotated via JS transform */
}

/* ============================================
   CONTROL PANEL
   ============================================ */

.control-panel {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.95);
    padding: 2rem;
    border-radius: 16px;
    text-align: center;
    min-width: 350px;
    border: 2px solid #00d4ff;
    box-shadow: 0 0 40px rgba(0, 212, 255, 0.3);
    z-index: 100;
}

.control-panel.hidden {
    display: none;
}

.control-panel h2 {
    font-size: 2rem;
    margin-bottom: 0.5rem;
    background: linear-gradient(135deg, #00d4ff 0%, #0099cc 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.control-panel p {
    color: #9ca3af;
    margin-bottom: 1.5rem;
}

.players-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 1rem;
    max-height: 150px;
    overflow-y: auto;
}

.player-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 1rem;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    border: 1px solid transparent;
    transition: all 0.2s;
}

.player-item.ready {
    border-color: #10b981;
    background: rgba(16, 185, 129, 0.1);
}

.player-color {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.3);
}

.player-name {
    flex: 1;
    text-align: left;
    font-weight: 500;
}

.player-status {
    font-size: 1.25rem;
}

.game-message {
    color: #00d4ff;
    font-size: 1.1rem;
    margin: 1rem 0;
    font-weight: 500;
}

.game-settings {
    margin: 1rem 0;
    padding: 1rem;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
}

.game-settings label {
    color: #9ca3af;
    font-size: 0.9rem;
}

.game-settings select {
    margin-left: 0.5rem;
    padding: 0.4rem 0.8rem;
    border-radius: 6px;
    border: 1px solid #00d4ff;
    background: #1a1a2e;
    color: white;
    font-size: 0.9rem;
    cursor: pointer;
}

.game-buttons {
    display: flex;
    gap: 1rem;
    justify-content: center;
    align-items: center;
    margin: 1rem 0;
    flex-wrap: wrap;
}

.btn-ready,
.btn-start {
    padding: 0.875rem 2rem;
    font-size: 1.1rem;
    font-weight: 600;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    margin: 0;
    transition: all 0.2s;
    flex: 1;
    min-width: 180px;
    max-width: 250px;
}

.btn-ready {
    background: linear-gradient(135deg, #6366f1 0%, #4f46e5 100%);
    color: white;
}

.btn-ready:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(99, 102, 241, 0.4);
}

.btn-ready.active {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
}

.btn-start {
    background: linear-gradient(135deg, #00d4ff 0%, #0099cc 100%);
    color: white;
}

.btn-start:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 212, 255, 0.4);
}

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

.btn-share-lobby {
    padding: 0.875rem 2rem;
    font-size: 1.1rem;
    font-weight: 600;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    margin: 0;
    background: linear-gradient(135deg, #22c55e 0%, #16a34a 100%);
    color: white;
    transition: all 0.2s;
    flex: 1;
    min-width: 180px;
    max-width: 250px;
}

.btn-share-lobby:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(34, 197, 94, 0.4);
}

/* ============================================
   GOAL OVERLAY
   ============================================ */

.goal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 200;
    animation: goalFadeIn 0.3s ease;
}

.goal-overlay.hidden {
    display: none;
}

@keyframes goalFadeIn {
    from { opacity: 0; transform: scale(0.8); }
    to { opacity: 1; transform: scale(1); }
}

.goal-text {
    font-size: 5rem;
    font-weight: bold;
    background: linear-gradient(135deg, #fbbf24 0%, #f59e0b 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: goalPulse 0.5s ease infinite alternate;
}

@keyframes goalPulse {
    from { transform: scale(1); }
    to { transform: scale(1.1); }
}

.goal-scorer {
    font-size: 1.5rem;
    color: #fff;
    margin-top: 1rem;
}

/* ============================================
   SIDE PANEL
   ============================================ */

.side-panel {
    background: rgba(0, 0, 0, 0.5);
    padding: 1.5rem;
    border-left: 2px solid #00d4ff;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    overflow-y: auto;
}

.side-panel h3 {
    font-size: 1.1rem;
    color: #00d4ff;
    margin-bottom: 0.5rem;
}

.side-panel h4 {
    font-size: 0.9rem;
    color: #9ca3af;
    margin-bottom: 0.5rem;
}

.controls-info {
    font-size: 0.85rem;
    color: #9ca3af;
    line-height: 1.6;
}

.controls-info p {
    margin-bottom: 0.5rem;
}

.leaderboard {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.leaderboard-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 6px;
}

.leaderboard-rank {
    font-size: 1.25rem;
    min-width: 30px;
}

.leaderboard-color {
    width: 16px;
    height: 16px;
    border-radius: 50%;
}

.leaderboard-name {
    flex: 1;
    font-weight: 500;
    font-size: 0.9rem;
}

.leaderboard-score {
    font-weight: bold;
    color: #00d4ff;
}

.game-stats {
    padding: 1rem;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
}

.stat-row {
    display: flex;
    justify-content: space-between;
    padding: 0.25rem 0;
    font-size: 0.9rem;
}

.stat-row span:first-child {
    color: #9ca3af;
}

.stat-row span:last-child {
    font-weight: 600;
    color: #fff;
}

.btn-danger {
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    color: white;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    margin-top: auto;
    width: 100%;
}

.btn-danger:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.4);
}

.btn-small {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
}

.btn-warning {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
    color: white;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s;
}

.btn-warning:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(245, 158, 11, 0.4);
}

.btn-primary {
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
    color: white;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.4);
}

.host-controls {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.host-controls button {
    width: 100%;
}

.btn-share-sidebar {
    width: 100%;
    padding: 0.75rem 1.5rem;
    margin-bottom: 0.5rem;
    border-radius: 8px;
    background: linear-gradient(135deg, #00d4ff 0%, #0099cc 100%);
    color: white;
    border: none;
    cursor: pointer;
    font-weight: 600;
    font-size: 1rem;
    transition: all 0.2s;
    box-shadow: 0 2px 8px rgba(0, 212, 255, 0.3);
}

.btn-share-sidebar:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 212, 255, 0.5);
}

.connection-info {
    background: rgba(0, 212, 255, 0.1);
    border: 1px solid rgba(0, 212, 255, 0.3);
    border-radius: 8px;
    padding: 0.75rem;
    margin-bottom: 0.5rem;
}

.connection-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.25rem 0;
    font-size: 0.9rem;
}

.connection-row:first-child {
    margin-bottom: 0.5rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid rgba(0, 212, 255, 0.2);
}


/* ============================================
   RESPONSIVE
   ============================================ */

/* Tablet and smaller screens */
@media (max-width: 900px) {
    #gameContainer {
        grid-template-columns: 1fr;
        grid-template-rows: auto 1fr auto;
    }

    .top-bar {
        padding: 0.5rem 0.75rem;
        gap: 0.5rem;
        min-height: auto;
    }

    .game-info h1 {
        font-size: 1.1rem;
    }

    .room-badge {
        font-size: 0.75rem;
        padding: 0.2rem 0.5rem;
    }

    .score-display {
        gap: 0.5rem;
    }

    .score-board {
        gap: 0.5rem;
        flex-wrap: wrap;
    }

    .score-item {
        padding: 0.25rem 0.5rem;
        font-size: 0.8rem;
    }

    .side-panel {
        border-left: none;
        border-top: 2px solid #00d4ff;
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: space-around;
        padding: 0.75rem;
        gap: 0.75rem;
        max-height: 30vh;
        overflow-y: auto;
    }

    .side-panel > * {
        flex: 1;
        min-width: 120px;
    }

    .side-panel h3 {
        font-size: 0.9rem;
        width: 100%;
    }

    .side-panel h4 {
        font-size: 0.85rem;
        width: 100%;
    }

    .btn-share-sidebar,
    .btn-danger {
        width: 100%;
        min-width: 100%;
        flex: 1 1 100%;
        padding: 0.5rem 1rem;
        font-size: 0.85rem;
    }


    .control-panel {
        min-width: 280px;
        padding: 1.5rem;
        max-width: 90vw;
    }

    .control-panel h2 {
        font-size: 1.5rem;
    }
}

/* Mobile landscape (width > height, small screen) */
@media (max-width: 900px) and (orientation: landscape) {
    #gameContainer {
        grid-template-columns: 1fr 200px;
        grid-template-rows: auto 1fr;
    }

    .top-bar {
        padding: 0.25rem 0.5rem;
        min-height: 40px;
    }

    .game-info h1 {
        font-size: 1rem;
    }

    .room-badge {
        display: none;
    }

    .score-item {
        padding: 0.15rem 0.35rem;
    }

    .side-panel {
        flex-direction: column;
        border-left: 2px solid #00d4ff;
        border-top: none;
        max-height: none;
        overflow-y: auto;
        padding: 0.5rem;
        gap: 0.5rem;
    }

    .side-panel > * {
        min-width: auto;
        width: 100%;
    }

    .side-panel h3,
    .side-panel h4 {
        font-size: 0.8rem;
        margin-bottom: 0.25rem;
    }

    .controls-info p {
        font-size: 0.75rem;
    }

    .game-arena {
        min-height: 200px;
        padding: 5px;
    }
}

/* Mobile portrait (height > width) - Rotate canvas */
@media (max-width: 768px) and (orientation: portrait) {
    body {
        overflow: hidden;
    }

    #gameContainer {
        grid-template-columns: 1fr;
        grid-template-rows: auto 1fr auto;
        height: 100vh;
        height: 100dvh; /* Dynamic viewport height for mobile */
    }

    .top-bar {
        padding: 0.35rem 0.5rem;
        min-height: 45px;
        gap: 0.35rem;
    }

    .game-info {
        gap: 0.5rem;
    }

    .game-info h1 {
        font-size: 0.95rem;
    }

    .room-badge {
        display: none;
    }

    .score-display {
        gap: 0.35rem;
    }

    .score-board {
        gap: 0.35rem;
    }

    .score-item {
        padding: 0.15rem 0.3rem;
        font-size: 0.7rem;
    }

    .score-value {
        font-size: 1rem;
    }

    .game-arena {
        display: flex;
        justify-content: center;
        align-items: center;
        padding: 10px;
        min-height: 50vh;
        flex: 1;
    }

    /* Portrait mode - canvas is rotated by JS */
    .game-arena.portrait-mode {
        min-height: 45vh;
    }

    #gameCanvas {
        /* Canvas dimensions and transform set by JS */
        display: block;
    }

    .side-panel {
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: center;
        padding: 0.5rem;
        gap: 0.5rem;
        max-height: 25vh;
        overflow-y: auto;
        border-top: 2px solid #00d4ff;
        border-left: none;
    }

    .side-panel > * {
        flex: 1 1 45%;
        min-width: 100px;
    }

    .side-panel h3,
    .side-panel h4 {
        font-size: 0.8rem;
        width: 100%;
        text-align: center;
        margin-bottom: 0.25rem;
    }

    .controls-info {
        display: none; /* Hide controls info on small portrait to save space */
    }

    .leaderboard {
        font-size: 0.75rem;
    }

    .game-stats {
        font-size: 0.75rem;
    }

    .stat-row {
        padding: 0.15rem 0;
    }

    .btn-share-sidebar,
    .btn-danger {
        padding: 0.4rem 0.75rem;
        font-size: 0.75rem;
        flex: 1 1 45%;
        min-width: 80px;
    }


    .control-panel {
        min-width: 260px;
        max-width: 95vw;
        padding: 1rem;
        max-height: 80vh;
        overflow-y: auto;
    }

    .control-panel h2 {
        font-size: 1.25rem;
    }

    .control-panel p {
        font-size: 0.85rem;
        margin-bottom: 1rem;
    }

    .game-settings label {
        font-size: 0.85rem;
    }

    .game-settings select {
        padding: 0.4rem;
        font-size: 0.85rem;
    }

    .btn-ready,
    .btn-start {
        padding: 0.6rem 1rem;
        font-size: 0.9rem;
    }

    /* Goal overlay adjustments */
    .goal-overlay .goal-text {
        font-size: 2.5rem;
    }

    .goal-overlay .goal-scorer {
        font-size: 1rem;
    }
}

/* Very small phones */
@media (max-width: 400px) {
    .top-bar {
        padding: 0.25rem 0.35rem;
    }

    .game-info h1 {
        font-size: 0.85rem;
    }

    .score-item {
        padding: 0.1rem 0.2rem;
        font-size: 0.65rem;
    }

    .score-value {
        font-size: 0.85rem;
    }

    .side-panel {
        max-height: 20vh;
        padding: 0.35rem;
    }

    .side-panel h3,
    .side-panel h4 {
        font-size: 0.7rem;
    }

    .btn-share-sidebar,
    .btn-danger {
        padding: 0.3rem 0.5rem;
        font-size: 0.7rem;
    }
}

/* ============================================
   FULLSCREEN TOGGLE BUTTON (Mobile Only)
   ============================================ */

.fullscreen-toggle-btn {
    position: fixed;
    top: 120px; /* Below share button */
    right: 16px;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(10px);
    border: 2px solid rgba(0, 212, 255, 0.4);
    color: #00d4ff;
    cursor: pointer;
    z-index: 50000;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.fullscreen-toggle-btn:hover {
    background: rgba(0, 212, 255, 0.2);
    border-color: #00d4ff;
    transform: scale(1.05);
}

.fullscreen-toggle-btn:active {
    transform: scale(0.95);
}

.fullscreen-toggle-btn svg {
    width: 24px;
    height: 24px;
}

/* Fullscreen mode - hide side panel and expand game arena */
body.fullscreen-mode #gameContainer {
    grid-template-columns: 1fr;
}

body.fullscreen-mode .side-panel {
    display: none;
}

body.fullscreen-mode .top-bar {
    padding: 0.5rem 0.75rem;
    min-height: 50px;
}

body.fullscreen-mode .game-info h1 {
    font-size: 1.25rem;
}

body.fullscreen-mode .game-arena {
    padding: 0.5rem;
}

/* Only show fullscreen button on mobile/tablet */
@media (min-width: 769px) {
    .fullscreen-toggle-btn {
        display: none !important;
    }
}

/* Adjust position on smaller screens */
@media (max-width: 768px) and (orientation: portrait) {
    .fullscreen-toggle-btn {
        top: 80px;
        right: 12px;
        width: 44px;
        height: 44px;
    }

    .fullscreen-toggle-btn svg {
        width: 22px;
        height: 22px;
    }
}
