/* ============================================================
   GLOBALS
============================================================ */
body {
    font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
    text-align: center;
    background-color: #0a0a0a;
    background-image:
        linear-gradient(45deg,  #111 25%, transparent 25%),
        linear-gradient(-45deg, #111 25%, transparent 25%),
        linear-gradient(45deg,  transparent 75%, #111 75%),
        linear-gradient(-45deg, transparent 75%, #111 75%);
    background-size: 80px 80px;
    background-position: 0 0, 0 40px, 40px -40px, -40px 0px;
    color: #e5e5e5;
    margin: 0;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
}

h3 {
    font-family: "Georgia", "Times New Roman", serif;
    text-transform: uppercase;
    letter-spacing: 3px;
    color: #000;
    font-weight: 900;
    font-size: 1.5rem;
    margin-bottom: 25px;
}

.screen { display: none; animation: fadeIn 0.4s ease-out; }
.subtitle { color: #888; font-size: 0.85rem; margin: 0 0 10px; }
.prompt-label { font-weight: bold; color: #3399cc; margin-bottom: 10px; }

/* ============================================================
   PANELS
============================================================ */
.section {
    background: #f0f0f0;
    padding: 35px 25px;
    width: 92vw;
    max-width: 420px;
    border-radius: 28px;
    border: 1px solid rgba(255,255,255,0.1);
    box-shadow: 0 30px 60px rgba(0,0,0,0.5);
    box-sizing: border-box;
    color: #333;
}

#emote-screen.section {
    position: relative;
    margin-top: 50px;
    padding-top: 30px;
    z-index: 0;
}

/* ============================================================
   BUTTONS — minimal base, .btn for primary style
============================================================ */
button, .custom-btn-label {
    font-family: "Georgia", "Times New Roman", serif;
    text-transform: uppercase;
    letter-spacing: 2px;
    cursor: pointer;
    border: none;
    outline: none;
    transition: all 0.2s ease;
    background: none;
    color: inherit;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
}
button:active { transform: translateY(1px); }

/* Primary dark action button — add .btn class in HTML to opt in */
.btn, .custom-btn-label {
    padding: 14px 28px;
    font-size: 0.9rem;
    font-weight: 700;
    border-radius: 14px;
    background: linear-gradient(135deg, #222 0%, #000 100%);
    color: #fff;
    text-decoration: none;
    margin: 10px;
    display: inline-block;
}
.btn:hover, .custom-btn-label:hover { transform: translateY(-2px); filter: brightness(1.2); }
.btn:active { transform: translateY(1px); filter: none; }

.btn-secondary { background: linear-gradient(135deg, #444 0%, #222 100%); }
.btn-confirm   { background: linear-gradient(135deg, #3964f4 0%, #0c25e1 100%); color: #000; }
.btn-full      { width: 85%; margin: 0 auto; display: block; }

/* Hold-to-confirm */
.hold-to-confirm {
    position: relative;
    overflow: hidden;
    background: #444;
    user-select: none;
    -webkit-user-select: none;
}
.btn-fill {
    position: absolute;
    top: 0; left: 0;
    width: 0%;
    height: 100%;
    background: linear-gradient(135deg, #3964f4 0%, #0c25e1 100%);
    transition: width 0.1s linear;
    z-index: 1;
}
.btn-text {
    position: relative;
    z-index: 2;
    pointer-events: none;
}

/* ============================================================
   LAYOUT UTILITIES
============================================================ */
.btn-row {
    display: flex;
    gap: 10px;
    justify-content: center;
    align-items: center;
}

.action-buttons {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    margin-top: 20px;
}

hr.divider { border: 0; border-top: 1px solid #eee; margin-bottom: 20px; }

/* ============================================================
   INPUTS
============================================================ */
input[type="text"],
input[type="password"] {
    padding: 14px;
    border-radius: 12px;
    border: 1px solid #eee;
    width: 85%;
    font-size: 1rem;
    text-align: center;
    background: #fdfdfd;
    color: #000;
    margin-bottom: 10px;
    box-sizing: border-box;
}

/* Chat input overrides — rounder, slightly different border */
#chatInput { border-radius: 20px; border: 2px solid #ddd; }

/* ============================================================
   TABS
============================================================ */
.tab-container {
    position: absolute;
    top: -40px;
    left: 30px;
    display: flex;
    gap: 3px;
    z-index: -1;
    margin-bottom: -15px;
}
.tab-btn {
    padding: 12px 35px;
    border-radius: 15px 15px 0 0;
    font-weight: bold;
    background: #787878;
    color: #353535;
    z-index: -1;
}
.tab-btn.active {
    background: #f0f0f0;
    color: #000;
    padding-bottom: 15px;
    margin-top: -5px;
}

/* ============================================================
   DRAW TOOLBAR
============================================================ */
.drawing-controls-row {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 4px;
    background: #fff;
    padding: 6px 8px;
    border-radius: 12px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.1);
    margin: 10px auto 20px auto;
    width: fit-content;
    max-width: 95%;
}

.tool-btn {
    background: #fff;
    border: 2px solid #eee;
    border-radius: 6px;
    width: 28px;
    height: 28px;
    flex-shrink: 0;
    padding: 0;
}
.tool-btn:hover  { background: #e8e8e8; border-color: #aaa; }
.tool-btn.active { background: #f0fefb; border: 3px solid #0084ff; color: #000; }

.emoji-icon { font-size: 1.1rem; line-height: 1; }

.toolbar-divider { width: 1px; height: 22px; background: #ddd; }

.color-swatch {
    width: 28px;
    height: 28px;
    border-radius: 6px;
    border: 2px solid #eee;
    overflow: hidden;
    position: relative;
    cursor: pointer;
    flex-shrink: 0;
    display: block;
}
.color-swatch input[type="color"] {
    position: absolute;
    width: 200%;
    height: 200%;
    top: -50%;
    left: -50%;
    border: none;
    padding: 0;
    cursor: pointer;
}

.brush-slider {
    width: 60px;
    accent-color: #000;
    cursor: pointer;
    margin: 0 4px;
}

/* ============================================================
   CANVASES (crop, draw, received images)
============================================================ */
.crop-container, #receivedImage, #receivedDrawing {
    border-radius: 18px;
    border: 8px solid #fff;
}
#cropCanvas { width: 100%; height: 100%; object-fit: cover; display: block; }

/* ---- Pixelation preview overlay ---- */
.crop-preview-wrap { position: relative; }

#pixelPreviewCanvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    border-radius: 12px;
    image-rendering: pixelated;
    touch-action: none;
    transition: opacity 0.1s;
}

.preview-hint {
    position: absolute;
    bottom: 12px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.7rem;
    color: #fff;
    opacity: 0.6;
    pointer-events: none;
    margin: 0;
    text-shadow: 0 1px 3px rgba(0,0,0,0.8);
    white-space: nowrap;
}

/* ---- StepSlider component ---- */
.step-slider {
    margin: 14px 0 8px;
    text-align: center;
}
.step-slider__label {
    font-size: 0.85rem;
    margin-bottom: 6px;
    color: #006dd2;
    font-weight: 600;
}
.step-slider__track {
    width: 100%;
    accent-color: #0084ff;
    cursor: pointer;
}

#receivedImage, #receivedDrawing { max-width: 90%; margin-bottom: 15px; }

/* ============================================================
   JUDGE SCREEN
============================================================ */
#options-container {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 20px;
}

.judge-option {
    width: 100px;
    height: 100px;
    border: 4px solid #eee;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    object-fit: cover;
}
.judge-option.selected { border-color: #005eff; transform: scale(1.05); }

.option-wrapper { position: relative; display: inline-block; }
.option-wrapper.selected::after {
    content: '✓';
    position: absolute;
    top: -5px; right: -5px;
    background: #005eff;
    color: #000;
    width: 24px; height: 24px;
    border-radius: 50%;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    border: 2px solid #fff;
}

/* ============================================================
   EMOTES TAB
============================================================ */
#emote-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    margin: 20px 0;
    width: 100%;
}
#emote-grid button {
    margin: 0;
    padding: 0;
    width: 100%;
    aspect-ratio: 1;
    font-size: 1.4rem;
    border-radius: 12px;
    background: #f5f5f5;
    color: #000;
}

#chat-input-wrap { margin-bottom: 20px; }

.vote-btn {
    width: 55px;
    height: 55px;
    border-radius: 50%;
    background: #f5f5f5;
    color: #000;
    border: 1px solid #ddd;
}
.vote-btn.active { background: #000; color: #fff; }

/* ============================================================
   JOYSTICK
============================================================ */
#joystick-container {
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 30px auto 10px auto;
}
#joystick-base {
    width: 150px;
    height: 150px;
    background: #b4b0b0;
    border-radius: 50%;
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
}
#joystick-handle {
    width: 60px;
    height: 60px;
    background: radial-gradient(circle at 30% 30%, #444, #000);
    border-radius: 50%;
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
}

/* ============================================================
   FACE CANVAS SECTION
============================================================ */
.drawing-section {
    margin-top: 30px;
    border-top: 1px solid #eee;
    padding-top: 20px;
}
.drawing-row {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-bottom: 10px;
}
.canvas-group {
    display: flex;
    flex-direction: column;
    align-items: center;
}
.paint-canvas {
    background: #e5e5e5;
    border: 2px solid #333;
    border-radius: 12px;
    cursor: crosshair;
    touch-action: none;
    width: 120px;
    height: 120px;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
}
.canvas-label {
    font-family: "Georgia", serif;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: #666;
    margin-bottom: 5px;
}
.canvas-btn-row { display: flex; gap: 4px; margin-top: 5px; }

.clear-btn {
    padding: 5px 10px;
    font-size: 0.6rem;
    margin-top: 5px;
    background: #eee;
    color: #333;
    border-radius: 8px;
}

.face-canvas-toolbar {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
}
.face-color-history {
    display: flex;
    gap: 5px;
    align-items: center;
}
.face-color-chip {
    width: 22px;
    height: 22px;
    border-radius: 5px;
    border: 2px solid #ccc;
    cursor: pointer;
    padding: 0;
    flex-shrink: 0;
    transition: transform 0.1s, border-color 0.1s;
}
.face-color-chip:hover { transform: scale(1.2); border-color: #888; }
.face-tool-btn {
    background: #f5f5f5;
    color: #333;
    padding: 5px 12px;
    font-size: 1rem;
    border-radius: 8px;
    border: 2px solid #ddd;
    line-height: 1;
}
.face-tool-btn:hover { background: #e0e0e0; }
#flipEyeBtn.active { background: #000; color: #fff; border-color: #005eff; }

/* ============================================================
   CHARACTER CUSTOMIZATION
============================================================ */
.adj-btn {
    background: #000;
    color: #fff;
    border-radius: 5px;
    width: 30px;
    height: 30px;
    font-size: 1.2rem;
}
.adj-btn:active { transform: scale(0.9); }

.val-display {
    font-family: monospace;
    font-weight: bold;
    font-size: 1.1rem;
    color: #333;
}

/* ============================================================
   SPINNER
============================================================ */
.spinner {
    margin: 20px auto;
    width: 40px;
    height: 40px;
    border: 4px solid #005eff;
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

/* ============================================================
   PICTO STUDIO SCREEN
============================================================ */

/* Outer clip — replaces border/radius that was on .crop-container */
.picto-viewport {
    box-sizing: border-box;
    border-radius: 18px;
    border: 8px solid #fff;
    overflow: hidden;
    position: relative;
    touch-action: none;
    aspect-ratio: 1 / 1;
    width: 100%;
}

/* Transform target for zoom/pan */
.picto-canvas-wrap {
    background: #fff;
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0; left: 0;
    transform-origin: 0 0;
    will-change: transform;
}

#pictoCanvas {
    width: 100%;
    height: 100%;
    display: block;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
    cursor: crosshair;
    touch-action: none;
}

/* Zoom controls row */
.picto-zoom-controls {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    margin: 8px auto 0;
}
.picto-zoom-btn {
    background: #fff;
    border: 2px solid #ccc;
    border-radius: 8px;
    width: 36px; height: 36px;
    font-size: 1.2rem;
    font-weight: bold;
    cursor: pointer;
    line-height: 1;
}
.picto-zoom-reset { min-width: 48px; font-size: 0.85rem; font-family: monospace; }
.picto-zoom-divider { width: 1px; height: 24px; background: #ccc; margin: 0 2px; }
.picto-zoom-btn.active { background: #333; color: #fff; border-color: #333; }

/* Dot characters for size buttons — larger than emoji-icon default */
.picto-dot { font-size: 1.3rem; line-height: 1; }

/* ============================================================
   PICTO UPLOAD PREVIEW OVERLAY
============================================================ */
#pictoUploadPreview {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.88);
    z-index: 200;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

/* ============================================================
   MOBILE — scale everything down for small phone viewports
   Targets phones up to ~430px wide or ~820px tall (portrait)
============================================================ */
@media (max-width: 430px), (max-height: 820px) {
    /* Card */
    .section          { padding: 22px 16px; }
    #emote-screen.section { margin-top: 28px; padding-top: 18px; }

    /* Headings */
    h3 { font-size: 1.1rem; margin-bottom: 14px; }

    /* Tabs */
    .tab-container    { top: -30px; left: 16px; gap: 2px; }
    .tab-btn          { padding: 7px 18px; font-size: 0.72rem; border-radius: 11px 11px 0 0; }
    .tab-btn.active   { padding-bottom: 11px; margin-top: -4px; }

    /* Emote grid */
    #emote-grid       { gap: 8px; margin: 10px 0 14px; }
    #emote-grid button { font-size: 1.15rem; border-radius: 10px; }

    /* Chat */
    #chatInput        { padding: 9px 14px; font-size: 0.88rem; }
    #chat-container   { margin-bottom: 12px; }

    /* Joystick */
    #joystick-container { margin: 14px auto 4px; }
    #joystick-base    { width: 110px; height: 110px; }
    #joystick-handle  { width: 44px; height: 44px; }

    /* Primary buttons */
    .btn, .custom-btn-label { padding: 11px 20px; font-size: 0.82rem; }
}

/* ============================================================
   PICTO HSV COLOR PICKER PANEL
============================================================ */
#colorPickerPanel {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.88);
    z-index: 300;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    box-sizing: border-box;
}
.color-panel-card {
    background: #f0f0f0;
    border-radius: 22px;
    padding: 20px 18px 16px;
    width: 100%;
    max-width: 320px;
    box-shadow: 0 30px 60px rgba(0, 0, 0, 0.6);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    box-sizing: border-box;
}
.color-panel-title {
    font-family: "Georgia", "Times New Roman", serif;
    text-transform: uppercase;
    letter-spacing: 3px;
    font-weight: 900;
    font-size: 1rem;
    color: #111;
    margin: 0;
}
.color-wheel-canvas {
    width: 260px;
    height: 260px;
    cursor: crosshair;
    touch-action: none;
    display: block;
}
.color-panel-preview-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
}
.color-panel-preview-swatch {
    width: 44px;
    height: 44px;
    border-radius: 10px;
    border: 3px solid #ccc;
    background: #000;
}
.color-history-row {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    justify-content: center;
    width: 100%;
    min-height: 30px;
}
.color-history-chip {
    width: 26px;
    height: 26px;
    border-radius: 6px;
    border: 2px solid #ccc;
    cursor: pointer;
    padding: 0;
    flex-shrink: 0;
    transition: transform 0.1s, border-color 0.1s;
}
.color-history-chip:hover {
    transform: scale(1.2);
    border-color: #555;
}

@media (max-width: 430px), (max-height: 820px) {
    .color-wheel-canvas { width: 220px; height: 220px; }
    .color-panel-card   { padding: 16px 14px 12px; gap: 10px; }
}

/* ============================================================
   ANIMATIONS
============================================================ */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to   { opacity: 1; transform: translateY(0); }
}
@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ============================================================
   LOBBY JOIN SCREEN
============================================================ */
.lobby-error {
    color: #cc3300;
    font-size: 0.85rem;
    margin: 4px 0 8px;
    background: #fff0ee;
    border-radius: 8px;
    padding: 8px 12px;
    width: 85%;
    margin-left: auto;
    margin-right: auto;
    box-sizing: border-box;
}
