body, html {
    margin: 0;
    padding: 0;
    overflow: hidden;
    background-color: #f4f5f7; /* Light background */
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
}

#editor-container {
    width: 100vw;
    height: 100vh;
    position: relative;
    cursor: cell;
}

#editor-container:active {
    cursor: cell;
}

#grid-container {
    position: absolute;
    top: 0;
    left: 0;
    transform-origin: 0 0; /* Zoom from the top-left corner */
}

#grid {
    --cell-size: 30px;
    display: grid;
    user-select: none;
    grid-template-columns: repeat(45, var(--cell-size));
    grid-template-rows: repeat(45, var(--cell-size));
    outline: 1px solid #e0e0e0; /* Lighter grid border */
}

.grid-cell {
    user-select: none;
    position: relative; /* Needed for quadrant container positioning */
    width: var(--cell-size);
    height: var(--cell-size);
    box-sizing: border-box;
    outline: solid 1px #e0e0e0;
    /* border-right: 1px solid #e0e0e0; Visible gray lines */
    /* border-bottom: 1px solid #e0e0e0; Visible gray lines */
    background-color: #ffffff; /* White cells */
}

.major-v-line {
    border-right: 1.5px solid #c0c0c0; /* Bolder vertical line */
}

.major-h-line {
    border-bottom: 1.5px solid #c0c0c0; /* Bolder horizontal line */
}

/* Floating Menu */
#block-menu {
    position: fixed;
    bottom: 4px;
    left: 50%;
    /* width: 400px; */
    /* overflow-x: auto; */
    /* overflow-y: visible; */
    transform: translateX(-50%);
    background-color: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-radius: 12px;
    /* border: 1px solid rgba(0, 0, 0, 0.1); */
    /* padding: 4px; */
    /* padding-top: calc(100vh - 40px); */
    /* padding-bottom: 0px; */
    /* height: 100vh; */
    display: flex;
    align-items: end;
    gap: 5px;
    z-index: 1000;
    /* box-shadow: 0 10px 30px rgba(0,0,0,0.1); */
}

.submenu {
    position: relative;
}

.submenu-header {
    padding: 4px;
    width: 32px; /* Set a fixed width */
    height: 32px; /* Set a fixed height */
    color: #333;
    background-color: rgba(0, 0, 0, 0.05);
    border-radius: 8px;
    cursor: pointer;
    transition: background-color 0.2s ease;
    user-select: none;
    display: flex; /* Use flexbox for centering */
    align-items: center;
    justify-content: center;
    font-size: 24px; /* Smaller font for text fallback */
}

.submenu-header:hover {
    background-color: rgba(0, 0, 0, 0.1);
}

.submenu-header img {
    height: 32px;
    width: 32px;
    object-fit: contain;
}

.submenu-content {
    display: none; /* This ensures menus are closed by default */
    position: absolute;
    bottom: 90%;
    z-index: 1000000;
    left: 50%;
    transform: translateX(-50%);
    margin-bottom: 10px;
    background-color: rgba(250, 250, 250, 0.98);
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 8px;
    padding: 8px;
    width: 240px;
    box-shadow: 0 -5px 20px rgba(0,0,0,0.1);
    max-height: 200px;
    overflow-y: auto;
    gap: 8px;
}

@media (max-width: 800px) {
    .submenu-content {
        position: fixed;
        transform: none;
        left: calc(50% - 120px);
    }
}

.submenu.active .submenu-content {
    grid-template-columns: repeat(auto-fill, 30px);
    justify-content: space-between;
    display: grid;
}

.submenu-item {
    padding: 0; /* Remove padding for image items */
    cursor: pointer;
    /* border-radius: 4px; */
    transition: background-color 0.2s ease;
    height: 32px;
    width: 32px;
    /* width: 100%; */
    /* aspect-ratio: 1 / 1; Make items square */
    /* object-fit: contain; Ensure image fits well */
}

.submenu-item:hover {
    background-color: rgba(0, 0, 0, 0.08);
}

.grid-cell:hover {
    /* : solid 2px #9e9e9e; */
    background-color: #e9e9e9;
}

.submenu-item.selected-block {
    /* box-shadow: #055ebee7 0px 0px 4px 0px; */
    background-color: rgba(169, 169, 169, 0.404);
    box-sizing: border-box;
    outline: 3px dashed rgb(116, 116, 116);
}

.color-swatch {
    width: 30px;
    height: 30px;
    border-radius: 4px;
    cursor: pointer;
    border: 1px solid rgba(0,0,0,0.1);
    transition: all 0.2s ease;
}

.color-swatch.selected-block {
    border-color: #007bff;
    transform: scale(1.1);
}

.quadrant-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 1fr 1fr;
}

.quadrant {
    width: 100%;
    height: 100%;
    box-sizing: border-box;
}

.brush-active .quadrant {
    oueline: 1px solid #eee;
    /* border-bottom: 1px solid #eee; */
}

.brush-active .grid-cell .quadrant:hover {
    background-color: rgba(0, 0, 0, 0.1);
}

.rotation-container {
    grid-column: 1 / -1;
    display: flex;
    gap: 8px;
    /* padding: 8px; */
    border-radius: 6px;
    margin-top: 8px;
}

.rotate-btn {
    flex: 1;
    padding: 4px;
    font-size: 18px;
    background-color: #fff;
    border: 1px solid #ccc;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.rotate-btn:hover {
    background-color: #f0f0f0;
}

/* Property Editor */
#property-editor {
    position: fixed;
    left: 20px;
    top: 50%;
    transform: translateY(-50%);
    width: 220px;
    background-color: #fff;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.15);
    border: 1px solid rgba(0, 0, 0, 0.1);
    padding: 16px;
    z-index: 1100;
    transition: opacity 0.2s ease, transform 0.2s ease;
}

#property-editor.hidden {
    opacity: 0;
    pointer-events: none;
    transform: translateY(-50%) scale(0.95);
}

#property-editor h3 {
    margin-top: 0;
    font-size: 16px;
    border-bottom: 1px solid #eee;
    padding-bottom: 8px;
    margin-bottom: 16px;
}

#property-fields .property-row {
    margin-bottom: 12px;
}

#property-fields label {
    display: block;
    font-size: 12px;
    margin-bottom: 4px;
    color: #555;
}

#property-fields input {
    width: 100%;
    padding: 8px;
    border: 1px solid #ccc;
    border-radius: 4px;
    box-sizing: border-box;
}

#property-editor .editor-buttons {
    display: flex;
    gap: 8px;
    margin-top: 16px;
}

#property-editor .editor-buttons button {
    flex: 1;
    padding: 10px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 500;
}

#save-props-btn {
    background-color: #007bff;
    color: white;
}

#cancel-props-btn {
    background-color: #eee;
}

/* 타이머 컨테이너 스타일 */
.timer-container {
    background: rgba(255, 255, 255, 0.757);
    backdrop-filter: blur(4px);
    transition-duration: 0.2s;
    justify-content: center;
    border-radius: 1000px;
    margin-bottom: 2rem;
    align-items: center;
    position: fixed;
    display: flex;
    /* display: none; */
    height: 56px;
    width: 56px;
    left: 10px;
    top: 10px;
}

/* 남은 시간 표시 스타일 */
.timer-display {
    position: absolute;
    font-size: 18px;
    color: #272727;
    z-index: 1;
}

/* 타이머 프로그레스 바 (SVG) 스타일 */
.timer-progress {
    position: absolute;
    width: 54px;
    height: 54px;
    /* 시계 방향으로 시작하도록 -90도 회전 */
    transform: rotate(-90deg);
}

.progress-bg {
    fill: none;
    stroke: #485460;
    stroke-width: 0;
}

.progress-bar {
    fill: none;
    stroke: #00388b;
    stroke-width: 4;
    stroke-linecap: round;
    transition: stroke-dashoffset 0.1s linear, stroke 0.5s;
}

#chats {
    /* border: solid 1px rgba(141, 141, 141, 0.295); */
    /* background-color: #ffffff35; */
    /* backdrop-filter: blur(4px); */
    height: calc(100vh - 20px);
    border-radius: 16px;
    overflow-y: auto;
    position: fixed;
    padding: 8px;
    width: 280px;
    right: 16px;
    top: 16px;
}

#chats::-webkit-scrollbar {
    display: none;
}

.chat {
    border: solid 1px rgba(141, 141, 141, 0.295);
    background-color: #ffffff35;
    backdrop-filter: blur(4px);
    word-break: break-all;
    
    border-radius: 8px;
    display: grid;
    padding: 8px;
    gap: 8px;
}

#thread>.chat {
    margin-top: 8px;
}

.chat>*:nth-child(1), #nicknamefield {
    font-size: 12px;
    display: block;
    color: #555;
    outline: none;
    border: none;
}

.chat>*:nth-child(2) {
    width: 264px;
    outline: none;
    border: none;
    resize: none;
}

.chat>*:nth-child(3) {
    font-size: 12px;
    display: block;
    color: #555;
    border: none;
}

#sendchat {
    width: 264px;
}

.flat {
    transition-duration: 0.3s;
    transform: scaleY(0);
    overflow: hidden;
    opacity: 0.0;
    height: 0px;
}

.expanded {
    transition-timing-function: cubic-bezier(0.25, 0.46, 0.45, 0.94);
    transition-duration: 0.3s;
    transform: scaleY(1);
    height: auto;
    overflow: hidden;
    opacity: 1.0;
}

@media (max-width: 800px) {
    #chats {
        width: 150px;
    }
    #sendchat {
        width: 134px;
    }
    .chat>*:nth-child(1) {
        width: 134px;
    }
    .chat>*:nth-child(2) {
        width: 134px;
        outline: none;
        border: none;
        resize: none;
    }
}