* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    user-select: none;  
}

body {
    min-height: 100vh;
    background: linear-gradient(135deg, #0B2027 0%, #122C3C 40%, #1B3A4B 100%);
    font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    color: var(--text-main);
    display: flex;
    flex-direction: column;
    align-items: center;
    overflow-x: hidden;
}

.container {
    margin-top: 9vh;
    margin-bottom: 1vh;
    width: 95vw;
    z-index: 1;
}

.main-panel {
    background: var(--bg-glass);
    border-radius: 4vw;
    border: 0.3vw solid var(--card-border);
    box-shadow: var(--card-shadow), inset 0 0.2vw 0 rgba(255, 255, 255, 0.05);
    padding: 3vw;
    display: flex;
    flex-direction: column;
    gap: 5vw;
    position: relative;
    overflow: hidden;
}

.main-panel::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 0.2vw;
    background: linear-gradient(90deg, transparent 0%, var(--border-glow) 50%, transparent 100%);
}

.left-section {
    display: flex;
    flex-direction: column;
    gap: 2vw;
    width: 100%;
}

.question-section {
    text-align: center;
    padding: 2vh 3vw;
    background: var(--bg-glass);
    border-radius: 4vw;
    border: 0.3vw solid var(--card-border);
    position: relative;
    overflow: hidden;
}

.question-section::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(0, 217, 232, 0.08) 0%, transparent 70%);
}

.question-label {
    font-size: 2.5vw;
    text-transform: uppercase;
    letter-spacing: 0.15em;
    color: var(--text-muted);
    margin-bottom: 2vw;
    font-weight: 600;
    position: relative;
    z-index: 1;
}

.pinyin {
    font-size: 6vw;
    font-weight: 800;
    background: var(--btn-primary-bg);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 1vh;
    letter-spacing: 0.8vw;
    position: relative;
    z-index: 1;
    filter: drop-shadow(0 0 5vw rgba(0, 217, 232, 0.4));
}

.meaning {
    font-size: 4vw;
    color: var(--text-primary);
    font-weight: 600;
    position: relative;
    z-index: 1;
}

#characterDiv {
    min-height: 20vw;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 3vw;
    flex-wrap: wrap;
    padding: 2vw 2vw;
}

.character-indicator {
    width: 15vw;
    height: 15vw;
    border-radius: 2.5vw;
    border: 0.5vw solid var(--card-border);
    background: var(--bg-dark);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 8vw;
    font-weight: 700;
    color: var(--text-muted);
}

.character-indicator::before {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(circle at center, rgba(0, 217, 232, 0.05), transparent);
    opacity: 0;
    transition: opacity 0.3s;
    border-radius: 2.5vw;
}

.character-indicator.active {
    border-color: var(--accent-primary);
    color: var(--accent-primary);
    box-shadow: 
        0 0 5vw rgba(0, 217, 232, 0.3),
        0 0 10vw rgba(0, 217, 232, 0.1),
        inset 0 0 5vw rgba(0, 217, 232, 0.1);
    transform: scale(1.1);
}

.character-indicator.active::before {
    opacity: 1;
}

.character-indicator.completed {
    border-color: rgba(124, 255, 124, 0.4);
    background: rgba(10, 40, 10, 0.3);
    color: #7cff7c;
    box-shadow: 
        0 0 4vw rgba(124, 255, 124, 0.2),
        inset 0 0 4vw rgba(124, 255, 124, 0.05);
}

.character-indicator.completed::after {
    content: '✓';
    position: absolute;
    top: -2vw;
    right: -2vw;
    width: 6vw;
    height: 6vw;
    background: linear-gradient(135deg, #7cff7c, #5cdf5c);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 3.5vw;
    color: #0a0e27;
    font-weight: 900;
    box-shadow: 0 1vw 3vw rgba(124, 255, 124, 0.4);
    animation: checkmarkPop 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

@keyframes checkmarkPop {
    0% {
        transform: scale(0) rotate(-180deg);
        opacity: 0;
    }
    50% {
        transform: scale(1.3) rotate(10deg);
    }
    100% {
        transform: scale(1) rotate(0deg);
        opacity: 1;
    }
}

.controls-section {
    display: flex;
    flex-direction: column;
    gap: 1.5vw;
}
.control-btn {
    height: 10vw;
    padding: 0 4vw;
    border-radius: 3vw;
    font-size: 3.5vw;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1vw;
    white-space: nowrap;
    position: relative;
    overflow: hidden;
}

.control-btn::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
}

.control-btn:active::before {
    width: 60vw;
    height: 60vw;
}

.btn-primary {
    background: var(--btn-primary-bg);
    color: var(--btn-primary-text);
    border: 0.3vw solid var(--btn-secondary-border);
    box-shadow: inset 0 0.2vw 0 rgba(0, 217, 232, 0.1);}

.btn-primary:active {
    background: var(--btn-primary-hover);
    transform: translateY(-0.5vw);
    box-shadow: 
        0 2vw 6vw rgba(0, 217, 232, 0.5),
        inset 0 0.2vw 0 rgba(255, 255, 255, 0.3);
}

.btn-secondary {
    background: var(--btn-secondary-bg);
    color: var(--btn-secondary-text);
    border: 0.3vw solid var(--btn-secondary-border);
}

.btn-secondary:active {
    background: var(--btn-secondary-hover);
    border-color: var(--accent-primary);
    transform: translateY(-0.4vw);
    box-shadow: 
        0 1.5vw 4vw rgba(0, 217, 232, 0.2),
        inset 0 0.2vw 0 rgba(0, 217, 232, 0.1);
}

.jump-section {
    display: flex;
    align-items: center;
    gap: 2.5vw;
    flex-wrap: wrap;
}

#GoWordBtn {
    flex-shrink: 0;
}

#LevelSelectors {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 1vh;
    width: 100%;
}

.right-section {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
}

.canvas-container {
    width: 90vw;
    height: 90vw;
    background: var(--bg-dark);
    border-radius: 4vw;
    border: 0.5vw solid var(--card-border);
    position: relative;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: var(--card-shadow), inset 0 0.2vw 0 rgba(0, 217, 232, 0.1);
    touch-action: none;
}

#characterTarget {
    position: absolute;
    inset: 0;
    z-index: 1;
}

.hint-canvas {
    position: absolute;
    inset: 0;
    border-radius: 4vw;
}

.control-btn:focus-visible,
#LevelStart:focus-visible {
    outline: 0.6vw solid var(--accent-primary);
    outline-offset: 0.5vw;
}

.jump-control {
    display: flex;
    align-items: center;
    gap: 2vw;
    background: rgba(0, 217, 232, 0.08);
    border: 0.3vw solid var(--input-border);
    border-radius: 3vw;
    padding: 1vw 2vw;
}

.jump-btn {
    background: var(--btn-primary-bg);
    border: none;
    color: var(--btn-primary-text);
    cursor: pointer;
    padding: 1.5vw 5vw;
    border-radius: 2.5vw;
    font-size: 4vw;
    font-weight: 700;
    transition: all 0.3s ease;
    box-shadow: 0 0.5vh 2vw rgba(0, 217, 232, 0.3);
}

.jump-btn:active {
    background: var(--btn-primary-hover);
    box-shadow: 0 1vh 3vw rgba(0, 217, 232, 0.5);
    transform: translateY(-0.5vw);
}

.jump-input {
    flex: 1;
    width: 100%;
    background: var(--input-bg);
    border: 0.3vw solid var(--input-border);
    color: var(--accent-primary);
    padding: 1.5vw 3vw;
    border-radius: 2.5vw;
    font-size: 4vw;
    font-weight: 600;
    text-align: center;
    outline: none;
    transition: all 0.3s ease;
}

.jump-input:focus {
    border-color: var(--input-border-focus);
    box-shadow: 0 0 2vw rgba(0, 217, 232, 0.4);
    background: rgba(0, 217, 232, 0.12);
}

.jump-input::placeholder {
    color: var(--input-placeholder);
}

.jump-input::-webkit-outer-spin-button,
.jump-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.jump-input[type=number] {
    -moz-appearance: textfield;
}

.button-group {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5vw;
    align-items: center;
}

.button-group #LevelStart {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    height: 10vw;
    background: var(--input-bg);
    border: 0.3vw solid var(--input-border);
    color: var(--input-text);
    border-radius: 3vw;
    padding: 0 3vw;
    font-size: 3.5vw;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s ease;
    outline: none;
    text-align: center;
}

.button-group #indexspan {
    padding: 2.5vw 2vw;
    background: rgba(0, 217, 232, 0.1);
    border: 0.3vw solid var(--input-border);
    border-radius: 3vw;
    font-size: 3.5vw;
    font-weight: 700;
    color: var(--accent-primary);
    text-align: center;
    display: inline-block;
}

.controls-bottom {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 3vw;
    width: 100%;
}

#indexspan, 
.jump-control {
    flex: 1; 
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 0;
}

#indexspan {
    text-align: center;
    white-space: nowrap;
}

.custom-dropdown {
  position: relative !important;
  width: 100% !important;
  user-select: none;
}
.custom-dropdown-selected{
    padding: 1.5vw !important;
}

@media (min-width: 768px){
    .container {
        margin-top: 12vh;
        width: 80vw;
    }

    .main-panel {
        display: grid;
        grid-template-columns: 1fr 1fr;
        grid-template-rows: auto auto 1fr;
        gap: 1vw;
        padding: 2vw;
        border-radius: 2vw;
        border: 0.2vw solid var(--card-border);
    }

    .main-panel::before {
        height: 0.15vw;
    }

    .left-section {
        grid-column: 1;
        grid-row: 1 / 3;
        gap: 1vw;
    }

    .controls-section:first-of-type {
        grid-column: 2;
        grid-row: 1;
        gap: 1.2vw;
    }

    .controls-section:last-of-type {
        grid-column: 2;
        grid-row: 2;
        gap: 1.2vw;
    }

    .right-section {
        grid-column: 1 / -1;
        grid-row: 3;
    }

    .question-section {
        min-height: 17vw;
        padding: 1vw;
        border-radius: 2vw;
        border: 0.2vw solid var(--card-border);
    }

    .question-label {
        font-size: 1vw;
        margin-bottom: 0.75vw;
    }

    .pinyin {
        font-size: 1.8vw;
        letter-spacing: 0.35vw;
        margin-bottom: 0.75vw;
        filter: drop-shadow(0 0 2.5vw rgba(0, 217, 232, 0.4));
    }

    .meaning {
        font-size: 1.5vw;
    }

    #characterDiv {
        min-height: 9vw;
        gap: 0.75vw;
        padding: 1vw;
    }

    .character-indicator {
        width: 6.5vw;
        height: 6.5vw;
        border-radius: 1.5vw;
        border: 0.3vw solid var(--card-border);
        font-size: 4.5vw;
    }

    .character-indicator::before {
        border-radius: 1.5vw;
    }

    .character-indicator.active {
        box-shadow: 
            0 0 2.5vw rgba(0, 217, 232, 0.3),
            0 0 5vw rgba(0, 217, 232, 0.1),
            inset 0 0 2.5vw rgba(0, 217, 232, 0.1);
    }

    .character-indicator.completed {
        box-shadow: 
            0 0 2vw rgba(124, 255, 124, 0.2),
            inset 0 0 2vw rgba(124, 255, 124, 0.05);
    }

    .character-indicator.completed::after {
        top: -1vw;
        right: -1vw;
        width: 3vw;
        height: 3vw;
        font-size: 1.8vw;
        box-shadow: 0 0.5vw 1.5vw rgba(124, 255, 124, 0.4);
    }

    .controls-section {
        gap: 1vw;
    }

    .button-group {
        gap: 1vw;
    }

    .control-btn {
        height: 4.5vw;
        padding: 0 2vw;
        border: 0.2vw solid var(--btn-secondary-border);
        border-radius: 1.5vw;
        font-size: 1.5vw;
        gap: 0.8vw;
    }

    .btn-primary:active {
        transform: translateY(-0.3vw);
        box-shadow: 
            0 1.5vw 4vw rgba(0, 217, 232, 0.5),
            inset 0 0.15vw 0 rgba(255, 255, 255, 0.3);
    }

    .btn-secondary:active {
        transform: translateY(-0.25vw);
        box-shadow: 
            0 1vw 2.5vw rgba(0, 217, 232, 0.2),
            inset 0 0.15vw 0 rgba(0, 217, 232, 0.1);
    }

    .button-group #indexspan {
        padding: 1.3vw 1.5vw;
        border: 0.2vw solid var(--input-border);
        border-radius: 1.5vw;
        font-size: 1.5vw;
    }  

    .canvas-container {
        width: 55vw;
        height: 55vw;
        border-radius: 2.5vw;
        border: 0.3vw solid var(--card-border);
    }

    .hint-canvas {
        border-radius: 2.5vw;
    }

    .control-btn:focus-visible {
        outline: 0.4vw solid var(--accent-primary);
        outline-offset: 0.3vw;
    }

    .jump-control {
        gap: 0.5vw;
        padding: 0.5vh 1.5vw;
        border-radius: 1.5vw;
        border: 0.2vw solid var(--input-border);
    }
    
    .jump-btn {
        padding: 0.9vh 2vw;
        border-radius: 1.2vw;
        font-size: 1.5vw;
    }
    
    .jump-input {
        min-width: 10vw;
        padding: 0.9vh 1.8vw;
        border-radius: 1.2vw;
        font-size: 1.5vw;
        border: 0.2vw solid var(--input-border);
    }
    
    .button-group #LevelStart {
        height: 4.5vw;
        border: 0.2vw solid var(--input-border);
        border-radius: 1.5vw;
        padding: 0 1.8vw;
        font-size: 1.5vw;
    }  

    #LevelSelectors {
        width: 100%;
    }  

    .custom-dropdown-selected{
        padding: 0.6vw !important;
    }
}

@media (min-width: 1024px), (orientation: landscape) {
    body{
        height: 100vh;
    }

    .container {
        margin: 0 auto; 
        width: 75vw;
        display: flex;
        align-items: center;
        min-height: 86vh;
        padding-top: 13vh;
    }

    .main-panel {
        display: grid;
        grid-template-columns: 0.8fr 1.2fr;
        grid-auto-rows: auto;
        gap: 0.6vw 0.6vw;
        padding: 0.7vw;
        max-height: 100%;
        border-radius: 1.8vw;
        border: 0.15vw solid var(--card-border);
    }

    .main-panel::before {
        height: 0.12vw;
    }

    .left-section {
        grid-column: 1;
        gap: 0.5vw;
        width: 100%;
    }

    .controls-section {
        gap: 0.4vw;
        width: 100%;
    }

    .controls-section:first-of-type {
        grid-column: 1;
        gap: 1vw;
    }

    .controls-section:last-of-type {
        grid-column: 1;
        gap: 1vw;
    }

    .right-section {
        grid-column: 2;
        grid-row: 1 / -1;
    }

    .question-section {
        min-height: 14vw;
        padding: 1vw;
        border-radius: 1.5vw;
        border: 0.15vw solid var(--card-border);
    }

    .question-label {
        font-size: 0.65vw;
        margin-bottom: 0.4vw;
    }

    .pinyin {
        font-size: 1.6vw;
        margin-bottom: 0.5vh;
        letter-spacing: 0.3vw;
        filter: drop-shadow(0 0 1.5vw rgba(0, 217, 232, 0.4));
    }

    .meaning {
        font-size: 1.15vw;
    }

    #characterDiv {
        min-height: 7vw;
        gap: 1vw;
        padding: 1vw;
    }

    .character-indicator {
        width: 5vw;
        height: 5vw;
        border-radius: 1.2vw;
        border: 0.2vw solid var(--card-border);
        font-size: 3vw;
    }

    .character-indicator::before {
        border-radius: 1.2vw;
    }

    .character-indicator.active {
        box-shadow: 
            0 0 1.8vw rgba(0, 217, 232, 0.3),
            0 0 3.5vw rgba(0, 217, 232, 0.1),
            inset 0 0 1.8vw rgba(0, 217, 232, 0.1);
    }

    .character-indicator.completed {
        box-shadow: 
            0 0 1.5vw rgba(124, 255, 124, 0.2),
            inset 0 0 1.5vw rgba(124, 255, 124, 0.05);
    }

    .character-indicator.completed::after {
        top: -0.7vw;
        right: -0.7vw;
        width: 2vw;
        height: 2vw;
        font-size: 1.1vw;
        box-shadow: 0 0.4vw 1vw rgba(124, 255, 124, 0.4);
    }

    .button-group {
        gap: 0.4vw;
    }

    .button-group #indexspan {
        height: 2.9vw;
    }      

    .control-btn {
        height: 3vw;
        padding: 0 1.8vw;
        border: 0.15vw solid var(--btn-secondary-border);
        border-radius: 1vw;
        font-size: 1.1vw;
        gap: 0.6vw;
    }

    .btn-primary:hover {
        transform: translateY(-0.2vw);
        box-shadow: 
            0 1vw 2.5vw rgba(0, 217, 232, 0.5),
            inset 0 0.12vw 0 rgba(255, 255, 255, 0.3);
    }

    .btn-secondary:hover {
        transform: translateY(-0.18vw);
        box-shadow: 
            0 0.7vw 1.8vw rgba(0, 217, 232, 0.2),
            inset 0 0.12vw 0 rgba(0, 217, 232, 0.1);
    }

    .button-group #indexspan {
        padding: 0.5vw 1.3vw;
        border: 0.15vw solid var(--input-border);
        border-radius: 1vw;
        font-size: 1.2vw;
    }
    .canvas-container {
        width: 38vw;
        height: 38vw;
        border-radius: 2vw;
        border: 0.25vw solid var(--card-border);
    }

    .hint-canvas {
        border-radius: 2vw;
    }

    .control-btn:focus-visible {
        outline: 0.25vw solid var(--accent-primary);
        outline-offset: 0.2vw;
    }

    .jump-control {
        gap: 0.4vw;
        padding: 0.5vh 1.2vw;
        border-radius: 1vw;
        border: 0.15vw solid var(--input-border);
    }
    
    .jump-btn {
        padding: 1vh 1.4vw;
        border-radius: 0.9vw;
        font-size: 1.1vw;
    }
    
    .jump-input {
        min-width: 8vw;
        padding: 0.8vh 1vw;
        border-radius: 0.9vw;
        font-size: 1.1vw;
        border: 0.15vw solid var(--input-border);
    }
    
    .button-group #LevelStart {
        height: 3vw;
        border: 0.15vw solid var(--input-border);
        border-radius: 1vw;
        padding: 0 1.5vw;
        font-size: 1.1vw;
    }

    #LevelSelectors {
        width: 100%;
    }    

    .custom-dropdown-selected{
        padding: 1.4vw !important;
    }    
}

@media (orientation: landscape) and (hover: none) and (pointer: coarse) {
    html, body {
        overflow: auto;
    }
}