/* ============================
   WOODSLIDE — Theme bois chaud
   ============================ */
:root {
    --bg-dark: #1a0f0a;
    --bg-medium: #2d1f14;
    --bg-card: #3a2518;
    --primary: #c17f3e;
    --primary-light: #e0a86e;
    --accent: #f4c67a;
    --text: #f5efe6;
    --text-muted: #a89279;
    --success: #6fcf6a;
    --danger: #e74c3c;
    --board-bg: #5c3d2e;
    --board-border: #8b5e3c;
    --board-cell: #4a2e1e;
}

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

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

/* ---- SCREENS ---- */
.screen {
    display: none;
    position: fixed;
    inset: 0;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 10;
}
.screen.active { display: flex; }

/* ---- LOADING ---- */
#screenLoading {
    background: radial-gradient(ellipse at center, #3a2518 0%, #1a0f0a 70%);
}
.loading-container { text-align: center; padding: 2rem; }
.loading-logo { margin-bottom: 1.5rem; }
.loading-planks {
    display: flex;
    gap: 6px;
    justify-content: center;
    align-items: flex-end;
}
.lp {
    width: 18px;
    border-radius: 4px;
    animation: lpBounce 1.2s ease-in-out infinite;
}
.lp-red { height: 50px; background: linear-gradient(180deg, #ff6b6b, #c0392b); animation-delay: 0s; }
.lp-blue { height: 40px; background: linear-gradient(180deg, #74b9ff, #2980b9); animation-delay: 0.15s; }
.lp-green { height: 55px; background: linear-gradient(180deg, #55efc4, #00b894); animation-delay: 0.3s; }
.lp-yellow { height: 45px; background: linear-gradient(180deg, #ffeaa7, #fdcb6e); animation-delay: 0.45s; }
@keyframes lpBounce {
    0%, 100% { transform: scaleY(1); }
    50% { transform: scaleY(0.6); }
}
.loading-title {
    font-family: 'Fredoka One', cursive;
    font-size: 2.8rem;
    color: var(--accent);
    text-shadow: 0 3px 15px rgba(244,198,122,0.4);
}
.loading-subtitle { color: var(--text-muted); margin-top: 0.3rem; font-size: 1rem; }
.loading-bar-container {
    width: 220px;
    height: 6px;
    background: var(--bg-card);
    border-radius: 3px;
    margin: 1.5rem auto 0.8rem;
    overflow: hidden;
}
.loading-bar {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--primary), var(--accent));
    border-radius: 3px;
    transition: width 0.3s;
}
.loading-text { color: var(--text-muted); font-size: 0.85rem; }

/* ---- BACK TO HUB ---- */
.back-to-hub {
    position: absolute;
    top: 12px;
    left: 16px;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.85rem;
    z-index: 20;
    transition: color 0.2s;
}
.back-to-hub:hover { color: var(--accent); }

/* ---- HOME ---- */
#screenHome {
    background: radial-gradient(ellipse at center top, #3a2518 0%, #1a0f0a 70%);
}
.home-container { text-align: center; width: 100%; max-width: 420px; padding: 1rem; }
.home-header { margin-bottom: 2rem; }
.home-title {
    font-family: 'Fredoka One', cursive;
    font-size: 3.2rem;
    color: var(--primary-light);
    text-shadow: 0 4px 20px rgba(193,127,62,0.3);
}
.home-title span { color: var(--accent); }
.home-subtitle { color: var(--text-muted); font-size: 1.05rem; margin-top: 0.3rem; }
.home-version { color: var(--text-muted); font-size: 0.75rem; margin-top: 1.5rem; opacity: 0.5; }

/* ---- MENU BUTTONS ---- */
.home-menu { display: flex; flex-direction: column; gap: 10px; }
.menu-btn {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 14px 18px;
    background: var(--bg-card);
    border: 1px solid rgba(193,127,62,0.15);
    border-radius: 14px;
    color: var(--text);
    font-family: 'Poppins', sans-serif;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.2s;
}
.menu-btn:hover, .menu-btn:active {
    background: rgba(193,127,62,0.15);
    border-color: var(--primary);
    transform: translateX(4px);
}
.menu-btn.primary {
    background: linear-gradient(135deg, var(--primary), #a0612d);
    border-color: var(--primary-light);
    font-weight: 600;
}
.menu-btn.primary:hover { background: linear-gradient(135deg, var(--primary-light), var(--primary)); }
.btn-icon { font-size: 1.3rem; width: 32px; text-align: center; }
.btn-label { flex: 1; text-align: left; }
.btn-arrow { color: var(--text-muted); font-size: 1.1rem; }

/* ---- SCREEN CONTAINER ---- */
.screen-container {
    width: 100%;
    max-width: 520px;
    padding: 1.5rem;
    max-height: 100vh;
    overflow-y: auto;
}
.back-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    font-family: 'Poppins', sans-serif;
    font-size: 0.95rem;
    cursor: pointer;
    margin-bottom: 1rem;
}
.back-btn:hover { color: var(--accent); }
.screen-title {
    font-family: 'Fredoka One', cursive;
    font-size: 1.6rem;
    color: var(--accent);
    margin-bottom: 1.2rem;
}

/* ---- SCORES ---- */
.scores-tabs { display: flex; gap: 8px; margin-bottom: 1rem; }
.score-tab {
    flex: 1;
    padding: 8px 10px;
    background: var(--bg-card);
    border: 1px solid transparent;
    border-radius: 10px;
    color: var(--text-muted);
    font-family: 'Poppins', sans-serif;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s;
}
.score-tab.active {
    background: rgba(193,127,62,0.2);
    border-color: var(--primary);
    color: var(--accent);
}
.scores-table-container { overflow-x: auto; }
.scores-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}
.scores-table th {
    text-align: left;
    padding: 8px 10px;
    color: var(--text-muted);
    border-bottom: 1px solid var(--bg-card);
    font-weight: 500;
    font-size: 0.8rem;
    text-transform: uppercase;
}
.scores-table td {
    padding: 10px;
    border-bottom: 1px solid rgba(58,37,24,0.5);
}
.scores-table tr:first-child td { color: var(--accent); font-weight: 600; }
.scores-empty { color: var(--text-muted); text-align: center; margin-top: 2rem; }

/* ---- HOW TO PLAY ---- */
.howto-content {
    color: var(--text);
    line-height: 1.7;
    font-size: 0.95rem;
}
.howto-content h3 {
    color: var(--accent);
    font-family: 'Fredoka One', cursive;
    margin: 1.2rem 0 0.5rem;
    font-size: 1.1rem;
}
.howto-content p { margin-bottom: 0.7rem; }
.howto-content .howto-key {
    display: inline-block;
    background: var(--bg-card);
    border: 1px solid var(--primary);
    border-radius: 6px;
    padding: 2px 8px;
    font-size: 0.85rem;
    color: var(--accent);
    margin: 0 2px;
}

/* ---- GAME SCREEN ---- */
#screenGame.active {
    display: flex;
    background: var(--bg-dark);
}
.game-layout {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    height: 100%;
    max-width: 600px;
    padding: 8px;
    gap: 6px;
}
.game-top-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 4px 8px;
}
.game-back-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 6px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}
.game-back-btn:hover { color: var(--accent); background: var(--bg-card); }
.game-mode-badge {
    background: var(--bg-card);
    color: var(--primary-light);
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 500;
}
.game-level-badge {
    background: var(--primary);
    color: #fff;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
    transition: background 0.3s;
}
.game-timer {
    margin-left: auto;
    color: var(--accent);
    font-family: 'Fredoka One', cursive;
    font-size: 1.1rem;
}

/* ---- STATS BAR ---- */
.game-stats-bar {
    display: flex;
    gap: 12px;
    width: 100%;
    justify-content: center;
}
.stat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    background: var(--bg-card);
    border-radius: 10px;
    padding: 6px 16px;
    min-width: 80px;
}
.stat-label {
    font-size: 0.65rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
}
.stat-value {
    font-family: 'Fredoka One', cursive;
    font-size: 1.1rem;
    color: var(--accent);
}

/* ---- GAME BOARD ---- */
.game-board-wrapper {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    min-height: 0;
}
#gameCanvas {
    border-radius: 12px;
    touch-action: none;
}

/* ---- HINT BAR ---- */
.game-hint-bar {
    width: 100%;
    text-align: center;
    padding: 6px 12px;
    background: var(--bg-card);
    border-radius: 10px;
    border-left: 3px solid var(--primary);
}
.hint-text {
    color: var(--text-muted);
    font-size: 0.8rem;
}

/* ---- ACTIONS ---- */
.game-actions {
    display: flex;
    gap: 10px;
    width: 100%;
    justify-content: center;
    padding-bottom: 8px;
}
.action-btn {
    padding: 10px 20px;
    background: var(--bg-card);
    border: 1px solid rgba(193,127,62,0.2);
    border-radius: 12px;
    color: var(--text);
    font-family: 'Poppins', sans-serif;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s;
}
.action-btn:hover {
    background: rgba(193,127,62,0.15);
    border-color: var(--primary);
}
.action-btn:active { transform: scale(0.95); }

/* ---- TOAST ---- */
.toast-container {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
}
.toast {
    padding: 10px 24px;
    border-radius: 12px;
    font-family: 'Fredoka One', cursive;
    font-size: 1rem;
    text-align: center;
    animation: toastIn 0.3s ease, toastOut 0.4s ease 2s forwards;
    pointer-events: none;
}
.toast.info { background: var(--primary); color: #fff; }
.toast.bonus { background: linear-gradient(135deg, var(--accent), #e0a86e); color: #1a0f0a; }
.toast.error { background: var(--danger); color: #fff; }

@keyframes toastIn { from { opacity: 0; transform: translateY(-20px); } to { opacity: 1; transform: translateY(0); } }
@keyframes toastOut { from { opacity: 1; } to { opacity: 0; transform: translateY(-20px); } }

/* ---- MODAL ---- */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(10,5,2,0.85);
    z-index: 500;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(6px);
}
.modal-overlay.active { display: flex; }
.modal {
    background: var(--bg-medium);
    border: 1px solid var(--primary);
    border-radius: 20px;
    padding: 2rem 1.8rem;
    max-width: 380px;
    width: 90%;
    text-align: center;
    box-shadow: 0 20px 60px rgba(0,0,0,0.6);
}
.modal h2 {
    font-family: 'Fredoka One', cursive;
    font-size: 1.5rem;
    color: var(--accent);
    margin-bottom: 1rem;
}
.modal-score {
    font-family: 'Fredoka One', cursive;
    font-size: 2.5rem;
    color: var(--accent);
    margin: 0.5rem 0;
    text-shadow: 0 3px 15px rgba(244,198,122,0.3);
}
.modal-stat {
    display: flex;
    justify-content: space-between;
    padding: 6px 0;
    border-bottom: 1px solid rgba(193,127,62,0.15);
    font-size: 0.9rem;
}
.modal-stat span:first-child { color: var(--text-muted); }
.modal-stat span:last-child { color: var(--text); font-weight: 600; }
.modal-stars {
    font-size: 2rem;
    margin: 0.8rem 0;
    letter-spacing: 6px;
}
.modal-btn {
    display: block;
    width: 100%;
    padding: 12px;
    margin-top: 10px;
    border: 1px solid rgba(193,127,62,0.2);
    border-radius: 12px;
    font-family: 'Poppins', sans-serif;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.2s;
    background: var(--bg-card);
    color: var(--text);
}
.modal-btn.primary {
    background: linear-gradient(135deg, var(--primary), #a0612d);
    border-color: var(--primary-light);
    color: #fff;
    font-weight: 600;
}
.modal-btn:hover { transform: translateY(-1px); }

/* ---- MODAL INPUT ---- */
.modal-input {
    width: 100%;
    padding: 12px 16px;
    background: var(--bg-dark);
    border: 2px solid var(--primary);
    border-radius: 12px;
    color: var(--text);
    font-family: 'Poppins', sans-serif;
    font-size: 1.1rem;
    text-align: center;
    outline: none;
    margin: 0.5rem 0;
}
.modal-input:focus { border-color: var(--accent); }

/* ---- MOBILE ---- */
@media (max-width: 600px) {
    .home-title { font-size: 2.4rem; }
    .game-layout { padding: 4px; gap: 4px; }
    .stat-item { padding: 4px 10px; min-width: 65px; }
    .stat-value { font-size: 0.95rem; }
    .action-btn { padding: 10px 14px; font-size: 0.85rem; }
}
