/* ================================================================
 * pendu.css — Le Pendu
 * Accessibility-first: large text, high contrast, big touch targets
 * ============================================================== */

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

body {
    font-family: 'Segoe UI', Arial, sans-serif;
    background: linear-gradient(155deg, #1a2a3a 0%, #0e1c2c 100%);
    color: #f0f4f8;
    min-height: 100vh;
    font-size: 18px;
    line-height: 1.5;
}

/* ================================================================
 * Screens
 * ============================================================== */

.screen {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}
.screen.hidden { display: none !important; }

/* ================================================================
 * Settings Screen
 * ============================================================== */

.settings-container {
    width: 100%;
    max-width: 580px;
    padding: 32px 28px;
    background: rgba(255, 255, 255, 0.07);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 22px;
    margin: 20px 16px;
    display: flex;
    flex-direction: column;
    gap: 26px;
}

.back-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: #88bbdd;
    text-decoration: none;
    font-size: 1.1rem;
    font-weight: 600;
    padding: 10px 6px;
    border-radius: 8px;
    transition: color 0.2s;
    align-self: flex-start;
}
.back-link:hover { color: #ffffff; }
.back-link:focus { outline: 4px solid #f39c12; outline-offset: 4px; }

.game-title {
    font-size: clamp(2.2rem, 7vw, 3.2rem);
    font-weight: 800;
    color: #ffffff;
    display: flex;
    align-items: center;
    gap: 14px;
    line-height: 1.1;
}

.game-subtitle {
    font-size: clamp(1.05rem, 2.5vw, 1.3rem);
    color: #9bbdd4;
    margin-top: -12px;
}

/* Rules box */
.rules-box {
    background: rgba(85, 153, 255, 0.08);
    border-left: 5px solid #5599ff;
    border-radius: 0 12px 12px 0;
    padding: 18px 20px;
}
.rules-heading {
    font-size: clamp(1rem, 2.5vw, 1.15rem);
    font-weight: 700;
    color: #cce4ff;
    margin-bottom: 12px;
    letter-spacing: 0.3px;
}
.rules-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.rules-list li {
    padding-left: 22px;
    position: relative;
    font-size: clamp(0.95rem, 2.2vw, 1.1rem);
    color: #ddeeff;
    line-height: 1.5;
}
.rules-list li::before {
    content: '▸';
    position: absolute;
    left: 0;
    color: #5599ff;
}

/* Difficulty buttons */
.setting-group {
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.setting-label {
    font-size: clamp(1rem, 2.5vw, 1.15rem);
    font-weight: 700;
    color: #cce4ff;
}
.btn-group {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}
.setting-btn {
    flex: 1;
    min-width: 100px;
    padding: 16px 18px;
    font-size: clamp(1rem, 2.5vw, 1.15rem);
    font-weight: 600;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-radius: 12px;
    background: transparent;
    color: #ffffff;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
    min-height: 60px;
}
.setting-btn:hover {
    background: rgba(255, 255, 255, 0.12);
    border-color: rgba(255, 255, 255, 0.55);
}
.setting-btn:focus { outline: 4px solid #f39c12; outline-offset: 3px; }
.setting-btn.active {
    background: #ffffff;
    color: #1a2a3a;
    border-color: #ffffff;
    font-weight: 800;
}

/* Start/Play button */
.start-btn {
    width: 100%;
    padding: 22px;
    font-size: clamp(1.2rem, 3vw, 1.5rem);
    font-weight: 800;
    background: linear-gradient(135deg, #27ae60, #2ecc71);
    color: #ffffff;
    border: none;
    border-radius: 14px;
    cursor: pointer;
    transition: transform 0.15s, box-shadow 0.15s;
    box-shadow: 0 6px 20px rgba(39, 174, 96, 0.38);
    min-height: 70px;
    letter-spacing: 0.5px;
}
.start-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 28px rgba(39, 174, 96, 0.5);
}
.start-btn:active { transform: translateY(0); }
.start-btn:focus  { outline: 4px solid #f39c12; outline-offset: 4px; }

/* ================================================================
 * Game Header
 * ============================================================== */

.game-header {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: rgba(0, 0, 0, 0.3);
    border-bottom: 2px solid rgba(255, 255, 255, 0.1);
    gap: 12px;
    flex-shrink: 0;
}

.header-btn {
    padding: 10px 16px;
    font-size: 1.4rem;
    background: rgba(255, 255, 255, 0.1);
    color: #ffffff;
    border: 2px solid rgba(255, 255, 255, 0.28);
    border-radius: 10px;
    cursor: pointer;
    min-width: 54px;
    min-height: 54px;
    transition: background 0.2s;
}
.header-btn:hover { background: rgba(255, 255, 255, 0.2); }
.header-btn:focus { outline: 4px solid #f39c12; outline-offset: 3px; }

.difficulty-badge {
    font-size: 1rem;
    font-weight: 700;
    padding: 8px 18px;
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.1);
    color: #cce4ff;
    border: 2px solid rgba(255, 255, 255, 0.2);
    white-space: nowrap;
}

.error-box {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: clamp(0.95rem, 2.2vw, 1.1rem);
    font-weight: 600;
    color: #ffffff;
    background: rgba(0, 0, 0, 0.28);
    padding: 10px 16px;
    border-radius: 10px;
    border: 2px solid rgba(255, 255, 255, 0.18);
    white-space: nowrap;
}
.error-box strong {
    font-size: clamp(1.15rem, 2.8vw, 1.45rem);
    color: #ff8b8b;
}

/* ================================================================
 * Game Area (main content)
 * ============================================================== */

#game-screen {
    flex-direction: column;
    justify-content: flex-start;
}

.game-area {
    flex: 1;
    width: 100%;
    max-width: 640px;
    margin: 0 auto;
    padding: 14px 14px 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
    overflow-y: auto;
}

/* Hangman SVG */
.hangman-wrap {
    width: clamp(130px, 32vw, 190px);
    flex-shrink: 0;
}
.hangman-wrap svg { width: 100%; height: auto; }

.gallows {
    stroke: #7aaacc;
    stroke-width: 8;
    stroke-linecap: round;
    fill: none;
}
.body-part {
    stroke: #ff8b8b;
    stroke-width: 7;
    stroke-linecap: round;
    fill: none;
}
/* SVG circle needs fill explicitly set */
#hg-head { fill: none; }

.hidden-part { display: none; }

/* ----------------------------------------------------------------
 * Word display — large blank/letter cells
 * -------------------------------------------------------------- */

.word-display {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: flex-end;
    gap: 6px 10px;
    padding: 6px 4px;
    min-height: 80px;
    width: 100%;
}

.letter-cell {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
}

.letter-char {
    font-size: clamp(2rem, 7.5vw, 3.4rem);
    font-weight: 800;
    color: transparent;          /* hidden by default */
    min-width: 38px;
    text-align: center;
    line-height: 1;
    letter-spacing: 1px;
    user-select: none;
}

.letter-line {
    width: 100%;
    min-width: 36px;
    height: 5px;
    background: rgba(255, 255, 255, 0.45);
    border-radius: 3px;
}

/* Revealed: show the letter in green */
.letter-cell.revealed .letter-char {
    color: #7de8a0;
    text-shadow: 0 2px 8px rgba(125, 232, 160, 0.35);
}
.letter-cell.revealed .letter-line { background: #7de8a0; }

/* Space between words (for multi-word phrases if needed) */
.letter-cell.space {
    width: 18px;
}

/* ----------------------------------------------------------------
 * Status message
 * -------------------------------------------------------------- */

.status-msg {
    font-size: clamp(1rem, 2.8vw, 1.25rem);
    font-weight: 600;
    padding: 10px 20px;
    border-radius: 10px;
    text-align: center;
    min-height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    max-width: 460px;
    transition: background 0.2s, border-color 0.2s;
}
.status-msg.correct {
    background: rgba(46, 204, 113, 0.18);
    color: #7de8a0;
    border: 2px solid rgba(46, 204, 113, 0.38);
}
.status-msg.wrong {
    background: rgba(231, 76, 60, 0.18);
    color: #ff8b8b;
    border: 2px solid rgba(231, 76, 60, 0.38);
}
.status-msg.info {
    background: rgba(52, 152, 219, 0.12);
    color: #9bbdd4;
    border: 2px solid rgba(52, 152, 219, 0.28);
}

/* ----------------------------------------------------------------
 * Letter keyboard A–Z
 * -------------------------------------------------------------- */

.keyboard {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 6px;
    width: 100%;
    max-width: 500px;
    padding: 2px;
}

.key-btn {
    width:  clamp(48px, 10.5vw, 64px);
    height: clamp(48px, 10.5vw, 64px);
    font-size: clamp(1.1rem, 2.6vw, 1.45rem);
    font-weight: 800;
    border-radius: 10px;
    border: 3px solid rgba(255, 255, 255, 0.28);
    background: rgba(255, 255, 255, 0.1);
    color: #ffffff;
    cursor: pointer;
    transition: background 0.12s, transform 0.1s, border-color 0.12s;
    display: flex;
    align-items: center;
    justify-content: center;
}
.key-btn:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.6);
    transform: translateY(-2px);
}
.key-btn:focus { outline: 4px solid #f39c12; outline-offset: 3px; }

/* Correct guess — green */
.key-btn.correct {
    background: rgba(46, 204, 113, 0.22);
    border-color: #2ecc71;
    color: #7de8a0;
    cursor: default;
    transform: none;
}

/* Wrong guess — red, faded, strikethrough visual */
.key-btn.wrong {
    background: rgba(231, 76, 60, 0.12);
    border-color: rgba(231, 76, 60, 0.45);
    color: rgba(255, 139, 139, 0.6);
    cursor: default;
    opacity: 0.65;
    transform: none;
    text-decoration: line-through;
}

.key-btn:disabled { pointer-events: none; }

/* ================================================================
 * End Screen
 * ============================================================== */

#end-screen {
    padding: 24px 16px;
}

.end-container {
    width: 100%;
    max-width: 480px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 22px;
    padding: 40px 28px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 18px;
    text-align: center;
}

.result-icon {
    font-size: clamp(3.5rem, 12vw, 5.5rem);
    line-height: 1;
}

.result-title {
    font-size: clamp(1.8rem, 5.5vw, 2.6rem);
    font-weight: 800;
    color: #ffffff;
    line-height: 1.2;
}

.result-subtitle {
    font-size: clamp(1rem, 2.5vw, 1.2rem);
    color: #9bbdd4;
}

.result-word {
    font-size: clamp(1.8rem, 5.5vw, 2.8rem);
    font-weight: 800;
    color: #7de8a0;
    letter-spacing: 6px;
    text-shadow: 0 2px 12px rgba(125, 232, 160, 0.3);
    word-break: break-all;
}

.end-buttons {
    display: flex;
    flex-direction: column;
    gap: 14px;
    width: 100%;
    margin-top: 6px;
}

.end-btn {
    width: 100%;
    padding: 20px;
    font-size: clamp(1.1rem, 2.8vw, 1.3rem);
    font-weight: 700;
    border-radius: 14px;
    border: none;
    cursor: pointer;
    text-decoration: none;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.15s, box-shadow 0.15s;
    min-height: 64px;
}
.end-btn.primary {
    background: linear-gradient(135deg, #27ae60, #2ecc71);
    color: #ffffff;
    box-shadow: 0 4px 16px rgba(39, 174, 96, 0.38);
}
.end-btn.primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(39, 174, 96, 0.5);
}
.end-btn.secondary {
    background: rgba(255, 255, 255, 0.1);
    color: #cce4ff;
    border: 2px solid rgba(255, 255, 255, 0.24);
}
.end-btn.secondary:hover { background: rgba(255, 255, 255, 0.18); }
.end-btn:focus { outline: 4px solid #f39c12; outline-offset: 4px; }

/* ================================================================
 * Mobile
 * ============================================================== */

@media (max-width: 480px) {
    .settings-container { padding: 20px 16px; margin: 12px; }
    .game-area          { padding: 10px 10px 16px; gap: 10px; }
    .keyboard           { gap: 5px; }
    .end-container      { padding: 28px 18px; }
}

/* ================================================================
 * Animations
 * ============================================================== */

@keyframes bounceIn {
    0%   { transform: scale(0.6); opacity: 0.5; }
    70%  { transform: scale(1.12); }
    100% { transform: scale(1);   opacity: 1; }
}
.key-btn.correct { animation: bounceIn 0.28s ease-out forwards; }

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    20%, 60%  { transform: translateX(-6px); }
    40%, 80%  { transform: translateX(6px); }
}
.shake { animation: shake 0.38s ease-in-out; }

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to   { opacity: 1; transform: translateY(0); }
}
#end-screen .end-container { animation: fadeIn 0.4s ease-out; }
