/* Material Design M3 Expressive - Custom CSS */

:root {
    /* M3 Color System - Primary */
    --md-sys-color-primary: #6750A4;
    --md-sys-color-on-primary: #FFFFFF;
    --md-sys-color-primary-container: #EADDFF;
    --md-sys-color-on-primary-container: #21005D;
    
    /* Secondary */
    --md-sys-color-secondary: #625B71;
    --md-sys-color-on-secondary: #FFFFFF;
    --md-sys-color-secondary-container: #E8DEF8;
    --md-sys-color-on-secondary-container: #1D192B;
    
    /* Tertiary */
    --md-sys-color-tertiary: #7D5260;
    --md-sys-color-on-tertiary: #FFFFFF;
    --md-sys-color-tertiary-container: #FFD8E4;
    --md-sys-color-on-tertiary-container: #31111D;
    
    /* Error */
    --md-sys-color-error: #B3261E;
    --md-sys-color-on-error: #FFFFFF;
    --md-sys-color-error-container: #F9DEDC;
    --md-sys-color-on-error-container: #410E0B;
    
    /* Surface */
    --md-sys-color-surface: #FEF7FF;
    --md-sys-color-on-surface: #1D1B20;
    --md-sys-color-surface-variant: #E7E0EC;
    --md-sys-color-on-surface-variant: #49454F;
    --md-sys-color-surface-container: #F3EDF7;
    --md-sys-color-surface-container-high: #ECE6F0;
    --md-sys-color-surface-container-highest: #E6E0E9;
    
    /* Outline */
    --md-sys-color-outline: #79747E;
    --md-sys-color-outline-variant: #CAC4D0;
    
    /* M3 Typography */
    --md-sys-typescale-headline-large: 500 32px/40px 'Roboto', sans-serif;
    --md-sys-typescale-headline-medium: 500 28px/36px 'Roboto', sans-serif;
    --md-sys-typescale-headline-small: 500 24px/32px 'Roboto', sans-serif;
    --md-sys-typescale-title-large: 500 22px/28px 'Roboto', sans-serif;
    --md-sys-typescale-title-medium: 500 16px/24px 'Roboto', sans-serif;
    --md-sys-typescale-body-large: 400 16px/24px 'Roboto', sans-serif;
    --md-sys-typescale-body-medium: 400 14px/20px 'Roboto', sans-serif;
    --md-sys-typescale-label-large: 500 14px/20px 'Roboto', sans-serif;
    
    /* M3 Shape */
    --md-sys-shape-corner-small: 8px;
    --md-sys-shape-corner-medium: 12px;
    --md-sys-shape-corner-large: 16px;
    --md-sys-shape-corner-extra-large: 28px;
    
    /* M3 Elevation */
    --md-sys-elevation-1: 0 1px 2px rgba(0,0,0,0.3), 0 1px 3px 1px rgba(0,0,0,0.15);
    --md-sys-elevation-2: 0 1px 2px rgba(0,0,0,0.3), 0 2px 6px 2px rgba(0,0,0,0.15);
    --md-sys-elevation-3: 0 4px 8px 3px rgba(0,0,0,0.15), 0 1px 3px rgba(0,0,0,0.3);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font: var(--md-sys-typescale-body-large);
    background-color: var(--md-sys-color-surface);
    color: var(--md-sys-color-on-surface);
    min-height: 100vh;
}

.container {
    max-width: 600px;
    margin: 0 auto;
    padding: 24px 16px;
}

/* Typography */
h1 {
    font: var(--md-sys-typescale-headline-large);
    color: var(--md-sys-color-on-surface);
    margin-bottom: 24px;
    text-align: center;
}

h2 {
    font: var(--md-sys-typescale-headline-medium);
    color: var(--md-sys-color-on-surface);
    margin-bottom: 16px;
}

h3 {
    font: var(--md-sys-typescale-title-large);
    color: var(--md-sys-color-on-surface);
    margin-bottom: 12px;
}

/* Cards */
.card {
    background-color: var(--md-sys-color-surface-container);
    border-radius: var(--md-sys-shape-corner-large);
    padding: 24px;
    margin-bottom: 16px;
    box-shadow: var(--md-sys-elevation-1);
}

.card-elevated {
    background-color: var(--md-sys-color-surface-container-high);
    box-shadow: var(--md-sys-elevation-2);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font: var(--md-sys-typescale-label-large);
    padding: 10px 24px;
    border: none;
    border-radius: 100px;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
    min-height: 40px;
}

.btn-filled {
    background-color: var(--md-sys-color-primary);
    color: var(--md-sys-color-on-primary);
}

.btn-filled:hover {
    box-shadow: var(--md-sys-elevation-1);
    background-color: #7965AF;
}

.btn-filled:active {
    background-color: #8E7CBC;
}

.btn-tonal {
    background-color: var(--md-sys-color-secondary-container);
    color: var(--md-sys-color-on-secondary-container);
}

.btn-tonal:hover {
    box-shadow: var(--md-sys-elevation-1);
    background-color: #DED4EB;
}

.btn-outlined {
    background-color: transparent;
    color: var(--md-sys-color-primary);
    border: 1px solid var(--md-sys-color-outline);
}

.btn-outlined:hover {
    background-color: rgba(103, 80, 164, 0.08);
}

.btn-text {
    background-color: transparent;
    color: var(--md-sys-color-primary);
    padding: 10px 12px;
}

.btn-text:hover {
    background-color: rgba(103, 80, 164, 0.08);
}

.btn-fab {
    width: 56px;
    height: 56px;
    border-radius: var(--md-sys-shape-corner-large);
    padding: 0;
    box-shadow: var(--md-sys-elevation-3);
}

.btn-fab-small {
    width: 40px;
    height: 40px;
    border-radius: var(--md-sys-shape-corner-medium);
}

.btn-error {
    background-color: var(--md-sys-color-error);
    color: var(--md-sys-color-on-error);
}

.btn-error:hover {
    background-color: #C4433C;
}

.btn-block {
    width: 100%;
}

.btn:disabled {
    opacity: 0.38;
    cursor: not-allowed;
}

/* Text Fields */
.text-field {
    position: relative;
    margin-bottom: 16px;
}

.text-field input {
    width: 100%;
    padding: 16px;
    font: var(--md-sys-typescale-body-large);
    background-color: var(--md-sys-color-surface-container-highest);
    border: none;
    border-bottom: 2px solid var(--md-sys-color-on-surface-variant);
    border-radius: var(--md-sys-shape-corner-small) var(--md-sys-shape-corner-small) 0 0;
    color: var(--md-sys-color-on-surface);
    transition: all 0.2s ease;
}

.text-field input:focus {
    outline: none;
    border-bottom-color: var(--md-sys-color-primary);
    background-color: var(--md-sys-color-surface-container-high);
}

.text-field input::placeholder {
    color: var(--md-sys-color-on-surface-variant);
}

.text-field label {
    display: block;
    font: var(--md-sys-typescale-body-medium);
    color: var(--md-sys-color-on-surface-variant);
    margin-bottom: 4px;
}

/* Lists */
.list {
    list-style: none;
}

.list-item {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 12px 16px;
    border-radius: var(--md-sys-shape-corner-medium);
    transition: background-color 0.2s ease;
}

.list-item:hover {
    background-color: rgba(0, 0, 0, 0.04);
}

.list-item-icon {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: var(--md-sys-color-primary-container);
    color: var(--md-sys-color-on-primary-container);
    border-radius: 50%;
}

.list-item-content {
    flex: 1;
}

.list-item-title {
    font: var(--md-sys-typescale-body-large);
    color: var(--md-sys-color-on-surface);
}

.list-item-subtitle {
    font: var(--md-sys-typescale-body-medium);
    color: var(--md-sys-color-on-surface-variant);
}

/* Divider */
.divider {
    height: 1px;
    background-color: var(--md-sys-color-outline-variant);
    margin: 16px 0;
}

/* Chips */
.chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 16px;
    background-color: var(--md-sys-color-surface-container-high);
    border: 1px solid var(--md-sys-color-outline);
    border-radius: 8px;
    font: var(--md-sys-typescale-label-large);
    color: var(--md-sys-color-on-surface-variant);
}

/* Score Display */
.score-display {
    text-align: center;
    padding: 16px;
}

.score-value {
    font-size: 72px;
    font-weight: 500;
    color: var(--md-sys-color-primary);
    line-height: 1;
    margin-bottom: 8px;
}

.score-label {
    font: var(--md-sys-typescale-title-medium);
    color: var(--md-sys-color-on-surface-variant);
}

/* Score Controls */
.score-controls {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    margin-top: 8px;
}

.score-controls .btn {
    padding: 16px;
    font-size: 18px;
}

/* Score Row Layout */
.score-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    margin-top: 8px;
}

.score-controls-left,
.score-controls-right {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.score-controls-left .btn,
.score-controls-right .btn {
    padding: 12px 16px;
    font-size: 16px;
    min-width: 80px;
}

.score-row .score-display {
    padding: 8px 24px;
}

.score-row .score-value {
    margin-bottom: 0;
}

/* QR Code */
.qr-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 24px;
}

.qr-code {
    background: white;
    padding: 16px;
    border-radius: var(--md-sys-shape-corner-medium);
    margin-bottom: 16px;
}

.qr-code img {
    display: block;
    width: 200px;
    height: 200px;
}

.join-code {
    font-size: 48px;
    font-weight: 500;
    letter-spacing: 8px;
    color: var(--md-sys-color-primary);
    margin: 16px 0;
}

/* Player List */
.player-list {
    list-style: none;
}

.player-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-radius: var(--md-sys-shape-corner-medium);
    margin-bottom: 8px;
    background-color: var(--md-sys-color-surface-container);
}

.player-name {
    display: flex;
    align-items: center;
    gap: 12px;
    font: var(--md-sys-typescale-body-large);
}

.player-avatar {
    width: 40px;
    height: 40px;
    background-color: var(--md-sys-color-tertiary-container);
    color: var(--md-sys-color-on-tertiary-container);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font: var(--md-sys-typescale-title-medium);
}

.player-score {
    font: var(--md-sys-typescale-headline-small);
    color: var(--md-sys-color-primary);
    min-width: 60px;
    text-align: right;
}

.host-badge {
    font: var(--md-sys-typescale-label-large);
    color: var(--md-sys-color-tertiary);
    background-color: var(--md-sys-color-tertiary-container);
    padding: 2px 8px;
    border-radius: 4px;
    margin-left: 8px;
}

.you-badge {
    font: var(--md-sys-typescale-label-large);
    color: var(--md-sys-color-secondary);
    background-color: var(--md-sys-color-secondary-container);
    padding: 2px 8px;
    border-radius: 4px;
    margin-left: 8px;
}

/* Game View Layout */
.game-view {
    display: flex;
    flex-direction: column;
    gap: 16px;
   /* min-height: calc(100vh - 48px);*/
}

.my-score-section {
    flex: 1;
}

.other-scores-section {
    flex: 1;
}

@media (orientation: landscape) and (min-width: 768px) {
    .container {
        max-width: 100%;
        padding: 16px 24px;
    }
    
    .game-view {
        flex-direction: row;
    }
    
    .my-score-section {
        flex: 1;
        max-width: 50%;
    }
    
    .other-scores-section {
        flex: 1;
        max-width: 50%;
        overflow-y: auto;
    }
}

/* Utilities */
.text-center {
    text-align: center;
}

.mt-16 {
    margin-top: 16px;
}

.mt-24 {
    margin-top: 24px;
}

.mb-16 {
    margin-bottom: 16px;
}

.mb-24 {
    margin-bottom: 24px;
}

.gap-8 {
    gap: 8px;
}

.flex {
    display: flex;
}

.flex-col {
    flex-direction: column;
}

.items-center {
    align-items: center;
}

.justify-center {
    justify-content: center;
}

.justify-between {
    justify-content: space-between;
}

/* Status Message */
.status-message {
    padding: 12px 16px;
    border-radius: var(--md-sys-shape-corner-medium);
    font: var(--md-sys-typescale-body-medium);
    margin-bottom: 16px;
}

.status-success {
    background-color: #D1FAE5;
    color: #065F46;
}

.status-error {
    background-color: var(--md-sys-color-error-container);
    color: var(--md-sys-color-on-error-container);
}

.status-info {
    background-color: var(--md-sys-color-primary-container);
    color: var(--md-sys-color-on-primary-container);
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 48px 24px;
    color: var(--md-sys-color-on-surface-variant);
}

.empty-state .material-icons {
    font-size: 64px;
    margin-bottom: 16px;
    opacity: 0.5;
}

/* Loading */
.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 24px;
    color: var(--md-sys-color-on-surface-variant);
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.loading .material-icons {
    animation: spin 1s linear infinite;
}

/* Button Groups */
.btn-group {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.btn-group-vertical {
    flex-direction: column;
}

/* Snackbar placeholder for JS */
.snackbar {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    background-color: var(--md-sys-color-on-surface);
    color: var(--md-sys-color-surface);
    padding: 14px 24px;
    border-radius: var(--md-sys-shape-corner-small);
    box-shadow: var(--md-sys-elevation-3);
    z-index: 1000;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.snackbar.show {
    opacity: 1;
}
