/* ============================================
   حروف مع عزيز - Hex Game Styles
   Purple gradient theme, RTL Arabic, Responsive
   ============================================ */

:root {
    --purple-dark: #1a0a2e;
    --purple-mid: #2d1b69;
    --purple-light: #5b21b6;
    --purple-glow: #7c3aed;
    --yellow: #fbbf24;
    --yellow-hover: #f59e0b;
    --cyan: #22d3ee;
    --cyan-hover: #06b6d4;
    --red: #ef4444;
    --red-hover: #dc2626;
    --green: #22c55e;
    --green-hover: #16a34a;
    --glass-bg: rgba(255, 255, 255, 0.1);
    --glass-border: rgba(255, 255, 255, 0.2);
    --text-primary: #ffffff;
    --text-secondary: rgba(255, 255, 255, 0.7);
    --font: 'Tajawal', sans-serif;

    --team1-color: #3b82f6;
    --team2-color: #ef4444;
}

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

body {
    font-family: var(--font);
    background: linear-gradient(135deg, var(--purple-dark) 0%, var(--purple-mid) 50%, var(--purple-light) 100%);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    direction: rtl;
}

/* Screens */
.screen {
    display: none;
    min-height: 100vh;
    padding: 20px;
    align-items: center;
    justify-content: center;
    flex-direction: column;
}

.screen.active {
    display: flex;
}

/* Glass Card */
.glass-card {
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    border-radius: 24px;
    padding: 40px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

/* Buttons */
.btn {
    font-family: var(--font);
    font-size: 1.2rem;
    font-weight: 700;
    padding: 14px 48px;
    border: none;
    border-radius: 16px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-block;
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
}

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

.btn-yellow { background: var(--yellow); color: var(--purple-dark); }
.btn-yellow:hover { background: var(--yellow-hover); }
.btn-cyan { background: var(--cyan); color: var(--purple-dark); }
.btn-cyan:hover { background: var(--cyan-hover); }
.btn-red { background: var(--red); color: white; }
.btn-red:hover { background: var(--red-hover); }
.btn-green { background: var(--green); color: white; }
.btn-green:hover { background: var(--green-hover); }

.btn-small {
    font-size: 0.9rem;
    padding: 8px 24px;
    border-radius: 10px;
}

.btn-icon {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    color: white;
    width: 40px;
    height: 40px;
    border-radius: 12px;
    cursor: pointer;
    font-size: 1.2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.3s;
}

.btn-icon:hover { background: rgba(255, 255, 255, 0.2); }

/* ============================================
   LANDING SCREEN
   ============================================ */
#landing-screen {
    position: relative;
    overflow: hidden;
}

.floating-letters {
    position: absolute;
    inset: 0;
    pointer-events: none;
}

.float-letter {
    position: absolute;
    font-size: 3rem;
    font-weight: 900;
    color: rgba(255, 255, 255, 0.08);
    left: var(--x);
    top: var(--y);
    animation: floatLetter 6s ease-in-out infinite;
    animation-delay: var(--delay);
}

@keyframes floatLetter {
    0%, 100% { transform: translateY(0) rotate(0deg); }
    50% { transform: translateY(-20px) rotate(10deg); }
}

.landing-content {
    text-align: center;
    max-width: 500px;
    width: 100%;
    animation: fadeInUp 0.8s ease;
}

.game-title {
    font-size: 3.5rem;
    font-weight: 900;
    margin-bottom: 10px;
    background: linear-gradient(135deg, var(--yellow), var(--cyan));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.game-subtitle {
    font-size: 1.2rem;
    color: var(--text-secondary);
    margin-bottom: 30px;
}

@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(30px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ============================================
   LANDING BUTTONS
   ============================================ */
.landing-buttons {
    display: flex;
    gap: 12px;
    margin-bottom: 20px;
}

.landing-btn {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 16px 12px !important;
    border-radius: 16px !important;
}

.landing-btn-icon {
    font-size: 1.8rem;
    line-height: 1;
}

.landing-btn-text {
    font-size: 1rem;
    font-weight: 800;
}

.landing-btn-desc {
    font-size: 0.7rem;
    font-weight: 400;
    opacity: 0.8;
}

.landing-join {
    width: 100%;
}

.join-divider {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 14px;
    color: var(--text-secondary);
    font-size: 0.85rem;
}

.join-divider::before,
.join-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: rgba(255,255,255,0.15);
}

.join-row {
    display: flex;
    gap: 10px;
}

.join-code-input {
    flex: 1;
    padding: 12px 16px;
    background: rgba(255, 255, 255, 0.08);
    border: 2px solid rgba(255, 255, 255, 0.15);
    border-radius: 12px;
    color: white;
    font-family: var(--font);
    font-size: 1.2rem;
    font-weight: 800;
    text-align: center;
    letter-spacing: 8px;
    outline: none;
    transition: border-color 0.3s;
}

.join-code-input:focus {
    border-color: var(--cyan);
}

.join-code-input::placeholder {
    letter-spacing: 2px;
    font-size: 0.9rem;
    font-weight: 400;
}

.join-btn {
    padding: 12px 24px !important;
    font-size: 1rem !important;
    border-radius: 12px !important;
    white-space: nowrap;
}

.setup-actions {
    display: flex;
    gap: 10px;
}

.setup-actions .btn {
    flex: 1;
}

/* ============================================
   SETUP SCREEN
   ============================================ */
.setup-container {
    max-width: 520px;
    width: 100%;
    animation: fadeInUp 0.6s ease;
}

.setup-container h2 {
    text-align: center;
    font-size: 1.8rem;
    margin-bottom: 24px;
}

.setup-section { margin-bottom: 24px; }

.setup-label {
    display: block;
    font-size: 1rem;
    font-weight: 700;
    margin-bottom: 10px;
    color: var(--text-secondary);
}

.grid-size-options,
.timer-options,
.mode-options {
    display: flex;
    gap: 10px;
}

.grid-size-btn,
.timer-btn,
.mode-btn {
    flex: 1;
    padding: 12px;
    background: rgba(255, 255, 255, 0.08);
    border: 2px solid rgba(255, 255, 255, 0.15);
    border-radius: 12px;
    color: white;
    font-family: var(--font);
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s;
}

.grid-size-btn:hover, .timer-btn:hover, .mode-btn:hover {
    background: rgba(255, 255, 255, 0.15);
}

.grid-size-btn.active, .timer-btn.active, .mode-btn.active {
    background: var(--purple-glow);
    border-color: var(--purple-glow);
}

/* Game Mode Cards */
.mode-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 14px 12px;
    text-align: center;
}

.mode-icon {
    font-size: 1.6rem;
    line-height: 1;
}

.mode-title {
    font-size: 1rem;
    font-weight: 800;
}

.mode-desc {
    font-size: 0.7rem;
    font-weight: 400;
    color: var(--text-secondary);
    line-height: 1.3;
}

.mode-btn.active .mode-desc {
    color: rgba(255, 255, 255, 0.8);
}

.teams-setup {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.team-setup {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.team-color-dot {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    flex-shrink: 0;
    border: 2px solid rgba(255, 255, 255, 0.3);
}

.team-input {
    flex: 1;
    min-width: 120px;
    padding: 10px 14px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 10px;
    color: white;
    font-family: var(--font);
    font-size: 1rem;
    outline: none;
    transition: border-color 0.3s;
}

.team-input::placeholder { color: rgba(255, 255, 255, 0.4); }
.team-input:focus { border-color: var(--purple-glow); }

.color-picker {
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    background: none;
    padding: 0;
}

.color-picker::-webkit-color-swatch-wrapper { padding: 2px; }
.color-picker::-webkit-color-swatch {
    border-radius: 8px;
    border: 2px solid rgba(255, 255, 255, 0.3);
}

.team-direction {
    font-size: 0.8rem;
    color: var(--text-secondary);
    white-space: nowrap;
}

/* ============================================
   GAME SCREEN
   ============================================ */
#game-screen {
    padding: 10px;
    gap: 8px;
}

.game-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    max-width: 600px;
    padding: 10px 16px;
    background: var(--glass-bg);
    backdrop-filter: blur(10px);
    border-radius: 16px;
    border: 1px solid var(--glass-border);
}

.team-score {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
}

.team-score-name {
    font-size: 0.85rem;
    font-weight: 700;
}

.team-direction-label {
    font-size: 0.7rem;
    color: var(--text-secondary);
}

.round-info {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* ============================================
   HEX GRID
   ============================================ */
.hex-board-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 1;
    width: 100%;
    padding: 20px;
}

.hex-grid {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0;
}

.hex-row {
    display: flex;
    gap: 4px;
}

.hex-cell {
    width: var(--cell-size, 60px);
    height: var(--cell-size, 60px);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: var(--cell-font, 1.4rem);
    font-weight: 800;
    cursor: pointer;
    transition: all 0.3s ease;
    user-select: none;
    -webkit-user-select: none;
    position: relative;
    clip-path: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%);
    background: rgba(255, 255, 255, 0.12);
    color: white;
}

.hex-cell:hover:not(.claimed) {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.08);
}

.hex-cell.claimed {
    cursor: default;
    animation: claimPop 0.4s ease;
}

.hex-cell.claimed.team1 {
    background: var(--team1-color);
}

.hex-cell.claimed.team2 {
    background: var(--team2-color);
}

.hex-cell.win-path {
    animation: winGlow 0.6s ease-in-out infinite alternate;
}

@keyframes winGlow {
    from { filter: brightness(1); }
    to { filter: brightness(1.5); }
}

@keyframes claimPop {
    0% { transform: scale(1); }
    50% { transform: scale(1.15); }
    100% { transform: scale(1); }
}

/* Board edges to indicate team sides */
.board-edge {
    position: absolute;
    border-radius: 8px;
}

.edge-top, .edge-bottom {
    height: 6px;
    left: 15%;
    right: 15%;
    background: var(--team1-color);
}

.edge-top { top: 8px; }
.edge-bottom { bottom: 8px; }

.edge-left, .edge-right {
    width: 6px;
    top: 15%;
    bottom: 15%;
    background: var(--team2-color);
}

.edge-right { right: 0; }
.edge-left { left: 0; }

/* Turn Indicator */
.turn-indicator {
    padding: 12px 32px;
    background: var(--glass-bg);
    backdrop-filter: blur(10px);
    border-radius: 16px;
    border: 2px solid var(--glass-border);
    font-size: 1.1rem;
    font-weight: 700;
    transition: all 0.4s ease;
}

/* ============================================
   QUESTION MODAL
   ============================================ */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    padding: 20px;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.question-card {
    max-width: 500px;
    width: 100%;
    text-align: center;
    animation: scaleIn 0.3s ease;
    position: relative;
    overflow: hidden;
}

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

.timer-bar-container {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: rgba(255, 255, 255, 0.1);
}

.timer-bar {
    height: 100%;
    background: var(--yellow);
    border-radius: 0 0 4px 4px;
    transition: width 0.1s linear;
    width: 100%;
}

.timer-bar.warning { background: var(--red); }

.selected-letter-display {
    width: 70px;
    height: 70px;
    margin: 0 auto 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    font-weight: 900;
    clip-path: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%);
    background: var(--purple-glow);
}

.question-text {
    font-size: 1.3rem;
    font-weight: 700;
    line-height: 1.8;
    margin-bottom: 20px;
}

.answer-reveal-wrapper {
    margin-bottom: 20px;
}

.btn-reveal {
    font-family: var(--font);
    font-size: 0.95rem;
    font-weight: 600;
    padding: 10px 24px;
    background: rgba(255, 255, 255, 0.08);
    border: 2px dashed rgba(255, 255, 255, 0.25);
    border-radius: 12px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.3s;
    width: 100%;
    display: block;
}

.btn-reveal:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.4);
}

.btn-reveal.hidden {
    display: none;
}

.question-answer {
    font-size: 1.4rem;
    font-weight: 900;
    color: var(--green);
    padding: 10px;
    background: rgba(34, 197, 94, 0.1);
    border-radius: 10px;
    display: none;
}

.question-answer.visible {
    display: block;
    animation: revealPulse 0.4s ease;
}

@keyframes revealPulse {
    0% { transform: scale(0.9); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}

.decision-actions {
    display: flex;
    gap: 10px;
}

/* ============================================
   MODERATOR MODAL
   ============================================ */
.moderator-card {
    border: 2px solid var(--yellow);
}

.moderator-badge {
    display: inline-block;
    background: var(--yellow);
    color: var(--purple-dark);
    font-size: 0.8rem;
    font-weight: 700;
    padding: 4px 16px;
    border-radius: 20px;
    margin-bottom: 12px;
}

.moderator-answer {
    font-size: 1.4rem;
    font-weight: 900;
    color: var(--green);
    margin-bottom: 20px;
    padding: 10px;
    background: rgba(34, 197, 94, 0.1);
    border-radius: 10px;
}

.moderator-actions {
    display: flex;
    gap: 10px;
}

.btn-mod {
    flex: 1;
    padding: 14px 16px;
    font-size: 1rem;
    border-radius: 14px;
}

/* ============================================
   WINNER SCREEN
   ============================================ */
#winner-screen {
    position: relative;
    overflow: hidden;
}

#confetti-container {
    position: absolute;
    inset: 0;
    pointer-events: none;
    overflow: hidden;
}

.confetti {
    position: absolute;
    width: 10px;
    height: 10px;
    top: -10px;
    animation: confettiFall linear forwards;
}

@keyframes confettiFall {
    to {
        top: 110vh;
        transform: rotate(720deg);
    }
}

.winner-content {
    text-align: center;
    max-width: 450px;
    width: 100%;
    animation: fadeInUp 0.8s ease;
    z-index: 1;
}

.winner-trophy { font-size: 4rem; margin-bottom: 10px; }

.winner-team {
    font-size: 2.2rem;
    font-weight: 900;
    margin-bottom: 8px;
}

.winner-subtitle {
    font-size: 1.3rem;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.winner-desc {
    font-size: 0.95rem;
    color: var(--text-secondary);
    margin-bottom: 24px;
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 600px) {
    .glass-card {
        padding: 24px 18px;
        border-radius: 18px;
    }

    .game-title { font-size: 2.4rem; }

    .btn {
        font-size: 1rem;
        padding: 12px 36px;
    }

    .question-text { font-size: 1.1rem; }

    .answer-input-wrapper { flex-direction: column; }

    .timer-options, .mode-options { flex-wrap: wrap; }
    .timer-btn, .mode-btn { min-width: calc(50% - 5px); }

    .float-letter { font-size: 2rem; }

    .moderator-actions { flex-direction: column; }
}

@media (max-width: 380px) {
    .game-title { font-size: 2rem; }
}

.hidden { display: none !important; }

/* ============================================
   END GAME BUTTON
   ============================================ */
.btn-end-game {
    position: fixed;
    bottom: 20px;
    left: 20px;
    background: rgba(239, 68, 68, 0.2);
    color: var(--red);
    border: 1px solid var(--red);
    padding: 10px 20px;
    border-radius: 12px;
    font-family: var(--font);
    font-size: 0.9rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s ease;
    z-index: 50;
}

.btn-end-game:hover {
    background: var(--red);
    color: white;
}

/* ============================================
   STEAL PHASE
   ============================================ */
.steal-phase {
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

.steal-label {
    font-size: 1.3rem;
    font-weight: 900;
    padding: 8px 20px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.1);
    text-align: center;
    width: 100%;
    animation: pulse-steal 1s ease infinite;
}

.steal-phase .btn-mod {
    width: 100%;
}

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

/* ============================================
   BUZZ WAITING (Online mode - host waits for buzz)
   ============================================ */
.buzz-waiting {
    text-align: center;
    padding: 16px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 14px;
    border: 2px dashed rgba(255, 255, 255, 0.2);
    margin-top: 8px;
}

.buzz-waiting-icon {
    font-size: 2.5rem;
    animation: buzzPulse 1.5s ease-in-out infinite;
}

.buzz-waiting-text {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-secondary);
    margin-top: 8px;
}

@keyframes buzzPulse {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.15); opacity: 0.7; }
}

/* ============================================
   LOBBY SCREEN
   ============================================ */
.lobby-container {
    max-width: 520px;
    width: 100%;
    animation: fadeInUp 0.6s ease;
    text-align: center;
}

.lobby-container h2 {
    font-size: 1.8rem;
    margin-bottom: 20px;
}

.room-code-section {
    margin-bottom: 24px;
}

.room-code-display {
    font-size: 3.5rem;
    font-weight: 900;
    letter-spacing: 16px;
    color: var(--yellow);
    background: rgba(251, 191, 36, 0.1);
    border: 2px solid rgba(251, 191, 36, 0.3);
    border-radius: 16px;
    padding: 16px 24px;
    margin: 10px 0;
    font-variant-numeric: tabular-nums;
}

.room-code-hint {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.host-controller-link {
    margin-top: 16px;
    padding: 16px;
    background: rgba(251, 191, 36, 0.1);
    border: 1px solid rgba(251, 191, 36, 0.3);
    border-radius: 14px;
    text-align: center;
}

.lobby-teams {
    display: flex;
    gap: 12px;
    margin-bottom: 16px;
}

.lobby-team {
    flex: 1;
    background: rgba(255, 255, 255, 0.06);
    border-radius: 14px;
    padding: 14px;
    text-align: right;
}

.lobby-team-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
    font-weight: 700;
}

.lobby-team-dot {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    flex-shrink: 0;
}

.lobby-player-list {
    list-style: none;
    font-size: 0.9rem;
}

.lobby-player-list li {
    padding: 5px 0;
    border-bottom: 1px solid rgba(255,255,255,0.06);
}

.lobby-player-list li:last-child {
    border-bottom: none;
}

.lobby-empty {
    color: var(--text-secondary);
    font-style: italic;
    font-size: 0.85rem;
}

.lobby-player-icon {
    margin-left: 6px;
}

.lobby-count {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 16px;
}

/* ============================================
   BUZZ MODAL (Host side)
   ============================================ */
.buzz-card {
    max-width: 400px;
    width: 90%;
    text-align: center;
    animation: scaleIn 0.3s ease;
}

.buzz-icon {
    font-size: 3rem;
    margin-bottom: 10px;
    animation: buzzShake 0.5s ease;
}

@keyframes buzzShake {
    0%, 100% { transform: rotate(0deg); }
    25% { transform: rotate(-15deg); }
    75% { transform: rotate(15deg); }
}

.buzz-phase-label {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.buzz-timer-circle {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    border: 4px solid var(--yellow);
    display: none;
    align-items: center;
    justify-content: center;
    margin: 10px auto;
    animation: timerPulse 1s ease infinite;
}

.buzz-timer-circle.warning {
    border-color: var(--red);
}

.buzz-timer-num {
    font-size: 1.8rem;
    font-weight: 900;
    color: var(--yellow);
}

.buzz-timer-circle.warning .buzz-timer-num {
    color: var(--red);
}

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

.buzz-player-name {
    font-size: 2rem;
    font-weight: 900;
    margin-bottom: 4px;
}

.buzz-team-name {
    font-size: 1rem;
    font-weight: 700;
    margin-bottom: 20px;
}

@keyframes scaleIn {
    from { opacity: 0; transform: scale(0.8); }
    to { opacity: 1; transform: scale(1); }
}
