/* =========================
   1) CSS VARIABLES & GLOBAL
   ========================= */
   :root {
    --bg-color: #ffffff;
    --gradient-end: #eaeaea;
    --light-bg: #f0f8ff;
    --primary-color: #007acc;
    --primary-hover: #005fa3;
    --secondary-color: #333333;
    --shadow-light: rgba(0, 0, 0, 0.1);
    --shadow-medium: 0 2px 5px rgba(0, 0, 0, 0.1);
    --shadow-strong: 0 8px 15px rgba(0, 0, 0, 0.1);
    --transition-speed: 0.3s;
  }
  
  * { box-sizing: border-box; }
  
  body {
    display: flex;
    flex-direction: column;
    align-items: center;
    font-family: inherit;;
    margin: 0;
    min-height: 100vh;
  }
  
  
  /* =========================
     2) HEADER / NAVBAR
     ========================= */
  header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    background-color: var(--bg-color);
    box-shadow: var(--shadow-medium);
    padding: 15px 20px;
    margin-bottom: 20px;
  }
  header .logo {
    color: var(--primary-color);
    font-size: 1.5rem;
    font-weight: bold;
    text-decoration: none;
  }
  header nav { display: flex; gap: 15px; }
  header nav a {
    color: var(--primary-color);
    font-size: 1.1rem;
    text-decoration: none;
    transition: color var(--transition-speed);
  }
  header nav a:hover { color: var(--primary-hover); }
  
  /* =========================
     3) FIXED LAYOUT FRAME
     ========================= */
  /* Keep the “good” small-screen width and center it on large screens */
  .fixed-layout {
    width: 1024px;
    margin: 0 auto;
    padding: 0 16px;
  }
  @media (max-width: 1060px) {
    .fixed-layout {
      width: 100%;
      max-width: 1024px;
    }
  }
  .fixed-layout img,
  .fixed-layout svg,
  .fixed-layout canvas {
    max-width: 100%;
    height: auto;
  }
  
  /* =========================
     4) MAIN CONTAINER
     ========================= */
  .container {
    position: relative;           /* hands will position relative to this */
    background-color: var(--bg-color);
    border-radius: 20px;
    text-align: center;
    width: 90%;
    max-width: 1000px;
    padding: 30px;
    margin: 40px auto;
    overflow: visible;            /* allow hands to hang below slightly */
  }
  
  h1 {
    color: var(--primary-color);
    font-size: 3rem;
    margin-bottom: 25px;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.2);
  }
  
  /* =========================
     5) INPUTS & BUTTONS
     ========================= */
  #typing-input {
    width: 70%;
    font-size: 18px;
    padding: 12px;
    border: 2px solid var(--primary-color);
    border-radius: 10px;
    outline: none;
    transition: border-color var(--transition-speed);
  }
  #typing-input:focus { border-color: var(--secondary-color); }
  
  button {
    margin-top: 15px;
    padding: 12px 25px;
    font-size: 18px;
    color: var(--bg-color);
    background-color: var(--primary-color);
    border: none;
    border-radius: 10px;
    cursor: pointer;
    transition: background-color var(--transition-speed), color var(--transition-speed);
  }
  button:hover {
    background-color: var(--gradient-end);
    color: var(--primary-color);
  }
  
  /* =========================
     6) FEEDBACK
     ========================= */
  #feedback {
    font-size: 20px;
    margin-top: 20px;
  }
  
  /* =========================
     7) KEYBOARD
     ========================= */
  .keyboard {
    position: relative;   /* create stacking context */
    z-index: 2;           /* below hands (which are z=5), above background */
    background-color: var(--gradient-end);
    border-radius: 15px;
    display: grid;
    gap: 4px;
    grid-template-columns: repeat(15, 1fr);
    max-width: 830px;
    padding: 15px;
    margin: 25px auto 0;
  }
  .key {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 50px;
    background-color: var(--bg-color);
    color: var(--secondary-color);
    border-radius: 8px;
    box-shadow: 0 2px 3px rgba(0,0,0,0.15);
    cursor: pointer;
    font-size: 16px;
    transition: background-color 0.2s, transform 0.1s;
  }
  .key:hover { transform: scale(1.05); }
  .key.active { background-color: var(--light-bg); box-shadow: 0 0 8px rgba(0,0,0,0.3); }
  .key.highlight { background-color: var(--primary-color); color: var(--bg-color); }
  .key.correct-press { background-color: #28a745; color: var(--bg-color); box-shadow: 0 0 5px rgba(0,0,0,0.6); }
  .key.incorrect { background-color: #b0b0b0; color: var(--bg-color); box-shadow: 0 0 5px rgba(0,0,0,0.6); }
  
  .wide-key, .extra-wide-key { grid-column: span 2; }
  .right-shift { grid-column: span 3; }
  .spacebar { grid-column: span 7; }
  
  /* =========================
     8) PROMPT & SPEECH BUBBLE
     ========================= */
  #typing-prompt {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    background-color: var(--bg-color);
    border-radius: 12px;
    padding: 15px;
    margin: 25px 0;
  }
  .prompt-text {
    display: flex; flex-direction: column; align-items: center;
    color: var(--secondary-color); font-size: 20px;
  }
  .prompt-image { width: 20%; vertical-align: middle; }
  
  .key-box {
    display: inline-block;
    padding: 12px 15px;
    margin-top: 8px;
    background-color: var(--bg-color);
    border: 3px solid var(--primary-color);
    border-radius: 8px;
    color: var(--primary-color);
    font-size: 26px;
    font-weight: bold;
  }
  
  .speech-bubble {
    position: relative;
    display: inline-block;
    background-color: var(--bg-color);
    border: 2px solid var(--primary-color);
    border-radius: 8px;
    padding: 10px 15px;
    margin: 10px auto;
    z-index: 2; /* above hands */
  }
  .speech-bubble .key-box {
    background: none; border: none; color: var(--primary-color);
    font-size: 1.5rem; font-weight: bold;
  }
  
  /* =========================
     9) TYPING PROGRESS
     ========================= */
  #typed-progress {
    display: flex;
    justify-content: center;
    gap: 12px;
    margin: 20px 0;
  }
  .letter-box {
    display: flex; align-items: center; justify-content: center;
    width: 80px; height: 80px;
    background-color: var(--bg-color);
    border: 2px solid #ccc;
    border-radius: 8px;
    color: var(--secondary-color);
    font-size: 60px; font-weight: bold;
  }
  .letter-box.correct { border-color: var(--primary-color); color: var(--primary-color); }
  .letter-box.upcoming { color: #ccc; }
  
  /* =========================
     10) PENGUIN PROMPT SECTION
     ========================= */
  #penguin-section { display: none; text-align: center; margin-bottom: 20px; }
  .level-intro {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 30px;
    margin: 30px auto;
    max-width: 900px;
  }
  .penguin-image { display: block; width: 200px; }
  .right-section {
    position: relative;
    background-color: var(--bg-color);
    border: 2px solid #ccc;
    border-radius: 10px;
    max-width: 350px;
    padding: 20px;
    z-index: 2; /* above hands */
  }
  .right-section::before {
    content: "";
    position: absolute;
    left: -20px; top: 50%;
    transform: translateY(-50%);
    border: 10px solid transparent; border-left: 0; border-right-color: #ccc;
  }
  .right-section::after {
    content: "";
    position: absolute;
    left: -18px; top: 50%;
    transform: translateY(-50%);
    border: 10px solid transparent; border-left: 0; border-right-color: var(--bg-color);
  }
  
  /* =========================
     11) HAND OVERLAY
     ========================= */
  /* Base positioning & scaling shared by all hand overlays */
  .hand-a-active,
  .hand-b-active,
  .hand-c-active,
  .hand-comma-active,
  .hand-semicolon_active,
  .hand-d-active,
  .hand-e-active,
  .hand-f-active,
  .hand-g-active,
  .hand-h-active,
  .hand-i-active,
  .hand-j-active,
  .hand-k-active,
  .hand-l-active,
  .hand-m-active,
  .hand-n-active,
  .hand-o-active,
  .hand-p-active,
  .hand-q-active,
  .hand-r-active,
  .hand-s-active,
  .hand-t-active,
  .hand-u-active,
  .hand-v-active,
  .hand-w-active,
  .hand-x-active,
  .hand-y-active,
  .hand-z-active {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    bottom: -10px;                 /* tweak up/down as needed */
    z-index: 5;                    /* above keyboard */
    pointer-events: none;          /* never block key clicks/hover */
    width: min(900px, calc(100% - 40px));
    aspect-ratio: 2.1;
    background-position: center;
    background-repeat: no-repeat;
    background-size: contain;
  }
  
  /* Slightly raise hands while penguin prompt is active */
  .penguin-active .hand-a-active,
  .penguin-active .hand-b-active,
  .penguin-active .hand-c-active,
  .penguin-active .hand-comma-active,
  .penguin-active .hand-semicolon_active,
  .penguin-active .hand-d-active,
  .penguin-active .hand-e-active,
  .penguin-active .hand-f-active,
  .penguin-active .hand-g-active,
  .penguin-active .hand-h-active,
  .penguin-active .hand-i-active,
  .penguin-active .hand-j-active,
  .penguin-active .hand-k-active,
  .penguin-active .hand-l-active,
  .penguin-active .hand-m-active,
  .penguin-active .hand-n-active,
  .penguin-active .hand-o-active,
  .penguin-active .hand-p-active,
  .penguin-active .hand-q-active,
  .penguin-active .hand-r-active,
  .penguin-active .hand-s-active,
  .penguin-active .hand-t-active,
  .penguin-active .hand-u-active,
  .penguin-active .hand-v-active,
  .penguin-active .hand-w-active,
  .penguin-active .hand-x-active,
  .penguin-active .hand-y-active,
  .penguin-active .hand-z-active {
    bottom: -24px;
  }
  
  /* Per-key images (no positioning here—just the image) */
  .hand-a-active { background-image: url('a_key.png'); }
  .hand-b-active { background-image: url('b2_key.png'); }
  .hand-c-active { background-image: url('c_key.png'); }
  .hand-comma-active { background-image: url('comma_key.png'); }
  .hand-semicolon_active { background-image: url('Semicolon_key.png'); }
  .hand-d-active { background-image: url('D_key.png'); }
  .hand-e-active { background-image: url('e_key.png'); }
  .hand-f-active { background-image: url('F_key.png'); }
  .hand-g-active { background-image: url('g_key.png'); }
  .hand-h-active { background-image: url('h_key.png'); }
  .hand-i-active { background-image: url('I_Key.png'); }
  .hand-j-active { background-image: url('J_Key.png'); }
  .hand-k-active { background-image: url('K_key.png'); }
  .hand-l-active { background-image: url('L_key.png'); }
  .hand-m-active { background-image: url('m_key.png'); }
  .hand-n-active { background-image: url('n_key.png'); }
  .hand-o-active { background-image: url('o_key.png'); }
  .hand-p-active { background-image: url('p_key.png'); }
  .hand-q-active { background-image: url('q_key.png'); }
  .hand-r-active { background-image: url('r_key.png'); }
  .hand-s-active { background-image: url('s_key.png'); }
  .hand-t-active { background-image: url('t_key.png'); }
  .hand-u-active { background-image: url('u_key.png'); }
  .hand-v-active { background-image: url('v_key.png'); }
  .hand-w-active { background-image: url('w_key.png'); }
  .hand-x-active { background-image: url('x2_key.png'); }
  .hand-y-active { background-image: url('y_key.png'); }
  .hand-z-active { background-image: url('z2_key.png'); }
  
  /* =========================
     12) RESPONSIVE TWEAKS
     ========================= */
  @media (max-width: 600px) {
    .keyboard {
      grid-template-columns: repeat(10, 1fr);
      max-width: 100%;
    }
    h1 { font-size: 2.5rem; }
    #typing-input { font-size: 16px; width: 90%; }
    .letter-box { width: 60px; height: 60px; font-size: 48px; }
  }
  
/* Keyboard + hands share the same sizing box */
.kb-wrap {
  position: relative;
  width: min(830px, 100%);   /* match your keyboard’s max width */
  margin: 25px auto 0;       /* same spacing you had */
}

/* Make the keyboard fill the wrap exactly */
.kb-wrap .keyboard {
  width: 100%;
  max-width: none;           /* width controlled by .kb-wrap now */
  margin: 0;                 /* kb-wrap handles centering/margins */
}

/* Hands are now locked to the keyboard’s width */
.kb-wrap #left-hand,
.kb-wrap .hand {
  position: absolute;
  left: 47%;
  transform: translateX(-50%);
  bottom: -65px;              /* nudge up/down to align with key bottoms */
  z-index: 5;
  pointer-events: none;

  width: 100%;               /* EXACTLY the keyboard width */
  aspect-ratio: 2.1;
  background-position: center;
  background-repeat: no-repeat;
  background-size: contain;
}
