/* ─── Variables (ACTotal Theme) ─── */
:root {
    --bg: #050506;
    --surface: #111827;
    --surface-light: #1f2937;
    --surface-hover: #374151;
    --accent: #00A7E1;
    --accent-glow: rgba(0, 167, 225, 0.35);
    --text: #ffffff;
    --text-dim: #9ca3af;
    --radius: 20px;
    --radius-sm: 12px;

    /* Specific Game Colors */
    --key-wrong: #ef4444;
    /* Red for wrong keys */
    --key-correct: #10b981;
    /* Green for correct keys */
}

/* ─── Base Reset & Common ─── */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html,
body {
    height: 100%;
    font-family: 'Inter', sans-serif;
    background: var(--bg);
    color: var(--text);
    -webkit-tap-highlight-color: transparent;
    overflow-x: hidden;
}

/* ─── Layout ─── */
.app-container {
    display: flex;
    flex-direction: column;
    min-height: 100dvh;
    padding: 1.5rem;
    max-width: 500px;
    margin: 0 auto;
}

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 2rem;
    flex-shrink: 0;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 1rem;
}

header h1 {
    font-size: 1.8rem;
    font-weight: 800;
    background: linear-gradient(135deg, var(--accent), #007bb5);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: -0.02em;
}

.btn-icon {
    width: 42px;
    height: 42px;
    border-radius: var(--radius-sm);
    border: 1px solid rgba(255, 255, 255, .08);
    background: var(--surface);
    color: var(--text-dim);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    transition: all .2s;
    font-size: 1.2rem;
}

.btn-icon:hover {
    background: var(--surface-light);
    color: var(--text);
}

/* ─── Views Manager ─── */
.game-content {
    flex: 1;
    position: relative;
    display: flex;
    flex-direction: column;
}

.app-view {
    display: none;
    flex-direction: column;
    height: 100%;
    width: 100%;
    animation: fadeIn 0.3s ease-out;
}

.app-view.active {
    display: flex;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ─── View 1: Setup ─── */
.setup-card {
    background: var(--surface);
    border: 1px solid rgba(255, 255, 255, .05);
    border-radius: var(--radius);
    padding: 2rem;
    text-align: center;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    margin: auto 0;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
}

.setup-card h2 {
    font-size: 1.5rem;
    font-weight: 700;
}

.setup-card p {
    color: var(--text-dim);
    font-size: 0.95rem;
    line-height: 1.5;
}

.category-select-wrapper {
    position: relative;
    width: 100%;
}

.category-select-wrapper::after {
    content: '▼';
    position: absolute;
    right: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-dim);
    pointer-events: none;
    font-size: 0.8rem;
}

.styled-select {
    width: 100%;
    padding: 1.2rem 1rem;
    background: var(--bg);
    border: 1px solid rgba(255, 255, 255, .1);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-size: 1rem;
    font-family: inherit;
    font-weight: 600;
    appearance: none;
    outline: none;
    cursor: pointer;
    transition: border-color 0.2s;
}

.styled-select:focus {
    border-color: var(--accent);
}

.styled-select option {
    background: var(--surface);
    color: var(--text);
}

/* ─── View 2: Game Board ─── */
/* SVG Drawing */
.drawing-container {
    flex-shrink: 0;
    height: 180px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 2rem;
}

.hangman-svg {
    height: 100%;
    max-width: 100%;
    overflow: visible;
}

.body-part {
    transition: opacity 0.3s ease;
}

/* Word Display */
.word-display {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-bottom: 3rem;
    min-height: 50px;
}

.letter-slot {
    width: 35px;
    height: 45px;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    font-size: 1.8rem;
    font-weight: 800;
    text-transform: uppercase;
    border-bottom: 3px solid var(--text);
    color: var(--text);
    transition: all 0.2s;
}

.letter-slot.empty {
    color: transparent;
    border-bottom: 3px solid var(--text-dim);
}

/* Keyboard */
.keyboard-grid {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 6px;
    margin-top: auto;
    padding-bottom: 1rem;
}

.key-btn {
    flex: 1 1 calc(10% - 6px);
    /* Roughly 10 keys per row */
    min-width: 32px;
    max-width: 45px;
    height: 48px;
    background: var(--surface-light);
    border: none;
    border-radius: 8px;
    color: var(--text);
    font-size: 1.1rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.2s;
    user-select: none;
    touch-action: manipulation;
    /* Faster touch response */
}

.key-btn:active {
    transform: scale(0.95);
    background: var(--surface-hover);
}

.key-btn.correct {
    background: var(--key-correct);
    color: #fff;
    opacity: 0.8;
    pointer-events: none;
}

.key-btn.wrong {
    background: rgba(255, 255, 255, 0.05);
    color: var(--key-wrong);
    border: 1px solid rgba(239, 68, 68, 0.3);
    opacity: 0.5;
    pointer-events: none;
}

/* ─── View 3: Results ─── */
.result-card {
    background: var(--surface);
    border: 1px solid rgba(255, 255, 255, .05);
    border-radius: var(--radius);
    padding: 3rem 2rem;
    text-align: center;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    margin: auto 0;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.4);
}

#resultTitle {
    font-size: 2.2rem;
    font-weight: 800;
    letter-spacing: -0.02em;
}

.title-win {
    color: var(--key-correct);
}

.title-lose {
    color: var(--key-wrong);
}

.result-message {
    color: var(--text-dim);
    font-size: 1rem;
}

.result-word {
    font-size: 2rem;
    font-weight: 800;
    color: var(--text);
    letter-spacing: 0.1em;
    margin: 0.5rem 0 1.5rem;
    word-break: break-all;
}

/* ─── Buttons ─── */
.btn-primary,
.btn-secondary {
    width: 100%;
    padding: 1.2rem;
    border: none;
    border-radius: var(--radius-sm);
    font-family: 'Inter', sans-serif;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.15s, box-shadow 0.15s;
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent), #007bb5);
    color: #fff;
    box-shadow: 0 5px 20px var(--accent-glow);
}

.btn-secondary {
    background: var(--surface-light);
    color: var(--text);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.btn-primary:active,
.btn-secondary:active {
    transform: scale(0.98);
}