@font-face{font-family:'Hornbill';src:url('./lib/HappyMonkey-Regular.ttf')}

body{
    margin: 0;
    user-select: none;
    font-family:'Hornbill', sans-serif;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    overflow: hidden;
    }
    
    #full-area {
        width: 100%;
        height: 100vh;
        user-select: none;
        overflow: hidden;
        background: white;
        color: #2a193c;
      }


      #full-area #game-area {
        position: absolute;
        width: 1024px;
        height: 600px;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%) scale(1);
        border-radius: 0px;
        overflow: hidden;
        background: url('./media/images/background.png');
        background-repeat: no-repeat;
        background-size: cover;
        background-position: center;
      }

      #game-area {
        display: flex;
      }

      #game-area * {
        box-sizing: border-box;
      }

      .start-screen,
      .editor-screen {
        width: 100%;
        height: 100%;
      }

      .editor-screen {
        display: flex;
      }

      .start-screen {
        position: relative;
        display: flex;
        align-items: center;
        justify-content: center;
        padding: 0;
        overflow: hidden;
      }

      .start-card {
        position: relative;
        width: 100%;
        height: 82%;
        max-height: 100%;
        background: #9fffd982;
        overflow: hidden;
        display: flex;
        flex-direction: column;
        gap: 18px;
        padding: 150px 24px 110px;
        box-shadow: 0 20px 36px rgba(42, 25, 60, 0.2);
        z-index: 1;
      }

      /* WAVE CONTAINERS */

      .wave-top-track,
      .wave-bottom-track {
        position: absolute;
        left: 0;
        width: 100%;
        height: 54px;
        pointer-events: none;
        overflow: hidden;
        z-index: 2;
      }

      .wave-top-track {
        top: 0;
      }

      .wave-bottom-track {
        bottom: 0;
      }

      /* TOP WAVE */

      .wave-top-track::before {
        content: "";
        position: absolute;
        inset: 0;

        background-image: url("data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTAwJSIgaGVpZ2h0PSIxMDBweCIgdmlld0JveD0iMCAwIDEyODAgMTQwIiBwcmVzZXJ2ZUFzcGVjdFJhdGlvPSJub25lIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjxnIGZpbGw9IiNBRkNFMzYiPjxwYXRoIGQ9Ik0xMjgwIDg2Yy0xOS45LTE3LjIxLTQwLjA4LTM5LjY5LTc5Ljg5LTM5LjY5LTU3LjQ5IDAtNTYuOTMgNDYuNTktMTE1IDQ2LjU5LTUzLjYxIDAtNTkuNzYtMzkuNjItMTE1LjYtMzkuNjJDOTIzLjcgNTMuMjcgOTI0LjI2IDg3IDg1My44OSA4N2MtODkuMzUgMC03OC43NC04Ny0xODguMi04N0M1NTQgMCA1NDMuOTUgMTIxLjggNDIzLjMyIDEyMS44Yy0xMDAuNTIgMC0xMTcuODQtNTQuODgtMTkxLjU2LTU0Ljg4LTc3LjA2IDAtMTAwIDQ4LjU3LTE1MS43NSA0OC41Ny00MCAwLTYwLTEyLjIxLTgwLTI5LjUxdjU0SDEyODB6Ii8+PC9nPjwvc3ZnPg==");

        background-repeat: repeat-x;
        background-size: 640px 54px;

        animation: waveScrollTop 20s linear infinite;
      }

      /* BOTTOM WAVE */

      .wave-bottom-track::before {
        content: "";
        position: absolute;
        inset: 0;

        background-image: url("data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTAwJSIgaGVpZ2h0PSIxMDBweCIgdmlld0JveD0iMCAwIDEyODAgMTQwIiBwcmVzZXJ2ZUFzcGVjdFJhdGlvPSJub25lIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjxnIGZpbGw9IiNBRkNFMzYiPjxwYXRoIGQ9Ik0wIDB2MTAwYzIwIDE3LjMgNDAgMjkuNTEgODAgMjkuNTEgNTEuNzkgMCA3NC42OS00OC41NyAxNTEuNzUtNDguNTcgNzMuNzIgMCA5MSA1NC44OCAxOTEuNTYgNTQuODhDNTQzLjk1IDEzNS44IDU1NCAxNCA2NjUuNjkgMTRjMTA5LjQ2IDAgOTguODUgODcgMTg4LjIgODcgNzAuMzcgMCA2OS44MS0zMy43MyAxMTUuNi0zMy43MyA1NS44NSAwIDYyIDM5LjYyIDExNS42IDM5LjYyIDU4LjA4IDAgNTcuNTItNDYuNTkgMTE1LTQ2LjU5IDM5LjggMCA2MCAyMi40OCA3OS44OSAzOS42OVYweiIvPjwvZz48L3N2Zz4");

        background-repeat: repeat-x;
        background-size: 640px 54px;
        animation: waveScrollBottom 28s linear infinite;
      }

      /* ANIMATIONS */

      @keyframes waveScrollTop {
        from {
          background-position-x: 0;
        }
        to {
          background-position-x: -640px;
        }
      }

      @keyframes waveScrollBottom {
        from {
          background-position-x: 0;
        }
        to {
          background-position-x: -640px;
        }
      }
      
      .start-title {
        margin: 0;
        font-size: 2rem;
        text-align: center;
        color: #266BB4;
        font-weight: bold;
        margin-top: -110px
      }

      .start-subtitle {
        margin: 0;
        text-align: center;
        font-size: 1rem;
      }

      .start-create-btn {
        bottom: 0;
        align-self: center;
        min-width: 280px;
        font-size: 1.05rem;
      }

      .start-designs {
        display: flex;
        gap: 10px;
        height: 255px;
        z-index: 9;
      }

      .start-designs h2 {
        margin: 0;
        text-align: center;
      }

      .start-page-picker {
        display: grid;
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 12px;
        overflow-x: auto;
        padding-right: 4px;
      }

      .start-page-thumb {
        width: 100%;
        height: 255px;
        border-radius: 12px;
        border: 2px solid rgba(42, 25, 60, 0.18);
        background: #fff;
        object-fit: contain;
        cursor: pointer;
        transition: transform .2s ease, box-shadow .2s ease;
      }

      .start-page-thumb:hover {
        transform: translateY(-2px);
      }

      .toolbar {
        width: 300px;
        height: 100%;
        background: #4CBEB8;
        padding: 14px 12px;
        display: flex;
        flex-direction: column;
        gap: 8px;
        border-right: 2px solid rgba(42, 25, 60, 0.2);
        overflow-y: scroll;
      }

      .toolbar h1 {
        margin: 0;
        font-size: 1.6rem;
        letter-spacing: 0.5px;
      }

      .toolbar-subtitle {
        margin: 0;
        font-size: 0.9rem;
      }

      .tool-group {
        background: rgba(255, 250, 240, 0.72);
        border: 1px solid rgba(42, 25, 60, 0.18);
        border-radius: 14px;
        padding: 8px;
        text-align: center;
      }

      .tool-group h2 {
        margin: 8px 0;
        font-size: 0.95rem;
      }

      .create-char-btn {
        width: 100%;
        padding: 10px 12px;
        font-size: 1rem;
        font-weight: bold;
        background: #EA9752;
        color: #fff4d9;
        border: none;
        border-radius: 10px;
        cursor: pointer;
      }

      .create-char-btn:hover {
        background: #266BB4;
      }

      .back-btn {
        display: flex;
        align-items: center;
        gap: 6px;
        width: auto;
        height: auto;
        padding: 8px 14px;
        font-size: 0.95rem;
        font-family: inherit;
        margin-bottom: 20px;
      }

      .design-dropdown {
        position: relative;
        margin-top: 8px;
      }

      .design-dropdown:last-child {
        margin-bottom: 0;
      }

      .dropdown-toggle {
        cursor: pointer;
        display: flex;
        align-items: center;
        justify-content: space-between;
        margin: 0;
      }

      .dropdown-arrow {
        font-size: 0.7rem;
        transition: transform 0.25s ease;
      }

      .dropdown-toggle.open .dropdown-arrow {
        transform: rotate(180deg);
      }

      .page-picker {
        display: grid;
        grid-template-columns: repeat(3, 1fr);
        gap: 6px;
        max-height: 200px;
        overflow-y: auto;
        overflow-x: hidden;
      }

      .page-thumb {
        width: 100%;
        aspect-ratio: 1;
        border-radius: 8px;
        border: 2px solid rgba(42, 25, 60, 0.22);
        cursor: pointer;
        transition: transform .2s ease, box-shadow .2s ease;
        object-fit: contain;
        background: #fff;
      }

      .page-thumb:hover {
        transform: translateY(-2px);      
      }

      .page-thumb.active {
        transform: translateY(-2px); 
      }

      .page-picker.design-column {
        display: flex;
        flex-direction: column;
        gap: 8px;
        overflow-y: auto;
        overflow-x: hidden;
        max-height: 460px;
        padding-right: 2px;
      }

      .page-picker.design-column .page-thumb {
        width: 100%;
        height: 168px;
        aspect-ratio: auto;
        object-fit: contain;
        flex: 0 0 auto;
      }

      .pattern-picker {
        display: grid;
        grid-template-columns: repeat(3, 1fr);
        gap: 6px;
        max-height: 200px;
        overflow-y: auto;
        overflow-x: hidden;
      }

      .pattern-thumb {
        width: 100%;
        aspect-ratio: 1;
        border-radius: 8px;
        border: 2px solid rgba(42, 25, 60, 0.22);
        cursor: pointer;
        transition: transform .2s ease, box-shadow .2s ease;
        object-fit: contain;
        background: #fff;
      }

      .pattern-thumb:hover {
        transform: translateY(-2px);
      }

      .pattern-thumb.active {
        transform: translateY(-2px); 
      }

      .palette {
        display: grid;
        grid-template-columns: repeat(6, minmax(0, 1fr));
        gap: 8px;
        margin-bottom: 8px;
      }

      .custom-color-label {
        display: block;
        font-size: 0.9rem;
        margin-bottom: 4px;
      }

      #custom-color {
        width: 100%;
        height: 34px;
        border: 1px solid rgba(42, 25, 60, 0.35);
        border-radius: 8px;
        background: #fff9ef;
        cursor: pointer;
      }

      .color-swatch {
        width: 100%;
        aspect-ratio: 1;
        border-radius: 10px;
        border: 2px solid rgba(42, 25, 60, 0.22);
        cursor: pointer;
        transition: transform .2s ease, box-shadow .2s ease;
      }

      .color-swatch.active {
        transform: translateY(-2px);        
      }

      .custom-swatch {
        position: relative;
        background: linear-gradient(135deg, #ff6b6b, #ffd93d, #6bcb77, #4d96ff, #9b59b6);
        padding: 0;
      }

      .custom-swatch span {
        font-size: 1.4rem;
        font-weight: bold;
        color: #2a193c;
        line-height: 1;
        text-shadow: 0 0 3px rgba(255,255,255,0.8);
      }

      .tool-buttons,
      .action-group {
        display: grid;
        grid-template-columns: 1fr;
        gap: 8px;
      }

      .icon-row {
        display: flex;
        flex-direction: row;
        gap: 6px;
        align-items: center;
      }

      .icon-btn {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 40px;
        height: 40px;
        padding: 0;
        flex-shrink: 0;
      }

      .icon-btn svg {
        pointer-events: none;
      }

      .icon-separator {
        width: 1px;
        height: 28px;
        background: rgba(42, 25, 60, 0.25);
        flex-shrink: 0;
        margin: 0 2px;
      }

      button {
        border: 1px solid rgba(42, 25, 60, 0.35);
        border-radius: 10px;
        background: #fff9ef;
        color: #2a193c;
        font-family: inherit;
        font-size: 0.92rem;
        padding: 8px 10px;
        cursor: pointer;
        transition: background .2s ease, transform .2s ease;
      }

      button:hover {
        background: #ffe7b6;
      }

      button:active {
        transform: scale(0.98);
      }

      button.active {
        background: #2a193c;
        color: #fff4d9;
      }

      .size-label {
        display: block;
        margin-bottom: 4px;
      }

      #size-range {
        width: 100%;
      }

      .canvas-stage {
        flex: 1;
        height: 100%;
        display: flex;
        align-items: center;
        justify-content: center;
        padding: 10px;
        background: linear-gradient(160deg, rgba(58, 72, 103, 0.12) 0%, rgba(255, 255, 255, 0.6) 70%);
      }

      .paper-wrap {
        width: 100%;
        height: 100%;
        background: #ffffff;
        border-radius: 12px;
        box-shadow: inset 0 0 0 1px rgba(42, 25, 60, 0.14), 0 20px 36px rgba(42, 25, 60, 0.2);
        display: flex;
        align-items: center;
        justify-content: center;
        padding: 8px;
        position: relative;
        overflow: hidden;
      }

      #drawing-canvas {
        width: 100%;
        height: 100%;
        display: block;
        border-radius: 8px;
        touch-action: none;
        cursor: crosshair;
      }

      #pattern-overlay {
        position: absolute;
        top: 8px; left: 8px; right: 8px; bottom: 8px;
        pointer-events: none;
        border-radius: 8px;
        overflow: hidden;
        z-index: 10;
      }

      .placed-pattern {
        position: absolute;
        pointer-events: auto;
        cursor: grab;
        transform-origin: center center;
      }

      .placed-pattern.selected {
        outline: 2px dashed #2a193c;
        outline-offset: 4px;
      }

      .placed-pattern.dragging {
        cursor: grabbing;
        opacity: 0.7;
      }

      #trash-bin {
        position: absolute;
        bottom: 16px;
        right: 16px;
        width: 48px;
        height: 48px;
        font-size: 28px;
        background: rgba(244, 67, 54, 0.85);
        border-radius: 50%;
        display: flex;
        align-items: center;
        justify-content: center;
        z-index: 20;
        box-shadow: 0 4px 12px rgba(0,0,0,0.25);
        transition: transform .2s ease;
      }

      #trash-bin.hover {
        transform: scale(1.25);
        background: rgba(244, 67, 54, 1);
      }

      .pattern-controls {
        display: flex;
        gap: 6px;
        margin-bottom: 8px;
      }

      .pattern-controls button {
        flex: 1;
        padding: 6px 0;
        font-size: 1.1rem;
        text-align: center;
      }
      
      iframe{
        position: absolute;
        width: 1024px;
        height: 600px;
        top: 50%;
        left: 50%;
        transform: translate(-50%,-50%);
        overflow: hidden;
    }

      /* Custom scrollbar */
      * {
        scrollbar-width: thin;
        scrollbar-color: #32A39B transparent;
      }

      ::-webkit-scrollbar {
        width: 6px;
      }

      ::-webkit-scrollbar-track {
        background: transparent;
      }

      ::-webkit-scrollbar-thumb {
        background: #5CC8B8;
        border-radius: 10px;
      }

      ::-webkit-scrollbar-button {
        display: none;
      }
      
    .toolbar {
      position: relative;
      width: 300px;
      height: 100%;
      background: #4CBEB8;
      padding: 14px 12px;
      display: flex;
      flex-direction: column;
      gap: 8px;
      border-right: 2px solid rgba(42, 25, 60, 0.2);
      overflow-y: auto;
      overflow-x: hidden;
    }

    .toolbar-stars {
      position: absolute;
      inset: 0;
      pointer-events: none;
      overflow: hidden;
      z-index: 0;
    }

    .toolbar > *:not(.toolbar-stars) {
      position: relative;
      z-index: 1;
    }

    .start-card-stars {
      position: absolute;
      inset: 0;
      pointer-events: none;
      overflow: hidden;
      z-index: 0;
    }

    .start-card > *:not(.start-card-stars) {
      position: relative;
      z-index: 1;
    }

    .start-card-star,
    .toolbar-star {
      position: absolute;
      left: 0;
      top: 0;
      will-change: transform, opacity;
      background: currentColor;
      color: inherit;
      clip-path: polygon(
        50% 0%,
        61% 35%,
        98% 35%,
        68% 57%,
        79% 91%,
        50% 70%,
        21% 91%,
        32% 57%,
        2% 35%,
        39% 35%
      );
    }

    .board-tools {
      position: absolute;
      left: 10.8%;
      top: 86%;
      z-index: 30;
      background: #d85fdb36;
      border: 1px solid rgba(42, 25, 60, 0.18);
      border-radius: 18px;
      padding: 10px 12px;
      box-shadow: 0 10px 24px rgba(42, 25, 60, 0.18);
      backdrop-filter: blur(6px);
      cursor: grab;
    }

    .board-tools.dragging {
      cursor: grabbing;
    }

    .board-tools .tool-buttons {
      display: flex;
      align-items: center;
      gap: 8px;
    }

    .board-tools .icon-btn {
      width: 46px;
      height: 46px;
      border-radius: 12px;
      border: none;
      background: none;
    }

    .board-tools .icon-btn img{
      width: 42px;
      height: 42px;
    }

    .board-tools .icon-btn.active {
      transform: scale(1.3);
    }

    .board-tools .icon-separator {
      width: 1px;
      height: 28px;
      background: rgba(42, 25, 60, 0.2);
      margin: 0 4px;
    }

    .board-size-popup {
      position: absolute;
      left: 50%;
      bottom: calc(100% + 14px);
      transform: translateX(-50%);
      width: 78px;
      min-height: 170px;
      background: rgba(255, 248, 240, 0.98);
      border: 1.5px solid rgba(42, 25, 60, 0.14);
      border-radius: 24px;
      box-shadow:
        0 14px 32px rgba(42, 25, 60, 0.16),
        inset 0 1px 0 rgba(255, 255, 255, 0.65);
      display: none;
      flex-direction: column;
      align-items: center;
      justify-content: flex-start;
      gap: 12px;
      padding: 14px 0 16px;
      backdrop-filter: blur(10px);
    }

    .board-size-popup.open {
      display: flex;
    }

    .board-size-value {
      font-size: 0.95rem;
      line-height: 1;
      white-space: nowrap;
      text-align: center;
      color: #2a193c;
      font-weight: 700;
      letter-spacing: 0.2px;
    }

    .board-size-range {
    --fill-percent: 0%;
    -webkit-appearance: none;
    appearance: none;
    writing-mode: vertical-lr;
    direction: rtl;
    width: 28px;
    height: 110px;
    margin: 0;
    padding: 0;
    background: transparent;
    cursor: pointer;
    display: block;
  }

  /* WebKit */
  .board-size-range::-webkit-slider-runnable-track {
    width: 8px;
    height: 110px;
    border-radius: 999px;
    background: linear-gradient(
      to top,
      #1f7bd8 0%,
      #1f7bd8 var(--fill-percent),
      rgba(42, 25, 60, 0.18) var(--fill-percent),
      rgba(42, 25, 60, 0.18) 100%
    );
  }

  .board-size-range::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: #024F9A;
    border: none;
    box-shadow:
      0 2px 6px rgba(20, 130, 227, 0.28),
      0 0 0 4px rgba(20, 130, 227, 0.12);
    margin-left: -7px;
  }

  /* Firefox */
  .board-size-range::-moz-range-track {
    width: 8px;
    height: 110px;
    background: rgba(42, 25, 60, 0.18);
    border-radius: 999px;
    border: none;
  }

  .board-size-range::-moz-range-progress {
    width: 8px;
    background: #2868AF;
    border-radius: 999px;
  }

  .board-size-range::-moz-range-thumb {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: #024F9A;
    border: none;
    box-shadow:
      0 2px 6px rgba(20, 130, 227, 0.28),
      0 0 0 4px rgba(20, 130, 227, 0.12);
  }

    .board-size-popup::after {
      content: "";
      position: absolute;
      left: 50%;
      top: 100%;
      transform: translateX(-50%);
      width: 14px;
      height: 14px;
      background: rgba(255, 248, 240, 0.98);
      border-right: 1.5px solid rgba(42, 25, 60, 0.14);
      border-bottom: 1.5px solid rgba(42, 25, 60, 0.14);
      rotate: 45deg;
      margin-top: -7px;
    }

    #pencil-btn {
      position: relative;
    }

    .board-color-wrap {
      position: relative;
    }

    .board-color-popup {
      position: absolute;
      left: 50%;
      bottom: calc(100% + 10px);
      transform: translateX(-50%);
      width: 220px;
      background: rgba(255, 249, 239, 0.98);
      border: 1px solid rgba(42, 25, 60, 0.18);
      border-radius: 16px;
      box-shadow: 0 10px 24px rgba(42, 25, 60, 0.18);
      display: none;
      padding: 12px;
      gap: 10px;
    }

    .board-color-popup.open {
      display: flex;
      flex-direction: column;
    }

    .board-palette {
      display: grid;
      grid-template-columns: repeat(6, minmax(0, 1fr));
      gap: 8px;
      margin: 0;
    }

    .board-color-popup #custom-color {
      position: static !important;
      width: 100%;
      height: 36px;
      opacity: 1 !important;
      pointer-events: auto !important;
      border: 1px solid rgba(42, 25, 60, 0.25);
      border-radius: 10px;
      background: #fff9ef;
      cursor: pointer;
    }

    #download-btn{
      border-radius:999px;
      background-color: #4CBEB8;
      width: 42px;
      height: 42px;
    }