/* Base Layout & Typography */
body { font-family: 'Poppins', sans-serif; background-color: #f1f5f9; color: #334155; margin: 0; padding: 15px; transition: background-color 0.4s ease, color 0.4s ease; }
.hidden { display: none !important; }

/* Top Bar */
.top-bar { display: flex; justify-content: space-between; align-items: center; max-width: 1100px; margin: 0 auto 10px auto; }
.top-bar button { background: #ffffff; border: none; box-shadow: 0 2px 10px rgba(0,0,0,0.05); color: #475569; padding: 8px 16px; border-radius: 30px; cursor: pointer; font-size: 14px; font-weight: 600; transition: all 0.2s; }
.top-bar button:hover { transform: translateY(-2px); box-shadow: 0 4px 12px rgba(0,0,0,0.1); color: #0f172a; }

/* --- SIDE-BY-SIDE LAYOUT --- */
.layout-wrapper { display: flex; gap: 40px; max-width: 1100px; margin: 0 auto; align-items: flex-start; justify-content: center;}

/* Sidebar (Left) */
.sidebar { width: 320px; flex-shrink: 0; background: #ffffff; padding: 20px; border-radius: 20px; box-shadow: 0 10px 30px rgba(0,0,0,0.06); box-sizing: border-box;}
.main-content { display: flex; flex-direction: column; align-items: center;}

/* Headers & Score */
.header-container { text-align: center; margin-bottom: 20px; }
h1 { font-size: 32px; margin: 0 0 5px 0; font-weight: 700; color: #0f172a; letter-spacing: -1px; line-height: 1.1;}
.score-board { font-size: 16px; font-weight: 600; color: #3b82f6; background: #eff6ff; padding: 8px 15px; border-radius: 12px; display: inline-block; margin-top: 10px; }
.quick-tip { font-size: 12px; color: #64748b; background: #f8fafc; padding: 10px; border-radius: 8px; margin: 15px 0 0 0; text-align: center; line-height: 1.4; border: 1px solid #e2e8f0; }

/* Controls & Buttons */
.controls { display: flex; flex-direction: column; gap: 10px; margin-bottom: 20px; }
.sidebar-divider { border: none; border-top: 1px solid #e2e8f0; margin: 10px 0; }
button.action-btn, button.hint-btn, button.danger-btn, button.warning-btn { padding: 12px; font-size: 13px; cursor: pointer; border-radius: 12px; width: 100%; font-family: 'Poppins', sans-serif; outline: none; border: none; font-weight: 600; transition: all 0.2s; }

button.action-btn { background-color: #3b82f6; color: white; box-shadow: 0 4px 15px rgba(59, 130, 246, 0.3); }
button.action-btn:hover { background-color: #2563eb; transform: translateY(-2px); }

button.warning-btn { background-color: #64748b; color: white; }
button.warning-btn:hover { background-color: #475569; transform: translateY(-2px); }

button.hint-btn { background-color: #f59e0b; color: white; box-shadow: 0 4px 15px rgba(245, 158, 11, 0.3); }
button.hint-btn:hover:not(:disabled) { background-color: #d97706; transform: translateY(-2px); }
button.hint-btn:disabled { background-color: #cbd5e1; box-shadow: none; cursor: not-allowed; }

button.danger-btn { background-color: #ef4444; color: white; box-shadow: 0 4px 15px rgba(239, 68, 68, 0.3); }
button.danger-btn:hover { background-color: #dc2626; transform: translateY(-2px); }
button.danger-btn.outline { background-color: transparent; border: 2px solid #ef4444; color: #ef4444; box-shadow: none; padding: 10px; }
button.danger-btn.outline:hover { background-color: #fef2f2; transform: none; }

/* History Panel */
#history-panel { background: #f8fafc; padding: 12px; border-radius: 12px; font-size: 12px; border: 1px solid #e2e8f0; }
#history-list { list-style: none; padding: 0; margin: 8px 0 0 0; color: #475569; }
#history-list li { padding: 6px 0; border-bottom: 1px dashed #cbd5e1; }
#history-list li:last-child { border-bottom: none; padding-bottom: 0; }

/* --- MAIN GAME AREA --- */
.board-container { display: flex; flex-direction: column; align-items: center; background: #ffffff; padding: 25px; border-radius: 20px; box-shadow: 0 10px 40px rgba(0,0,0,0.08); margin-top: 5px; width: 100%; max-width: 550px;}

#message { height: 24px; font-weight: 700; color: #e11d48; margin-bottom: 10px; font-size: 16px; }

/* Hint Display */
#hint-display { background: #fffbeb; color: #b45309; padding: 12px 20px; border-radius: 10px; border: 1px solid #fde68a; margin-bottom: 15px; font-size: 14px; font-weight: 600; text-align: center; width: 100%; box-sizing: border-box; }

/* Word Grid & Labels */
#board { display: flex; flex-direction: column; gap: 6px; margin-bottom: 15px; width: 100%; align-items: center;}
.row-container { display: flex; align-items: center; gap: 12px; }
.row-label { width: 70px; font-size: 13px; font-weight: 700; color: #94a3b8; text-align: right; letter-spacing: 0.5px; text-transform: uppercase;}
.row { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.tile { width: 55px; height: 55px; border: 2px solid #cbd5e1; border-radius: 8px; font-size: 30px; font-weight: 700; display: flex; justify-content: center; align-items: center; text-transform: uppercase; background-color: white; color: #0f172a; transition: transform 0.3s, background-color 0.4s, border-color 0.4s, color 0.4s; }

/* Tile States */
.tile.filled { border-color: #64748b; animation: pop 0.1s ease-in-out; }
.tile.correct { background-color: #10b981; color: white; border-color: #10b981; }
.tile.present { background-color: #f59e0b; color: white; border-color: #f59e0b; }
.tile.absent { background-color: #64748b; color: white; border-color: #64748b; }
@keyframes pop { 50% { transform: scale(1.1); } }

/* Mini Legend & Text */
.mini-legend { display: flex; gap: 15px; justify-content: center; margin-bottom: 10px; font-size: 12px; font-weight: 600; color: #64748b; }
.legend-item { display: flex; align-items: center; gap: 5px; }
.legend-box { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
.legend-box.correct { background-color: #10b981; }
.legend-box.present { background-color: #f59e0b; }
.legend-box.absent { background-color: #64748b; }

.submit-tip { font-size: 12px; color: #3b82f6; font-weight: 600; margin: 10px 0 15px 0;}

/* Keyboard */
#keyboard { display: flex; flex-direction: column; gap: 8px; width: 100%; }
.keyboard-row { display: flex; justify-content: center; gap: 6px; }
.key { background-color: #e2e8f0; border: none; border-radius: 6px; padding: 15px 10px; font-size: 14px; font-weight: 700; cursor: pointer; text-transform: uppercase; flex: 1; max-width: 45px; display: flex; justify-content: center; align-items: center; transition: all 0.2s; color: #334155; font-family: 'Poppins', sans-serif;}
.key.large { max-width: 65px; font-size: 12px; }
.key:active { transform: scale(0.95); }

.key.correct { background-color: #10b981; color: white; }
.key.present { background-color: #f59e0b; color: white; }
.key.absent { background-color: #64748b; color: white; }

/* GLOWING ENTER BUTTON ANIMATION */
.key.enter-ready { background-color: #3b82f6 !important; color: white !important; animation: pulse-enter 1s infinite; }
@keyframes pulse-enter { 0% { transform: scale(1); } 50% { transform: scale(1.05); } 100% { transform: scale(1); } }

/* Tutorial Modal */
#tutorial-modal { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(15, 23, 42, 0.7); display: flex; justify-content: center; align-items: center; z-index: 1000; backdrop-filter: blur(3px); }
.tutorial-content { background: #fff; padding: 30px; border-radius: 20px; max-width: 450px; width: 90%; position: relative; box-shadow: 0 20px 50px rgba(0,0,0,0.2); }
.close-btn { position: absolute; top: 15px; right: 20px; cursor: pointer; font-size: 24px; font-weight: bold; color: #64748b; }
.tutorial-content hr { border: none; border-top: 1px solid #e2e8f0; margin: 15px 0; }
.example-row { display: flex; gap: 4px; margin-bottom: 5px; margin-top: 15px; }
.tile.mini { width: 35px; height: 35px; font-size: 20px; border-width: 2px;}

/* Responsive */
@media (max-width: 850px) {
    .layout-wrapper { flex-direction: column; align-items: center; gap: 20px;}
    .sidebar { width: 100%; max-width: 450px; }
    .row-label { display: none; }
    .tile { width: 50px; height: 50px; font-size: 24px; }
    .key { padding: 15px 5px; font-size: 12px; }
}

/* --- DARK MODE --- */
body.dark-mode { background-color: #0f172a; color: #f8fafc; }
body.dark-mode .top-bar button { background: #1e293b; color: #cbd5e1; box-shadow: 0 2px 10px rgba(0,0,0,0.2); }
body.dark-mode .top-bar button:hover { background: #334155; color: #fff; }
body.dark-mode .sidebar, body.dark-mode .board-container, body.dark-mode .tutorial-content { background-color: #1e293b; color: #f8fafc; box-shadow: 0 10px 30px rgba(0,0,0,0.3); border: 1px solid #334155; }
body.dark-mode h1 { color: #f8fafc; }
body.dark-mode .score-board { background: #0f172a; color: #60a5fa; }
body.dark-mode .quick-tip, body.dark-mode .tutorial-content hr, body.dark-mode .sidebar-divider { border-color: #334155; }
body.dark-mode .quick-tip { background: #0f172a; color: #94a3b8; }
body.dark-mode #history-panel { background: #0f172a; border-color: #334155; }
body.dark-mode #history-list li { border-color: #334155; color: #94a3b8; }
body.dark-mode .mini-legend, body.dark-mode .row-label { color: #94a3b8; }
body.dark-mode .submit-tip { color: #60a5fa; }
body.dark-mode button.danger-btn.outline { border-color: #ef4444; color: #ef4444; }
body.dark-mode button.danger-btn.outline:hover { background-color: rgba(239, 68, 68, 0.1); }
body.dark-mode #hint-display { background: #451a03; color: #fde68a; border-color: #78350f; }
body.dark-mode .tile { background-color: #1e293b; border-color: #334155; color: #f8fafc; }
body.dark-mode .tile.filled { border-color: #94a3b8; }
body.dark-mode .key { background-color: #334155; color: #f8fafc; }
body.dark-mode .key:hover { background-color: #475569; }
body.dark-mode .tile.correct, body.dark-mode .key.correct { background-color: #10b981; border-color: #10b981; color: white;}
body.dark-mode .tile.present, body.dark-mode .key.present { background-color: #f59e0b; border-color: #f59e0b; color: white;}
body.dark-mode .tile.absent, body.dark-mode .key.absent { background-color: #0f172a; border-color: #0f172a; color: white;}