/* Word Association Game - Dark Mode UI */
/* Inspired by Claude.ai with grey/orange color palette */

:root {
    /* Dark mode backgrounds */
    --bg-primary: #1a1a1a;
    --bg-secondary: #242424;
    --bg-elevated: #2d2d2d;
    --bg-hover: #363636;
    --bg-active: #404040;

    /* Orange accent palette */
    --accent-primary: #e07a3c;
    --accent-light: #f09860;
    --accent-dark: #c56a2c;
    --accent-subtle: rgba(224, 122, 60, 0.15);
    --accent-glow: rgba(224, 122, 60, 0.3);

    /* Text colors */
    --text-primary: #f5f5f5;
    --text-secondary: #a0a0a0;
    --text-tertiary: #707070;
    --text-inverse: #1a1a1a;

    /* Semantic colors */
    --success: #4ade80;
    --success-bg: rgba(74, 222, 128, 0.15);
    --danger: #f87171;
    --danger-bg: rgba(248, 113, 113, 0.15);
    --warning: #fbbf24;
    --warning-bg: rgba(251, 191, 36, 0.15);

    /* Borders and dividers */
    --border-subtle: rgba(255, 255, 255, 0.08);
    --border-default: rgba(255, 255, 255, 0.12);
    --border-strong: rgba(255, 255, 255, 0.2);

    /* Shadows */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.5);
    --shadow-glow: 0 0 20px var(--accent-glow);

    /* Spacing and sizing */
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --radius-full: 9999px;

    /* Transitions */
    --transition-fast: 150ms ease;
    --transition-base: 200ms ease;
    --transition-slow: 300ms ease;
}

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

/* Base styles */
html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background: var(--bg-primary);
    min-height: 100vh;
    color: var(--text-primary);
    line-height: 1.5;
}

/* Container */
.container {
    max-width: 480px;
    margin: 0 auto;
    padding: 24px 16px;
    min-height: 100vh;
}

/* Cards */
.card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: 24px;
    margin-bottom: 16px;
    transition: border-color var(--transition-base), box-shadow var(--transition-base);
}

.card:hover {
    border-color: var(--border-default);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border-subtle);
}

/* Typography */
h1 {
    font-size: 1.875rem;
    font-weight: 600;
    text-align: center;
    color: var(--text-primary);
    margin-bottom: 24px;
    letter-spacing: -0.02em;
}

h2 {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
    letter-spacing: -0.01em;
}

h3 {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 12px;
}

p {
    color: var(--text-secondary);
}

/* Forms */
.form-group {
    margin-bottom: 16px;
}

label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

input[type="text"] {
    width: 100%;
    padding: 14px 16px;
    font-size: 1rem;
    font-family: inherit;
    color: var(--text-primary);
    background: var(--bg-primary);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

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

input[type="text"]:hover {
    border-color: var(--border-strong);
}

input[type="text"]:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px var(--accent-subtle);
}

input[type="text"].uppercase {
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    padding: 14px 24px;
    font-size: 0.9375rem;
    font-weight: 600;
    font-family: inherit;
    text-align: center;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-fast);
    gap: 8px;
}

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

.btn-primary {
    background: var(--accent-primary);
    color: var(--text-inverse);
}

.btn-primary:hover:not(:disabled) {
    background: var(--accent-light);
    box-shadow: var(--shadow-glow);
}

.btn-primary:active:not(:disabled) {
    background: var(--accent-dark);
}

.btn-success {
    background: var(--success);
    color: var(--text-inverse);
}

.btn-success:hover:not(:disabled) {
    filter: brightness(1.1);
    box-shadow: 0 0 20px rgba(74, 222, 128, 0.3);
}

.btn-danger {
    background: var(--danger);
    color: var(--text-inverse);
}

.btn-danger:hover:not(:disabled) {
    filter: brightness(1.1);
    box-shadow: 0 0 20px rgba(248, 113, 113, 0.3);
}

.btn-secondary {
    background: var(--bg-elevated);
    color: var(--text-secondary);
    border: 1px solid var(--border-default);
}

.btn-secondary:hover:not(:disabled) {
    background: var(--bg-hover);
    color: var(--text-primary);
    border-color: var(--border-strong);
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--accent-primary);
    color: var(--accent-primary);
}

.btn-outline:hover:not(:disabled) {
    background: var(--accent-subtle);
}

.btn-sm {
    padding: 10px 16px;
    font-size: 0.8125rem;
}

/* Divider */
.divider {
    display: flex;
    align-items: center;
    text-align: center;
    margin: 24px 0;
    color: var(--text-tertiary);
}

.divider::before,
.divider::after {
    content: '';
    flex: 1;
    border-bottom: 1px solid var(--border-subtle);
}

.divider span {
    padding: 0 16px;
    font-size: 0.75rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

/* Room Code Display */
.room-code {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
}

.room-code-value {
    font-size: 1.75rem;
    font-weight: 700;
    letter-spacing: 0.15em;
    color: var(--accent-primary);
    font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace;
}

.copy-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 10px;
    background: var(--bg-elevated);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-sm);
    cursor: pointer;
    color: var(--text-secondary);
    transition: all var(--transition-fast);
}

.copy-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
    border-color: var(--border-strong);
}

.copy-btn svg {
    width: 18px;
    height: 18px;
}

/* Player List */
.player-list {
    list-style: none;
}

.player-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 0;
    border-bottom: 1px solid var(--border-subtle);
}

.player-item:last-child {
    border-bottom: none;
}

.player-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.player-status {
    width: 8px;
    height: 8px;
    border-radius: var(--radius-full);
    background: var(--success);
    box-shadow: 0 0 8px rgba(74, 222, 128, 0.5);
}

.player-status.disconnected {
    background: var(--text-tertiary);
    box-shadow: none;
}

.player-name {
    font-weight: 500;
    color: var(--text-primary);
}

.player-badge {
    font-size: 0.6875rem;
    font-weight: 600;
    padding: 3px 8px;
    border-radius: var(--radius-full);
    background: var(--accent-primary);
    color: var(--text-inverse);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.player-word-status {
    font-size: 0.8125rem;
    color: var(--text-tertiary);
}

.player-word-status.submitted {
    color: var(--success);
}

.player-kick-btn {
    padding: 6px 12px;
    font-size: 0.75rem;
    font-weight: 500;
    background: transparent;
    border: 1px solid var(--danger);
    color: var(--danger);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.player-kick-btn:hover {
    background: var(--danger-bg);
}

/* Timer */
.timer {
    font-size: 1.75rem;
    font-weight: 700;
    font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace;
    color: var(--accent-primary);
}

.timer.warning {
    color: var(--warning);
}

.timer.danger {
    color: var(--danger);
    animation: pulse 1s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

/* Word Display */
.word-display {
    text-align: center;
    padding: 32px 20px;
    background: var(--bg-elevated);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    margin: 20px 0;
}

.word-display h3 {
    margin-bottom: 12px;
    font-size: 0.8125rem;
}

.word-value {
    font-size: 1.75rem;
    font-weight: 600;
    color: var(--accent-light);
    word-break: break-word;
    letter-spacing: -0.01em;
}

/* Player Selector */
.player-selector {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.player-select-btn {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 16px 18px;
    font-size: 0.9375rem;
    font-family: inherit;
    font-weight: 500;
    background: var(--bg-elevated);
    color: var(--text-primary);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.player-select-btn:hover:not(:disabled) {
    border-color: var(--accent-primary);
    background: var(--accent-subtle);
}

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

.player-select-btn .guessed-word {
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--success);
}

/* Waiting State */
.waiting-state {
    text-align: center;
    padding: 40px 24px;
}

.waiting-state .checkmark {
    width: 64px;
    height: 64px;
    margin: 0 auto 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    color: var(--success);
    background: var(--success-bg);
    border-radius: var(--radius-full);
}

.waiting-state h3 {
    font-size: 1.125rem;
    text-transform: none;
    letter-spacing: normal;
    margin-bottom: 8px;
    color: var(--text-primary);
}

.waiting-state p {
    color: var(--text-secondary);
}

/* Scores */
.score-list {
    list-style: none;
}

.score-item {
    display: flex;
    align-items: center;
    padding: 16px 0;
    border-bottom: 1px solid var(--border-subtle);
}

.score-item:last-child {
    border-bottom: none;
}

.score-item:first-child {
    background: linear-gradient(90deg, var(--accent-subtle), transparent);
    margin: 0 -24px;
    padding: 16px 24px;
    border-radius: var(--radius-sm);
}

.score-rank {
    font-size: 1.5rem;
    width: 40px;
}

.score-name {
    flex: 1;
    font-weight: 500;
    color: var(--text-primary);
}

.score-points {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--accent-primary);
    font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace;
}

/* Breakdown */
.breakdown-item {
    padding: 16px;
    background: var(--bg-elevated);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    margin-bottom: 10px;
}

.breakdown-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.breakdown-name {
    font-weight: 600;
    color: var(--text-primary);
}

.breakdown-word {
    font-style: italic;
    color: var(--accent-light);
}

.breakdown-details {
    font-size: 0.8125rem;
    color: var(--text-secondary);
}

.breakdown-details span {
    display: block;
    margin-top: 4px;
}

/* Round Info */
.round-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.round-number {
    font-weight: 600;
    color: var(--text-primary);
}

/* Connection Status */
.connection-status {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    padding: 10px 16px;
    text-align: center;
    font-size: 0.8125rem;
    font-weight: 600;
    z-index: 1000;
    transform: translateY(-100%);
    transition: transform var(--transition-slow);
}

.connection-status.visible {
    transform: translateY(0);
}

.connection-status.disconnected {
    background: var(--danger);
    color: var(--text-inverse);
}

.connection-status.reconnecting {
    background: var(--warning);
    color: var(--text-inverse);
}

/* Toast Notifications */
.toast-container {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    padding: 14px 24px;
    background: var(--bg-elevated);
    color: var(--text-primary);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    animation: toastIn 0.3s ease;
    font-size: 0.875rem;
    font-weight: 500;
}

.toast.error {
    background: var(--danger-bg);
    border-color: var(--danger);
    color: var(--danger);
}

.toast.success {
    background: var(--success-bg);
    border-color: var(--success);
    color: var(--success);
}

@keyframes toastIn {
    from {
        opacity: 0;
        transform: translateY(16px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Loading Spinner */
.spinner {
    display: inline-block;
    width: 18px;
    height: 18px;
    border: 2px solid var(--border-default);
    border-radius: var(--radius-full);
    border-top-color: var(--accent-primary);
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Utility Classes */
.hidden {
    display: none !important;
}

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

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

.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }

/* Responsive */
@media (min-width: 768px) {
    .container {
        padding: 48px 24px;
    }

    h1 {
        font-size: 2.25rem;
    }

    .card {
        padding: 32px;
    }

    .score-item:first-child {
        margin: 0 -32px;
        padding: 16px 32px;
    }
}

/* Focus visible for accessibility */
:focus-visible {
    outline: 2px solid var(--accent-primary);
    outline-offset: 2px;
}

/* Selection color */
::selection {
    background: var(--accent-primary);
    color: var(--text-inverse);
}

/* ── Link Preview Card ────────────────────────────────────── */

.share-card h3 {
    margin-bottom: 4px;
}

.link-preview {
    display: flex;
    border-radius: var(--radius-md);
    overflow: hidden;
    background: var(--bg-elevated);
    border: 1px solid var(--border-default);
    margin-top: 16px;
    transition: border-color var(--transition-base);
}

.link-preview:hover {
    border-color: var(--accent-primary);
}

.link-preview-accent {
    width: 4px;
    flex-shrink: 0;
    background: var(--accent-primary);
    border-radius: var(--radius-sm) 0 0 var(--radius-sm);
}

.link-preview-body {
    padding: 14px 16px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
}

.link-preview-site {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 2px;
}

.link-preview-icon {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

.link-preview-sitename {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--accent-primary);
    text-transform: uppercase;
    letter-spacing: 0.07em;
}

.link-preview-title {
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--text-primary);
    line-height: 1.3;
}

.link-preview-code {
    font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace;
    color: var(--accent-light);
    letter-spacing: 0.1em;
}

.link-preview-description {
    font-size: 0.8125rem;
    color: var(--text-secondary);
    line-height: 1.4;
}

.link-preview-url {
    font-size: 0.6875rem;
    color: var(--text-tertiary);
    font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-top: 4px;
}

/* Scrollbar styling */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-primary);
}

::-webkit-scrollbar-thumb {
    background: var(--border-strong);
    border-radius: var(--radius-full);
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-tertiary);
}
