/* ========================================
   COSMIC KITCHEN CHAOS — Retro Space Theme
   ======================================== */

@import url('https://fonts.googleapis.com/css2?family=Fredoka+One&family=Nunito:wght@400;700;900&display=swap');

:root {
    --bg-dark: #0a0a2e;
    --bg-medium: #1a1a4e;
    --purple: #6c5ce7;
    --pink: #fd79a8;
    --cyan: #00cec9;
    --yellow: #ffeaa7;
    --orange: #e17055;
    --green: #00b894;
    --red: #d63031;
    --white: #dfe6e9;
    --grabber-color: #e17055;
    --defender-color: #00b894;
    --font-display: 'Fredoka One', cursive;
    --font-body: 'Nunito', sans-serif;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html, body {
    height: 100%;
    overflow: hidden;
    font-family: var(--font-body);
    background: var(--bg-dark);
    color: var(--white);
}

.landing-page,
.landing-page body {
    overflow-y: auto;
}

/* Stars background */
.stars-bg {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    z-index: 0;
    background:
        radial-gradient(2px 2px at 20px 30px, #fff, transparent),
        radial-gradient(2px 2px at 40px 70px, rgba(255,255,255,0.8), transparent),
        radial-gradient(1px 1px at 90px 40px, #fff, transparent),
        radial-gradient(1px 1px at 130px 80px, rgba(255,255,255,0.6), transparent),
        radial-gradient(2px 2px at 160px 30px, #fff, transparent),
        radial-gradient(1px 1px at 200px 60px, rgba(255,255,255,0.7), transparent);
    background-size: 200px 100px;
    animation: twinkle 4s ease-in-out infinite alternate;
}

@keyframes twinkle {
    0% { opacity: 0.5; }
    100% { opacity: 1; }
}

/* Views */
.view {
    display: none;
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    z-index: 1;
}
.view.active { display: flex; flex-direction: column; }

.overlay {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    z-index: 100;
    background: rgba(10, 10, 46, 0.92);
    justify-content: center;
    align-items: center;
}
.overlay.active { display: flex; }

/* Game-end overlay fades in (z-index 101 so it renders above round-end) */
.overlay.fade-in {
    display: flex;
    opacity: 0;
    z-index: 101;
    animation: overlayFadeIn 1.5s ease-out forwards;
}
.overlay.fade-in .game-end-content {
    transform: translateY(20px);
    animation: contentSlideUp 1.5s ease-out 0.3s forwards;
    opacity: 0;
}
@keyframes overlayFadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}
@keyframes contentSlideUp {
    from { transform: translateY(20px); opacity: 0; }
    to   { transform: translateY(0);    opacity: 1; }
}

/* Player game-end view fade-in */
.view.fade-in-view {
    display: flex;
    flex-direction: column;
    animation: viewFadeIn 1.5s ease-out forwards;
}
.view.fade-in-view .game-end-phone {
    opacity: 0;
    transform: translateY(20px);
    animation: contentSlideUp 1.5s ease-out 0.3s forwards;
}
@keyframes viewFadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

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

.btn {
    font-family: var(--font-display);
    border: none;
    border-radius: 16px;
    cursor: pointer;
    transition: transform 0.15s, box-shadow 0.15s;
    text-transform: uppercase;
    letter-spacing: 1px;
}

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

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

.btn-primary {
    background: linear-gradient(135deg, var(--purple), var(--pink));
    color: white;
    font-size: 1.2em;
    padding: 16px 32px;
    box-shadow: 0 4px 20px rgba(108, 92, 231, 0.4);
}

.btn-secondary {
    background: linear-gradient(135deg, var(--cyan), var(--green));
    color: var(--bg-dark);
    font-size: 1em;
    padding: 12px 24px;
}

.btn-large {
    width: 100%;
    max-width: 400px;
    font-size: 1.3em;
    padding: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.btn-icon { font-size: 1.5em; }
.btn-sub {
    font-family: var(--font-body);
    font-size: 0.5em;
    opacity: 0.8;
    text-transform: none;
    letter-spacing: 0;
}

/* ========== DIFFICULTY SELECTOR ========== */

.difficulty-section {
    width: 100%;
    max-width: 400px;
    text-align: center;
}

.difficulty-label {
    font-family: var(--font-display);
    font-size: 1em;
    color: var(--cyan);
    letter-spacing: 2px;
    text-transform: uppercase;
    margin-bottom: 10px;
}

.difficulty-options {
    display: flex;
    gap: 8px;
    justify-content: center;
}

.diff-btn {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 12px 8px;
    background: rgba(108, 92, 231, 0.15);
    border: 3px solid rgba(108, 92, 231, 0.3);
    border-radius: 14px;
    color: var(--white);
    cursor: pointer;
    transition: all 0.2s;
    font-family: var(--font-body);
}

.diff-btn:hover {
    border-color: var(--purple);
    background: rgba(108, 92, 231, 0.25);
}

.diff-btn.selected {
    border-color: var(--cyan);
    background: rgba(0, 206, 201, 0.15);
    box-shadow: 0 0 16px rgba(0, 206, 201, 0.3);
}

.diff-icon { font-size: 1.6em; }
.diff-name {
    font-family: var(--font-display);
    font-size: 0.9em;
    letter-spacing: 1px;
}
.diff-desc {
    font-size: 0.65em;
    opacity: 0.6;
}

/* Rounds selector */
.rounds-section {
    width: 100%;
    max-width: 400px;
    text-align: center;
    margin-top: 10px;
}

.rounds-label {
    font-family: var(--font-display);
    font-size: 1em;
    color: var(--cyan);
    letter-spacing: 2px;
    text-transform: uppercase;
    margin-bottom: 10px;
}

.rounds-options {
    display: flex;
    gap: 8px;
    justify-content: center;
}

.rounds-btn {
    flex: 1;
    padding: 12px 8px;
    background: rgba(108, 92, 231, 0.15);
    border: 3px solid rgba(108, 92, 231, 0.3);
    border-radius: 14px;
    color: var(--white);
    cursor: pointer;
    transition: all 0.2s;
    font-family: var(--font-display);
    font-size: 1.3em;
    letter-spacing: 1px;
}

.rounds-btn:hover {
    border-color: var(--purple);
    background: rgba(108, 92, 231, 0.25);
}

.rounds-btn.selected {
    border-color: var(--cyan);
    background: rgba(0, 206, 201, 0.15);
    box-shadow: 0 0 16px rgba(0, 206, 201, 0.3);
}

/* Available rooms list */
.available-rooms {
    width: 100%;
    max-width: 400px;
    text-align: center;
}

.available-rooms-title {
    font-family: var(--font-display);
    font-size: 1.1em;
    color: var(--cyan);
    letter-spacing: 2px;
    text-transform: uppercase;
    margin-bottom: 12px;
}

.room-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.room-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: rgba(0, 206, 201, 0.08);
    border: 2px solid rgba(0, 206, 201, 0.25);
    border-radius: 14px;
    color: var(--white);
    cursor: pointer;
    transition: all 0.2s;
    font-family: var(--font-body);
    text-align: left;
    width: 100%;
}

.room-card:hover {
    border-color: var(--cyan);
    background: rgba(0, 206, 201, 0.18);
    box-shadow: 0 0 16px rgba(0, 206, 201, 0.2);
    transform: translateY(-1px);
}

.room-card-code {
    font-family: var(--font-display);
    font-size: 1.4em;
    letter-spacing: 3px;
    color: var(--cyan);
    min-width: 70px;
}

.room-card-info {
    font-size: 0.8em;
    opacity: 0.7;
    flex: 1;
}

.room-card-players {
    font-size: 0.85em;
    opacity: 0.9;
    white-space: nowrap;
}

.room-card-clock {
    flex-shrink: 0;
    display: flex;
    align-items: center;
}

.room-card-clock svg {
    display: block;
}

/* ========== LANDING PAGE ========== */

.landing-page .container {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100%;
    padding: 20px;
    gap: 30px;
}

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

.logo-icon {
    font-size: 4em;
    animation: float 3s ease-in-out infinite;
}

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

.game-title {
    font-family: var(--font-display);
    font-size: 3em;
    line-height: 1.1;
    background: linear-gradient(135deg, var(--cyan), var(--yellow), var(--pink));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-shadow: none;
}

.game-subtitle {
    font-size: 1.1em;
    color: var(--cyan);
    margin-top: 8px;
}

.menu-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    width: 100%;
    max-width: 400px;
}

.divider {
    display: flex;
    align-items: center;
    width: 100%;
    gap: 16px;
    color: rgba(255,255,255,0.3);
}
.rooms-divider {
    margin: 8px 0 4px;
    font-size: 0.8em;
}
.divider::before, .divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: rgba(255,255,255,0.15);
}

.join-section {
    text-align: center;
    width: 100%;
}

.join-label {
    margin-bottom: 12px;
    font-size: 1.1em;
}

.code-input-group {
    display: flex;
    gap: 12px;
    justify-content: center;
}

.code-input {
    font-family: var(--font-display);
    font-size: 2em;
    width: 160px;
    text-align: center;
    padding: 12px;
    border: 3px solid var(--purple);
    border-radius: 12px;
    background: rgba(108, 92, 231, 0.15);
    color: var(--yellow);
    outline: none;
    letter-spacing: 8px;
}

.code-input:focus {
    border-color: var(--cyan);
    box-shadow: 0 0 20px rgba(0, 206, 201, 0.3);
}

.footer-info {
    text-align: center;
    opacity: 0.6;
    font-size: 0.9em;
}

/* ========== HOST PAGE — LOBBY ========== */

.host-header {
    position: relative;
    text-align: center;
    padding: 16px;
    background: linear-gradient(180deg, rgba(10,10,46,0.9), transparent);
}

.game-title-small {
    font-family: var(--font-display);
    font-size: 1.4em;
    color: var(--cyan);
}

.lobby-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 30px;
    padding: 20px;
    overflow-y: auto;
}

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

.room-code-label {
    font-size: 1em;
    color: var(--cyan);
    letter-spacing: 3px;
    text-transform: uppercase;
}

.room-code-huge {
    font-family: var(--font-display);
    font-size: 5em;
    color: var(--yellow);
    letter-spacing: 12px;
    text-shadow: 0 0 30px rgba(255, 234, 167, 0.5);
}

.room-url {
    font-size: 0.85em;
    color: rgba(255,255,255,0.4);
    margin-top: 8px;
    word-break: break-all;
}

.difficulty-badge {
    margin-top: 10px;
    font-family: var(--font-display);
    font-size: 1em;
    color: var(--yellow);
    letter-spacing: 1px;
}

/* Room timeout progress bar (host lobby) */
.room-timeout-bar {
    width: 100%;
    max-width: 400px;
    text-align: center;
}

.room-timeout-label {
    font-family: var(--font-body);
    font-size: 0.8em;
    color: rgba(255,255,255,0.5);
    margin-bottom: 6px;
}

.room-timeout-track {
    height: 4px;
    background: rgba(255,255,255,0.1);
    border-radius: 2px;
    overflow: hidden;
}

.room-timeout-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--cyan), var(--green));
    border-radius: 2px;
    transition: width 1s linear;
}

.players-section {
    text-align: center;
    width: 100%;
    max-width: 600px;
}

.players-section h2 {
    font-family: var(--font-display);
    margin-bottom: 16px;
}

.player-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    justify-content: center;
}

.player-card {
    background: rgba(108, 92, 231, 0.2);
    border: 2px solid var(--purple);
    border-radius: 12px;
    padding: 12px 20px;
    display: flex;
    align-items: center;
    gap: 10px;
    animation: slideIn 0.3s ease-out;
}

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

.player-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3em;
}

.player-name {
    font-weight: 700;
    font-size: 1.1em;
}

/* ========== HOST PAGE — GAME VIEW ========== */

.game-hud {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 20px;
    background: linear-gradient(180deg, rgba(10,10,46,0.95), rgba(10,10,46,0.7));
    z-index: 10;
}

.hud-left, .hud-right { flex: 1; }
.hud-right { text-align: right; }
.hud-center { text-align: center; }

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

.team-label {
    font-size: 0.85em;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.grabber-score .score-value { color: var(--grabber-color); }
.defender-score .score-value { color: var(--defender-color); }

.score-value {
    font-family: var(--font-display);
    font-size: 2em;
}

.round-display {
    font-family: var(--font-display);
    color: var(--cyan);
    font-size: 1.1em;
}

.timer-display {
    font-family: var(--font-display);
    font-size: 2.5em;
    color: var(--yellow);
}

.timer-display.timer-urgent, .play-timer.timer-urgent {
    color: var(--red);
    animation: pulse 0.5s ease-in-out infinite;
}

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

.table-area {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.table-surface {
    position: relative;
    width: 100%;
    max-width: 700px;
    aspect-ratio: 4 / 3;
    background: radial-gradient(ellipse, #2d1b69 0%, #1a0f40 70%);
    border: 4px solid var(--purple);
    border-radius: 24px;
    box-shadow: 0 0 40px rgba(108, 92, 231, 0.3), inset 0 0 60px rgba(108, 92, 231, 0.1);
    overflow: hidden;
}

.food-item-host {
    position: absolute;
    transform: translate(-50%, -50%);
    transition: all 0.3s;
    z-index: 2;
}

.food-emoji {
    font-size: 3.75em;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.5));
    display: block;
}

.food-item-host.food-stolen {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0);
}

/* Hand animations on host screen */
.hand-host {
    position: absolute;
    font-size: 2em;
    z-index: 5;
    pointer-events: none;
}

.hand-from-left {
    left: -40px;
    top: var(--target-y);
    animation: reachFromLeft var(--duration, 1.5s) ease-in forwards;
}
.hand-from-right {
    right: -40px;
    top: var(--target-y);
    animation: reachFromRight var(--duration, 1.5s) ease-in forwards;
}
.hand-from-top {
    top: -40px;
    left: var(--target-x);
    animation: reachFromTop var(--duration, 1.5s) ease-in forwards;
}
.hand-from-bottom {
    bottom: -40px;
    left: var(--target-x);
    animation: reachFromBottom var(--duration, 1.5s) ease-in forwards;
}

@keyframes reachFromLeft {
    to { left: var(--target-x); }
}
@keyframes reachFromRight {
    to { right: calc(100% - var(--target-x)); }
}
@keyframes reachFromTop {
    to { top: var(--target-y); }
}
@keyframes reachFromBottom {
    to { bottom: calc(100% - var(--target-y)); }
}

.hand-swatted {
    animation: swatAway 0.4s ease-out forwards !important;
    color: transparent;
}
.hand-swatted::after {
    content: '💥';
    position: absolute;
    font-size: 1.5em;
    top: -10px; left: -10px;
}

.hand-grabbed {
    animation: grabAway 0.4s ease-out forwards !important;
    opacity: 0;
}

@keyframes swatAway {
    to { transform: rotate(90deg) scale(0); opacity: 0; }
}
@keyframes grabAway {
    to { transform: scale(0.5); opacity: 0; }
}

.host-feedback {
    position: absolute;
    bottom: 10px;
    left: 50%;
    transform: translateX(-50%);
    padding: 8px 16px;
    border-radius: 8px;
    font-family: var(--font-display);
    font-size: 1em;
    animation: feedbackPop 1.5s ease-out forwards;
    z-index: 20;
}
.grabber-feedback { background: var(--grabber-color); color: white; }
.defender-feedback { background: var(--defender-color); color: white; }

@keyframes feedbackPop {
    0% { opacity: 1; transform: translateX(-50%) translateY(0); }
    100% { opacity: 0; transform: translateX(-50%) translateY(-30px); }
}

/* ========== COUNTDOWN OVERLAY ========== */

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

.countdown-round {
    font-family: var(--font-display);
    font-size: 1.5em;
    color: var(--cyan);
    margin-bottom: 20px;
}

.countdown-number {
    font-family: var(--font-display);
    font-size: 8em;
    color: var(--yellow);
    animation: countPulse 1s ease-in-out infinite;
}

@keyframes countPulse {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.2); opacity: 0.8; }
}

/* ========== ROUND END OVERLAY ========== */

.round-end-content, .game-end-content {
    text-align: center;
    padding: 40px;
}

.round-end-content h2, .game-end-content h2 {
    font-family: var(--font-display);
    font-size: 2em;
    color: var(--yellow);
    margin-bottom: 20px;
}

.round-end-scores {
    font-size: 1.3em;
    margin-bottom: 20px;
}

.score-row {
    display: flex;
    justify-content: center;
    gap: 40px;
}

.round-end-next {
    color: var(--cyan);
    font-style: italic;
}

/* ========== GAME END OVERLAY ========== */

.winner-announcement {
    margin-bottom: 30px;
}

.winner-emoji {
    font-size: 4em;
    margin-bottom: 10px;
}

.winner-text {
    font-family: var(--font-display);
    font-size: 2em;
    color: var(--yellow);
}

.final-team-scores {
    font-size: 1.2em;
    color: var(--cyan);
    margin-top: 10px;
}

.final-scores {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 24px;
}

.final-player-score {
    display: flex;
    align-items: center;
    gap: 12px;
    justify-content: center;
    font-size: 1.1em;
    padding: 8px;
    background: rgba(108, 92, 231, 0.15);
    border-radius: 8px;
}

.rank {
    font-family: var(--font-display);
    color: var(--yellow);
    width: 40px;
}

.final-pts {
    font-family: var(--font-display);
    color: var(--cyan);
}

/* ========== BACK / LEAVE BUTTON ========== */

.btn-back {
    position: absolute;
    top: 12px;
    left: 12px;
    font-family: var(--font-body);
    font-size: 0.85em;
    font-weight: 700;
    color: rgba(255, 255, 255, 0.6);
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 8px;
    padding: 6px 14px;
    cursor: pointer;
    z-index: 20;
    transition: all 0.15s;
}

.btn-back:active {
    transform: scale(0.93);
    background: rgba(255, 255, 255, 0.15);
}

.btn-leave-end {
    margin-top: 20px;
}

.game-end-buttons {
    display: flex;
    gap: 15px;
    justify-content: center;
    margin-top: 25px;
    flex-wrap: wrap;
}

/* ========== PLAYER PAGE — JOIN ========== */

.play-header {
    position: relative;
    text-align: center;
    padding: 30px 20px 20px;
}

.logo-icon-small {
    font-size: 2.5em;
}

.join-form {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 20px;
    gap: 20px;
}

.join-room-code {
    font-family: var(--font-display);
    font-size: 1.3em;
    color: var(--cyan);
}

.join-room-code span {
    color: var(--yellow);
    font-size: 1.5em;
    letter-spacing: 4px;
}

.name-input {
    font-family: var(--font-body);
    font-size: 1.3em;
    font-weight: 700;
    width: 100%;
    max-width: 300px;
    text-align: center;
    padding: 16px;
    border: 3px solid var(--purple);
    border-radius: 16px;
    background: rgba(108, 92, 231, 0.15);
    color: var(--white);
    outline: none;
}

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

/* ========== PLAYER PAGE — WAITING ========== */

.waiting-content {
    position: relative;
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 20px;
    gap: 20px;
}

.waiting-icon {
    font-size: 3em;
    animation: float 2s ease-in-out infinite;
}

.waiting-content h2 {
    font-family: var(--font-display);
    color: var(--cyan);
}

.waiting-players {
    display: flex;
    flex-direction: column;
    gap: 8px;
    font-size: 1.1em;
}

.waiting-player {
    padding: 6px 16px;
    background: rgba(108, 92, 231, 0.15);
    border-radius: 8px;
}

/* ========== PLAYER PAGE — ROLE REVEAL ========== */

.role-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 30px;
    gap: 16px;
}

.role-round {
    font-size: 1em;
    color: var(--cyan);
}

.role-icon {
    font-size: 5em;
    animation: float 2s ease-in-out infinite;
}

.role-title {
    font-family: var(--font-display);
    font-size: 2em;
}

.role-grabber .role-title { color: var(--grabber-color); }
.role-defender .role-title { color: var(--defender-color); }

.role-desc {
    font-size: 1.1em;
    text-align: center;
    opacity: 0.8;
}

.role-countdown {
    font-family: var(--font-display);
    font-size: 4em;
    color: var(--yellow);
    margin-top: 20px;
}

/* ========== PLAYER PAGE — GRABBER ========== */

.play-hud {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 16px;
    background: linear-gradient(180deg, rgba(10,10,46,0.95), transparent);
    z-index: 10;
}

.play-hud-left, .play-hud-right { flex: 1; }
.play-hud-right { text-align: right; }
.play-hud-center { text-align: center; }

.role-badge {
    font-family: var(--font-display);
    font-size: 0.8em;
    padding: 4px 12px;
    border-radius: 20px;
    letter-spacing: 1px;
}

.grabber-badge { background: var(--grabber-color); color: white; }
.defender-badge { background: var(--defender-color); color: white; }

.play-timer {
    font-family: var(--font-display);
    font-size: 1.8em;
    color: var(--yellow);
}

.my-score {
    font-family: var(--font-display);
    font-size: 1.8em;
    color: var(--cyan);
}

.food-grid {
    flex: 1;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    padding: 16px;
    overflow-y: auto;
    align-content: start;
}

.food-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 16px 8px;
    background: rgba(108, 92, 231, 0.2);
    border: 3px solid var(--purple);
    border-radius: 16px;
    color: var(--white);
    cursor: pointer;
    transition: all 0.15s;
    font-family: var(--font-body);
}

.food-btn:active {
    transform: scale(0.92);
    border-color: var(--grabber-color);
    background: rgba(225, 112, 85, 0.3);
}

.food-btn.food-reaching {
    border-color: var(--yellow);
    animation: reaching 1.5s ease-in-out;
}

.food-btn.food-grabbed {
    opacity: 0;
    transform: scale(0);
    transition: all 0.4s;
}

@keyframes reaching {
    0% { box-shadow: 0 0 0 rgba(255,234,167,0); }
    50% { box-shadow: 0 0 20px rgba(255,234,167,0.5); }
    100% { box-shadow: 0 0 0 rgba(255,234,167,0); }
}

.food-btn-emoji { font-size: 3.75em; }
.food-btn-name {
    font-size: 0.75em;
    opacity: 0.7;
}

.cooldown-bar {
    height: 6px;
    background: rgba(255,255,255,0.1);
    margin: 0 16px 16px;
    border-radius: 3px;
    overflow: hidden;
}

.cooldown-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--grabber-color), var(--yellow));
    border-radius: 3px;
    width: 0;
}

/* ========== PLAYER PAGE — DEFENDER ========== */

.defender-table {
    flex: 1;
    position: relative;
    margin: 16px;
    background: radial-gradient(ellipse, #2d1b69 0%, #1a0f40 70%);
    border: 3px solid var(--purple);
    border-radius: 20px;
    overflow: hidden;
}

.defender-food {
    position: absolute;
    transform: translate(-50%, -50%);
    font-size: 2.7em;
    opacity: 0.5;
    pointer-events: none;
}

/* Swattable hands on defender phone — default is medium */
.swat-hand {
    position: absolute;
    font-size: 2.6em;
    z-index: 10;
    border: none;
    background: rgba(225, 112, 85, 0.12);
    border-radius: 50%;
    cursor: pointer;
    padding: 18px;
    min-width: 64px;
    min-height: 64px;
    display: flex;
    align-items: center;
    justify-content: center;
    filter: drop-shadow(0 0 10px rgba(225, 112, 85, 0.5));
    transform: translate(-50%, -50%);
}

/* Difficulty overrides for swat targets */
.difficulty-easy .swat-hand {
    font-size: 3.2em;
    padding: 25px;
    min-width: 80px;
    min-height: 80px;
    filter: drop-shadow(0 0 14px rgba(225, 112, 85, 0.7));
    background: rgba(225, 112, 85, 0.15);
}

.difficulty-hard .swat-hand {
    font-size: 2em;
    padding: 12px;
    min-width: 48px;
    min-height: 48px;
    filter: drop-shadow(0 0 6px rgba(225, 112, 85, 0.3));
    background: rgba(225, 112, 85, 0.08);
}

.swat-hand.hand-from-left {
    left: -50px;
    top: var(--target-y);
    animation: reachFromLeft var(--duration, 1.5s) ease-in forwards;
}
.swat-hand.hand-from-right {
    right: -50px;
    top: var(--target-y);
    animation: reachFromRight var(--duration, 1.5s) ease-in forwards;
}
.swat-hand.hand-from-top {
    top: -50px;
    left: var(--target-x);
    animation: reachFromTop var(--duration, 1.5s) ease-in forwards;
}
.swat-hand.hand-from-bottom {
    bottom: -50px;
    left: var(--target-x);
    animation: reachFromBottom var(--duration, 1.5s) ease-in forwards;
}

.swat-hand.hand-swatted {
    animation: swatAway 0.4s ease-out forwards !important;
}

.swat-hand.hand-escaped {
    animation: fadeOut 0.3s ease-out forwards !important;
}

@keyframes fadeOut {
    to { opacity: 0; }
}

/* ========== FEEDBACK ========== */

.action-feedback {
    position: fixed;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%);
    padding: 10px 24px;
    border-radius: 30px;
    font-family: var(--font-display);
    font-size: 1em;
    background: rgba(108, 92, 231, 0.9);
    color: white;
    opacity: 0;
    transition: opacity 0.3s;
    z-index: 50;
    pointer-events: none;
    white-space: nowrap;
}

.action-feedback.show {
    opacity: 1;
    animation: feedbackBounce 0.3s ease-out;
}

@keyframes feedbackBounce {
    0% { transform: translateX(-50%) scale(0.8); }
    50% { transform: translateX(-50%) scale(1.05); }
    100% { transform: translateX(-50%) scale(1); }
}

/* ========== PHONE ROUND/GAME END ========== */

.round-end-phone, .game-end-phone {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 30px;
    gap: 20px;
    text-align: center;
    overflow-y: auto;
}

.round-end-phone h2, .game-end-phone h2 {
    font-family: var(--font-display);
    font-size: 2em;
    color: var(--yellow);
}

.your-round-score, .your-final-score {
    font-size: 1.3em;
}

.your-round-score strong {
    font-family: var(--font-display);
    font-size: 1.5em;
    color: var(--cyan);
}

.teams-swap {
    color: var(--pink);
    font-style: italic;
    animation: float 2s ease-in-out infinite;
}

.winner-phone {
    font-family: var(--font-display);
    font-size: 1.5em;
    color: var(--yellow);
}

.final-team-scores-phone {
    font-size: 1.1em;
    color: var(--cyan);
    margin-top: 10px;
}

/* Player scores on phone game-end */
.final-scores-phone {
    display: flex;
    flex-direction: column;
    gap: 6px;
    width: 100%;
    max-width: 320px;
    margin-top: 12px;
}

.final-player-score-phone {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    background: rgba(108, 92, 231, 0.15);
    border-radius: 10px;
    font-size: 0.95em;
}

.rank-phone {
    font-family: var(--font-display);
    color: var(--yellow);
    width: 28px;
    text-align: center;
    flex-shrink: 0;
}

.final-avatar-phone {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1em;
    flex-shrink: 0;
}

.final-name-phone {
    flex: 1;
    font-weight: 700;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.final-pts-phone {
    font-family: var(--font-display);
    color: var(--cyan);
    flex-shrink: 0;
}

.team-scores-small {
    font-size: 0.85em;
    color: rgba(255,255,255,0.6);
    margin-top: 8px;
}

/* ========== QR / ROOM CODE DISPLAY ========== */

.room-qr {
    display: flex;
    justify-content: center;
    margin-bottom: 12px;
}
.room-qr canvas {
    border: 4px solid var(--white);
    border-radius: 12px;
    box-shadow: 0 0 20px rgba(255, 234, 167, 0.3);
    max-width: 200px;
    max-height: 200px;
}

.qr-fallback { text-align: center; }
.room-code-display {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.room-code-big {
    font-family: var(--font-display);
    font-size: 3em;
    color: var(--yellow);
}
.room-code-url {
    font-size: 0.8em;
    color: rgba(255,255,255,0.4);
}

/* ========== HOST CONTROLS (Pause/Stop) ========== */

.host-controls {
    display: flex;
    justify-content: center;
    gap: 12px;
    padding: 8px 20px;
    background: rgba(10, 10, 46, 0.6);
}

.btn-control {
    font-family: var(--font-display);
    font-size: 0.85em;
    padding: 8px 20px;
    border-radius: 10px;
    letter-spacing: 1px;
    transition: transform 0.15s, opacity 0.15s;
}

.btn-control:active {
    transform: scale(0.93);
}

.btn-pause {
    background: var(--yellow);
    color: var(--bg-dark);
}

.btn-resume {
    background: var(--green);
    color: white;
}

.btn-stop {
    background: var(--red);
    color: white;
}

.btn-danger {
    background: linear-gradient(135deg, var(--red), #c0392b);
    color: white;
    font-family: var(--font-display);
    font-size: 1.1em;
    padding: 14px 28px;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    letter-spacing: 1px;
}

.btn-danger:active {
    transform: scale(0.95);
}

/* ========== PAUSE OVERLAY ========== */

.pause-content, .stop-confirm-content {
    text-align: center;
    padding: 40px;
}

.pause-icon {
    font-size: 5em;
    margin-bottom: 10px;
    animation: float 2s ease-in-out infinite;
}

.pause-content h2, .stop-confirm-content h2 {
    font-family: var(--font-display);
    font-size: 2.5em;
    color: var(--yellow);
    margin-bottom: 16px;
}

.pause-time {
    font-size: 1.2em;
    color: var(--cyan);
    margin-bottom: 30px;
}

.pause-buttons {
    display: flex;
    flex-direction: column;
    gap: 16px;
    align-items: center;
}

.stop-confirm-content p {
    font-size: 1.1em;
    color: rgba(255,255,255,0.7);
    margin-bottom: 30px;
}

.stop-confirm-buttons {
    display: flex;
    gap: 16px;
    justify-content: center;
    flex-wrap: wrap;
}

/* ========== PAUSE ON PHONE ========== */

.pause-phone {
    text-align: center;
    padding: 40px;
}

.pause-phone .pause-icon {
    font-size: 4em;
}

.pause-phone h2 {
    font-family: var(--font-display);
    font-size: 2em;
    color: var(--yellow);
    margin: 16px 0;
}

.pause-phone p {
    color: var(--cyan);
    font-size: 1.1em;
}

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

@media (max-width: 480px) {
    .game-title { font-size: 2.2em; }
    .room-code-huge { font-size: 3.5em; }
    .food-grid { grid-template-columns: repeat(2, 1fr); gap: 8px; }
    .food-btn-emoji { font-size: 3em; }
    .score-value { font-size: 1.5em; }
    .timer-display { font-size: 2em; }
}

@media (min-width: 768px) and (max-height: 600px) {
    /* Landscape tablet/laptop */
    .table-surface {
        max-width: 90vh;
    }
}

/* ========================================
   Character Picker
   ======================================== */

.character-picker {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    margin: 1rem 0;
    user-select: none;
    -webkit-user-select: none;
}

.char-arrow {
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    width: 48px;
    height: 48px;
    font-size: 2rem;
    color: var(--white);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
}

.char-arrow:hover, .char-arrow:active {
    background: rgba(255, 255, 255, 0.2);
    border-color: var(--cyan);
    color: var(--cyan);
}

.char-preview {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}

.char-image {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid var(--cyan);
    background: var(--bg-medium);
    box-shadow: 0 0 20px rgba(0, 206, 201, 0.3);
    transition: transform 0.2s;
}

.char-image:hover {
    transform: scale(1.05);
}

.char-name {
    font-family: var(--font-display);
    font-size: 1rem;
    color: var(--cyan);
    text-transform: capitalize;
}

/* Player picture thumbnails — small (waiting list, rankings on phone) */
.player-pic-small {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
    vertical-align: middle;
    margin-right: 0.4rem;
    border: 2px solid rgba(255, 255, 255, 0.3);
}

/* Player avatar image in host lobby cards */
.player-avatar-img {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid var(--cyan);
    background: var(--bg-medium);
}

/* Final ranking avatar image (host screen) */
.final-avatar-img {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid rgba(255, 255, 255, 0.3);
    vertical-align: middle;
}

/* Final ranking avatar image (phone screen) */
.final-avatar-phone-img {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid rgba(255, 255, 255, 0.3);
    vertical-align: middle;
}

/* ========================================
   Winner Portrait with Flowers
   ======================================== */

.winner-portrait {
    position: relative;
    display: inline-block;
    margin: 0.5rem auto 0.8rem;
}

.winner-pic {
    width: 140px;
    height: 140px;
    border-radius: 50%;
    object-fit: cover;
    border: 4px solid var(--yellow);
    box-shadow: 0 0 30px rgba(255, 234, 167, 0.5), 0 0 60px rgba(255, 234, 167, 0.2);
    position: relative;
    z-index: 2;
    animation: winner-glow 2s ease-in-out infinite alternate;
}

@keyframes winner-glow {
    from { box-shadow: 0 0 20px rgba(255, 234, 167, 0.4), 0 0 40px rgba(255, 234, 167, 0.15); }
    to   { box-shadow: 0 0 35px rgba(255, 234, 167, 0.7), 0 0 70px rgba(255, 234, 167, 0.3); }
}

.winner-portrait-name {
    font-family: var(--font-display);
    font-size: 1.3rem;
    color: var(--yellow);
    margin-top: 0.3rem;
    text-shadow: 0 0 10px rgba(255, 234, 167, 0.5);
}

/* Flower decorations */
.flower {
    position: absolute;
    font-size: 1.6rem;
    z-index: 1;
    animation: flower-sway 3s ease-in-out infinite alternate;
    filter: drop-shadow(0 0 4px rgba(255, 255, 255, 0.3));
}

.flower-tl { top: -8px;  left: -8px;  animation-delay: 0s; }
.flower-tr { top: -8px;  right: -8px; animation-delay: 0.5s; }
.flower-bl { bottom: 24px; left: -12px; animation-delay: 1s; }
.flower-br { bottom: 24px; right: -12px; animation-delay: 1.5s; }
.flower-l  { top: 50%;  left: -28px; transform: translateY(-50%); animation-delay: 0.3s; }
.flower-r  { top: 50%;  right: -28px; transform: translateY(-50%); animation-delay: 0.8s; }

@keyframes flower-sway {
    from { transform: rotate(-8deg) scale(1); }
    to   { transform: rotate(8deg) scale(1.1); }
}

.flower-l, .flower-r {
    animation-name: flower-sway-side;
}

@keyframes flower-sway-side {
    from { transform: translateY(-50%) rotate(-8deg) scale(1); }
    to   { transform: translateY(-50%) rotate(8deg) scale(1.1); }
}

/* Smaller portrait on phone */
.winner-portrait-phone .winner-pic {
    width: 100px;
    height: 100px;
}

.winner-portrait-phone .flower {
    font-size: 1.2rem;
}

.winner-portrait-phone .winner-portrait-name {
    font-size: 1.1rem;
}

.winner-portrait-phone .flower-l { left: -20px; }
.winner-portrait-phone .flower-r { right: -20px; }
