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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #2c3e50 0%, #34495e 100%);
    min-height: 100vh; color: #fff;
}
.screen { min-height: 100vh; display: flex; flex-direction: column; }
.screen.hidden { display: none !important; }
.hidden { display: none !important; }

.settings-container {
    max-width: 560px; margin: auto; padding: 40px;
    background: rgba(0,0,0,0.3); border-radius: 20px; text-align: center;
}
.settings-container h1 { font-size: 3rem; margin-bottom: 10px; }
.settings-container h2 { font-size: 2rem; margin-bottom: 30px; font-weight: normal; opacity: 0.9; }
.setting-group { margin-bottom: 24px; }
.setting-group label { display: block; font-size: 1.3rem; margin-bottom: 10px; }
.button-group { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.setting-btn {
    padding: 12px 18px; font-size: 1.05rem;
    border: 3px solid #fff; background: transparent; color: #fff;
    border-radius: 12px; cursor: pointer; transition: all 0.2s;
    min-width: 110px; min-height: 56px;
}
.setting-btn:hover { background: rgba(255,255,255,0.2); transform: scale(1.05); }
.setting-btn:focus { outline: 4px solid #f39c12; outline-offset: 2px; }
.setting-btn.active { background: #fff; color: #2c3e50; font-weight: bold; }
.player-input {
    width: 100%; padding: 14px 18px; font-size: 1.3rem;
    border: 3px solid #fff; border-radius: 10px;
    background: rgba(255,255,255,0.9); color: #2c3e50; text-align: center;
}
.primary-btn {
    margin-top: 18px; padding: 18px 40px; font-size: 1.7rem;
    background: #e74c3c; color: #fff; border: none; border-radius: 15px;
    cursor: pointer; font-weight: bold; transition: all 0.2s;
    min-height: 70px; display: flex; width: 100%; align-items: center; justify-content: center;
    text-decoration: none;
}
.primary-btn:hover { background: #c0392b; transform: scale(1.03); }
.primary-btn:focus { outline: 4px solid #f39c12; outline-offset: 3px; }
.secondary-btn { margin-top: 12px; background: rgba(255,255,255,0.2); border: 3px solid #fff; }
.secondary-btn:hover { background: rgba(255,255,255,0.35); }
.back-btn { text-decoration: none; }

.rules-summary {
    background: rgba(255,255,255,0.1); border-radius: 12px;
    padding: 18px 22px; margin: 20px 0; text-align: left;
}
.rules-summary h3 { font-size: 1.3rem; margin-bottom: 10px; }
.rules-summary ul { list-style: none; }
.rules-summary li { font-size: 1.05rem; padding: 5px 0; opacity: 0.9; }
.rules-summary li::before { content: '• '; color: #f39c12; font-weight: bold; }

.error-msg { color: #e74c3c; font-size: 1.1rem; margin-top: 8px; }

/* Code Builder */
.code-builder { display: flex; gap: 14px; justify-content: center; margin-bottom: 16px; }
.code-slot {
    width: 72px; height: 72px; border-radius: 50%;
    border: 4px solid rgba(255,255,255,0.4);
    background: rgba(255,255,255,0.1); cursor: default;
    display: flex; align-items: center; justify-content: center;
    font-size: 0.8rem; color: rgba(255,255,255,0.5); transition: all 0.2s;
    position: relative;
}
.code-slot.filled { border-color: rgba(255,255,255,0.8); }

/* Header */
.game-header {
    display: flex; justify-content: space-between; align-items: center;
    padding: 12px 20px; background: rgba(0,0,0,0.3);
    flex-wrap: wrap; gap: 10px; min-height: 80px;
}
.game-header h1 { font-size: 1.8rem; }
.attempts-display {
    font-size: 1.4rem; font-weight: bold;
    padding: 10px 20px; border-radius: 10px;
    background: rgba(255,255,255,0.15);
}
.action-btn {
    padding: 12px 18px; font-size: 1.05rem;
    background: rgba(255,255,255,0.9); color: #2c3e50;
    border: none; border-radius: 10px; cursor: pointer;
    font-weight: bold; transition: all 0.2s; min-height: 48px;
    text-decoration: none; display: inline-flex; align-items: center; justify-content: center;
}
.action-btn:hover { background: #fff; transform: scale(1.05); }
.action-btn:focus { outline: 4px solid #f39c12; outline-offset: 2px; }

/* Game Area */
.game-area {
    flex: 1; display: flex; flex-direction: column;
    align-items: center; padding: 16px; gap: 14px; overflow-y: auto;
}

/* History */
.history { display: flex; flex-direction: column; gap: 8px; width: 100%; max-width: 440px; }
.history-row {
    display: flex; align-items: center; gap: 10px;
    background: rgba(0,0,0,0.2); border-radius: 10px; padding: 8px 14px;
}
.history-num { font-size: 1rem; opacity: 0.6; width: 26px; text-align: right; flex-shrink: 0; }
.history-pegs { display: flex; gap: 6px; align-items: center; }
.history-feedback { display: flex; gap: 4px; flex-wrap: wrap; max-width: 60px; margin-left: auto; }

/* Pegs */
.peg {
    width: 48px; height: 48px; border-radius: 50%;
    border: 3px solid rgba(0,0,0,0.2); flex-shrink: 0;
    position: relative; display: flex; align-items: center; justify-content: center;
}
.peg.small { width: 22px; height: 22px; border-width: 2px; }
.peg.rouge  { background: #e74c3c; }
.peg.bleu   { background: #3498db; }
.peg.vert   { background: #27ae60; }
.peg.jaune  { background: #f1c40f; border-color: rgba(0,0,0,0.15); }
.peg.violet { background: #9b59b6; }
.peg.orange { background: #e67e22; }
/* Feedback pegs — per user request: red=right place, outline=right color, grey=miss */
.peg.empty  { background: #7f8c8d; border: 2px solid #95a5a6; }
.peg.black  { background: #e74c3c; border-color: rgba(255,255,255,0.4); }
.peg.white  { background: transparent; border: 3px solid rgba(255,255,255,0.85); box-shadow: inset 0 0 0 2px rgba(255,255,255,0.2); }

/* Colorblind symbols — overlaid on each colored circle via ::after */
.peg[data-color]::after,
.guess-peg[data-color]::after,
.palette-btn[data-color]::after,
.code-slot[data-color]::after {
    content: '';
    position: absolute; top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    font-size: 18px; font-weight: bold; line-height: 1;
    color: rgba(255,255,255,0.92); text-shadow: 0 1px 3px rgba(0,0,0,0.8);
    pointer-events: none;
}
.peg.small[data-color]::after { font-size: 11px; }
[data-color="rouge"]::after  { content: '▲'; }
[data-color="bleu"]::after   { content: '◆'; }
[data-color="vert"]::after   { content: '■'; }
[data-color="jaune"]::after  { content: '★'; }
[data-color="violet"]::after { content: '●'; }
[data-color="orange"]::after { content: '✕'; }

/* Legend bar */
.legend-bar {
    display: flex; gap: 16px; flex-wrap: wrap; justify-content: center;
    font-size: 0.85rem; opacity: 0.85;
    background: rgba(0,0,0,0.2); border-radius: 10px; padding: 8px 14px;
}
.legend-item { display: flex; align-items: center; gap: 6px; }
.legend-dot {
    width: 16px; height: 16px; border-radius: 50%; flex-shrink: 0; display: inline-block;
}
.correct-dot   { background: #e74c3c; border: 2px solid rgba(255,255,255,0.4); }
.misplaced-dot { background: transparent; border: 2px solid rgba(255,255,255,0.85); }
.miss-dot      { background: #7f8c8d; border: 2px solid #95a5a6; }

/* Guess row + palette stacked vertically */
.guess-and-palette {
    display: flex; flex-direction: column; align-items: center; gap: 14px;
    background: rgba(0,0,0,0.2); border-radius: 16px; padding: 12px 16px;
}

/* Current Guess */
.current-guess {
    display: flex; align-items: center; gap: 12px;
    background: rgba(0,0,0,0.25); border-radius: 14px;
    padding: 12px 16px; border: 3px solid rgba(243,156,18,0.5);
}
.guess-pegs { display: flex; gap: 10px; align-items: center; }
.guess-peg {
    width: 56px; height: 56px; border-radius: 50%;
    border: 3px solid rgba(255,255,255,0.4);
    background: rgba(255,255,255,0.1); cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    position: relative; transition: all 0.15s;
}
.guess-peg:hover { border-color: #f39c12; transform: scale(1.08); }
/* Selected peg: thick white border + bright orange outline for visibility on any color */
.guess-peg.selected {
    border-color: rgba(255,255,255,0.95);
    outline: 3px solid #f39c12;
    outline-offset: 2px;
    box-shadow: 0 0 16px rgba(243,156,18,0.8);
}
.submit-btn {
    padding: 12px 18px; font-size: 1.1rem; font-weight: bold;
    background: #27ae60; color: #fff; border: none; border-radius: 12px;
    cursor: pointer; transition: all 0.2s; min-height: 52px; white-space: nowrap;
}
.submit-btn:hover { background: #219a52; transform: scale(1.05); }
.submit-btn:focus { outline: 4px solid #f39c12; outline-offset: 2px; }
.submit-btn:disabled { opacity: 0.4; cursor: default; transform: none; }

/* Color Palette */
.color-palette {
    display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; align-items: center;
}
.palette-btn {
    width: 58px; height: 58px; border-radius: 50%;
    border: 4px solid rgba(255,255,255,0.4);
    cursor: pointer; transition: all 0.2s;
    position: relative;
}
.palette-btn:hover { transform: scale(1.12); border-color: #f39c12; box-shadow: 0 0 14px rgba(243,156,18,0.55); }
.palette-btn:focus { outline: 4px solid #f39c12; outline-offset: 3px; }

.waiting-msg { font-size: 1.3rem; opacity: 0.8; font-style: italic; }
.role-msg {
    font-size: 1.2rem; padding: 12px 20px; border-radius: 10px;
    background: rgba(52,152,219,0.2); border: 2px solid #3498db;
}

/* End Screen */
.result-container {
    max-width: 500px; margin: auto; padding: 50px 40px;
    background: rgba(0,0,0,0.4); border-radius: 20px; text-align: center;
}
.result-container h1 { font-size: 3rem; margin-bottom: 20px; }
.result-container p { font-size: 1.5rem; margin-bottom: 15px; opacity: 0.9; }
.reveal-code { display: flex; gap: 10px; justify-content: center; margin: 20px 0; }

@media (max-width: 768px) {
    .game-header { justify-content: center; }
    .header-left { display: none; }
    .header-center, .header-right { width: 100%; justify-content: center; }
    .peg { width: 38px; height: 38px; }
    .guess-peg { width: 46px; height: 46px; }
    .palette-btn { width: 48px; height: 48px; }
    .legend-bar { font-size: 0.78rem; gap: 10px; padding: 6px 10px; }
    .guess-and-palette { gap: 12px; padding: 10px; }
    .submit-btn { padding: 10px 14px; font-size: 1rem; }
}
