:root {
    --sys-font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
    --glass-bg: rgba(255, 255, 255, 0.75);
    --glass-border: rgba(255, 255, 255, 0.5);
    --glass-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.05);
    --text-main: #2d3436;
    --text-sub: #636e72;
    --border-color: rgba(0, 0, 0, 0.08);
    --btn-dark: #2d3436;
    --btn-dark-hover: #000000;
    --btn-light: rgba(255, 255, 255, 0.9);
    --btn-light-hover: #ffffff;
    --success: #00b894;
    --error: #ff7675;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: var(--sys-font);
    color: var(--text-main);
    background-color: #f5f6fa;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    overflow-x: hidden;
    position: relative;
    line-height: 1.6;
}

.bg-wrapper {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: -1;
    background: linear-gradient(135deg, #e0eafc, #cfdef3);
    overflow: hidden;
}

.shape {
    position: absolute;
    border-radius: 50%;
    filter: blur(60px);
    opacity: 0.6;
    animation: drift 20s infinite alternate ease-in-out;
}

.shape-1 {
    width: 50vw;
    height: 50vw;
    background: #ffffff;
    top: -10%;
    left: -10%;
}

.shape-2 {
    width: 40vw;
    height: 40vw;
    background: #dfe6e9;
    bottom: -10%;
    right: -10%;
    animation-delay: -5s;
}

.shape-3 {
    width: 30vw;
    height: 30vw;
    background: #f1f2f6;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    animation-delay: -10s;
}

@keyframes drift {
    0% { transform: translate(0, 0) scale(1); }
    100% { transform: translate(30px, 50px) scale(1.1); }
}

.app-container {
    width: 100%;
    max-width: 1200px;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    z-index: 1;
}

.glass-box {
    background: var(--glass-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--glass-border);
    box-shadow: var(--glass-shadow);
    border-radius: 16px;
}

.header {
    padding: 24px;
    text-align: center;
}

.header h1 {
    font-size: 24px;
    font-weight: 600;
    letter-spacing: 1px;
    margin-bottom: 8px;
}

.header p {
    font-size: 14px;
    color: var(--text-sub);
}

.main-layout {
    display: grid;
    grid-template-columns: 1fr 360px;
    gap: 20px;
    align-items: start;
}

.display-area {
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.text-section {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.section-label {
    font-size: 13px;
    color: var(--text-sub);
    font-weight: 500;
}

.text-board {
    background: rgba(255, 255, 255, 0.4);
    border-radius: 12px;
    padding: 20px;
    border: 1px solid var(--border-color);
}

.title-board {
    font-size: 20px;
    font-weight: 600;
    text-align: center;
    min-height: 70px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 2px;
}

.content-board {
    font-size: 16px;
    min-height: 300px;
    text-align: justify;
    word-break: break-word;
}

.char-hide {
    display: inline-block;
    width: 1em;
    text-align: center;
    border-bottom: 2px solid var(--text-main);
    color: transparent;
    margin: 0 1px;
    opacity: 0.2;
}

.char-show {
    display: inline-block;
    animation: pop 0.2s ease forwards;
}

@keyframes pop {
    0% { transform: scale(0.9); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}

.stats-bar {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
}

.stat-box {
    background: rgba(255, 255, 255, 0.4);
    border-radius: 12px;
    padding: 16px 12px;
    text-align: center;
    border: 1px solid var(--border-color);
}

.stat-num {
    display: block;
    font-size: 24px;
    font-weight: 600;
    margin-bottom: 4px;
}

.stat-name {
    font-size: 12px;
    color: var(--text-sub);
}

.control-area {
    padding: 24px;
    position: sticky;
    top: 20px;
}

.control-group {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.input-wrap {
    display: flex;
    gap: 8px;
}

.glass-input {
    flex: 1;
    height: 48px;
    background: rgba(255, 255, 255, 0.6);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    padding: 0 16px;
    font-size: 15px;
    font-family: inherit;
    color: var(--text-main);
    outline: none;
    transition: all 0.2s;
}

.glass-input:focus {
    background: #ffffff;
    border-color: #b2bec3;
}

.glass-input::placeholder {
    color: #a4b0be;
}

.glass-btn {
    height: 48px;
    padding: 0 20px;
    border: none;
    border-radius: 12px;
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
    white-space: nowrap;
}

.btn-dark {
    background: var(--btn-dark);
    color: #ffffff;
}

.btn-dark:active {
    background: var(--btn-dark-hover);
    transform: scale(0.98);
}

.btn-light {
    background: var(--btn-light);
    color: var(--text-main);
    border: 1px solid var(--border-color);
}

.btn-light:active {
    background: var(--btn-light-hover);
    transform: scale(0.98);
}

.glass-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

.toast {
    padding: 12px 16px;
    border-radius: 12px;
    font-size: 14px;
    text-align: center;
    background: #ffffff;
    transition: opacity 0.3s;
}

.toast.hide {
    opacity: 0;
    pointer-events: none;
    display: none;
}

.toast.succ {
    border-left: 4px solid var(--success);
}

.toast.err {
    border-left: 4px solid var(--error);
}

.history-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    min-height: 60px;
    margin-top: 8px;
}

.hist-char {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.4);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 15px;
    color: var(--text-sub);
}

.hist-char.hit {
    background: var(--text-main);
    color: #ffffff;
    border-color: var(--text-main);
}

.btn-wrap {
    display: flex;
    gap: 12px;
}

.btn-wrap .glass-btn {
    flex: 1;
}

.footer {
    padding: 20px;
    text-align: center;
}

.footer p, .footer a {
    font-size: 13px;
    color: var(--text-sub);
    text-decoration: none;
}

@media (max-width: 900px) {
    .main-layout {
        grid-template-columns: 1fr;
    }
    .control-area {
        position: static;
    }
}

@media (max-width: 500px) {
    .app-container {
        padding: 12px;
    }
    .header, .display-area, .control-area, .footer {
        padding: 16px;
    }
    .stats-bar {
        grid-template-columns: repeat(2, 1fr);
    }
    .btn-wrap {
        flex-direction: column;
    }
}