/* ═══════════════════════════════════════════
   Card Game Engine — Common Styles
   Dark premium card table aesthetic
   ═══════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700;800&family=JetBrains+Mono:wght@400;600&display=swap');

:root {
    /* Core palette */
    --bg-deep: #0a0a0f;
    --bg-surface: #12121a;
    --bg-card: #1a1a2e;
    --bg-elevated: #222240;
    --bg-felt: #0d1f0d;

    /* Accent colors */
    --red: #e94560;
    --red-glow: #e9456040;
    --gold: #e2b714;
    --gold-glow: #e2b71440;
    --blue: #00d2ff;
    --blue-glow: #00d2ff40;
    --green: #00e676;
    --green-glow: #00e67640;
    --purple: #a855f7;

    /* Text */
    --text-primary: #f0f0f5;
    --text-secondary: #8888aa;
    --text-muted: #555570;
    --text-accent: var(--gold);

    /* Borders */
    --border-subtle: #ffffff08;
    --border-card: #ffffff12;

    /* Fonts */
    --font-display: 'Outfit', sans-serif;
    --font-mono: 'JetBrains Mono', monospace;

    /* Sizing */
    --card-width: 100px;
    --card-height: 140px;
    --card-radius: 10px;
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;

    /* Transitions */
    --ease-out-back: cubic-bezier(0.34, 1.56, 0.64, 1);
    --ease-smooth: cubic-bezier(0.4, 0, 0.2, 1);
}

/* ─── Reset ─── */

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

html, body {
    font-family: var(--font-display);
    background: var(--bg-deep);
    color: var(--text-primary);
    -webkit-font-smoothing: antialiased;
    overflow: hidden;
    height: 100%;
    width: 100%;
}

/* ─── Cards ─── */

.card {
    position: relative;
    width: var(--card-width);
    height: var(--card-height);
    border-radius: var(--card-radius);
    border: 2px solid var(--card-border, var(--border-card));
    background: var(--bg-card);
    cursor: default;
    user-select: none;
    flex-shrink: 0;
    transform-style: preserve-3d;
    perspective: 600px;
}

.card-small {
    --card-width: 60px;
    --card-height: 84px;
    --card-radius: 6px;
}

.card-normal {
    --card-width: 100px;
    --card-height: 140px;
    --card-radius: 10px;
}

.card-large {
    --card-width: 140px;
    --card-height: 196px;
    --card-radius: 14px;
}

.card-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    padding: 8px;
    gap: 4px;
}

.card-icon {
    font-size: calc(var(--card-width) * 0.35);
    line-height: 1;
}

.card-name {
    font-weight: 700;
    font-size: calc(var(--card-width) * 0.13);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--card-accent, var(--text-primary));
    text-align: center;
}

.card-power {
    font-size: calc(var(--card-width) * 0.1);
    color: var(--text-secondary);
    text-transform: capitalize;
    font-weight: 300;
}

/* Card back */
.card-back {
    border-color: #333355;
    background: linear-gradient(135deg, #16162a, #1f1f3a);
}

.card-back-inner {
    background: repeating-conic-gradient(#ffffff06 0% 25%, transparent 0% 50%) 50% / 20px 20px;
    border-radius: calc(var(--card-radius) - 2px);
}

.card-back-diamond {
    font-size: calc(var(--card-width) * 0.3);
    color: #334;
    opacity: 0.5;
}

/* Selectable / interactive cards */
.card-selectable {
    cursor: pointer;
    transition: transform 200ms var(--ease-out-back), box-shadow 200ms ease;
}

.card-selectable:hover {
    transform: translateY(-8px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.4), 0 0 15px var(--card-accent, var(--red-glow));
}

.card-selectable:active {
    transform: translateY(-4px) scale(0.97);
}

.card-selected {
    transform: translateY(-12px);
    box-shadow: 0 0 20px var(--card-accent, var(--red)), 0 0 40px var(--card-accent, var(--red-glow));
    border-color: var(--card-accent, var(--red));
}

.card-revealed {
    animation: revealGlow 600ms ease-out;
}

/* Card stack */
.card-stack {
    position: relative;
    display: inline-block;
}

.stack-count {
    position: absolute;
    bottom: -8px;
    right: -8px;
    background: var(--bg-elevated);
    color: var(--text-secondary);
    font-weight: 700;
    font-size: 12px;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    border: 2px solid var(--border-card);
    z-index: 10;
    font-family: var(--font-mono);
}

/* ─── Buttons ─── */

.btn {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 14px;
    padding: 12px 28px;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 200ms var(--ease-smooth);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.btn-primary {
    background: var(--red);
    color: white;
    box-shadow: 0 4px 15px var(--red-glow);
}

.btn-primary:hover {
    background: #ff5a75;
    transform: translateY(-2px);
    box-shadow: 0 6px 20px var(--red-glow);
}

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

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

.btn-secondary:hover {
    background: #2a2a4a;
    border-color: var(--text-muted);
}

.btn-gold {
    background: linear-gradient(135deg, var(--gold), #c99a10);
    color: #1a1a2e;
    box-shadow: 0 4px 15px var(--gold-glow);
}

.btn-gold:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px var(--gold-glow);
}

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

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

.btn-large {
    padding: 16px 40px;
    font-size: 16px;
    border-radius: var(--radius-lg);
}

.btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none !important;
}

/* ─── Inputs ─── */

.input {
    font-family: var(--font-display);
    font-size: 16px;
    padding: 12px 16px;
    background: var(--bg-surface);
    border: 2px solid var(--border-card);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    outline: none;
    transition: border-color 200ms ease;
    width: 100%;
}

.input:focus {
    border-color: var(--red);
}

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

.input-code {
    text-align: center;
    font-family: var(--font-mono);
    font-size: 32px;
    font-weight: 700;
    letter-spacing: 0.3em;
    text-transform: uppercase;
    padding: 16px;
    max-width: 240px;
}

/* ─── Room Code Display ─── */

.room-code {
    font-family: var(--font-mono);
    font-size: 48px;
    font-weight: 700;
    letter-spacing: 0.2em;
    color: var(--gold);
    text-shadow: 0 0 20px var(--gold-glow);
}

.room-code-label {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.15em;
    color: var(--text-muted);
    margin-bottom: 4px;
}

/* ─── Player List ─── */

.player-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: 100%;
    max-width: 400px;
}

.player-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    background: var(--bg-surface);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-card);
}

.player-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 14px;
    flex-shrink: 0;
}

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

.player-badge {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    padding: 2px 8px;
    border-radius: 4px;
    background: var(--red);
    color: white;
    font-weight: 600;
}

/* ─── Status / Connection ─── */

.connection-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--green);
    box-shadow: 0 0 8px var(--green-glow);
}

.connection-dot.disconnected {
    background: var(--red);
    box-shadow: 0 0 8px var(--red-glow);
}

.status-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: var(--text-muted);
}

/* ─── Announcement Banner ─── */

.announcement {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 28px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--gold);
    text-shadow: 0 0 30px var(--gold-glow), 0 2px 10px rgba(0,0,0,0.5);
    z-index: 100;
    pointer-events: none;
    animation: announcePop 2s ease-out forwards;
}

/* ─── Timer ─── */

.timer {
    font-family: var(--font-mono);
    font-size: 24px;
    font-weight: 700;
    color: var(--text-secondary);
}

.timer.urgent {
    color: var(--red);
    animation: timerPulse 500ms infinite;
}

/* ─── Animations ─── */

@keyframes revealGlow {
    0% { box-shadow: 0 0 0px transparent; }
    50% { box-shadow: 0 0 40px var(--gold), 0 0 80px var(--gold-glow); }
    100% { box-shadow: 0 0 10px var(--gold-glow); }
}

@keyframes announcePop {
    0% { opacity: 0; transform: translate(-50%, -50%) scale(0.5); }
    15% { opacity: 1; transform: translate(-50%, -50%) scale(1.1); }
    30% { transform: translate(-50%, -50%) scale(1); }
    80% { opacity: 1; }
    100% { opacity: 0; transform: translate(-50%, -50%) scale(1) translateY(-20px); }
}

@keyframes timerPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.anim-shake {
    animation: shake 500ms ease-in-out;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    10%, 50%, 90% { transform: translateX(-4px); }
    30%, 70% { transform: translateX(4px); }
}

.anim-dramatic-reveal {
    animation: dramaticReveal 1000ms ease-out;
}

@keyframes dramaticReveal {
    0% { transform: scale(1) rotateY(0); filter: brightness(1); }
    30% { transform: scale(1.2) rotateY(90deg); filter: brightness(2); }
    60% { transform: scale(1.3) rotateY(180deg); filter: brightness(1.5); }
    100% { transform: scale(1) rotateY(360deg); filter: brightness(1); }
}

/* Fade in for page loads */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.fade-in {
    animation: fadeIn 400ms var(--ease-smooth) both;
}

.fade-in-delay-1 { animation-delay: 100ms; }
.fade-in-delay-2 { animation-delay: 200ms; }
.fade-in-delay-3 { animation-delay: 300ms; }
.fade-in-delay-4 { animation-delay: 400ms; }

/* ─── Utility ─── */

.text-gold { color: var(--gold); }
.text-red { color: var(--red); }
.text-blue { color: var(--blue); }
.text-green { color: var(--green); }
.text-muted { color: var(--text-muted); }
.text-secondary { color: var(--text-secondary); }
.text-center { text-align: center; }
.mono { font-family: var(--font-mono); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); }
