/* ============================================
   Tour Infernale - Styles
   Design neon sombre inspiré de Pulse Pattern
   ============================================ */

#game-main {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #0f0c29, #302b63, #24243e);
    color: #e0e0e0;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100dvh;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    touch-action: manipulation;
}

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

#game-main [hidden] { display: none !important; }

#game-container {
    width: 100%;
    max-width: 560px;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 10px 15px;
    gap: 8px;
}

/* ===== Header ===== */
#game-header {
    width: 100%;
    text-align: center;
    flex-shrink: 0;
}

#game-title {
    font-size: 1.6rem;
    font-weight: 700;
    background: linear-gradient(90deg, #00d2ff, #7b2ff7, #ff6fd8);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: 2px;
    text-transform: uppercase;
    margin-bottom: 8px;
}

/* ===== Scores ===== */
#scores-container {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 16px;
    flex-wrap: nowrap;
}

.score-box {
    display: flex;
    flex-direction: column;
    align-items: center;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 10px;
    padding: 4px 12px;
    min-width: 70px;
}

.score-box.score-red { border: 1px solid rgba(255, 80, 80, 0.4); }
.score-box.score-blue { border: 1px solid rgba(80, 140, 255, 0.4); }
.score-box.score-time { border: 1px solid rgba(0, 210, 255, 0.3); }

.score-label {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: #888;
    display: flex;
    align-items: center;
    gap: 4px;
}

.dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
}
.dot-red { background: radial-gradient(circle at 30% 30%, #ff8080, #c01010); box-shadow: 0 0 6px #ff3030; }
.dot-blue { background: radial-gradient(circle at 30% 30%, #80b0ff, #1030c0); box-shadow: 0 0 6px #3080ff; }

.score-number {
    font-size: 1.3rem;
    font-weight: 700;
    color: #fff;
    font-variant-numeric: tabular-nums;
}

/* ===== Plateau ===== */
#board-wrap {
    flex: 1 1 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 6px;
    min-height: 0;
    perspective: 900px;
}

#board {
    position: relative;
    width: min(96vw, 70vh, 560px);
    aspect-ratio: 1 / 1;
    border-radius: 18px;
    padding: 22px;
    background:
        repeating-linear-gradient(90deg, rgba(123, 47, 247, 0.03) 0 2px, transparent 2px 7px),
        repeating-linear-gradient(0deg, rgba(0, 0, 0, 0.15) 0 2px, transparent 2px 7px),
        linear-gradient(160deg, #1a1a3e 0%, #0f0c29 60%, #080615 100%);
    box-shadow:
        0 24px 60px rgba(0, 0, 0, 0.75),
        0 0 40px rgba(123, 47, 247, 0.15),
        inset 0 2px 0 rgba(255, 255, 255, 0.08),
        inset 0 -2px 0 rgba(0, 0, 0, 0.6),
        inset 0 0 0 2px rgba(0, 210, 255, 0.15),
        inset 0 0 50px rgba(0, 0, 0, 0.55);
    border: 1px solid #0f0c29;
    transform: rotateX(8deg);
    transform-style: preserve-3d;
}

#board::before {
    content: "";
    position: absolute;
    inset: 8px;
    border: 1px solid rgba(0, 210, 255, 0.12);
    border-radius: 12px;
    pointer-events: none;
    box-shadow: inset 0 0 20px rgba(0, 0, 0, 0.4);
}

.board-glow {
    position: absolute;
    inset: -4px;
    border-radius: 22px;
    pointer-events: none;
    background: radial-gradient(ellipse at center, rgba(123, 47, 247, 0.12), transparent 70%);
    animation: pulse-glow 3s ease-in-out infinite;
}

@keyframes pulse-glow {
    0%, 100% { opacity: 0.4; }
    50% { opacity: 0.8; }
}

#canvas, #canvas-buf {
    position: absolute;
    inset: 22px;
    width: calc(100% - 44px);
    height: calc(100% - 44px);
    display: block;
    border-radius: 8px;
}

#canvas { z-index: 2; touch-action: none; cursor: pointer; }
#canvas-buf { z-index: 1; }

/* ===== Ligne d'aide ===== */
#hint-line {
    flex: 0 0 auto;
    text-align: center;
    padding: 6px 14px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 10px;
    color: #b0b0ff;
    font-size: 0.9rem;
    font-weight: 500;
    min-height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
}

#hint-line strong { color: #00d2ff; font-weight: 700; }

/* ===== Contrôles ===== */
#controls-container {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex-shrink: 0;
}

.picker-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 5px;
}

.picker-btn {
    padding: 8px 4px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    background: rgba(255, 255, 255, 0.05);
    color: #e0e0e0;
    border-radius: 9px;
    font-weight: 600;
    font-size: 0.85rem;
    letter-spacing: 0.5px;
    cursor: pointer;
    transition: all 0.15s;
    -webkit-tap-highlight-color: transparent;
}

.picker-btn.active {
    background: linear-gradient(135deg, #00d2ff, #7b2ff7);
    color: #fff;
    border-color: #00d2ff;
    box-shadow: 0 0 12px rgba(0, 210, 255, 0.35);
}

.picker-btn:active { transform: scale(0.96); }
.picker-btn:disabled { opacity: 0.45; cursor: not-allowed; }

.opt-row {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 5px;
}

.opt-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    padding: 7px 4px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    color: #e0e0e0;
}

.opt-toggle input { accent-color: #7b2ff7; width: 14px; height: 14px; }
.opt-toggle input:disabled { opacity: 0.45; }

.action-row {
    display: grid;
    grid-template-columns: 1.3fr 1fr 1fr 1fr;
    gap: 6px;
}

.game-btn {
    padding: 12px 6px;
    border-radius: 10px;
    border: none;
    font-weight: 700;
    font-size: 0.85rem;
    letter-spacing: 0.5px;
    cursor: pointer;
    color: #fff;
    transition: transform 0.08s, box-shadow 0.15s, opacity 0.3s;
    -webkit-tap-highlight-color: transparent;
}

.game-btn:active { transform: scale(0.96); }
.game-btn:disabled { opacity: 0.45; cursor: not-allowed; }

.btn-play {
    background: linear-gradient(135deg, #00d2ff, #7b2ff7);
    box-shadow: 0 4px 15px rgba(0, 210, 255, 0.3);
}

.btn-stop {
    background: linear-gradient(135deg, #ff5252, #d50000);
    box-shadow: 0 4px 15px rgba(255, 82, 82, 0.3);
}

.btn-rules {
    background: linear-gradient(135deg, #ff6fd8, #7b2ff7);
    box-shadow: 0 4px 15px rgba(123, 47, 247, 0.3);
}

.btn-scores {
    background: rgba(255, 255, 255, 0.12);
    border: 2px solid rgba(255, 255, 255, 0.15);
}

/* ===== Message ===== */
.message {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.85);
    color: #b0b0ff;
    padding: 14px 22px;
    border-radius: 12px;
    border: 1px solid rgba(0, 210, 255, 0.3);
    font-weight: 700;
    z-index: 50;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.7);
    pointer-events: none;
    animation: fadein 0.2s;
}

@keyframes fadein {
    from { opacity: 0; transform: translate(-50%, -45%); }
    to   { opacity: 1; transform: translate(-50%, -50%); }
}

/* ===== Modales ===== */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.75);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 16px;
    backdrop-filter: blur(6px);
    animation: fadeIn 0.25s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-overlay.hidden { display: none !important; }

.modal-content {
    background: linear-gradient(135deg, #1a1a3e, #2a2a5e);
    border: 1px solid rgba(123, 47, 247, 0.4);
    border-radius: 16px;
    padding: 22px;
    max-width: 460px;
    width: 100%;
    max-height: 82vh;
    overflow-y: auto;
    position: relative;
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.5);
    color: #e0e0e0;
    animation: slideUp 0.3s ease;
}

@keyframes slideUp {
    from { transform: translateY(30px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.modal-close {
    position: absolute;
    top: 10px;
    right: 14px;
    background: none;
    border: none;
    color: #aaa;
    font-size: 1.8rem;
    cursor: pointer;
    line-height: 1;
    padding: 4px 8px;
    transition: color 0.2s;
}

.modal-close:hover { color: #fff; }

.modal-title {
    font-size: 1.3rem;
    font-weight: 700;
    margin-bottom: 14px;
    background: linear-gradient(90deg, #00d2ff, #7b2ff7);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-align: center;
}

.modal-body {
    font-size: 0.88rem;
    line-height: 1.6;
    color: #ccc;
}

.modal-body ul {
    list-style: disc;
    margin-left: 20px;
    margin-bottom: 12px;
    line-height: 1.7;
}

.modal-body ul ul { margin-top: 4px; }

.modal-body p { line-height: 1.6; margin-bottom: 8px; }

.modal-hint {
    opacity: 0.85;
    font-style: italic;
    margin: 10px 0 16px;
    color: #b0b0ff;
}

.modal-input {
    width: 100%;
    padding: 10px 12px;
    border-radius: 8px;
    border: 1px solid rgba(123, 47, 247, 0.4);
    background: rgba(0, 0, 0, 0.3);
    color: #fff;
    font-size: 15px;
    margin: 14px 0 6px;
}

.scores-list {
    margin: 8px 0 16px;
    max-height: 50vh;
    overflow-y: auto;
    font-size: 0.9rem;
}

.score-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 10px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    gap: 6px;
}

.score-row:nth-child(odd) {
    background: rgba(255, 255, 255, 0.03);
    border-radius: 6px;
    border-bottom: none;
}

.score-row .name { font-weight: 700; color: #00d2ff; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.score-row .lvl { font-size: 0.7rem; opacity: 0.7; padding: 2px 6px; background: rgba(123, 47, 247, 0.15); border-radius: 4px; }
.score-row .pts { font-weight: 800; color: #fff; font-variant-numeric: tabular-nums; }
.score-row .won { font-size: 1rem; }

/* ===== Utilitaires ===== */
.hidden { display: none !important; }

/* ===== Responsive ===== */
@media (max-height: 600px) {
    #game-container { padding: 5px 10px; gap: 4px; }
    #game-title { font-size: 1.1rem; margin-bottom: 3px; }
    .score-box { padding: 2px 8px; min-width: 60px; }
    .score-number { font-size: 1rem; }
    .picker-btn, .opt-toggle { padding: 5px 2px; font-size: 0.75rem; }
    .game-btn { padding: 9px 4px; font-size: 0.75rem; }
    #hint-line { padding: 4px 10px; min-height: 26px; font-size: 0.75rem; }
}

@media (max-width: 360px) {
    .opt-row { gap: 3px; }
    .action-row { gap: 4px; }
    #scores-container { gap: 6px; }
}
