@font-face {
    font-family: 'Pixelify Sans';
    src: url('./fonts/PixelifySans-Regular.woff2') format('woff2');
    font-weight: normal;
    font-style: normal;
    font-display: swap;
}

:root {
    --bg-color: #222222;       
    --grid-gap-color: #444444; 
    --cell-black: #070707;     
    --cell-white: #eeeeee;     
    --text-color: #ffffff;
    /* 新增变量用于控制按钮和面板尺寸 */
    --footer-height: 48px; 
    --footer-height-inner: 36px;
}

body {
    margin: 0;
    padding: 0;
    width: 100vw;
    height: 100vh;
    overflow: hidden;
    background-color: var(--bg-color);
    font-family: "Pixelify Sans", 'Segoe UI', sans-serif;
    color: var(--text-color);
    cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='32' height='32'%3E%3Ccircle cx='16' cy='16' r='10' fill='white' fill-opacity='0.3'/%3E%3Ccircle cx='16' cy='16' r='5' fill='white'/%3E%3C/svg%3E") 16 16, auto;
    user-select: none;
    -webkit-user-select: none;
}

body.grabbing {
    cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='32' height='32'%3E%3Ccircle cx='16' cy='16' r='10' fill='white' fill-opacity='0.3'/%3E%3Ccircle cx='16' cy='16' r='5' fill='white'/%3E%3C/svg%3E") 16 16, auto;
}

.cursor-click {
    cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='32' height='32'%3E%3Ccircle cx='16' cy='16' r='8' fill='white' fill-opacity='0.3'/%3E%3Ccircle cx='16' cy='16' r='3' fill='white'/%3E%3C/svg%3E") 16 16, auto !important;
    transition: transform 0.1s ease;
}

/* --- 毛玻璃 UI 组件 --- */
.glass-panel {
    position: fixed;
    z-index: 100;
    padding: 12px 24px;
    background: rgba(30, 30, 30, 0.65);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 50px;
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.5);
    text-align: center;
    pointer-events: auto;
    /* 保持基础过渡 */
    transition: opacity 0.3s, transform 0.3s;
}

/* 默认居中样式只给顶部和底部（左侧定位的） */
.header-ui, .footer-ui:not(#settings-button) {
    left: 50%;
    transform: translateX(-50%);
}

.header-ui {
    top: 20px;
}

.footer-ui {
    bottom: 20px;
    /* font-size: 0.6rem; */
    display: flex;
    flex-direction: column;
    gap: 5px;
    color: #aaa;
    width: fit-content;
    max-width: 80vw;
    white-space: nowrap;
}

h1 { 
    margin: 0;
    font-size: 1.5rem;
    letter-spacing: 2px;
    color: #fff;
    text-shadow: 0 2px 4px rgba(0,0,0,0.5);
}

.footer-ui a {
    color: #fff;
    text-decoration: none;
    border-bottom: 1px dotted #666;
    width: auto;
}

/* --- 设置按钮和选项面板样式 --- */
#settings-button {
    bottom: 20px;
    right: 20px;
    left: auto;
    transform: none;
    border-radius: 50%;
    width: var(--footer-height); 
    height: var(--footer-height);
    padding: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='32' height='32'%3E%3Ccircle cx='16' cy='16' r='10' fill='white' fill-opacity='0.3'/%3E%3Ccircle cx='16' cy='16' r='5' fill='white'/%3E%3C/svg%3E") 16 16, auto;
    transition: background 0.2s, transform 0.2s;
    pointer-events: auto;
}

#settings-button:hover {
    background: rgba(40, 40, 40, 0.65);
}

#settings-button svg {
    width: 60%;
    height: 60%;
    color: var(--text-color);
}

#options-panel {
    bottom: calc(20px + var(--footer-height) + 10px);
    right: 20px;
    left: auto;
    transform: none;
    width: var(--footer-height);
    padding: 12px 0;
    border-radius: 30px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    opacity: 1;
    visibility: visible; 
    /* 关键：确保所有属性都有 0.3s 的过渡，visibility 也必须声明过渡 */
    transition: opacity 0.3s ease-out, transform 0.3s ease-out, visibility 0.3s; 
    pointer-events: auto;
}

#options-panel.hidden {
    opacity: 0;
    transform: translateY(10px); 
    /* 关键：隐藏时设置 visibility: hidden，但由于设置了 transition，它会在 0.3s 后才生效 */
    visibility: hidden; 
}

/* Tooltip styles for option items */
.option-item {
    position: relative;
}

.option-item::before {
    content: attr(data-title);
    position: absolute;
    right: calc(100% + 15px);
    top: 50%;
    transform: translateY(-50%);
    background-color: rgba(30, 30, 30, 0.9);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    padding: 6px 10px;
    /* font-size: 0.6rem; */
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.2s ease, visibility 0.2s ease;
    z-index: 1000;
}

.option-item::after {
    content: "";
    position: absolute;
    right: calc(100% + 5px);
    top: 50%;
    transform: translateY(-50%);
    border: 5px solid transparent;
    border-left: 0;
    border-right-color: rgba(30, 30, 30, 0.9);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.2s ease, visibility 0.2s ease;
    z-index: 1000;
}

.option-item:hover::before,
.option-item:hover::after {
    opacity: 1;
    visibility: visible;
}

/* --- 视口与网格 --- */
#viewport {
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    will-change: transform;
}

#grid-container {
    box-shadow: 0 0 50px rgba(0,0,0,0.8);
}

#grid {
    display: grid;
    gap: 1px;
    background: var(--grid-gap-color); 
    padding: 1px;
}

.cell {
    background-color: var(--cell-black);
    cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='32' height='32'%3E%3Ccircle cx='16' cy='16' r='10' fill='white' fill-opacity='0.3'/%3E%3Ccircle cx='16' cy='16' r='5' fill='white'/%3E%3C/svg%3E") 16 16, auto;
    position: relative;
}

@media (hover: hover) {
    .cell:hover {
        opacity: 0.8;
        z-index: 10;
        transform: scale(1.1);
        box-shadow: 0 0 8px rgba(0,0,0,0.8);
        transition: transform 0.2s;
    }
}

.cell.white {
    background-color: var(--cell-white);
    transform: rotateY(180deg);
    transition: transform 0.5s;
}

.cell.pending::after {
    content: "";
    position: absolute;
    inset: 0;
    background: rgba(255, 255, 255, 0.1);
    animation: pulse 1s infinite;
}

@keyframes pulse {
    0% { opacity: 0; }
    50% { opacity: 1; }
    100% { opacity: 0; }
}

/* 提示弹窗样式 */
.hint-popup {
    top: 20px;
    right: 20px;
    left: auto;
    transform: translateX(120%);
    padding: 16px 24px;
    text-align: left;
    max-width: 300px;
    opacity: 1;
    visibility: visible;
    border-radius: 8px; /* 更小的圆角 */
    transition: transform 0.3s ease-out;
}

.hint-popup:not(.hidden) {
    transform: translateX(0);
}

.hint-close {
    position: absolute;
    top: 8px;
    right: 8px;
    cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='32' height='32'%3E%3Ccircle cx='16' cy='16' r='10' fill='white' fill-opacity='0.3'/%3E%3Ccircle cx='16' cy='16' r='5' fill='white'/%3E%3C/svg%3E") 16 16, auto;
    padding: 4px;
    border-radius: 50%;
    transition: background-color 0.2s;
}

.hint-close:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

.hint-content {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.hint-text {
    /* font-size: 0.7rem; */
    color: #ffffff;
    white-space: normal;
    line-height: 1.4;
}

.hint-text-en {
    /* font-size: 0.6rem; */
    color: #ffffff;
    white-space: normal;
    line-height: 1.4;
}

.hint-text-en ul {
    padding-left: 20px;
    margin: 0;
}

.hint-text-en li {
    margin: 5px 0;
}
