/* --- CSS Variables and Basic Reset --- */
    :root {
      --primary-color: #4CAF50;
      --secondary-color: #007bff;
      --danger-color: #f44336;
      --background-color: #000033;
      --light-text: #ffffff;
      --dark-text: #333333;
      --overlay-bg: rgba(0, 0, 0, 0.85);
      --win-overlay-bg: rgba(20, 100, 20, 0.9);
    }

    * { box-sizing: border-box; }

    body {
      margin: 0;
      overflow: hidden;
      font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
      background-color: var(--background-color);
      color: var(--light-text);
      position: fixed;
      width: 100%;
      height: 100%;
      touch-action: none;
      user-select: none;
      -webkit-user-select: none;
      -webkit-touch-callout: none;
    }

    /* --- Screen Management --- */
    .screen {
      position: absolute;
      top: 0; left: 0;
      width: 100%; height: 100%;
      display: none;
      flex-direction: column;
      align-items: center;
      justify-content: center;
      padding: 20px;
      box-sizing: border-box;
      background-color: var(--background-color);
      transition: opacity 0.5s ease;
      opacity: 0;
    }
    .screen.active {
      display: flex;
      opacity: 1;
    }

    /* --- Splash Screen Styling --- */
    #splash-screen {
      background: radial-gradient(circle at center, #6b46c1 0%, #3b82f6 25%, #6b46c1 50%, #3b82f6 75%, #6b46c1 100%);
      background-size: 100% 100%;
      position: relative;
      overflow: hidden;
    }
    #splash-screen::before {
      content: '';
      position: absolute;
      top: 50%; left: 50%;
      width: 200%; height: 200%;
      background: conic-gradient(
        from 0deg,
        #6b46c1 0deg 22.5deg, #3b82f6 22.5deg 45deg,
        #6b46c1 45deg 67.5deg, #3b82f6 67.5deg 90deg,
        #6b46c1 90deg 112.5deg, #3b82f6 112.5deg 135deg,
        #6b46c1 135deg 157.5deg, #3b82f6 157.5deg 180deg,
        #6b46c1 180deg 202.5deg, #3b82f6 202.5deg 225deg,
        #6b46c1 225deg 247.5deg, #3b82f6 247.5deg 270deg,
        #6b46c1 270deg 292.5deg, #3b82f6 292.5deg 315deg,
        #6b46c1 315deg 337.5deg, #3b82f6 337.5deg 360deg
      );
      transform: translate(-50%, -50%);
      z-index: 1;
      animation: rotate 20s linear infinite;
    }
    @keyframes rotate {
      from { transform: translate(-50%, -50%) rotate(0deg); }
      to { transform: translate(-50%, -50%) rotate(360deg); }
    }

    #splash-3d-container {
      position: absolute;
      top: 0; left: 0;
      width: 100%; height: 100%;
      z-index: 2;
      pointer-events: none;
    }

    .splash-content {
      position: relative;
      z-index: 10;
      text-align: center;
      display: flex;
      flex-direction: column;
      align-items: center;
      justify-content: center;
      width: 100%;
      max-width: 500px;
    }

    .title-container {
      text-align: center;
      margin-bottom: 40px;
      position: relative;
      z-index: 10;
      width: 100%;
    }
    .splash-title {
      font-size: clamp(2.5rem, 10vw, 4.5rem);
      font-weight: 900;
      color: #ffffff;
      text-shadow: 4px 4px 0px #000, -4px -4px 0px #000,
        4px -4px 0px #000, -4px 4px 0px #000,
        6px 6px 10px rgba(0, 0, 0, 0.8);
      letter-spacing: 0.05em;
      margin: 0;
      line-height: 0.9;
    }
    .splash-subtitle {
      font-size: clamp(1rem, 4vw, 1.5rem);
      color: #ffffff;
      margin-top: 10px;
      margin-bottom: 0;
      text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.8);
      font-weight: 600;
    }

    .menu-container {
      width: 100%;
      max-width: 380px;
      display: flex;
      flex-direction: column;
      align-items: center;
      gap: 15px;
      position: relative;
      z-index: 10;
      margin: 0 auto;
    }

    .btn {
      padding: 18px 24px;
      border-radius: 15px;
      border: 4px solid #000;
      color: #fff;
      cursor: pointer;
      font-size: 1.4rem;
      font-weight: 900;
      text-transform: uppercase;
      transition: transform 0.2s ease, background-color 0.3s ease, border-color 0.3s ease;
      text-shadow: 2px 2px 0px #000;
      letter-spacing: 0.1em;
      position: relative;
      overflow: hidden;
      pointer-events: all;
      width: 100%;
      max-width: 280px;
      text-align: center;
    }
    .btn:hover { transform: translateY(-3px) scale(1.05); }
    .btn:active { transform: scale(0.96) translateY(0); }

    .btn-primary {
      background: linear-gradient(135deg, #fbbf24 0%, #f59e0b 100%);
      box-shadow: 0 6px 0 #92400e, 0 8px 15px rgba(0, 0, 0, 0.3);
    }
    .btn-primary:hover { box-shadow: 0 8px 0 #92400e, 0 12px 20px rgba(0, 0, 0, 0.4); }

    .btn-secondary {
      background: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%);
      box-shadow: 0 6px 0 #1e3a8a, 0 8px 15px rgba(0, 0, 0, 0.3);
    }
    .btn-secondary:hover { box-shadow: 0 8px 0 #1e3a8a, 0 12px 20px rgba(0, 0, 0, 0.4); }

    .btn-danger {
      background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
      box-shadow: 0 6px 0 #991b1b, 0 8px 15px rgba(0, 0, 0, 0.3);
    }
    .btn-danger:hover { box-shadow: 0 8px 0 #991b1b, 0 12px 20px rgba(0, 0, 0, 0.4); }

    /* Floating CSS Shapes */
    .floating-shapes {
      position: absolute;
      top: 0; left: 0;
      width: 100%; height: 100%;
      pointer-events: none;
      z-index: 3;
    }
    .floating-shape {
      position: absolute;
      animation: float 8s ease-in-out infinite;
      opacity: 0.6;
    }
    .floating-shape:nth-child(2n) { animation-direction: reverse; animation-duration: 10s; }
    .floating-shape:nth-child(3n) { animation-delay: -3s; }
    .floating-shape:nth-child(4n) { animation-delay: -6s; }

    @keyframes float {
      0%, 100% { transform: translateY(0px) rotate(0deg) scale(1); }
      33% { transform: translateY(-30px) rotate(120deg) scale(1.1); }
      66% { transform: translateY(15px) rotate(240deg) scale(0.9); }
    }

    .shape-circle { width: 40px; height: 40px; border-radius: 50%; border: 6px solid; }
    .shape-square { width: 35px; height: 35px; border: 6px solid; border-radius: 6px; }
    .shape-triangle { width: 0; height: 0; border-left: 20px solid transparent; border-right: 20px solid transparent; border-bottom: 35px solid; }

    .color-red { border-color: #ef4444; }
    .color-blue { border-color: #3b82f6; }
    .color-green { border-color: #10b981; }
    .color-yellow { border-color: #fbbf24; }
    .color-purple { border-color: #8b5cf6; }
    .color-orange { border-color: #f97316; }

    .color-red.shape-triangle { border-bottom-color: #ef4444; border-left-color: transparent; border-right-color: transparent; }
    .color-blue.shape-triangle { border-bottom-color: #3b82f6; border-left-color: transparent; border-right-color: transparent; }
    .color-green.shape-triangle { border-bottom-color: #10b981; border-left-color: transparent; border-right-color: transparent; }

    /* --- Settings Screen Specific --- */
    #settings-screen .menu-container {
      background-color: rgba(0, 0, 0, 0.8);
      padding: 30px;
      border-radius: 15px;
      box-shadow: 0 4px 20px rgba(0,0,0,0.3);
      border: 4px solid #ffffff;
    }
    .setting-item {
      display: flex;
      justify-content: space-between;
      align-items: center;
      margin-bottom: 15px;
      width: 100%;
    }
    .setting-item label { font-size: 1.1rem; font-weight: 600; }
    .setting-item select {
      padding: 10px;
      border-radius: 8px;
      border: 2px solid #000;
      background-color: #fff;
      color: #000;
      font-size: 1rem;
      font-weight: 600;
      width: 100px;
      text-align: center;
    }

    /* --- Game Screen & UI --- */
    #game-screen { padding: 0; cursor: default; }
    #container { position: absolute; top: 0; left: 0; width: 100%; height: 100%; }

    #game-ui {
      position: absolute;
      top: 0; left: 0; right: 0;
      z-index: 100;
      display: flex;
      justify-content: space-between;
      align-items: flex-start;
      padding: 20px;
      pointer-events: none;
    }

    .rotation-controls {
      display: flex;
      flex-direction: row;
      gap: 10px;
      pointer-events: all;
    }
    .rotate-btn {
      width: 50px; height: 50px;
      border-radius: 50%;
      background-color: rgba(0, 0, 0, 0.7);
      color: var(--light-text);
      border: 2px solid rgba(255, 255, 255, 0.3);
      cursor: pointer;
      display: flex;
      align-items: center;
      justify-content: center;
      font-size: 1.5rem;
      font-weight: bold;
      transition: all 0.2s ease;
      text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.7);
    }
    .rotate-btn:hover { transform: scale(1.1); background-color: rgba(0, 0, 0, 0.9); border-color: rgba(255, 255, 255, 0.6); }
    .rotate-btn:active { transform: scale(0.95); }
    .rotate-btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

    #game-menu-btn, #game-score {
      pointer-events: all;
      font-size: clamp(1.2rem, 5vw, 1.8rem);
      font-weight: bold;
      color: var(--light-text);
      background-color: rgba(0, 0, 0, 0.5);
      padding: 10px 18px;
      border-radius: 12px;
      text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.7);
      transition: transform 0.2s ease;
    }
    #game-menu-btn:hover { transform: scale(1.05); }
    #game-menu-btn { cursor: pointer; }

    /* --- Overlays (Game Over / Win) --- */
    .overlay {
      position: absolute;
      top: 50%; left: 50%;
      transform: translate(-50%, -50%) scale(0.9);
      width: 90%; max-width: 400px;
      background-color: var(--overlay-bg);
      padding: 30px;
      border-radius: 20px;
      text-align: center;
      z-index: 200;
      box-shadow: 0 0 30px rgba(0, 0, 0, 0.5);
      display: none;
      opacity: 0;
      transition: transform 0.4s cubic-bezier(0.18, 0.89, 0.32, 1.28), opacity 0.3s ease;
    }
    .overlay.visible {
      display: block;
      opacity: 1;
      transform: translate(-50%, -50%) scale(1);
    }
    #gameWin { background-color: var(--win-overlay-bg); }
    .overlay h2 { margin-top: 0; font-size: clamp(1.8rem, 8vw, 2.5rem); }
    .overlay p { font-size: clamp(1rem, 4vw, 1.2rem); margin: 20px 0; }
    .overlay .btn { margin-top: 10px; width: 100%; }

    /* --- Level Transitions: progression controls on win/lose overlays --- */
    .progression-row {
      display: grid;
      grid-template-columns: 44px 1fr 44px;
      gap: 8px;
      align-items: center;
      margin-top: 14px;
    }
    .progression-step-btn {
      width: 44px; height: 44px;
      border-radius: 12px;
      background: rgba(255,255,255,0.12);
      color: #fff;
      border: 2px solid rgba(255,255,255,0.35);
      font-size: 1.3rem;
      font-weight: bold;
      cursor: pointer;
      transition: transform 0.15s ease, background 0.2s ease, opacity 0.2s ease;
      display: flex; align-items: center; justify-content: center;
      padding: 0;
    }
    .progression-step-btn:hover:not(:disabled) {
      background: rgba(255,255,255,0.25);
      transform: scale(1.05);
    }
    .progression-step-btn:active:not(:disabled) { transform: scale(0.95); }
    .progression-step-btn:disabled { opacity: 0.3; cursor: not-allowed; }
    .progression-shape-select {
      width: 100%;
      padding: 12px 10px;
      background: rgba(255,255,255,0.95);
      color: #1a1a1a;
      border: 2px solid rgba(255,255,255,0.35);
      border-radius: 12px;
      font-size: 1rem;
      font-weight: 600;
      font-family: inherit;
      text-align: center;
      cursor: pointer;
    }
    .progression-hint {
      margin: 10px 0 0;
      font-size: 0.85rem;
      color: rgba(255,255,255,0.65);
      font-weight: 500;
    }
    .progression-hint .next-size {
      color: #fbbf24;
      font-weight: bold;
    }
    #gameWin .progression-hint .next-size { color: #fde68a; }

    /* --- Sound toggle button --- */
    #sound-toggle-btn {
      position: fixed;
      top: 20px;
      right: 20px;
      width: 48px; height: 48px;
      border-radius: 50%;
      background: rgba(0,0,0,0.6);
      border: 2px solid rgba(255,255,255,0.3);
      color: #fff;
      font-size: 1.3rem;
      cursor: pointer;
      z-index: 50;
      display: flex;
      align-items: center;
      justify-content: center;
      transition: all 0.2s;
    }
    #sound-toggle-btn:hover { background: rgba(0,0,0,0.8); border-color: rgba(255,255,255,0.6); }
    #sound-toggle-btn.muted { opacity: 0.5; }

    /* --- Toast --- */
    #game-toast {
      position: fixed; bottom: 80px; left: 50%;
      transform: translateX(-50%) translateY(60px);
      background: rgba(15, 15, 30, 0.95);
      border: 1px solid #fbbf24;
      box-shadow: 0 0 25px rgba(251, 191, 36, 0.4);
      padding: 12px 22px;
      border-radius: 30px;
      display: flex; align-items: center; gap: 10px;
      color: #fff;
      opacity: 0;
      transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
      pointer-events: none;
      z-index: 300;
    }
    #game-toast.visible { transform: translateX(-50%) translateY(0); opacity: 1; }
    #game-toast .toast-icon { font-size: 1.4rem; }
    #game-toast .toast-text { font-size: 0.85rem; }
    #game-toast .toast-text strong { color: #fbbf24; }

    
.gameIconImage {
  position: absolute;
  border-radius: 30%;
  top: 375px;
  left: 180px;
  width: 225px;
  height: 100px;
  z-index: 200;
}

.gameIconImage:hover {
  position: absolute;
  border-radius: 30%;
  top: 375px;
  left: 180px;
  width: 225px;
  height: 100px;
  opacity: 0.75;
  z-index: 200;

}

.gameIconImageOther {
  position: absolute;
  border-radius: 30%;
  top: 375px;
  right: 160px;
  width: 225px;
  height: 100px;
  z-index: 200;

}

.gameIconImageOther:hover {
  position: absolute;
  border-radius: 30%;
  top: 375px;
  right: 160px;
  width: 225px;
  height: 100px;
  opacity: 0.75;
  z-index: 200;

}

.returnToGamePage {
  position: absolute;
  top: 500px;
  left: 160px;
  font-size: 2rem;
  font-weight: 1000;
  text-align: center;
  z-index: 200;
  color: goldenrod;

}

.returnToGamePage:hover {
  position: absolute;
  top: 500px;
  left: 160px;
  font-size: 2.6rem;
  font-weight: 1000;
  text-align: center;
  color: rgb(255, 255, 255);
  z-index: 200;

}

.returnToGamePageOther {
  position: absolute;
  top: 500px;
  right: 160px;
  font-size: 2rem;
  font-weight: 1000;
  text-align: center;
  z-index: 200;
  color: goldenrod;
}

.returnToGamePageOther:hover {
  position: absolute;
  top: 500px;
  right: 160px;
  font-size: 2.6rem;
  font-weight: 1000;
  text-align: center;
  color: rgb(235, 235, 235);
  z-index: 200;

}