/* =============================================
   RULETA RUSA DE RETOS - Styles
   Mobile-first, dark theme
   ============================================= */

/* CSS Variables */
:root {
    --bg-dark: #1a1a2e;
    --bg-card: #16213e;
    --bg-surface: #0f3460;
    --primary: #e94560;
    --primary-dark: #c73e54;
    --secondary: #0f3460;
    --accent: #ffd700;
    --safe: #4ade80;
    --safe-dark: #22c55e;
    --danger: #ef4444;
    --danger-dark: #dc2626;
    --text: #ffffff;
    --text-muted: #94a3b8;
    --suave: #4ade80;
    --picante: #fb923c;
    --extremo: #ef4444;
    --transition-speed: 0.3s;
    --border-radius: 12px;
}

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

/* Base */
html {
    font-size: 16px;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: var(--bg-dark);
    color: var(--text);
    min-height: 100vh;
    min-height: 100dvh;
    overflow-x: hidden;
}

/* Screen Management */
.screen {
    display: none;
    flex-direction: column;
    min-height: 100vh;
    min-height: 100dvh;
    padding: 20px;
    padding-bottom: max(20px, env(safe-area-inset-bottom));
}

.screen.active {
    display: flex;
}

/* =============================================
   BUTTONS
   ============================================= */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 4px;
    padding: 16px 24px;
    font-size: 1rem;
    font-weight: 600;
    border: none;
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: all var(--transition-speed);
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.btn:active {
    transform: scale(0.98);
}

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

.btn-large {
    min-height: 56px;
    font-size: 1.2rem;
    width: 100%;
}

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

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

.btn-secondary {
    background: var(--bg-surface);
    color: var(--text);
}

.btn-secondary:hover:not(:disabled) {
    background: var(--secondary);
}

.btn-success {
    background: var(--safe);
    color: var(--bg-dark);
}

.btn-success:hover:not(:disabled) {
    background: var(--safe-dark);
}

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

.btn-danger:hover:not(:disabled) {
    background: var(--danger-dark);
}

.btn-outline {
    background: transparent;
    border: 2px solid var(--text-muted);
    color: var(--text);
}

.btn-outline:hover:not(:disabled) {
    border-color: var(--text);
}

.btn-points {
    font-size: 0.75rem;
    font-weight: 400;
    opacity: 0.8;
}

.btn-points-negative {
    color: var(--danger);
}

/* Icon Buttons */
.btn-back {
    position: absolute;
    top: 20px;
    left: 20px;
    width: 44px;
    height: 44px;
    background: var(--bg-surface);
    border: none;
    border-radius: 50%;
    font-size: 1.5rem;
    color: var(--text);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-sound, .btn-help {
    position: absolute;
    width: 44px;
    height: 44px;
    background: var(--bg-surface);
    border: none;
    border-radius: 50%;
    font-size: 1.2rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-sound {
    bottom: 20px;
    left: 20px;
}

.btn-help {
    bottom: 20px;
    right: 20px;
    color: var(--text);
    font-weight: bold;
}

.btn-sound .sound-off {
    display: none;
}

body.sound-off .btn-sound .sound-on {
    display: none;
}

body.sound-off .btn-sound .sound-off {
    display: block;
}

/* =============================================
   SCREEN: HOME
   ============================================= */

.header {
    text-align: center;
    margin-bottom: 30px;
}

.title {
    font-size: 1.8rem;
    font-weight: 800;
    letter-spacing: 2px;
    margin-bottom: 5px;
}

.skull {
    display: inline-block;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

.subtitle {
    font-size: 1.2rem;
    color: var(--primary);
    font-weight: 600;
    letter-spacing: 4px;
}

.title-small {
    font-size: 1.5rem;
    margin-bottom: 20px;
}

/* Players Section */
.players-section {
    flex: 1;
    margin-bottom: 20px;
}

.players-section h2 {
    font-size: 0.9rem;
    color: var(--text-muted);
    letter-spacing: 2px;
    margin-bottom: 12px;
}

.add-player-form {
    display: flex;
    gap: 10px;
    margin-bottom: 16px;
}

.add-player-form input {
    flex: 1;
    padding: 14px 16px;
    font-size: 1rem;
    background: var(--bg-card);
    border: 2px solid var(--bg-surface);
    border-radius: var(--border-radius);
    color: var(--text);
    outline: none;
    transition: border-color var(--transition-speed);
}

.add-player-form input:focus {
    border-color: var(--primary);
}

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

.btn-add {
    width: 48px;
    height: 48px;
    background: var(--primary);
    border: none;
    border-radius: var(--border-radius);
    font-size: 1.5rem;
    color: var(--text);
    cursor: pointer;
    flex-shrink: 0;
}

.players-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 250px;
    overflow-y: auto;
}

.player-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: var(--bg-card);
    border-radius: var(--border-radius);
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(-20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.player-item .player-name {
    font-weight: 500;
}

.player-item .btn-remove {
    width: 32px;
    height: 32px;
    background: var(--danger);
    border: none;
    border-radius: 50%;
    color: var(--text);
    font-size: 1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.players-count {
    text-align: center;
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-top: 12px;
}

/* =============================================
   SCREEN: CATEGORY
   ============================================= */

#screen-category {
    padding-top: 70px;
}

.category-options {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.category-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 24px 20px;
    background: var(--bg-card);
    border: 2px solid transparent;
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: all var(--transition-speed);
}

.category-btn:hover {
    transform: translateY(-2px);
}

.category-btn[data-category="suave"]:hover {
    border-color: var(--suave);
}

.category-btn[data-category="picante"]:hover {
    border-color: var(--picante);
}

.category-btn[data-category="extremo"]:hover {
    border-color: var(--extremo);
}

.category-icon {
    font-size: 2.5rem;
}

.category-name {
    font-size: 1.2rem;
    font-weight: 700;
    letter-spacing: 2px;
}

.category-btn[data-category="suave"] .category-name {
    color: var(--suave);
}

.category-btn[data-category="picante"] .category-name {
    color: var(--picante);
}

.category-btn[data-category="extremo"] .category-name {
    color: var(--extremo);
}

.category-desc {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.age-warning {
    text-align: center;
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-top: 20px;
}

/* =============================================
   SCREEN: PLAYING
   ============================================= */

.game-header {
    text-align: center;
    margin-bottom: 20px;
}

.round-info {
    font-size: 1rem;
    color: var(--text-muted);
    margin-bottom: 10px;
}

.category-badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.8rem;
    margin-left: 8px;
}

.category-badge.suave {
    background: var(--suave);
    color: var(--bg-dark);
}

.category-badge.picante {
    background: var(--picante);
    color: var(--bg-dark);
}

.category-badge.extremo {
    background: var(--extremo);
    color: var(--text);
}

.scores-display {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 12px;
    font-size: 0.9rem;
}

.score-item {
    background: var(--bg-card);
    padding: 6px 12px;
    border-radius: 20px;
}

.score-item.current {
    background: var(--primary);
}

/* Cylinder */
.cylinder-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
}

.cylinder {
    width: 180px;
    height: 180px;
    position: relative;
}

.cylinder-inner {
    width: 100%;
    height: 100%;
    background: linear-gradient(145deg, #2a2a4e, #1a1a2e);
    border-radius: 50%;
    border: 4px solid var(--bg-surface);
    position: relative;
    box-shadow:
        inset 0 0 30px rgba(0,0,0,0.5),
        0 10px 30px rgba(0,0,0,0.3);
}

.chamber {
    position: absolute;
    width: 30px;
    height: 30px;
    background: radial-gradient(circle, #333 0%, #1a1a1a 100%);
    border-radius: 50%;
    border: 2px solid #444;
    transform-origin: center;
}

/* Position chambers in a circle */
.chamber[data-pos="1"] { top: 10px; left: 50%; transform: translateX(-50%); }
.chamber[data-pos="2"] { top: 30px; right: 15px; }
.chamber[data-pos="3"] { bottom: 30px; right: 15px; }
.chamber[data-pos="4"] { bottom: 10px; left: 50%; transform: translateX(-50%); }
.chamber[data-pos="5"] { bottom: 30px; left: 15px; }
.chamber[data-pos="6"] { top: 30px; left: 15px; }

.chamber.loaded {
    background: radial-gradient(circle, #e94560 0%, #8b0000 100%);
    box-shadow: 0 0 10px rgba(233, 69, 96, 0.5);
}

.gun-barrel {
    font-size: 3rem;
    margin-top: 20px;
}

/* Turn Info */
.turn-info {
    text-align: center;
    margin: 20px 0;
}

.turn-label {
    font-size: 0.9rem;
    color: var(--text-muted);
    letter-spacing: 2px;
}

.current-player-name {
    font-size: 1.8rem;
    font-weight: 800;
    color: var(--accent);
    animation: glow 2s infinite;
}

@keyframes glow {
    0%, 100% { text-shadow: 0 0 10px rgba(255, 215, 0, 0.5); }
    50% { text-shadow: 0 0 20px rgba(255, 215, 0, 0.8); }
}

.btn-trigger {
    position: relative;
    overflow: hidden;
}

.btn-trigger::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    background: rgba(255,255,255,0.2);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    transition: width 0.3s, height 0.3s;
}

.btn-trigger:active::after {
    width: 300px;
    height: 300px;
}

.chance-warning {
    text-align: center;
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-top: 16px;
}

/* =============================================
   SCREEN: SPINNING
   ============================================= */

.spinning-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.cylinder-spinning .cylinder-inner {
    animation: spin 0.2s linear infinite;
}

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

.spinning-text {
    margin-top: 40px;
    font-size: 1.2rem;
    color: var(--text-muted);
}

.click-sound {
    display: inline-block;
    animation: clickFade 0.6s ease infinite;
}

.click-sound:nth-child(2) {
    animation-delay: 0.2s;
}

.click-sound:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes clickFade {
    0%, 100% { opacity: 0.3; }
    50% { opacity: 1; }
}

/* =============================================
   SCREEN: SAFE / BANG
   ============================================= */

#screen-safe, #screen-bang {
    justify-content: center;
    align-items: center;
}

.result-container {
    text-align: center;
    padding: 40px 20px;
}

.result-icon {
    font-size: 5rem;
    margin-bottom: 20px;
}

.result-title {
    font-size: 2.5rem;
    font-weight: 800;
    margin-bottom: 10px;
}

.result-container.safe .result-title {
    color: var(--safe);
}

.result-title-bang {
    color: var(--danger);
    animation: shake 0.5s ease;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    20%, 60% { transform: translateX(-10px); }
    40%, 80% { transform: translateX(10px); }
}

.bang-icon {
    animation: explode 0.5s ease;
}

@keyframes explode {
    0% { transform: scale(0); }
    50% { transform: scale(1.3); }
    100% { transform: scale(1); }
}

.result-subtitle {
    font-size: 1.1rem;
    color: var(--text-muted);
}

.points-earned {
    margin-top: 20px;
    font-size: 1.5rem;
    font-weight: 700;
}

.points-positive {
    color: var(--safe);
}

.points-negative {
    color: var(--danger);
}

#screen-safe .btn {
    position: absolute;
    bottom: 40px;
    left: 20px;
    right: 20px;
}

/* =============================================
   SCREEN: CHALLENGE
   ============================================= */

#screen-challenge {
    justify-content: space-between;
}

.challenge-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.challenge-header {
    text-align: center;
    margin-bottom: 20px;
}

.challenge-player {
    display: block;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--accent);
    margin-bottom: 8px;
}

.challenge-label {
    font-size: 0.9rem;
    color: var(--text-muted);
    letter-spacing: 2px;
}

.challenge-card {
    background: var(--bg-card);
    border-radius: var(--border-radius);
    padding: 30px 24px;
    border-left: 4px solid var(--primary);
}

.challenge-text {
    font-size: 1.3rem;
    line-height: 1.5;
    text-align: center;
}

.challenge-buttons {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 30px;
}

/* =============================================
   SCREEN: FINISHED
   ============================================= */

.finished-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
}

.trophy {
    font-size: 5rem;
    animation: bounce 1s ease infinite;
}

@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-15px); }
}

.winner-name {
    font-size: 1.8rem;
    font-weight: 800;
    color: var(--accent);
    margin: 20px 0 30px;
}

.final-scores {
    width: 100%;
    max-width: 300px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.final-score-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: var(--bg-card);
    border-radius: var(--border-radius);
}

.final-score-item:first-child {
    background: linear-gradient(135deg, var(--accent) 0%, #ffa500 100%);
    color: var(--bg-dark);
}

.final-score-item .medal {
    font-size: 1.3rem;
    margin-right: 10px;
}

.final-score-item .name {
    flex: 1;
    font-weight: 600;
}

.final-score-item .score {
    font-weight: 700;
}

.finished-buttons {
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: 100%;
    margin-top: 30px;
}

/* =============================================
   MODALS
   ============================================= */

.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal[hidden] {
    display: none;
}

.modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
}

.modal-content {
    position: relative;
    background: var(--bg-card);
    border-radius: var(--border-radius);
    padding: 30px 24px;
    max-width: 400px;
    width: 100%;
    text-align: center;
    animation: modalIn 0.3s ease;
}

@keyframes modalIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.modal-content h2 {
    font-size: 1.5rem;
    margin-bottom: 20px;
}

.modal-content p {
    color: var(--text-muted);
    margin-bottom: 12px;
    line-height: 1.5;
}

.help-content {
    text-align: left;
    margin-bottom: 20px;
}

.help-content p {
    margin-bottom: 10px;
}

.help-tip {
    font-size: 0.9rem;
    color: var(--accent);
    margin-bottom: 20px;
}

.modal-buttons {
    display: flex;
    gap: 12px;
    margin-top: 20px;
}

.modal-buttons .btn {
    flex: 1;
}

/* =============================================
   TOAST
   ============================================= */

.toast {
    position: fixed;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--bg-card);
    color: var(--text);
    padding: 12px 24px;
    border-radius: 30px;
    font-size: 0.9rem;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    animation: toastIn 0.3s ease;
    z-index: 200;
}

.toast[hidden] {
    display: none;
}

@keyframes toastIn {
    from {
        opacity: 0;
        transform: translate(-50%, 20px);
    }
    to {
        opacity: 1;
        transform: translate(-50%, 0);
    }
}

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

@media (min-width: 480px) {
    .title {
        font-size: 2.2rem;
    }

    .cylinder {
        width: 220px;
        height: 220px;
    }

    .chamber {
        width: 36px;
        height: 36px;
    }

    .challenge-text {
        font-size: 1.5rem;
    }
}

@media (min-width: 768px) {
    .screen {
        max-width: 500px;
        margin: 0 auto;
    }
}

/* =============================================
   ACCESSIBILITY
   ============================================= */

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Focus states */
button:focus-visible,
input:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}
