* {
    position: relative;
}

html, body {
    margin: 0;
    padding: 0;
    width: 100vw;
    height: 100vh;
}

.canvas {
    display: flex;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: #f1f1f1;
    cursor: default;
}

.stage {
    position: relative;
    flex-shrink: 0;
}

#pixelCanvas {
    display: block;
    width: 100%;
    height: 100%;
    image-rendering: pixelated;
    image-rendering: -moz-crisp-edges;
}

#gridOverlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    background-image:
        linear-gradient(to right, rgba(0, 0, 0, 0.15) 1px, transparent 1px),
        linear-gradient(to bottom, rgba(0, 0, 0, 0.15) 1px, transparent 1px);
}

#colorPickerAnchor {
    position: fixed;
    width: 0;
    height: 0;
}

.message-box {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: #333;
    color: #fff;
    padding: 10px 20px;
    border-radius: 4px;
    font-family: sans-serif;
    font-size: 14px;
    z-index: 999999999;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.message-box.visible {
    opacity: 1;
}

.pixel-modal {
    position: fixed;
    display: none;
    background: rgba(255, 255, 255, 0.6);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.4);
    border-radius: 14px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
    padding: 12px;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-size: 13px;
    z-index: 1000;
    width: 270px;
    pointer-events: auto;
}

.pixel-modal::before {
    content: '';
    position: absolute;
    top: -24px;
    left: -24px;
    right: -24px;
    bottom: -24px;
    z-index: -1;
}

.pixel-modal.visible {
    display: block;
}

.pixel-modal img {
    width: 100%;
    height: 100px;
    object-fit: contain;
    background: #fefefe;
    border-radius: 4px;
    margin-bottom: 8px;
}

.pixel-modal-row {
    margin-bottom: 4px;
}

.progress-wrapper {
    position: fixed;
    bottom: 16px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 10px;
    z-index: 1000;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.progress-track {
    width: 220px;
    height: 4px;
    background: #e5e5ea;      /* světle šedá, Apple system gray */
    border-radius: 2px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    width: 0%;
    background: #34c759;      /* Apple system green */
    border-radius: 2px;
    transition: width 0.4s ease;
}

.progress-label {
    font-size: 13px;
    color: #333;
    white-space: nowrap;
    cursor: default;
}

.progress-count {
    font-size: 13px;
    color: #333;
    white-space: nowrap;
    font-variant-numeric: tabular-nums; /* čísla stejné šířky, bar nešije při změně délky */
    cursor: default;
}

.active-color-box {
    position: fixed;
    bottom: 16px;
    left: 16px;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.6);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.4);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    z-index: 1000;
}

.active-color-swatch {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: #ff0000;
    border: 1px solid rgba(0, 0, 0, 0.1);
    flex-shrink: 0;
    cursor: pointer;
}

.active-color-label {
    font-size: 11px;
    color: #555;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    cursor: default;
}

.active-color-hex {
    font-size: 14px;
    color: #111;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    cursor: default;
}

.nickname-box {
    position: fixed;
    top: 16px;
    left: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.6);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.4);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    z-index: 1000;
}

.nickname-input {
    border: none;
    background: rgba(255, 255, 255, 0.6);
    border-radius: 8px;
    padding: 6px 10px;
    font-size: 14px;
    color: #111;
    width: 140px;
    outline: none;
}

.nickname-input:focus {
    background: rgba(255, 255, 255, 0.9);
}

.nickname-set-btn {
    border: none;
    background: #34c759; /* Apple system blue */
    color: #fff;
    font-size: 13px;
    font-weight: 600;
    padding: 6px 14px;
    border-radius: 8px;
    cursor: pointer;
}

.nickname-set-btn:hover {
    background: #288b41;
}

.online-users-box {
    position: fixed;
    bottom: 16px;
    right: 16px;
    padding: 10px 14px;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.6);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.4);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    z-index: 1000;
    text-align: center;
}

.online-users-label {
    font-size: 11px;
    color: #555;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    cursor: default;
}

.online-users-count {
    font-size: 18px;
    font-weight: 600;
    color: #111;
    font-variant-numeric: tabular-nums;
    cursor: default;
}

.contributors-box {
    position: fixed;
    /* top: 16px; */
    top: 190px;
    right: 16px;
    width: 220px;
    padding: 14px;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.6);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.4);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    z-index: 1000;
}

.contributors-title {
    font-size: 11px;
    color: #555;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    margin-bottom: 4px;
}

.contributors-total {
    font-size: 14px;
    font-weight: 600;
    color: #111;
    margin-bottom: 10px;
}

.contributors-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 10px;
}

.contributor-row {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: #333;
}

.contributor-rank {
    color: #888;
    font-variant-numeric: tabular-nums;
    flex-shrink: 0;
    width: 16px;
}

.contributor-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.contributor-count {
    font-variant-numeric: tabular-nums;
    color: #555;
    flex-shrink: 0;
}

.contributors-show-all {
    width: 100%;
    border: none;
    background: #34c759;
    color: #fff;
    font-size: 13px;
    font-weight: 600;
    padding: 8px 0;
    border-radius: 8px;
    cursor: pointer;
}

.contributors-show-all:hover {
    background: #288b41;
}

.all-contributors-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.2);
    display: none;
    z-index: 1999;
}

.all-contributors-modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 360px;
    max-height: 70vh;
    display: none;
    flex-direction: column;
    padding: 16px;
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(255, 255, 255, 0.4);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    z-index: 2000;
}

.all-contributors-overlay.visible,
.all-contributors-modal.visible {
    display: flex;
}

.all-contributors-overlay.visible {
    display: block;
}

.all-contributors-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 15px;
    font-weight: 600;
    color: #111;
    margin-bottom: 12px;
    flex-shrink: 0;
}

.all-contributors-close {
    border: none;
    background: transparent;
    font-size: 20px;
    line-height: 1;
    color: #555;
    cursor: pointer;
    padding: 0 4px;
}

.all-contributors-list {
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.all-contributor-row {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    color: #333;
}

.all-contributor-rank {
    color: #888;
    font-variant-numeric: tabular-nums;
    flex-shrink: 0;
    width: 26px;
}

.all-contributor-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.all-contributor-count {
    font-variant-numeric: tabular-nums;
    color: #555;
    flex-shrink: 0;
}

.avatar-wrapper {
    flex-shrink: 0;
}

.user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
    cursor: pointer;
    border: 1px solid rgba(0, 0, 0, 0.1);
    display: block;
}

.user-avatar:hover {
    opacity: 0.85;
}

.eyedropper-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 8px;
    background: rgba(0, 0, 0, 0.05);
    color: #333;
    cursor: pointer;
    flex-shrink: 0;
    transition: background 0.2s ease;
}

.eyedropper-btn:hover {
    background: rgba(0, 0, 0, 0.1);
}

.eyedropper-btn.active {
    background: #007aff;
    color: #fff;
}

.canvas.eyedropper-mode {
    cursor: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="black" stroke-width="2"><path d="M19.5 4.5a2.5 2.5 0 0 1 0 3.5l-9 9-4 1 1-4 9-9a2.5 2.5 0 0 1 3.5 0Z"/></svg>') 2 22, crosshair;
}

.auth-box {
    position: fixed;
    top: 143px;   /* pod .nickname-box (top: 16px + jeho výška ~50px) */
    left: 16px;
    display: flex;
    gap: 8px;
    padding: 10px 14px;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.6);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.4);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    z-index: 1000;
    flex-direction: column;
}

.auth-btn {
    border: none;
    font-size: 13px;
    font-weight: 600;
    padding: 6px 14px;
    border-radius: 8px;
    cursor: pointer;
}

.auth-btn-primary {
    background: #007aff;
    color: #fff;
}

.auth-btn-primary:hover {
    background: #0066d6;
}

.auth-btn-secondary {
    background: rgba(0, 0, 0, 0.05);
    color: #111;
}

.auth-btn-secondary:hover {
    background: rgba(0, 0, 0, 0.1);
}

.youtube-widget {
    position: fixed;
    top: 16px;
    right: 16px;
    width: 250px;
    border-radius: 14px;
    overflow: hidden;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
    z-index: 999;
}

.youtube-widget iframe {
    display: block;
}
.top-bar {
    position: fixed;
    top: 16px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 10px 14px;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.6);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.4);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    z-index: 1001; /* nad ostatními widgety, aby zůstal i po skrytí GUI */
}

.top-bar-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 8px;
    background: rgba(0, 0, 0, 0.05);
    color: #333;
    cursor: pointer;
}

.top-bar-btn:hover {
    background: rgba(0, 0, 0, 0.1);
}

/* --- přepínač Show/Hide GUI --- */

.gui-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 13px;
    color: #333;
    user-select: none;
}

.gui-toggle input {
    display: none;
}

.gui-toggle-track {
    position: relative;
    width: 36px;
    height: 20px;
    background: rgba(0, 0, 0, 0.15);
    border-radius: 10px;
    transition: background 0.2s ease;
}

.gui-toggle-thumb {
    position: absolute;
    top: 2px;
    left: 2px;
    width: 16px;
    height: 16px;
    background: #fff;
    border-radius: 50%;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
    transition: transform 0.2s ease;
}

.gui-toggle input:checked + .gui-toggle-track {
    background: #34c759;
}

.gui-toggle input:checked + .gui-toggle-track .gui-toggle-thumb {
    transform: translateX(16px);
}

.gui-hidden .gui-element {
    display: none !important;
}

.info-modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 360px;
    max-height: 70vh;
    display: none;
    flex-direction: column;
    padding: 20px;
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(255, 255, 255, 0.4);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    z-index: 2000;
}

.info-modal.visible {
    display: flex;
}

.info-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 15px;
    font-weight: 600;
    color: #111;
    margin-bottom: 12px;
    flex-shrink: 0;
}

.info-modal-body {
    overflow-y: auto;
    text-align: center;
}

.info-modal-logo {
    width: 64px;
    height: 64px;
    border-radius: 16px;
    margin-bottom: 12px;
}

.info-modal-body h2 {
    font-size: 18px;
    margin: 0 0 10px;
    color: #111;
}

.info-modal-body p {
    font-size: 13px;
    line-height: 1.5;
    color: #333;
    margin: 0 0 10px;
    text-align: left;
}

.info-modal-copyright {
    font-size: 11px;
    color: #888;
    text-align: center !important;
    margin-top: 16px;
}

.buy-pixel-modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 300px;
    display: none;
    flex-direction: column;
    padding: 18px;
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(255, 255, 255, 0.4);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    z-index: 2000;
}

.buy-pixel-modal.visible {
    display: flex;
}

.buy-pixel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 15px;
    font-weight: 600;
    color: #111;
    margin-bottom: 14px;
}

.buy-pixel-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 13px;
    color: #333;
    margin-bottom: 8px;
}

.buy-pixel-label {
    color: #666;
}

.buy-pixel-value {
    font-variant-numeric: tabular-nums;
    font-weight: 600;
}

.buy-pixel-color-swatch {
    display: inline-block;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    border: 1px solid rgba(0, 0, 0, 0.1);
}

.buy-pixel-input,
.buy-pixel-textarea {
    width: 100%;
    box-sizing: border-box;
    border: none;
    background: rgba(255, 255, 255, 0.6);
    border-radius: 8px;
    padding: 8px 10px;
    font-size: 13px;
    color: #111;
    font-family: inherit;
    outline: none;
    margin-top: 8px;
    resize: none;
}

.buy-pixel-input:focus,
.buy-pixel-textarea:focus {
    background: rgba(255, 255, 255, 0.9);
}

.buy-pixel-confirm-btn {
    width: 100%;
    border: none;
    background: #007aff;
    color: #fff;
    font-size: 14px;
    font-weight: 600;
    padding: 10px 0;
    border-radius: 10px;
    cursor: pointer;
    margin-top: 14px;
}

.buy-pixel-confirm-btn:hover {
    background: #0066d6;
}

.buy-pixel-color-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    border: none;
    background: transparent;
    cursor: pointer;
    padding: 0;
}

.buy-pixel-color-hex {
    font-size: 13px;
    font-weight: 600;
    color: #111;
    font-variant-numeric: tabular-nums;
}

.buy-pixel-description-wrapper {
    position: relative;
}

.buy-pixel-description-wrapper .buy-pixel-textarea {
    padding-right: 34px; /* místo pro ikonku, ať text nepodtéká pod ni */
}

.emoji-btn {
    position: absolute;
    bottom: 8px;
    right: 6px;
    border: none;
    background: transparent;
    font-size: 16px;
    line-height: 1;
    cursor: pointer;
    padding: 2px;
    border-radius: 4px;
}

.emoji-btn:hover {
    background: rgba(0, 0, 0, 0.06);
}

.emoji-picker {
    position: fixed;
    display: none;
    grid-template-columns: repeat(9, 1fr);
    gap: 4px;
    max-height: 200px;
    overflow-y: auto;
    padding: 10px;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(255, 255, 255, 0.4);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
    z-index: 2100;
    box-sizing: border-box;
}

.emoji-picker.visible {
    display: grid;
}

.emoji-picker button {
    border: none;
    background: transparent;
    font-size: 18px;
    line-height: 1;
    padding: 4px;
    border-radius: 6px;
    cursor: pointer;
}

.emoji-picker button:hover {
    background: rgba(0, 0, 0, 0.08);
}

#pixelHighlight {
    position: absolute;
    display: none;
    pointer-events: none;
    background: rgba(255, 255, 255, 0.3);
    mix-blend-mode: difference; /* zajistí viditelnost na jakékoliv barvě podkladu */
    animation: pixelBlink 3s ease-in-out infinite;
}

#pixelHighlight.visible {
    display: block;
}

@keyframes pixelBlink {
    0%, 100% { opacity: 0.15; }
    50% { opacity: 0.85; }
}

.canvas.select-mode {
    cursor: crosshair;
}

.selection-box {
    position: absolute;
    display: none;
    background: rgba(0, 122, 255, 0.15);
    border: 1px solid rgba(0, 122, 255, 0.6);
    pointer-events: none;
}

.selection-box.visible {
    display: block;
}

#selectionOverlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    image-rendering: pixelated;
    image-rendering: -moz-crisp-edges;
}

#reservationOverlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.reservation-mark {
    position: absolute;
}

.reservation-mark.own {
    background-image: repeating-linear-gradient(
        45deg,
        rgba(0, 180, 0, 0.65) 0px,
        rgba(0, 180, 0, 0.65) 3px,
        transparent 3px,
        transparent 6px
    );
}

.reservation-mark.other {
    background-image: repeating-linear-gradient(
        45deg,
        rgba(220, 0, 0, 0.65) 0px,
        rgba(220, 0, 0, 0.65) 3px,
        transparent 3px,
        transparent 6px
    );
}

.wallet-box {
    position: fixed;
    top: 80px;
    left: 16px;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.6);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.4);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    z-index: 1000;
}

.wallet-balance {
    display: flex;
    flex-direction: column;
}

.wallet-label {
    font-size: 10px;
    color: #666;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.wallet-value {
    font-size: 14px;
    font-weight: 600;
    color: #111;
    font-variant-numeric: tabular-nums;
}

.wallet-buy-btn {
    border: none;
    background: #007aff;
    color: #fff;
    font-size: 13px;
    font-weight: 600;
    padding: 8px 14px;
    border-radius: 8px;
    cursor: pointer;
}

.wallet-buy-btn:hover {
    background: #0066d6;
}

.buy-credit-billing-toggle {
    margin-top: 10px;
    font-size: 13px;
    color: #333;
}

.buy-credit-billing-toggle label {
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
}