/* RESET + GLOBAL */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    height: 100%;
    background: #f5f5f5;
    color: #000;
    font-family: 'Courier New', monospace;
    min-height: 100vh;
    line-height: 1.6;
}

body {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    place-content: start;
    flex: 1;
}

/* MAIN CONTAINER + OVERLAY BORDER */
.container {
    max-width: 600px;
    margin: 40px auto;
    padding: 40px;
    border: 4px solid #000;
    background: #fff;
    position: relative;
}
.container::after {
    content: '';
    position: absolute;
    top: 6px; left: 6px; right: -6px; bottom: -6px;
    background: #000;
    z-index: -1;
}

/* HEADINGS & TEXT */
h2 {
    font-size: 24px;
    font-weight: bold;
    margin-bottom: 20px;
    border-bottom: 2px solid #000;
    padding-bottom: 10px;
}
p {margin-bottom: 20px;font-size: 24px;}
label {
    font-size: 1.1rem;
    user-select: none;
    cursor: pointer;
    font-weight: bold;
    letter-spacing: 0.02em;
}

/* TOPBAR & SNACKS */
#topbar {
    display: flex;
    gap: 2rem;
    margin-bottom: 2rem;
    align-items: center;
    border-bottom: 3px solid #000;
    padding-bottom: 1rem;
}
#snacks {
    font-size: 1.2rem;
    user-select: none;
    font-weight: bold;
}

/* DESCRIPTION BLOCK */
#description {
    text-align: center;
    border: 5px solid #000;
    background: #fff;
    padding: 1.5rem 2rem;
    margin: 2rem;
}

/* FLASHCARD BLOCK */
#card {
    font-size: 9rem;
    font-family: 'Sarabun', sans-serif;
    margin-bottom: 2rem;
    user-select: none;
    text-align: center;
    line-height: .55;
    border: 5px solid #000;
    background: #fff;
    padding: 3rem 2rem;
    box-shadow: none;
    transition: transform 0.28s cubic-bezier(.4,0,.2,1), opacity 0.28s cubic-bezier(.4,0,.2,1);
}
#card.slide-out { transform: translateY(-30px); opacity: 0; }
#card.slide-in  { transform: translateY(30px); opacity: 0; }
#card.show      { transform: translateY(0); opacity: 1; }

/* NEXT BUTTON */
#next-btn {
    display: none;
    margin:auto;
    margin-bottom:1rem;
    font-size: 1.3rem;
    font-weight: bold;
    border: 2px solid #000;
    border-radius: 0;
    background: #fff;
    cursor: pointer;
    text-transform: uppercase;
    padding: 0.7rem 2.2rem;
    z-index: 4;
    pointer-events: auto;
    box-shadow: 0 2px 16px 0 #fff7, 0 2px 16px 0 #fff0;
}
#next-btn:active { background: #000; color: #fff; }

/* OPTION BUTTONS */
#options {
    display: flex;
    flex-wrap: wrap;
    gap: .875rem;
    justify-content: center;
    margin-bottom: 2rem;
}
.option-btn {
    font-size: 2rem;
    min-width: 5rem;
    padding: 1rem;
    margin: 0.1rem;
    background: #fff;
    color: #000;
    border: 3px solid #000;
    border-radius: 0;
    cursor: pointer;
    font-family: inherit;
    font-weight: bold;
    text-transform: uppercase;
    position: relative;
    outline: none;
    box-shadow: none;
    transition: none;
}
.option-btn:hover, .option-btn:focus {
    background: #000;
    color: #fff;
    border-color: #000;
    z-index: 1;
}
.option-btn[data-correct="true"]:hover {
    outline: 3px solid #008000;
    outline-offset: -5px;
}
.option-btn.correct {
    background: #fff;
    color: #008000;
    border-color: #008000;
    text-decoration: underline;
}
.option-btn.wrong {
    background: #fff;
    color: #e33c48;
    border-color: #e33c48;
    text-decoration: line-through;
}
.option-btn.hint {
    background: #f2f2f2;
    color: #aaa;
    border-color: #aaa;
}
.option-btn:active {
    background: #222;
    color: #fff;
}

/* STATUS + CONTROLS */
#status {
    font-size: 1.15rem;
    color: #000;
    margin-bottom: 1.2rem;
    text-align: center;
    font-weight: bold;
    border-bottom: 2px solid #000;
    padding-bottom: 0.6rem;
    letter-spacing: 0.08em;
}
#hint-btn, #retry-btn {
    font-size: 1rem;
    padding: 0.4rem 1.4rem;
    border-radius: 0;
    border: 2px solid #000;
    background: #fff;
    color: #000;
    cursor: pointer;
    box-shadow: none;
    font-weight: bold;
    text-transform: uppercase;
    margin-left: 0.6rem;
}
#hint-btn:active, #retry-btn:active {
    background: #000;
    color: #fff;
}
#retry-btn { display: none; }

/* THAI WORD BUTTON */
.thai-word {
    display: inline;
    font-family: 'Sarabun', sans-serif;
    font-weight: bold;
    background: #eee;
    color: #000;
    padding: 2px 6px;
    border: none;
    cursor: pointer;
    outline: none;
    font-size: 22px;
    user-select: none;
}
.thai-word:hover, .thai-word:focus, .thai-word[aria-expanded="true"] {
    background: #fff;
    color: #000;
    outline: 3px solid #000;
    outline-offset: 2px;
}

/* TOOLTIP: WORD + CHAR */
.tooltip-container {
    position: fixed;
    z-index: 1000;
    pointer-events: none;
}
.word-tooltip, .char-tooltip {
    background: #fff;
    border: 4px solid #000;
    padding: 20px;
    font-family: 'Courier New', monospace;
    position: relative;
    pointer-events: auto;
}
.word-tooltip::after, .char-tooltip::after {
    content: '';
    position: absolute;
    top: 6px; left: 6px; right: -6px; bottom: -6px;
    background: #000;
    z-index: -1;
}
.tooltip-header, .char-tooltip-header {
    border-bottom: 2px solid #000;
    padding-bottom: 15px;
    margin-bottom: 15px;
}
.tooltip-thai-word {
    font-size: 32px;
    font-family: 'Sarabun', sans-serif;
    font-weight: bold;
    margin-bottom: 8px;
}
.tooltip-translit {
    font-size: 16px;
    text-transform: uppercase;
    margin-bottom: 8px;
}
.tooltip-meaning {
    font-size: 20px;
    font-weight: bold;
    text-transform: uppercase;
}
.tooltip-definition {
    font-size: 14px;
    margin-top: 15px;
    line-height: 1.4;
}

/* CHARACTER GRID & BLOCKS */
.character-grid {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 20px;
    padding: 15px;
    border: 2px solid #000;
    background: #f8f8f8;
}
.char-block {
    background: #fff;
    border: 2px solid #000;
    padding: 12px 16px;
    font-size: 20px;
    font-weight: bold;
    font-family: 'Sarabun', sans-serif;
    min-width: 50px;
    text-align: center;
    cursor: pointer;
}
.char-block:hover, .char-block:focus, .char-block[aria-expanded="true"] {
    background: #000;
    color: #fff;
}
.char-block[aria-disabled="true"] {
    background: #f0f0f0;
    border-color: #ccc;
    color: #999;
    cursor: default;
}
.char-tooltip-name {
    font-size: 24px;
    font-weight: bold;
    text-transform: uppercase;
}
.char-tooltip-actions {
    font-size: 18px;
    display: flex;
    gap: 8px;
    cursor: pointer;
    font-family: monospace;
}
.char-tooltip-class {
    display: inline-block;
    padding: 4px 8px;
    border: 2px solid #000;
    font-size: 12px;
    font-weight: bold;
    text-transform: uppercase;
}
.char-tooltip-class.high {
    background: #fff;
    color: #000;
}
.char-tooltip-class.mid {
    background: #666;
    color: #fff;
}
.char-tooltip-class.low {
    background: #000;
    color: #fff;
}
.char-tooltip-icon { font-size: 16px; margin-right: 8px; }
.char-tooltip-sound {font-size: 18px;font-weight: bold;text-transform: uppercase;margin-top: 10px;}
.char-tooltip-notes { font-size: 14px; margin-top: 10px; line-height: 1.4; }

/* RESPONSIVE */
@media (max-width: 768px) {
    .container { margin: 20px; padding: 20px; }
    .word-tooltip, .char-tooltip { width: calc(100vw - 40px); max-width: none; }
    .character-grid { padding: 10px; }
    .char-block { padding: 8px 12px; min-width: 40px; font-size: 18px; }
}
