    html, body { height: 100%; margin: 0; padding: 0; overflow: hidden; }
    canvas { display: block; }

    #auth-gate [hidden] { display: none; }

    button,
    [role="button"] {
      touch-action: manipulation;
    }
    
    /* Main container */
    #main-container {
      display: flex;
      width: 100vw;
      height: 100vh;
      position: relative; /* For absolute positioning of children */
    }

    /* App surface displayed behind history/avatar */
    #app-surface {
      position: absolute;
      inset: 0;
      z-index: 0;
      overflow: hidden;
      background:
        radial-gradient(circle at 20% 15%, rgba(20, 184, 166, 0.18), transparent 30%),
        linear-gradient(135deg, rgba(8, 13, 24, 0.78), rgba(17, 24, 39, 0.62));
    }

    .layout-portrait #app-surface {
      width: 100%;
      height: 70vh;
      right: auto;
      bottom: auto;
    }

    .layout-landscape #app-surface {
      width: 100%;
      height: 100vh;
      right: auto;
      bottom: auto;
    }

    #surface-frame {
      width: 100%;
      height: 100%;
      border: 0;
      background: transparent;
    }
    
    /* History window */
    #history-container {
      width: 100%;
      height: 100%;
      overflow-y: auto;
      padding: 1rem;
      background-color: rgba(26, 26, 46, 0.7); /* Dark blue background with more transparency */
      display: flex;
      flex-direction: column;
      color: #ffffff; /* White text for better contrast */
      position: absolute;
      z-index: 1; /* Behind the avatar */
      border: none;
      box-shadow: none;
      transition: opacity 160ms ease, visibility 160ms ease;
    }

    #history-container.history-hidden {
      opacity: 0;
      visibility: hidden;
      pointer-events: none;
    }
    
    #history-list {
      list-style-type: none;
      padding: 0;
      margin: 0;
      overflow-y: auto;
      flex-grow: 1;
    }
    
    .history-item {
      padding: 0.5rem;
      margin-bottom: 0.5rem;
      border-radius: 0.5rem;
      font-size: 0.9rem;
      word-break: break-word;
      color: #ffffff;
    }
    
    .history-item.user {
      background-color: rgba(79, 70, 229, 0.4); /* Indigo with opacity */
      border-left: 3px solid #4f46e5; /* Indigo */
      margin-right: 1rem;
      color: #ffffff;
      font-weight: 500;
      box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    }
    
    .history-item.avatar {
      background-color: rgba(16, 185, 129, 0.4); /* Emerald with opacity */
      border-left: 3px solid #10b981; /* Emerald */
      margin-left: 1rem;
      color: #ffffff;
      font-weight: 500;
      box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    }
    
    .history-item .timestamp {
      font-size: 0.7rem;
      opacity: 0.8;
      display: block;
      margin-top: 0.25rem;
      text-align: right;
      color: #a0aec0; /* Light blue gray */
    }
    
    #history-container h3 {
      color: #ffffff;
      margin-bottom: 0.75rem;
      padding-bottom: 0.5rem;
      border-bottom: 1px solid #2d3748; /* Dark gray */
    }
    
    /* Layout styles */
    .layout-portrait #main-container {
      flex-direction: column;
    }
    
    .layout-portrait #history-container {
      width: 100%;
      height: 70vh;
      top: 0;
      left: 0;
    }
    
    .layout-portrait #avatar-container {
      width: 100%;
      height: 70vh;
    }
    
    .layout-portrait .controls-container {
      width: 100%;
      height: 30vh;
      overflow-y: auto;
      padding: 1rem;
      position: relative;
      z-index: 3; /* Above everything */
      background-color: rgba(26, 26, 46, 0.8); /* Dark background with transparency */
      color: white;
      border-top: 1px solid rgba(255, 255, 255, 0.1);
      box-shadow: 0 -4px 6px rgba(0, 0, 0, 0.1);
    }
    
    .layout-landscape #main-container {
      flex-direction: row;
      position: relative;
    }
    
    .layout-landscape #history-container {
      width: 75%;
      height: 100%;
      left: 0;
      top: 0;
      border: none;
      outline: none;
    }
    
    .layout-landscape #avatar-container {
      width: 75%;
      height: 100vh;
      position: absolute;
      left: 0;
      top: 0;
      z-index: 10; /* Ensure avatar is in front of history */
    }
    
    .layout-landscape .controls-container {
      width: 25%;
      height: 100vh;
      overflow-y: auto;
      padding: 0.75rem;
      position: absolute;
      z-index: 15; /* Above everything */
      right: 0;
      top: 0;
      background-color: rgba(26, 26, 46, 0.8); /* Dark background with transparency */
      color: white;
      border-left: 1px solid rgba(255, 255, 255, 0.1);
      box-shadow: -4px 0 6px rgba(0, 0, 0, 0.1);
      display: flex;
      flex-direction: column;
      gap: 0.5rem;
    }

    /* Avatar container */
    #avatar-container {
      position: relative;
      z-index: 2; /* In front of the history */
      display: flex;
      align-items: center;
      justify-content: center;
      pointer-events: none; /* Allow clicks to pass through to history */
      background-color: transparent;
    }

    body.surface-oriented #avatar-container canvas {
      pointer-events: none !important;
    }

    /* Clear history button */
    #clear-history {
      margin-top: 0.5rem;
    }
