/* =============================================
   HANGMAN SHARED STYLES
   Used by: hangman-easy.html, hangman-classic.html
   ============================================= */

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

   :root {
     --paper: #fdfcf7;
     --paper-elevated: #ffffff;
     --ink: #1a1814;
     --ink-mid: #4a4640;
     --ink-light: #9a9690;
     --border: #d4cfc5;
     --border-strong: #b8b2a4;
     --accent: #c4302b;
     --accent-dark: #8b1e1a;
     --success: #4a7c44;
     --error: #c4302b;
     --key-bg: #d4cfc5;
     --key-bd: #b8b2a4;
     --input-bg: #f0ede6;
     --sugg-bg: #ffffff;
     --sugg-hover: #f0ede6;
     --sugg-border: #d4cfc5;
     --key-wrong-bg: #c8b8a2;
     --key-wrong-ink: #5a4a38;
   }
   
   body.dark {
     --paper: #0f0f11;
     --paper-elevated: #1a1a1f;
     --ink: #f0f0f5;
     --ink-mid: #b0b0c0;
     --ink-light: #686878;
     --border: #3a3a45;
     --border-strong: #555565;
     --accent: #e85752;
     --accent-dark: #c4302b;
     --success: #538d4e;
     --error: #ff6b6b;
     --key-bg: #2a2a30;
     --key-bd: #3d3d4e;
     --input-bg: #1d1d22;
     --sugg-bg: #22222a;
     --sugg-hover: #2e2e38;
     --sugg-border: #3a3a45;
     --key-wrong-bg: #3a3a45;
     --key-wrong-ink: #888;
   }
   
   html { background: var(--paper); }
   
   body {
     font-family: 'Source Serif 4', 'Noto Sans Malayalam', serif;
     background: var(--paper);
     color: var(--ink);
     display: flex; flex-direction: column; align-items: center;
     padding: 10px 16px 80px;
     min-height: 100vh;
     transition: background 0.2s, color 0.2s;
   }
   
   /* ---- TOP BAR ---- */
   .top-bar {
     width: 100%; max-width: 640px;
     display: flex; justify-content: space-between; align-items: center;
     padding: 10px 0; border-bottom: 1px solid var(--border);
     font-size: 10px; letter-spacing: 1.5px; text-transform: uppercase;
     color: var(--ink-mid); font-family: 'Source Serif 4', serif;
   }
   .top-bar a { color: var(--ink-mid); text-decoration: none; transition: color 0.15s; }
   .top-bar a:hover { color: var(--accent); }
   
   .top-bar-logo-mobile { display: none; width: 44px; height: 44px; }
   
   @media (max-width: 800px) {
     .top-bar-back-text { display: none; }
     .top-bar-logo-mobile { display: block; }
   }
   
   /* PC back-chip: visible on desktop, hidden on mobile (top-bar handles it) */
   .back-chip {
     position: fixed; top: 14px; left: 14px;
     display: none;
     background: var(--paper-elevated);
     border: 1px solid var(--border-strong);
     border-radius: 3px;
     padding: 5px; z-index: 100;
     text-decoration: none;
     transition: border-color 0.15s, background 0.15s;
   }
   .back-chip:hover { border-color: var(--accent); background: var(--border); }
   .back-chip img { width: 54px; height: 54px; display: block; }
   
   @media (min-width: 799px) {
     .back-chip { display: inline-flex; }
   }
   
   /* ---- HEADER ---- */
   header {
     text-align: center; padding: 18px 0 14px;
     width: 100%; max-width: 640px;
     border-bottom: 3px double var(--border-strong);
     margin-bottom: 16px; position: relative;
   }
   h1 {
     font-family: 'Merriweather', 'Noto Sans Malayalam', serif;
     font-size: clamp(1.8rem, 6vw, 2.8rem); font-weight: 900;
     letter-spacing: -0.5px; color: var(--ink); line-height: 1; margin-bottom: 10px;
   }
   .subtitle {
     font-size: 9px; text-transform: uppercase; letter-spacing: 4px;
     color: var(--ink-light); border-top: 1px solid var(--border);
     border-bottom: 1px solid var(--border); padding: 5px 16px; display: inline-block;
   }
   .help-btn {
     position: absolute; top: 18px; right: 0;
     width: 32px; height: 32px; border-radius: 50%;
     background: var(--paper-elevated); border: 2px solid var(--border-strong);
     display: flex; align-items: center; justify-content: center;
     cursor: pointer; font-size: 1.1em; font-weight: 700;
     color: var(--ink); transition: all 0.2s;
   }
   .help-btn:hover { background: var(--accent); color: #fff; border-color: var(--accent); }
   
   /* ---- GAME AREA ---- */
   .game-area { width: 100%; max-width: 640px; display: flex; flex-direction: column; align-items: center; }
   
   .mistakes-track { display: flex; gap: 8px; margin: 12px 0 4px; align-items: center; }
   .mistake-label {
     font-size: 9px; letter-spacing: 2px; text-transform: uppercase;
     color: var(--ink-light); margin-right: 4px; font-family: 'Source Serif 4', serif;
   }
   .mistake-dot {
     width: 10px; height: 10px; border-radius: 50%;
     border: 1.5px solid var(--border-strong); background: transparent;
     transition: background 0.2s, border-color 0.2s;
   }
   .mistake-dot.used { background: var(--accent); border-color: var(--accent); }
   
   /* ---- HANGMAN SVG ---- */
   #hangman-svg { width: 150px; height: 160px; margin: 10px 0 6px; }
   .draw-part {
     opacity: 0; stroke: var(--ink); stroke-width: 3.5; fill: none;
     stroke-linecap: round; stroke-linejoin: round; transition: opacity 0.3s ease;
   }
   .draw-part.visible { opacity: 1; }
   .scaffold { stroke: var(--border-strong); stroke-width: 2.5; fill: none; }
   
   hr.divider { width: 100%; border: none; border-top: 1px solid var(--border); margin: 8px 0 16px; }
   
   /* ---- WORD DISPLAY ---- */
   #word-display {
     display: flex; flex-wrap: wrap; gap: 6px 18px;
     justify-content: center; align-items: flex-end;
     width: 100%; max-width: 560px; margin-bottom: 12px;
   }
   .word-row { display: flex; gap: 6px; justify-content: center; flex-wrap: wrap; }
   .word-group { display: flex; gap: 5px; }
   
   .slot {
     min-width: 38px; height: 48px;
     border-bottom: 2.5px solid var(--border-strong);
     display: flex; align-items: center; justify-content: center;
     font-size: 22px; font-weight: 700; padding: 0 3px;
     color: var(--ink); font-family: 'Noto Sans Malayalam', sans-serif;
     transition: all 0.2s;
   }
   .slot.filled { border-bottom-color: var(--ink); }
   .slot.win  { border-bottom-color: var(--success); color: var(--success); font-weight: 900; }
   .slot.lose { border-bottom-color: var(--error);   color: var(--error);   font-weight: 900; }
   .slot.revealed { border-bottom-color: var(--success); color: var(--success); animation: slotPop 0.25s ease; }
   .slot.lose-reveal { color: var(--error); border-bottom-color: var(--error); }
   .slot.matra-hinted { color: var(--ink-light); border-bottom-color: var(--border); }
   
   @keyframes slotPop {
     0%  { transform: scale(1); }
     50% { transform: scale(1.18); }
     100%{ transform: scale(1); }
   }
   
   /* ---- STATUS ---- */
   #status {
     font-family: 'Playfair Display', serif; font-size: 1rem; font-style: italic;
     min-height: 28px; text-align: center; color: var(--ink-mid);
     margin-bottom: 20px; padding: 6px 0;
     border-top: 1px solid var(--border); border-bottom: 1px solid var(--border);
     width: 100%; max-width: 480px; letter-spacing: 0.3px;
   }
   #status.win  { color: var(--success); border-color: var(--success); }
   #status.lose { color: var(--error);   border-color: var(--error); }
   
   /* ---- RESET BUTTON ---- */
   #reset-btn {
     padding: 12px 36px; background: var(--accent); color: #fff;
     border: 2px solid var(--accent); cursor: pointer; font-size: 0.8rem; font-weight: 700;
     font-family: 'Source Serif 4', serif; letter-spacing: 3px; text-transform: uppercase;
     display: none; margin-top: 20px; transition: all 0.2s; border-radius: 2px;
   }
   #reset-btn:hover { background: transparent; color: var(--accent); }
   #reset-btn:active { transform: translateY(1px); }
   
   /* ---- CONFETTI CANVAS ---- */
   #confetti-canvas {
     position: fixed; inset: 0; width: 100%; height: 100%;
     pointer-events: none; z-index: 9998;
   }
   
   /* ---- WIN BANNER ---- */
   .win-banner {
     position: fixed; top: 50%; left: 50%;
     transform: translate(-50%, -50%) scale(0.88);
     opacity: 0;
     width: min(340px, 88vw);
     background: var(--paper-elevated);
     border: 1px solid var(--border-strong);
     border-top: 4px double var(--border-strong);
     border-bottom: 4px double var(--border-strong);
     padding: 28px 28px 24px;
     z-index: 9999; text-align: center; pointer-events: none;
     box-shadow: 0 16px 60px rgba(0,0,0,0.18), 0 2px 8px rgba(0,0,0,0.08);
     animation: winPop 0.45s cubic-bezier(0.34,1.56,0.64,1) 0.1s forwards,
                winFadeOut 0.4s ease-in 3.4s forwards;
   }
   .win-banner .win-sub {
     display: block;
     font-family: 'Source Serif 4', serif; font-size: 8.5px;
     letter-spacing: 4px; text-transform: uppercase; color: var(--ink-light);
     border-top: 1px solid var(--border); border-bottom: 1px solid var(--border);
     padding: 5px 0; margin-bottom: 16px;
   }
   .win-banner .win-title {
     display: block;
     font-family: 'Merriweather', serif; font-size: clamp(1.7rem, 7vw, 2.1rem);
     font-weight: 900; color: var(--success);
     letter-spacing: -0.5px; line-height: 1.1; margin-bottom: 14px;
   }
   .win-banner .win-movie {
     display: block;
     font-family: 'Noto Sans Malayalam', sans-serif; font-size: 0.95rem;
     font-style: italic; color: var(--ink-mid);
     border-top: 1px solid var(--border); padding-top: 12px; margin-top: 2px;
   }
   @keyframes winPop { to { transform: translate(-50%, -50%) scale(1); opacity: 1; } }
   @keyframes winFadeOut { to { opacity: 0; transform: translate(-50%, -50%) scale(0.97); } }
   
   /* ---- THEME TOGGLE ---- */
   .theme-toggle {
     position: fixed; bottom: 22px; right: 22px; width: 40px; height: 40px;
     background: var(--paper-elevated); border: 1px solid var(--border-strong);
     cursor: pointer; font-size: 16px; display: flex; align-items: center;
     justify-content: center; transition: background 0.2s; z-index: 9999; border-radius: 2px;
   }
   .theme-toggle:hover, .theme-toggle:active { background: var(--border); }
   
   /* ---- MODAL ---- */
   .modal-overlay {
     display: none; position: fixed; inset: 0;
     background: rgba(0,0,0,0.78); z-index: 2000;
     align-items: center; justify-content: center;
     backdrop-filter: blur(4px); animation: fadeIn 0.25s ease;
   }
   .modal-overlay.show { display: flex; }
   @keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
   .modal-box {
     background: var(--paper-elevated); border: 1px solid var(--border-strong);
     border-radius: 10px; padding: 28px 24px; max-width: 480px; width: 92%;
     max-height: 88vh; overflow-y: auto; position: relative;
     animation: popIn 0.35s cubic-bezier(0.34,1.56,0.64,1); color: var(--ink);
   }
   @keyframes popIn { from { transform: scale(0.9); opacity: 0; } to { transform: scale(1); opacity: 1; } }
   .modal-box h2 { font-family: 'Merriweather', serif; font-size: 1.4em; font-weight: 900; margin-bottom: 14px; }
   .modal-box h3 { font-size: 1em; font-weight: 700; color: var(--accent); margin: 14px 0 7px; font-family: 'Source Serif 4', serif; }
   .modal-box p, .modal-box li { font-size: 0.9em; line-height: 1.65; color: var(--ink-mid); margin-bottom: 8px; font-family: 'Noto Sans Malayalam', sans-serif; }
   .modal-box ul { margin-left: 18px; }
   .modal-close { position: absolute; top: 12px; right: 14px; font-size: 24px; cursor: pointer; background: none; border: none; color: var(--ink-mid); line-height: 1; }
   .modal-close:hover { color: var(--accent); }
   .modal-btn {
     display: block; margin: 18px auto 0; padding: 10px 28px;
     background: var(--accent); color: #fff; border: none; border-radius: 2px;
     font-family: 'Source Serif 4', serif; font-weight: 700; font-size: 0.8em;
     letter-spacing: 2px; text-transform: uppercase; cursor: pointer; transition: all 0.2s;
   }
   .modal-btn:hover { background: var(--accent-dark); }
   
   .tut-lang-toggle {
     display: flex; border: 1.5px solid var(--border-strong); border-radius: 3px;
     overflow: hidden; width: fit-content;
   }
   .tut-lang-btn {
     padding: 5px 14px; font-size: 10px; font-weight: 700; letter-spacing: 1.5px;
     text-transform: uppercase; cursor: pointer; border: none; background: transparent;
     color: var(--ink-mid); font-family: 'Source Serif 4', serif; transition: all 0.15s;
   }
   .tut-lang-btn:hover:not(.active) { background: var(--border); color: var(--ink); }
   .tut-lang-btn + .tut-lang-btn { border-left: 1.5px solid var(--border-strong); }
   .tut-lang-btn.active { background: var(--ink); color: var(--paper); }
   
   .tut-wrap {
     width: 100%; aspect-ratio: 4/3; border-radius: 6px; overflow: hidden;
     border: 1.5px solid var(--border-strong); background: var(--paper);
     margin-bottom: 16px;
   }
   .tut-wrap canvas { width: 100%; height: 100%; display: block; }
   
   /* ---- MEDIA QUERIES ---- */
   @media (max-width: 480px) {
     .slot { min-width: 30px; height: 42px; font-size: 18px; }
     #hangman-svg { width: 120px; height: 130px; }
     .modal-box { padding: 18px 16px; }
     .modal-header-row { flex-direction: column !important; align-items: flex-start !important; gap: 10px; padding-right: 32px; margin-bottom: 10px !important; }
     .modal-box h2 { font-size: 1.15em; }
   }