* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    width: 100vw;
    height: 100vh;
    overflow: hidden;
    background: #1a1a1a;
    font-family: -apple-system, BlinkMacSystemFont, 'PingFang SC', 'Microsoft YaHei', sans-serif;
    letter-spacing: 0;
}

#canvas-container {
    width: 100%;
    height: 100%;
}

canvas {
    display: block;
    width: 100%;
    height: 100%;
}

.info-panel {
    position: absolute;
    top: 88px;
    right: 20px;
    background: rgba(0, 0, 0, 0.85);
    color: white;
    padding: 16px;
    border-radius: 8px;
    width: min(340px, calc(100vw - 32px));
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
    transition: opacity 0.3s ease, transform 0.3s ease;
    backdrop-filter: blur(10px);
    overflow: hidden;
    overflow-y: auto;
    max-height: calc(100dvh - 190px);
    font-size: 12px;
}

.info-panel.hidden {
    opacity: 0;
    pointer-events: none;
    transform: translateY(-10px);
}

.close-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    background: none;
    border: none;
    color: white;
    font-size: 24px;
    cursor: pointer;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: background 0.2s;
}

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

.info-type {
    display: inline-block;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0;
    color: #66b3ff;
    background: rgba(102, 179, 255, 0.15);
    padding: 4px 8px;
    border-radius: 3px;
    margin-bottom: 8px;
    font-weight: 600;
}

#info-title {
    margin-bottom: 8px;
    font-size: 18px;
    padding-right: 30px;
    white-space: pre-line;
    overflow-wrap: anywhere;
    line-height: 1.6;
}

#info-detail {
    white-space: pre-line;
    overflow-wrap: anywhere;
    line-height: 1.5;
    color: #ddd;
    margin-bottom: 10px;
    font-size: 13px;
}

.wiki-link {
    display: inline-block;
    color: #66b3ff;
    text-decoration: none;
    font-size: 13px;
    padding: 6px 12px;
    background: rgba(102, 179, 255, 0.1);
    border-radius: 4px;
    border: 1px solid rgba(102, 179, 255, 0.3);
    transition: all 0.2s;
}

.term-line, .term-pinyin { display: block; }
.term-pinyin { font-size: 13px; font-weight: 400; color: #c7d9e5; line-height: 1.6; margin: 2px 0 5px; }

.wiki-link:hover {
    background: rgba(102, 179, 255, 0.2);
    border-color: rgba(102, 179, 255, 0.5);
    transform: translateX(2px);
}

.controls {
    position: absolute;
    bottom: 40px;
    left: 20px;
    display: flex;
    gap: 8px;
}

.heading { position: absolute; top: 20px; left: 20px; color: #eee; pointer-events: none; }
.heading h1 { font-size: 20px; font-weight: 600; }
.heading p { margin-top: 5px; font-size: 12px; color: #aaa; }
#load-status { position: absolute; top: 48%; left: 0; width: 100%; text-align: center; color: #eee; pointer-events: none; }
footer { position: absolute; bottom: 10px; left: 20px; font-size: 10px; }
footer a { color: #aaa; text-decoration: none; }
button:focus-visible, a:focus-visible { outline: 2px solid #fff; outline-offset: 3px; }
@media (max-width: 600px) {
    .info-panel { top: auto; bottom: 102px; right: 16px; max-height: 31dvh; }
    .controls { left: 16px; right: 16px; gap: 6px; }
    .controls .control-btn { min-height: 44px; flex: 1; padding: 8px 4px; min-width: 0; font-size: 12px; }
    #input-mode { flex: 0 0 96px; }
    .heading { left: 16px; }
}

.control-btn {
    background: rgba(0, 0, 0, 0.8);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.2);
    padding: 10px 16px;
    border-radius: 4px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    backdrop-filter: blur(10px);
}

.control-btn:hover {
    background: rgba(255, 255, 255, 0.1);
}

#reset-btn {
    background: rgba(255, 0, 0, 0.8);
    border-color: rgba(255, 0, 0, 0.5);
}

#reset-btn:hover {
    background: rgba(255, 0, 0, 1);
}

.toggle-btn.active {
    background: rgba(102, 179, 255, 0.8);
    border-color: rgba(102, 179, 255, 0.5);
}

.toggle-btn.active:hover {
    background: rgba(102, 179, 255, 1);
}
