* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    color: white;
    overflow-x: hidden;
}

.container {
    max-width: 500px;
    margin: 0 auto;
    padding: 20px;
    min-height: calc(100vh - 60px);
    display: flex;
    flex-direction: column;
}

/* Screens */
.screen {
    display: none;
    flex: 1;
}

.screen.active {
    display: flex;
    flex-direction: column;
}

/* Buttons */
button, .btn-primary, .btn-secondary {
    padding: 15px 25px;
    border: none;
    border-radius: 10px;
    font-size: 1.1rem;
    font-weight: bold;
    cursor: pointer;
    transition: transform 0.2s, opacity 0.2s;
    width: 100%;
    margin: 5px 0;
}

button:active {
    transform: scale(0.98);
}

button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-primary {
    background: #4CAF50;
    color: white;
}

.btn-secondary {
    background: #ff9800;
    color: white;
}

/* Join Screen */
.join-form {
    background: rgba(255,255,255,0.15);
    border-radius: 20px;
    padding: 25px;
    margin-top: 10px;
}

.join-ad {
    margin-top: 14px;
    border-radius: 16px;
    background: rgba(255,255,255,0.12);
    border: 1px solid rgba(255,255,255,0.22);
    padding: 12px;
}

.join-ad-link {
    display: block;
    color: inherit;
    text-decoration: none;
}

.join-ad-link:active {
    transform: scale(0.99);
}

.join-ad-label {
    font-size: 0.85rem;
    letter-spacing: 0.4px;
    text-transform: uppercase;
    opacity: 0.85;
    margin-bottom: 8px;
}

.join-ad-body {
    display: grid;
    grid-template-columns: 90px 1fr;
    gap: 12px;
    align-items: center;
}

.join-ad-image {
    width: 90px;
    height: 90px;
    border-radius: 12px;
    object-fit: cover;
    background: rgba(255,255,255,0.9);
}

.join-ad-text {
    font-size: 1rem;
    line-height: 1.25rem;
    font-weight: 600;
    color: rgba(255,255,255,0.95);
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: bold;
}

input[type="text"] {
    width: 100%;
    padding: 15px;
    border: none;
    border-radius: 10px;
    font-size: 1.1rem;
    text-align: center;
}

#gameCode {
    text-transform: uppercase;
    letter-spacing: 3px;
}

.error-message {
    background: rgba(244, 67, 54, 0.8);
    padding: 12px;
    border-radius: 8px;
    text-align: center;
    margin-bottom: 15px;
    display: none;
}

/* Avatar Section */
.avatar-section {
    margin: 20px 0;
    text-align: center;
}

.avatar-section label {
    display: block;
    margin-bottom: 10px;
    font-weight: bold;
}

.avatar-preview {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    background: white;
    margin: 0 auto 15px;
    overflow: hidden;
    border: 4px solid rgba(255,255,255,0.5);
}

.avatar-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.avatar-buttons {
    display: flex;
    gap: 10px;
}

.avatar-buttons button {
    flex: 1;
    padding: 12px;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.85);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: white;
    border-radius: 20px;
    padding: 20px;
    width: 90%;
    max-width: 350px;
    color: #333;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.modal-header h3 {
    font-size: 1.2rem;
}

.close-btn {
    background: none;
    border: none;
    font-size: 1.8rem;
    cursor: pointer;
    width: auto;
    padding: 0;
    line-height: 1;
}

.avatar-canvas-container {
    width: 100%;
    aspect-ratio: 1;
    border-radius: 50%;
    overflow: hidden;
    border: 3px solid #ddd;
    margin-bottom: 15px;
}

#avatarDrawingCanvas {
    width: 100%;
    height: 100%;
    cursor: crosshair;
    touch-action: none;
}

.modal-actions {
    display: flex;
    gap: 10px;
}

.modal-actions button {
    flex: 1;
}

/* Color Palette & Brush Sizes */
.color-palette {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 12px;
    justify-content: center;
}

.color-btn {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    border: 2px solid transparent;
    cursor: pointer;
    padding: 0;
}

.color-btn.active {
    border-color: #333;
    transform: scale(1.15);
}

.brush-sizes {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
    justify-content: center;
}

.brush-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: #f0f0f0;
    border: 2px solid transparent;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    padding: 0;
}

.brush-btn.active {
    border-color: #333;
}

.brush-btn span {
    border-radius: 50%;
    background: #333;
}

/* Waiting Screen */
.waiting-screen {
    text-align: center;
    justify-content: center;
    align-items: center;
}

.waiting-avatar {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    background: white;
    margin: 0 auto 20px;
    overflow: hidden;
}

.waiting-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.waiting-name {
    font-size: 1.8rem;
    margin-bottom: 20px;
}

.waiting-message {
    font-size: 1.1rem;
    opacity: 0.9;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 0.6; }
    50% { opacity: 1; }
}

/* Question Screen */
.question-screen, .type-answer-screen {
    text-align: center;
}

.question-info {
    margin-bottom: 15px;
    font-size: 1rem;
    opacity: 0.9;
}

.question-text {
    font-size: 1.2rem;
    background: rgba(255,255,255,0.15);
    padding: 20px;
    border-radius: 15px;
    margin-bottom: 20px;
}

.question-image-wrap {
    background: rgba(255,255,255,0.15);
    border-radius: 15px;
    padding: 12px;
    margin-bottom: 20px;
}

.question-image {
    width: 100%;
    max-height: 220px;
    object-fit: contain;
    display: block;
    border-radius: 10px;
}

.options-container {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    flex: 1;
}

.option-btn {
    padding: 20px 12px;
    border: none;
    border-radius: 12px;
    font-size: 1rem;
    font-weight: bold;
    color: white;
    cursor: pointer;
    transition: transform 0.2s, opacity 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    word-break: break-word;
    min-height: 80px;
}

.option-btn:active {
    transform: scale(0.95);
}

.option-btn.red { background: #e21b3c; }
.option-btn.blue { background: #1368ce; }
.option-btn.yellow { background: #d89e00; }
.option-btn.green { background: #26890c; }

.option-btn.selected {
    opacity: 0.7;
    transform: scale(0.95);
    box-shadow: inset 0 0 15px rgba(0,0,0,0.3);
}

.option-btn:disabled {
    cursor: not-allowed;
}

/* Type Answer */
.type-answer-form {
    margin-top: 20px;
}

.type-answer-form input {
    margin-bottom: 15px;
}

/* Draw Screen */
.draw-screen {
    text-align: center;
}

.draw-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.draw-header h2 {
    font-size: 1.2rem;
}

.draw-timer, .vote-timer {
    background: rgba(255,255,255,0.2);
    padding: 10px 15px;
    border-radius: 50%;
    font-size: 1.5rem;
    font-weight: bold;
    min-width: 50px;
}

.draw-canvas-container {
    background: white;
    border-radius: 15px;
    overflow: hidden;
    margin-bottom: 15px;
    aspect-ratio: 1;
}

#gameDrawingCanvas {
    width: 100%;
    height: 100%;
    cursor: crosshair;
    touch-action: none;
}

.draw-tools {
    background: rgba(255,255,255,0.1);
    padding: 15px;
    border-radius: 15px;
}

.draw-actions {
    display: flex;
    gap: 10px;
    margin-top: 10px;
}

.draw-actions button {
    flex: 1;
}

/* Vote Screen */
.vote-screen {
    text-align: center;
}

.vote-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.vote-header h2 {
    font-size: 1.3rem;
}

.vote-prompt {
    font-size: 1rem;
    opacity: 0.9;
    margin-bottom: 15px;
}

.vote-gallery {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    flex: 1;
    overflow-y: auto;
}

.vote-card {
    background: rgba(255,255,255,0.15);
    border-radius: 12px;
    padding: 10px;
    cursor: pointer;
    transition: transform 0.2s, border 0.2s;
    border: 3px solid transparent;
}

.vote-card:active {
    transform: scale(0.98);
}

.vote-card.selected {
    border-color: #4CAF50;
    background: rgba(76, 175, 80, 0.3);
}

.vote-card img {
    width: 100%;
    aspect-ratio: 1;
    object-fit: contain;
    background: white;
    border-radius: 8px;
}

.vote-card .artist {
    margin-top: 8px;
    font-size: 0.9rem;
    font-weight: bold;
}

/* Submitted Screens */
.answer-submitted {
    text-align: center;
    justify-content: center;
    align-items: center;
}

.submitted-icon {
    font-size: 4rem;
    margin-bottom: 20px;
}

.submitted-message {
    font-size: 1.5rem;
    margin-bottom: 10px;
}

.waiting-others {
    opacity: 0.8;
    animation: pulse 2s infinite;
}

/* Result Screen */
.result-screen {
    text-align: center;
    justify-content: center;
    align-items: center;
}

.result-icon {
    font-size: 5rem;
    margin-bottom: 15px;
}

.result-text {
    font-size: 2rem;
    margin-bottom: 10px;
}

.points-text {
    font-size: 1.4rem;
    opacity: 0.9;
}

.score-text {
    font-size: 1.1rem;
    margin-top: 20px;
    background: rgba(255,255,255,0.2);
    padding: 12px 25px;
    border-radius: 10px;
}

/* Game Over */
.game-over-screen {
    text-align: center;
}

.game-over-screen h2 {
    font-size: 2rem;
    margin-bottom: 15px;
}

.final-position {
    font-size: 3.5rem;
    margin: 15px 0;
}

.final-score {
    font-size: 1.5rem;
    margin-bottom: 20px;
}

.podium {
    display: flex;
    justify-content: center;
    align-items: flex-end;
    gap: 8px;
    margin: 20px 0;
}

.podium-place {
    text-align: center;
    padding: 10px;
    border-radius: 10px 10px 0 0;
    min-width: 80px;
}

.podium-place.first {
    background: linear-gradient(to top, #ffd700, #ffed4a);
    color: #333;
    min-height: 120px;
    order: 2;
}

.podium-place.second {
    background: linear-gradient(to top, #c0c0c0, #e0e0e0);
    color: #333;
    min-height: 90px;
    order: 1;
}

.podium-place.third {
    background: linear-gradient(to top, #cd7f32, #daa520);
    color: white;
    min-height: 60px;
    order: 3;
}

.podium-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: white;
    margin: 0 auto 5px;
    overflow: hidden;
}

.podium-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.podium-name {
    font-weight: bold;
    font-size: 0.8rem;
}

/* Disconnected */
.disconnected-screen {
    text-align: center;
    justify-content: center;
    align-items: center;
}

.disconnected-icon {
    font-size: 4rem;
    margin-bottom: 15px;
}

.disconnected-text {
    font-size: 1.5rem;
    margin-bottom: 10px;
}

.disconnected-sub {
    opacity: 0.8;
    margin-bottom: 25px;
}
