/* --- Utility --- */

.hidden {
    display: none !important;
}

/* --- Base --- */

*,
*::before,
*::after {
    box-sizing: border-box;
}

body {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: radial-gradient(ellipse at 50% 40%, #1a2332 0%, #0d1117 100%);
    margin: 0;
    text-align: center;
    color: #e0e0e0;
    overflow: hidden;
}

/* --- Start Screen --- */

#start-screen {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 28px;
}

/* --- Profile Selector --- */

#profile-selector {
    display: flex;
    align-items: center;
    gap: 8px;
}

#profile-dropdown {
    min-width: 160px;
    padding: 8px 12px;
    font-family: inherit;
    font-size: 0.95em;
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 8px;
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23888' stroke-width='1.5' fill='none'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    padding-right: 30px;
    cursor: pointer;
    transition: border-color 0.2s;
}

#profile-dropdown:focus {
    outline: none;
    border-color: rgba(0, 191, 165, 0.5);
}

#profile-dropdown option {
    background: #1c2233;
    color: #fff;
}

#add-profile-btn,
#delete-profile-btn {
    width: 36px;
    height: 36px;
    padding: 0;
    font-size: 0.85em;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0.7;
    transition: opacity 0.2s, background 0.2s;
}

#add-profile-btn:hover {
    opacity: 1;
    background: rgba(0, 137, 123, 0.3);
}

#delete-profile-btn:hover {
    opacity: 1;
    background: rgba(183, 28, 28, 0.3);
}

/* --- Game Container --- */

.container {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 40px;
}

/* --- Display Area & Timer --- */

#display-area {
    position: relative;
    width: min(70vw, 300px);
    height: min(70vw, 300px);
    display: flex;
    justify-content: center;
    align-items: center;
    background: radial-gradient(circle at 40% 35%, #2a3a4a, #1a1f2e);
    border-radius: 50%;
    border: 3px solid rgba(255, 255, 255, 0.06);
    box-shadow:
        0 0 40px rgba(0, 0, 0, 0.4),
        inset 0 2px 4px rgba(255, 255, 255, 0.04);
    transition: transform 0.25s ease, box-shadow 0.25s ease;
    cursor: default;
}

#display-area.clickable {
    cursor: pointer;
    border-color: rgba(0, 191, 165, 0.3);
    box-shadow:
        0 0 30px rgba(0, 191, 165, 0.15),
        0 0 60px rgba(0, 191, 165, 0.08),
        inset 0 2px 4px rgba(255, 255, 255, 0.04);
    animation: pulse 2s ease-in-out infinite;
}

#display-area.clickable:hover {
    transform: scale(1.04);
    box-shadow:
        0 0 40px rgba(0, 191, 165, 0.25),
        0 0 80px rgba(0, 191, 165, 0.1),
        inset 0 2px 4px rgba(255, 255, 255, 0.06);
}

@keyframes pulse {
    0%, 100% { box-shadow: 0 0 30px rgba(0, 191, 165, 0.15), 0 0 60px rgba(0, 191, 165, 0.08); }
    50%      { box-shadow: 0 0 40px rgba(0, 191, 165, 0.25), 0 0 80px rgba(0, 191, 165, 0.12); }
}

#timer-svg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    transform: rotate(-90deg);
}

.timer-background {
    fill: none;
    stroke: rgba(255, 255, 255, 0.06);
    stroke-width: 6;
}

.timer-progress {
    fill: none;
    stroke: #00c853;
    stroke-width: 6;
    filter: drop-shadow(0 0 6px rgba(0, 200, 83, 0.4));
}

#svg-character-text {
    font-size: 38px;
    font-family: 'Segoe UI', system-ui, sans-serif;
    fill: #ffffff;
    font-weight: 700;
    filter: drop-shadow(0 2px 8px rgba(0, 0, 0, 0.3));
}

/* --- Answer Buttons (practice mode) --- */

#answer-buttons {
    display: flex;
    gap: 24px;
    margin-top: 24px;
}

.answer-btn {
    width: 64px;
    height: 64px;
    padding: 0;
    font-size: 1.5em;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    border: 2px solid transparent;
    transition: transform 0.15s, box-shadow 0.2s, background 0.2s;
}

.answer-btn:active {
    transform: scale(0.92);
}

.answer-incorrect {
    background: rgba(211, 47, 47, 0.5);
    border-color: rgba(211, 47, 47, 0.3);
}

.answer-incorrect:hover {
    background: rgba(211, 47, 47, 0.7);
    box-shadow: 0 0 20px rgba(211, 47, 47, 0.3);
}

.answer-correct {
    background: rgba(0, 137, 123, 0.5);
    border-color: rgba(0, 191, 165, 0.3);
}

.answer-correct:hover {
    background: rgba(0, 137, 123, 0.7);
    box-shadow: 0 0 20px rgba(0, 191, 165, 0.3);
}

/* --- Buttons (shared reset) --- */

button {
    font-family: inherit;
    font-size: 0.9em;
    font-weight: 500;
    cursor: pointer;
    color: white;
    border: none;
    border-radius: 8px;
    transition: background-color 0.2s, transform 0.15s, box-shadow 0.2s;
}

button:active {
    transform: scale(0.97);
}

/* --- Start Button --- */

#start-button {
    width: 90px;
    height: 90px;
    padding: 0;
    font-size: 2em;
    background: linear-gradient(135deg, #00897b, #00bfa5);
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow:
        0 6px 20px rgba(0, 137, 123, 0.35),
        0 0 40px rgba(0, 191, 165, 0.1);
}

#start-button:hover {
    background: linear-gradient(135deg, #00a08e, #00d4b8);
    box-shadow:
        0 8px 28px rgba(0, 137, 123, 0.45),
        0 0 50px rgba(0, 191, 165, 0.15);
    transform: scale(1.06);
}

/* --- Corner Buttons (shared) --- */

.corner-btn {
    position: absolute;
    top: 16px;
    width: 42px;
    height: 42px;
    padding: 0;
    font-size: 1.1em;
    background: rgba(255, 255, 255, 0.08);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 50%;
    z-index: 100;
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0.65;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.corner-btn:hover {
    opacity: 1;
    background: rgba(255, 255, 255, 0.14);
}

#settings-button {
    right: 16px;
    transition: background-color 0.2s, opacity 0.2s, transform 0.3s;
}

#settings-button:hover {
    transform: rotate(45deg);
}

#profile-button {
    right: 66px;
    transition: background-color 0.2s, opacity 0.2s;
}

#auto-play-button {
    left: 16px;
    transition: all 0.3s ease;
}

#auto-play-button.active {
    background: rgba(0, 137, 123, 0.6);
    border-color: rgba(0, 191, 165, 0.4);
    opacity: 1;
    animation: rotate 2s linear infinite;
}

@keyframes rotate {
    from { transform: rotate(0deg); }
    to   { transform: rotate(360deg); }
}

/* --- Profile Panel (in-game) --- */

#profile-panel {
    position: absolute;
    top: 66px;
    right: 16px;
    background: #1c2233;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 12px 14px;
    z-index: 150;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.4);
    min-width: 220px;
}

.profile-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    font-size: 0.8em;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: rgba(255, 255, 255, 0.4);
}

.profile-panel-close {
    width: 24px;
    height: 24px;
    padding: 0;
    font-size: 0.75em;
    background: transparent;
    opacity: 0.5;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
}

.profile-panel-close:hover {
    opacity: 1;
    background: rgba(255, 255, 255, 0.1);
}

.profile-panel-body {
    display: flex;
    align-items: center;
    gap: 6px;
}

#game-profile-dropdown {
    flex: 1;
    min-width: 0;
    padding: 6px 28px 6px 10px;
    font-family: inherit;
    font-size: 0.9em;
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 6px;
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23888' stroke-width='1.5' fill='none'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 8px center;
    cursor: pointer;
}

#game-profile-dropdown:focus {
    outline: none;
    border-color: rgba(0, 191, 165, 0.5);
}

#game-profile-dropdown option {
    background: #1c2233;
    color: #fff;
}

#game-add-profile-btn,
#game-delete-profile-btn {
    width: 30px;
    height: 30px;
    padding: 0;
    font-size: 0.75em;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0.6;
    flex-shrink: 0;
    transition: opacity 0.2s, background 0.2s;
}

#game-add-profile-btn:hover {
    opacity: 1;
    background: rgba(0, 137, 123, 0.3);
}

#game-delete-profile-btn:hover {
    opacity: 1;
    background: rgba(183, 28, 28, 0.3);
}

/* --- Settings Panel --- */

#settings-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 200;
}

#settings-panel {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 90%;
    max-width: 380px;
    max-height: 90vh;
    overflow-y: auto;
    background: #1c2233;
    padding: 28px;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    z-index: 201;
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: #c8d0dc;
}

#settings-panel h2 {
    margin: 0 0 20px;
    font-size: 1.15em;
    font-weight: 600;
    text-align: center;
    color: #fff;
    letter-spacing: 0.02em;
}

/* --- Setting Groups (fieldsets) --- */

.setting-group {
    border: 1px solid rgba(255, 255, 255, 0.07);
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.03);
    padding: 14px 16px 10px;
    margin: 0 0 16px;
}

.setting-group legend {
    font-size: 0.75em;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: rgba(255, 255, 255, 0.4);
    padding: 0 8px;
}

/* --- Setting Rows (checkbox + label) --- */

.setting-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 0;
    cursor: pointer;
    font-size: 0.95em;
    color: #d0d8e4;
    user-select: none;
}

.setting-row:not(:last-child) {
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.setting-row input[type="checkbox"] {
    appearance: none;
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 4px;
    border: 2px solid rgba(255, 255, 255, 0.2);
    background: rgba(255, 255, 255, 0.05);
    cursor: pointer;
    flex-shrink: 0;
    position: relative;
    transition: border-color 0.15s, background-color 0.15s;
}

.setting-row input[type="checkbox"]:checked {
    background: #00897b;
    border-color: #00897b;
}

.setting-row input[type="checkbox"]:checked::after {
    content: '';
    position: absolute;
    left: 4px;
    top: 1px;
    width: 6px;
    height: 10px;
    border: solid #fff;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

/* --- Sub-options (indented under checkboxes) --- */

.sub-option {
    padding: 6px 0 6px 28px;
}

.sub-option label {
    font-size: 0.85em;
    color: rgba(255, 255, 255, 0.45);
    margin-right: 4px;
}

.sub-option input[type="number"] {
    width: 56px;
    padding: 5px 4px;
    margin-right: 12px;
    text-align: center;
    font-family: inherit;
    font-size: 0.9em;
    background: rgba(255, 255, 255, 0.06);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 6px;
    transition: border-color 0.2s;
}

.sub-option input[type="number"]:focus {
    outline: none;
    border-color: rgba(0, 191, 165, 0.5);
}

.sub-option input[type="text"] {
    width: 100%;
    padding: 8px 10px;
    font-family: 'SF Mono', 'Cascadia Code', 'Fira Code', monospace;
    font-size: 0.82em;
    letter-spacing: 1.5px;
    background: rgba(255, 255, 255, 0.06);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 6px;
    transition: border-color 0.2s;
}

.sub-option input[type="text"]:focus {
    outline: none;
    border-color: rgba(0, 191, 165, 0.5);
}

.setting-hint {
    font-size: 0.82em;
    color: rgba(255, 255, 255, 0.35);
    margin: 0 0 10px;
    line-height: 1.4;
}

/* --- Settings Action Buttons --- */

.settings-actions {
    display: flex;
    gap: 8px;
    margin-top: 8px;
}

.settings-actions button {
    flex: 1;
    padding: 10px 0;
    font-size: 0.85em;
    border-radius: 8px;
}

.btn-primary {
    background: #00897b;
}

.btn-primary:hover {
    background: #00a08e;
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.14);
}

.btn-danger {
    background: rgba(183, 28, 28, 0.6);
}

.btn-danger:hover {
    background: rgba(211, 47, 47, 0.7);
}

.btn-small {
    padding: 6px 14px;
    font-size: 0.8em;
}
