:root {
    --background-color: #000000;
    --background-color-2:  #000000;
    --highlight: #ffffff;
    --shadow-color: #c0c0c0;

    --button-color: var(--text-color);
  
    /* --game-font: 'Goma'; */
    --game-font: 'SquareAntiqua';

    --font: Arial, sans-serif;
    --font-2: 'Garamond', 'EB Garamond', 'Adobe Garamond Pro', serif;

    --text-color: #ffffff;
    --text-color-2: #000000;

    --primary-color: #ffffff;
    --accent-color: #ffffff;
    --inline-color: #d09500;
    --delete-color: #a8280e;
    --border-color: #000000;
    --modal-overlay-color: rgba(0, 0, 0, 0.5);
    --primary-light: rgba(12, 11, 95, 0.05);
    --accent-light: rgba(255, 246, 115, 0.3);
  }
  
  /* Back link styling */
  .back-link {
    color: var(--primary-color);
    text-decoration: none;
    cursor: pointer;
    font-size: 11px;
    font-weight: normal;
    font-family: var(--font);
    border-bottom: 1px solid transparent;
    transition: border-color 0.2s;
  }
  
  .back-link:hover {
    border-bottom-color: var(--primary-color);
  }
  
  /* Text container styling */
  .text {
    display: flex;
    align-items: center;
    height: 100%;
  }
  
  /* Subtitle styling */
  .subtitle {
    margin-left: 15px;
    font-size: 16px;
    font-weight: bold;
    color: var(--primary-color);
    text-transform: uppercase;
    font-family: var(--game-font);
    /* text-shadow: 1px 1px 0px #fff; */
  }
  
  #background {
    z-index: 1000;
    pointer-events: none;
    /* background-color: #FFDCACFF; */
    background-color: var(--accent-color);
    position: absolute;
    border-radius: 0.5em;
    box-shadow: 4px 4px 0px var(--shadow-color);
  }
  
  .current-highlight { /* the active column */
    position: absolute;
    left: var(--col-left);
    top: var(--col-top);
    background-color: var(--col-color);
    transition: left 0.2s ease-in-out, top 0.2s ease-in-out;
    border-radius: 0.4em;
    transition: background-color 0.1s step-end;
    z-index: 1002 !important;
    animation: pulse-margin 2s ease-in infinite forwards;
    transition: scale 0.2s ease-in-out;
  }
  
  @keyframes pulse-margin {
    0% {
      transform: scale(1);
    }
    20% {
      transform: scale(1);
    }
    25% {
      transform: scale(1.1);
    }
    75% {
      transform: scale(1.1);
    }
    80% {
      transform: scale(1);
    }
    100% {
      transform: scale(1);
    }
  }
  
  
  .current-markup {
    position: absolute;
    bottom: -48px;
    left: 50%;
    transform: translateX(-50%);
    color: inherit;
    pointer-events: none;
  }

  .remove {
    animation: remove var(--rotate-time) ease-in-out forwards;
    transform-origin: bottom center;
  }

  @keyframes remove {
    0% {
      transform: rotateX(0deg);
    }
    100% {
      transform: rotateX(90deg);
    }
  }

  @keyframes add {
    0% {
      transform: rotateX(90deg);
    }
    100% {
      transform: rotateX(0deg);
    }
  }
  
  .delete {
    color: transparent;
    /* color: var(--data-color); */
  }
  
  .delete:after {
    content: 'DELETE';
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translateX(-50%) translateY(-50%);
    color: var(--delete-color);
    font-size: 12px;
    font-weight: bold;
  }
  
  .move {
    position: absolute;
    font-family: var(--game-font);
    pointer-events: none;
    z-index: 1001;
  }
  
  /* Default input and dropdown styles */
  input, select, .dropdown {
    font-family: var(--font);
    background-color: transparent;
    border: 2px solid var(--primary-color);
    color: var(--primary-color);
    padding: 6px 10px;
    font-size: 12px;
    cursor: pointer;
    outline: none;
    transition: background-color 0.2s, color 0.2s;
  }
  
  input:hover, select:hover, .dropdown:hover {
    background-color: var(--primary-light);
  }
  
  input:focus, select:focus, .dropdown:focus {
    background-color: var(--primary-color);
    color: var(--accent-color);
  }
  
  input option, select option, .dropdown option {
    background-color: var(--accent-color);
    color: var(--primary-color);
  }
  
  /* Default label and checkbox styling */
  label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 12px;
  }
  
  
  .corpus-controls {
    display: flex;
    gap: 12px;
    margin-top: 16px;
  }
  
  input[type="checkbox"] {
    width: 16px;
    height: 16px;
    margin: 0;
    cursor: pointer;
  }
  
  /* Make dropdown and checkbox appear on same line */
  .option {
    display: flex;
    align-items: center;
    gap: 8px;
    font-family: var(--font);
  }
  
  .option select, .option input, .option .dropdown {
    font-family: var(--font);
    font-size: 10px;
    padding: 2px 6px;
    background-color: transparent;
    border: 1px solid var(--primary-color);
    color: var(--primary-color);
    cursor: pointer;
  }
  
  .option label {
    font-family: var(--font);
    font-size: 10px;
    color: var(--primary-color);
  }
  
  /* Final poem styling */
  .final-poem {
    font-family: Garamond, "EB Garamond", "Adobe Garamond Pro", serif;
    font-size: 18px;
    line-height: 1.6;
    color: var(--primary-color);
    white-space: pre-wrap;
    padding: 20px;
    background-color: var(--accent-light);
    border-left: 3px solid var(--primary-color);
    margin: 10px 0;
  }
  
  /* Control Icons */
  .control-icons {
    position: fixed;
    left: 50%;
    top: 50%;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5em;
    z-index: 1500;
    opacity: 0.6;
    transition: opacity 0.2s ease;
  }
  
  .control-icons.hidden {
    opacity: 0;
    pointer-events: none;
  }
  
  .control-icon-row {
    display: flex;
    gap: 0.5em;
    justify-content: center;
  }
  
  .control-icon {
    width: 2.5rem;
    height: 2.5rem;
    background-color: var(--highlight);
    border-radius: 0.375em;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    color: var(--accent-color);
  }
  
  .control-icon svg {
    stroke: var(--accent-color);
    width: 1.25rem;
    height: 1.25rem;
  }
  
  .control-icon.spacebar {
    width: 9rem;
  }
  
  .control-icon span {
    font-family: var(--font-2);
    font-size: 0.6rem;
    margin-top: 0.125em;
  }
  
  #editor-container {
    position: relative;
    width: 80vw;
    height: 80vh;
    margin: 10vh auto;
  }

  #editor {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: var(--background-color);
    color: var(--text-color);
    font-family: var(--game-font);
    font-size: 16px;
    /* border: 1.2px solid var(--primary-color); */
    padding: 10px;
    box-sizing: border-box;
    outline: none;
    overflow: auto;
  }

  #editor.text-hidden {
    color: transparent;
    caret-color: var(--text-color);
  }

  #overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    padding: 10px;
    box-sizing: border-box;
  }

  /* ============================================================================
     FRAGMENT PERFORMANCE LAYER STRUCTURE
     ============================================================================
     
     Layer hierarchy (from bottom to top):
     
     #editor-container
     ├── #editor (z-index: default) — The actual editable text area
     └── #overlay (pointer-events: none) — Non-interactive visual layer
         ├── .fragment-text-wrapper
         │   ├── #bottomLayer (z-index: 0)
         │   │   └── .fragment-text.bottom-text — Original/unmodified text
         │   ├── #layer-0 (z-index: 1)
         │   │   ├── .fragment-text.layer-text — Synonymized text (1st synonyms)
         │   │   └── .glass-overlay — Blur effect
         │   ├── #layer-1 (z-index: 2)
         │   │   ├── .fragment-text.layer-text — Synonymized text (2nd synonyms)
         │   │   └── .glass-overlay — Blur effect
         │   └── ... (n layers, each with increasing z-index)
         └── .control-points-layer (z-index: 100) — SVG with draggable points
     
     How it works:
     - #editor: The contenteditable area where the user types
     - #overlay: Sits on top of editor, passes through pointer events
     - #bottomLayer: Shows original text, no clipping (full area)
     - #layer-N: Each layer shows text with Nth synonym for each word,
       clipped to a triangle via CSS clip-path: polygon(...)
     - .glass-overlay: Inside each layer, applies backdrop-filter blur
     - .control-points-layer: SVG overlay with 3 control points per layer
       (color-coded to distinguish which layer each point controls)
     
     Visual effect:
     - Original text visible everywhere (from bottom layer)
     - Each triangle fragment shows different synonymized text
     - Higher z-index layers appear on top of lower ones (no blending)
     - Drag control points to reshape each layer's triangle
     ============================================================================ */

  .fragment-text-wrapper {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;

  }

  .fragment-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: flex-start;
    justify-content: flex-start;

  }

  .fragment-text {
    font-family: var(--game-font);
    font-size: 16px;
    width: 100%;
    height: 100%;
    padding: 10px;
    box-sizing: border-box;
    color: var(--text-color);
    white-space: pre-wrap;
    word-wrap: break-word;
    line-height: 1.5;
  }

  /* Layer z-index and background are set via inline styles in JS
     to support dynamic number of layers. Each layer gets:
     - z-index: layer index (0 for bottom, 1+ for overlay layers)
     - background-color: var(--background-color) for clipped layers
  */

  .glass-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    backdrop-filter: blur(0.5px);
    -webkit-backdrop-filter: blur(0.5px);
  }

  .control-points-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 100;
  }
