/* ========================================
   SKULL GAME - Styles
   Theme: Dark / Gold / Red
   ======================================== */

:root {
    --bg: #1a1a2e;
    --bg-card: #16213e;
    --bg-input: #0f1627;
    --primary: #c9a227;
    --primary-dark: #a68521;
    --accent: #e74c3c;
    --accent-dark: #c0392b;
    --success: #2ecc71;
    --text: #e0d5c1;
    --text-secondary: #8b8178;
    --border: #2d2d44;
    --card-back: #2d2d44;
    --flower: #e91e63;
    --skull: #9c27b0;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Prompt', sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    overflow-x: hidden;
}

.container {
    max-width: 600px;
    margin: 0 auto;
    padding: 20px;
    min-height: 100vh;
}

/* ========================================
   SECTIONS
   ======================================== */

.section {
    display: none;
    flex-direction: column;
    align-items: center;
    animation: fadeIn 0.3s ease;
}

.section.active {
    display: flex;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ========================================
   BACK BUTTON
   ======================================== */

.back-home {
    align-self: flex-start;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.9rem;
    margin-bottom: 10px;
    transition: color 0.2s;
}

.back-home:hover { color: var(--primary); }

/* ========================================
   LOGO
   ======================================== */

.logo {
    text-align: center;
    margin-bottom: 2rem;
}

.logo-icon {
    font-size: 4rem;
    display: block;
    margin-bottom: 5px;
    animation: float 3s ease-in-out infinite;
}

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

.logo h1 {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--primary);
    letter-spacing: 0.3rem;
    text-shadow: 0 0 20px rgba(201, 162, 39, 0.3);
}

.tagline {
    color: var(--text-secondary);
    font-size: 0.95rem;
    margin-top: 5px;
}

/* ========================================
   CARD (Container)
   ======================================== */

.card {
    background: var(--bg-card);
    border-radius: 16px;
    padding: 24px;
    width: 100%;
    max-width: 500px;
    border: 1px solid var(--border);
}

/* ========================================
   INPUT
   ======================================== */

.input-group {
    margin-bottom: 16px;
}

.input-group label {
    display: block;
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.input-group input {
    width: 100%;
    padding: 12px 16px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--bg-input);
    color: var(--text);
    font-family: 'Prompt', sans-serif;
    font-size: 1rem;
    outline: none;
    transition: border-color 0.2s;
}

.input-group input:focus {
    border-color: var(--primary);
}

/* ========================================
   BUTTONS
   ======================================== */

.button-group {
    display: flex;
    gap: 10px;
    margin-bottom: 16px;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 20px;
    border: none;
    border-radius: 10px;
    font-family: 'Prompt', sans-serif;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    flex: 1;
}

.btn:active { transform: scale(0.97); }

.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: #1a1a2e;
}

.btn-primary:hover { filter: brightness(1.1); }

.btn-secondary {
    background: var(--border);
    color: var(--text);
}

.btn-secondary:hover { background: #3d3d54; }

.btn-accent {
    background: linear-gradient(135deg, var(--accent), var(--accent-dark));
    color: white;
}

.btn-accent:hover { filter: brightness(1.1); }

.btn-danger {
    background: transparent;
    color: var(--accent);
    border: 1px solid var(--accent);
}

.btn-danger:hover { background: rgba(231, 76, 60, 0.1); }

.btn-large { padding: 16px 32px; font-size: 1.2rem; }
.btn-small { padding: 8px 16px; font-size: 0.85rem; flex: none; }

.btn-icon { font-size: 1.2em; }

.hidden { display: none !important; }

/* ========================================
   JOIN ROOM
   ======================================== */

.join-room {
    margin-top: 10px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}

/* ========================================
   ROOM LIST
   ======================================== */

.room-lobby { width: 100%; }

.room-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.room-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--bg-card);
    padding: 12px 16px;
    border-radius: 10px;
    border: 1px solid var(--border);
}

.room-info { display: flex; flex-direction: column; gap: 2px; }
.room-name { font-weight: 500; }
.room-host { font-size: 0.8rem; color: var(--text-secondary); }
.room-meta { display: flex; align-items: center; gap: 10px; font-size: 0.85rem; color: var(--text-secondary); }
.no-rooms { text-align: center; color: var(--text-secondary); padding: 20px; }
.loading-spinner { text-align: center; color: var(--text-secondary); padding: 20px; }

/* ========================================
   RULES
   ======================================== */

.rules-preview {
    margin-top: 2rem;
    width: 100%;
    max-width: 500px;
}

.rules-preview h3 {
    text-align: center;
    margin-bottom: 1rem;
    color: var(--primary);
}

.rules-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.rule-item {
    background: var(--bg-card);
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 0.9rem;
    border-left: 3px solid var(--primary);
}

/* ========================================
   LOBBY
   ======================================== */

.room-header {
    text-align: center;
    margin-bottom: 1.5rem;
}

.room-code-display {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    background: var(--bg-card);
    padding: 10px 20px;
    border-radius: 12px;
    border: 1px solid var(--primary);
}

.room-code-display .label {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.room-code-display .code {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary);
    letter-spacing: 0.3rem;
}

.btn-copy {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.2rem;
    padding: 4px;
}

.player-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 16px 0;
}

.player-item {
    display: flex;
    align-items: center;
    gap: 6px;
    background: var(--bg-input);
    padding: 8px 14px;
    border-radius: 20px;
    font-size: 0.9rem;
}

.player-item.me {
    border: 1px solid var(--primary);
}

.badge {
    background: var(--primary);
    color: var(--bg);
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 0.7rem;
    font-weight: 600;
}

.lobby-actions {
    text-align: center;
    margin-top: 16px;
}

.waiting-text {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.min-players-text {
    color: var(--text-secondary);
    font-size: 0.8rem;
    margin-top: 8px;
}

/* ========================================
   GAME HEADER
   ======================================== */

.game-header {
    width: 100%;
    max-width: 500px;
    text-align: center;
    margin-bottom: 1rem;
}

.phase-indicator {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-size: 1.1rem;
    font-weight: 600;
}

.phase-icon { font-size: 1.5rem; }

#roundCounter {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-left: 8px;
}

.turn-indicator {
    margin-top: 8px;
    padding: 6px 16px;
    border-radius: 20px;
    font-size: 0.9rem;
    background: var(--bg-card);
    display: inline-block;
    color: var(--text-secondary);
}

.turn-indicator.my-turn {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: var(--bg);
    font-weight: 600;
    animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(201, 162, 39, 0.4); }
    50% { box-shadow: 0 0 0 10px rgba(201, 162, 39, 0); }
}

/* ========================================
   SCOREBOARD
   ======================================== */

.scoreboard {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
    margin-bottom: 1rem;
    width: 100%;
    max-width: 500px;
}

.score-item {
    display: flex;
    align-items: center;
    gap: 6px;
    background: var(--bg-card);
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.85rem;
    border: 1px solid var(--border);
}

.score-item.me { border-color: var(--primary); }
.score-item.current-turn { background: rgba(201, 162, 39, 0.15); }
.score-item.eliminated { opacity: 0.5; }
.score-stars { font-size: 0.9rem; }
.eliminated-badge {
    font-size: 0.7rem;
    color: var(--accent);
    background: rgba(231, 76, 60, 0.2);
    padding: 1px 6px;
    border-radius: 8px;
}

/* ========================================
   PLAYER BOARDS (Placed cards)
   ======================================== */

.player-boards {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    justify-content: center;
    margin-bottom: 1rem;
    width: 100%;
    max-width: 500px;
}

.player-board {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 12px;
    min-width: 140px;
    flex: 1;
    max-width: 230px;
}

.player-board.me { border-color: var(--primary); }
.player-board.active-turn { box-shadow: 0 0 12px rgba(201, 162, 39, 0.3); }

.board-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.board-name {
    font-weight: 600;
    font-size: 0.85rem;
}

.board-info {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.board-cards {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.placed-card {
    width: 40px;
    height: 56px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    font-weight: 700;
}

.placed-card.face-down {
    background: var(--card-back);
    border: 1px solid var(--border);
    color: var(--text-secondary);
}

.placed-card.own.flower {
    background: linear-gradient(135deg, #e91e63, #c2185b);
    color: white;
    border: 1px solid #e91e63;
}

.placed-card.own.skull {
    background: linear-gradient(135deg, #9c27b0, #7b1fa2);
    color: white;
    border: 1px solid #9c27b0;
}

.no-cards {
    font-size: 0.75rem;
    color: var(--text-secondary);
    padding: 8px 0;
}

/* ========================================
   ACTION PANELS
   ======================================== */

.action-panel {
    width: 100%;
    max-width: 500px;
    background: var(--bg-card);
    border-radius: 12px;
    padding: 20px;
    border: 1px solid var(--border);
    margin-bottom: 1rem;
}

.action-panel h3 {
    text-align: center;
    margin-bottom: 12px;
    color: var(--primary);
}

/* Hand Cards */
.hand-cards {
    display: flex;
    gap: 12px;
    justify-content: center;
}

.hand-card {
    width: 100px;
    height: 140px;
    border-radius: 12px;
    border: 2px solid var(--border);
    background: var(--bg-input);
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.2s;
    font-family: 'Prompt', sans-serif;
}

.hand-card:hover { transform: translateY(-5px); }
.hand-card:active { transform: scale(0.95); }

.hand-card.flower {
    border-color: var(--flower);
    color: var(--flower);
}

.hand-card.flower:hover {
    background: rgba(233, 30, 99, 0.1);
    box-shadow: 0 0 15px rgba(233, 30, 99, 0.3);
}

.hand-card.skull {
    border-color: var(--skull);
    color: var(--skull);
}

.hand-card.skull:hover {
    background: rgba(156, 39, 176, 0.1);
    box-shadow: 0 0 15px rgba(156, 39, 176, 0.3);
}

.card-emoji { font-size: 2.5rem; }
.card-label { font-size: 0.85rem; font-weight: 500; }

/* Bid Panel */
.bid-options {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
    margin-bottom: 12px;
}

.bid-btn {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: 2px solid var(--primary);
    background: transparent;
    color: var(--primary);
    font-family: 'Prompt', sans-serif;
    font-size: 1.2rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
}

.bid-btn:hover {
    background: var(--primary);
    color: var(--bg);
}

.bid-actions {
    display: flex;
    justify-content: center;
}

/* Place or Bid choice */
.choice-buttons {
    display: flex;
    gap: 12px;
}

/* Reveal Panel */
.reveal-hint {
    text-align: center;
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 12px;
}

.reveal-targets {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.reveal-target-btn {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 10px;
    color: var(--text);
    font-family: 'Prompt', sans-serif;
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.2s;
}

.reveal-target-btn:hover:not(.disabled) {
    border-color: var(--primary);
    background: rgba(201, 162, 39, 0.1);
}

.reveal-target-btn.own { border-color: var(--primary); }
.reveal-target-btn.disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.target-cards {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

/* Waiting Panel */
.waiting-panel {
    width: 100%;
    max-width: 500px;
    text-align: center;
    padding: 20px;
    background: var(--bg-card);
    border-radius: 12px;
    border: 1px solid var(--border);
    margin-bottom: 1rem;
}

.waiting-panel p {
    color: var(--text-secondary);
    font-size: 1rem;
}

/* ========================================
   REVEAL OVERLAY
   ======================================== */

.reveal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    opacity: 0;
    transition: opacity 0.3s;
}

.reveal-overlay.show { opacity: 1; }

.reveal-content {
    text-align: center;
}

.reveal-card-anim {
    width: 120px;
    height: 168px;
    margin: 0 auto 20px;
    perspective: 600px;
}

.reveal-card-inner {
    width: 100%;
    height: 100%;
    position: relative;
    transform-style: preserve-3d;
    transition: transform 0.6s;
}

.reveal-card-anim.flip .reveal-card-inner {
    transform: rotateY(180deg);
}

.reveal-card-back,
.reveal-card-front {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 3rem;
}

.reveal-card-back {
    background: var(--card-back);
    border: 2px solid var(--border);
}

.reveal-card-front {
    background: var(--bg-card);
    border: 2px solid var(--primary);
    transform: rotateY(180deg);
}

.reveal-card-anim.skull .reveal-card-front {
    border-color: var(--accent);
    background: linear-gradient(135deg, #2d1b30, #1a1a2e);
    animation: skullShake 0.5s ease 0.6s;
}

.reveal-card-anim.flower .reveal-card-front {
    border-color: var(--flower);
    background: linear-gradient(135deg, #2d1b24, #1a1a2e);
}

@keyframes skullShake {
    0%, 100% { transform: rotateY(180deg) translateX(0); }
    25% { transform: rotateY(180deg) translateX(-10px); }
    75% { transform: rotateY(180deg) translateX(10px); }
}

.reveal-player-name {
    color: var(--text);
    font-size: 1.1rem;
    font-weight: 500;
}

/* ========================================
   ROUND RESULT OVERLAY
   ======================================== */

.round-result-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 101;
    animation: fadeIn 0.3s;
}

.round-result-content {
    text-align: center;
    padding: 40px;
}

.round-result-icon {
    font-size: 4rem;
    margin-bottom: 16px;
    animation: bounceIn 0.5s;
}

@keyframes bounceIn {
    0% { transform: scale(0); }
    50% { transform: scale(1.3); }
    100% { transform: scale(1); }
}

.round-result-title {
    font-size: 1.8rem;
    font-weight: 700;
    margin-bottom: 8px;
}

.skull-found .round-result-title { color: var(--accent); }
.success .round-result-title { color: var(--primary); }

.round-result-message {
    font-size: 1rem;
    color: var(--text-secondary);
}

/* ========================================
   RESULTS
   ======================================== */

.result-content {
    width: 100%;
    max-width: 500px;
    text-align: center;
}

.winner-announcement {
    margin-bottom: 2rem;
}

.winner-icon {
    font-size: 4rem;
    margin-bottom: 10px;
    animation: float 2s ease-in-out infinite;
}

.winner-announcement h2 {
    font-size: 2rem;
    color: var(--primary);
}

.winner-reason {
    color: var(--text-secondary);
    margin-top: 5px;
}

.final-scores {
    background: var(--bg-card);
    border-radius: 12px;
    padding: 20px;
    border: 1px solid var(--border);
    margin-bottom: 20px;
}

.final-scores h3 {
    margin-bottom: 12px;
    color: var(--primary);
}

.final-score-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: 8px;
    margin-bottom: 4px;
}

.final-score-item.winner {
    background: rgba(201, 162, 39, 0.15);
    border: 1px solid var(--primary);
}

.final-score-item.eliminated { opacity: 0.5; }
.final-score-item .rank { font-weight: 700; color: var(--primary); }
.final-score-item .name { flex: 1; }
.final-score-item .score { color: var(--text-secondary); }

/* ========================================
   CHAT WIDGET
   ======================================== */

.chat-widget {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 50;
}

.chat-toggle-btn {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: var(--primary);
    border: none;
    font-size: 1.3rem;
    cursor: pointer;
    position: relative;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.unread-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: var(--accent);
    color: white;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    font-size: 0.7rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chat-container {
    position: absolute;
    bottom: 60px;
    right: 0;
    width: 300px;
    max-height: 400px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.chat-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 14px;
    background: var(--bg-input);
    font-weight: 500;
    font-size: 0.9rem;
}

.chat-close-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.2rem;
    cursor: pointer;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 10px;
    min-height: 200px;
    max-height: 280px;
}

.chat-msg {
    margin-bottom: 6px;
}

.chat-msg .chat-name {
    font-size: 0.75rem;
    color: var(--primary);
    font-weight: 600;
}

.chat-msg.mine .chat-name { color: var(--success); }

.chat-msg .chat-text {
    display: block;
    font-size: 0.85rem;
    color: var(--text);
}

.chat-input-area {
    display: flex;
    padding: 8px;
    gap: 6px;
    border-top: 1px solid var(--border);
}

.chat-input-area input {
    flex: 1;
    padding: 8px 12px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--bg-input);
    color: var(--text);
    font-family: 'Prompt', sans-serif;
    font-size: 0.85rem;
    outline: none;
}

.chat-input-area button {
    padding: 8px 14px;
    border-radius: 8px;
    border: none;
    background: var(--primary);
    color: var(--bg);
    font-family: 'Prompt', sans-serif;
    font-weight: 600;
    cursor: pointer;
}

/* ========================================
   RESPONSIVE
   ======================================== */

@media (max-width: 480px) {
    .container { padding: 12px; }
    .logo h1 { font-size: 2rem; }
    .logo-icon { font-size: 3rem; }

    .hand-card {
        width: 80px;
        height: 112px;
    }

    .card-emoji { font-size: 2rem; }

    .player-board { min-width: 120px; }
    .placed-card { width: 34px; height: 48px; font-size: 1rem; }

    .bid-btn { width: 42px; height: 42px; font-size: 1rem; }

    .chat-container {
        width: 260px;
        right: -10px;
    }

    .choice-buttons {
        flex-direction: column;
    }

    .reveal-card-anim { width: 100px; height: 140px; }
}
