/* ========================================
   TOKENS (Design Variables)
   ======================================== */
    :root {
      /* Colors */
      --c-text: #fff;
      --c-text-dark: #262626;
      --c-overlay: rgba(0, 0, 0, 0.1);
      --c-overlay-strong: rgba(0, 0, 0, 0.15);
      --c-stroke: rgba(255, 255, 255, 0.08);
      --c-stroke-strong: rgba(255, 255, 255, 0.4);

      /* Typography (base + fluid) */
      --fs-body: 16px;
      --fs-sm: 14px;
      --fs-md: 18px;              /* buttons, message text */
      --fs-lg: 20px;              /* hover/large */
      --fs-hero: clamp(116px, 18vw, 200px);  /* big logo text */
      --fs-cta: clamp(24px, 6vw, 80px);      /* big Start button */

      /* Blurs */
      --blur-sm: 4px;
      --blur-md: 8px;
      --blur-lg: 0px;

       /* Shadows */
      --shadow-out-sm: 0 4px 4px rgba(0,0,0,0.05);
      --shadow-out-md: 0 6px 6px rgba(0,0,0,0.05);
      --shadow-in-sm: inset 0 1px 1px rgba(255,255,255,0.08);
      --shadow-in-md: inset 0 1px 1px rgba(255,255,255,0.3);

      /* Sizes */
      --sz-icon: 24px;
      --sz-icon-lg: 34px;
      --sz-btn-h: 45px;
      --sz-btn-h-lg: 50px;
      --sz-ui-gap: 12px;
    }

    .baumans-regular {
      font-family: "Baumans", system-ui;
      font-weight: 400;
      font-style: normal;
    }

    .nanum-pen-script-regular {
      font-family: "Nanum Pen Script", cursive;
      font-weight: 400;
      font-style: normal;
    }

    /* Body */
    html,
    body {
      margin: 0;
      padding: 0;
      display: flex;
      justify-content: center;
      align-items: center;
      overflow: hidden;
      font-family: 'Arial', sans-serif;
    }

    /* Canvas */
    canvas {
      display: block;
      margin: 0;
      padding: 0;
      position: absolute;
      top: 0;
      left: 0;
      width: 100vw;
      height: 100vh;
      z-index: 0;
    }

    /* UI */
    .ui-bar {
      position: fixed;
      bottom: 0;
      width: 98vw;
      height: auto;
      margin-bottom: 12px;
      display: flex;
      justify-content: space-between;
      align-items: flex-end;
      z-index: 3;
    }

    .action-buttons {
      display: flex;
      justify-content: center;
      align-items: center;
      gap: 12px;
      width: fit-content;
      height: 60px;
      padding: 0px 12px;
      border-radius: 40px;
      background: rgba(0, 0, 0, 0.1);
      backdrop-filter: blur(4px);
      -webkit-backdrop-filter: blur(4px);
      border-bottom: 1.5px solid rgba(255, 255, 255, 0.08);
      box-shadow:
        0 6px 6px rgba(0, 0, 0, 0.05),
        inset 0 1px 1px rgba(255, 255, 255, 0.08);
    }

    /* Button */
    button {
      display: flex;
      align-items: center;
      gap: 8px;
      width: auto;
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
      height: 45px;
      font-size: var(--fs-md);
      text-align: center;
      padding: 10px 20px;
      box-sizing: border-box;
      border: 0.2px solid rgba(255, 255, 255, 0.4);
      border-radius: 50px;
      background: rgba(255, 255, 255, 0.1);
      color: var(--c-text);
      backdrop-filter: blur(var(--blur-sm));
      -webkit-backdrop-filter: blur(var(--blur-sm));
      box-shadow: 0 2px 2px rgba(255,255,255,0.2), var(--shadow-in-md);
      cursor: pointer;
      transition: all 0.3s ease;
      justify-items: center;
    }

    button:hover, button.hand-hover {
      background: rgba(255, 255, 255, 0.2);
      backdrop-filter: blur(10px);
      width: auto;
      height: 50px;
      font-size: var(--fs-lg);
    }

    button .icon {
      width: 24px;
      height: width;
      display: block;
      pointer-events: none;
    }

    button:hover .icon, button.icon.hand-hover {
      width: 34px;
      height: width;
    }

    #toggle-btn {
      width: 100px;
      height: 100px;
      color: white;
      display: flex;
      justify-content: center;
      align-items: center;
      z-index: 20;
      cursor: pointer;
      background: rgba(0, 0, 0, 0.1);
      backdrop-filter: blur(4px);
      -webkit-backdrop-filter: blur(4px);
      border-bottom: 1.5px solid rgba(255, 255, 255, 0.08);
      box-shadow:
        0 6px 6px rgba(0, 0, 0, 0.05),
        inset 0 1px 1px rgba(255, 255, 255, 0.08);
    }

    #toggle-btn .icon {
      width: 50px;
      height: 50px;
    }

    #toggle-btn:hover {
      scale: 1.1;
      background: rgba(0, 0, 0, 0.15);
      backdrop-filter: blur(8px);
      -webkit-backdrop-filter: blur(8px);
    }

    #toggle-btn .icon :hover {
      width: 60px;
      height: 60px;
    }

    /* overlay */
    .overlay {
      position: fixed;
      top: clamp(40px, 7vh, 60px);
      left: 0;
      width: 100vw;
      height: calc(100vh - clamp(40px, 7vh, 60px) * 2);
      background-color: rgba(0, 0, 0, 0.1);
      pointer-events: none;
      z-index: 1;
      overflow: hidden;
    }

    .overlay::before {
      content: '';
      position: absolute;
      top: 50%;
      left: 50%;
      width: clamp(150px, min(95vw, 95vh), 700px);
      height: clamp(150px, min(95vw, 95vh), 700px);
      border-radius: 50%;
      transform: translate(-50%, -50%);
      box-shadow: 0 0 0 calc(100vh - clamp(40px, 7vh, 60px) * 2) rgba(219, 173, 106, 0.95);
      z-index: 2;
    }

    /* Toast message */
    #message {
      position: fixed;
      top: 0;
      margin-top: 12px;
      font-size: 18px;
      font-size: var(--fs-md);
      text-align: center;
      padding: clamp(10px, 2vh, 20px);
      white-space: pre-line;
      display: none;
      border-radius: 15px;
      z-index: 10000;
      background: rgba(20, 20, 20, 0.5);
      color: #fff;
      backdrop-filter: blur(4px) saturate(160%);
      -webkit-backdrop-filter: blur(4px) saturate(160%);
      border-bottom: 1.5px solid rgba(255, 255, 255, 0.08);
      box-shadow:
        0 4px 4px rgba(0, 0, 0, 0.05),
        inset 0 1px 1px rgba(255, 255, 255, 0.08);
    }

    /* Selection ring */
    #selected-mark {
      position: absolute;
      width: clamp(20px, 2vw, 60px);
      height: clamp(20px, 2vw, 60px);
      border-radius: 50%;
      border: 2px solid rgba(255, 255, 255, 0.35);
      background: rgba(255, 255, 255, 0.1);
      backdrop-filter: blur(1px) saturate(100%);
      -webkit-backdrop-filter: blur(1px) saturate(100%);
      box-shadow:
        0 2px 10px rgba(255, 255, 255, 0.2),
        inset 0 1px 1px rgba(255, 255, 255, 0.25);
      pointer-events: none;
      display: none;
      z-index: 8;
      transition: transform 0.2s ease, box-shadow 0.3s ease;
    }

    #selected-mark::before {
      content: "";
      position: absolute;
      inset: 0;
      border-radius: 50%;
      background: radial-gradient(circle at top left,
          rgba(255, 255, 255, 0.4),
          rgba(255, 255, 255, 0.05) 70%);
      pointer-events: none;
      opacity: 0.8;
    }

    #selected-mark.active {
      transform: scale(1.08);
      box-shadow:
        0 4px 15px rgba(255, 255, 255, 0.25),
        inset 0 1px 2px rgba(255, 255, 255, 0.35);
    }

    @keyframes pulseGlass {

      0%,
      100% {
        transform: scale(1);
        opacity: 1;
      }

      50% {
        transform: scale(1.2);
        opacity: 0.85;
      }
    }

    #selected-mark.active {
      animation: pulseGlass 2s ease-in-out infinite;
    }

    /* hand indicator */
    #hand-ind {
      position: absolute;
      width: 60px;
      height: 60px;
      opacity: 0.75;
      display: none;
      pointer-events: none;
      z-index: 999;
    }

    /* frame options */
    #frame-options, #frame-overlay {
      position: fixed;
      inset: 0;
      display: none;
      justify-content: center;
      align-items: center;
      /* background: var(--c-overlay); */
      /* backdrop-filter: blur(var(--blur-lg));
      -webkit-backdrop-filter: blur(var(--blur-lg)); */
      z-index: 10000;
    }

    #frame-options {
      gap: 80px;
      /* animation: fadeIn 0.3s ease; */
    }

    #rect-frame-btn {
      width: auto;
      height: auto;
      padding-bottom: 25px;
      flex-direction: column;
      background: rgba(0, 0, 0, 0.1);
      backdrop-filter: blur(var(--blur-sm));
      -webkit-backdrop-filter: blur(var(--blur-lg));
    }

    #round-frame-btn {
      width: auto;
      height: auto;
      padding-bottom: 25px;
      flex-direction: column;
      background: rgba(0, 0, 0, 0.1);
      backdrop-filter: blur(var(--blur-sm));
      -webkit-backdrop-filter: blur(var(--blur-lg));
    }

    #frame-options button img {
      width: 300px;
      height: 300px;
      display: block;
      margin-bottom: 12px;
      opacity: 0.9;
      transition: transform 0.3s ease, opacity 0.3s ease;
    }

    #frame-options button:hover {
      transform: scale(1.05);
    }

    #frame-options button:hover img {
      transform: scale(1.03);
    }

    #frame-options button span {
      display: block;
      font-size: 18px;
      color: white;
      margin-top: 6px;
      text-transform: uppercase;
    }

    #frame-overlay-img {
      max-width: 90vw;
      max-height: 90vh;
      width: auto;
      height: auto;
      opacity: 0.88;
    }

    #frame-overlay.show {
      display: flex;
    }

    #frame-overlay-img.is-final {
      opacity: 0;
      transform: scale(.96);
      animation: revealShot .45s ease-out forwards;
    }

    @keyframes revealShot {
      to {
        opacity: 1;
        transform: scale(1);
      }
    }

    @keyframes fadeOut {
      from {
        opacity: 1;
      }

      to {
        opacity: 0;
      }
    }

    @keyframes fadeIn {
      from {
        opacity: 0;
      }

      to {
        opacity: 1;
      }
    }

    /* ------ small screen ----- */
    @media (max-width: 680px) {
      #toggle-btn {
        width: 50px;
        height: 50px;
      }

      #toggle-btn .icon {
        width: 25px;
        height: 25px;
      }

      .action-buttons {
        gap: 6px;
        padding: 0px 6px;
        height: 50px;
      }

      button {
        width: auto;
        height: 40px;
        font-size: 14px;
        padding: 6px 12px;
        display: flex;
      }

      button:hover {
        font-size: 15px;
        height: 45px;
      }

      .ui-bar {
        width: fit-content;
        justify-content: space-around;
        margin-bottom: 12px;
        gap: 5px;
      }

      #frame-options button span {
        font-size: 14px;
      }

      #frame-options {
        flex-direction: column;
        gap: 40px;
        padding: 40px 0;
      }

      #frame-options button img {
        width: 220px;
        height: 220px;
      }

      #frame-options button span {
        font-size: 14px;
      }

      #message {
        margin-top: 12px;
        font-size: 14px;
        padding: 12px;
        border-radius: 5px;
      }
    }

    @media (max-width: 400px) {
      #toggle-btn {
        width: 40px;
        height: 40px;
      }

      #toggle-btn .icon {
        width: 25px;
        height: 25px;
      }

      .ui-bar {
        gap: 4px;
      }

      .action-buttons {
        gap: 4px;
        width: fit-content;
        padding: 0px 6px;
        height: 40px;
      }

      button {
        width: auto;
        height: 30px;
        font-size: 14px;
        padding: 6px 5px;
      }

      button:hover {
        font-size: 15px;
        height: 45px;
      }

      #frame-options button span {
        font-size: 12px;
      }

      #frame-options {
        gap: 40px;
        padding: 40px 0;
      }

      #frame-options button img {
        width: 220px;
        height: 220px;
      }

      #frame-options button span {
        font-size: 12px;
      }

      #message {
        margin-top: 12px;
        font-size: 12px;
        padding: 12px;
        border-radius: 5px;
      }
    }

    /* ===== Start Screen ===== */
    #start-screen {
      position: fixed;
      inset: 0;
      z-index: 9998;
      display: flex;
      flex-direction: row;
      justify-content: top;
      width: 100vw;
      box-sizing: border-box;
      align-items: center;
      background: #F0F0F0;
      animation: startFadeIn .35s ease-out both;
    }

    .start-left { 
      display: flex; 
      flex-direction: column; 
      height: 100%; 
      width: 50vw; 
      box-sizing: border-box;
      padding-left: 4vw;
      padding-right: 4vw;
      justify-content: center; 
      gap: 4px;
      z-index: 999;
    }
    .start-right { 
      display: flex; 
      justify-content: center;
      height: 100%;
      width: 50vw; 
    }
   
    #start-cover {
      width: 50vw;
    }

    .start-description { 
      display: flex; 
      flex-direction: column;
      height: fit-content; 
      gap: 3px; 
      margin: 12px; 
    }

    /* Start screen text */
    .start-logo, .logo-bloom { 
      margin: 0; 
      font-size: 12vw;
    }
    .logo-bloom { color: #7b8378; }
    .start-logo { color: #6a6a6a; font-family: "Baumans", system-ui; }
    .start-lead, .start-sub, .start-note { font-size: var(--fs-md); color: #878686; margin: 0; }
    .start-gif img { width: 130px; opacity: 0.75;}
    .start-note { display: flex; align-items: end; gap: 12px; }

    .start-btn-container {
      width: 100%;
      height: fit-content;
      display: flex;
      justify-content: end;
    }

    /* start btn */
    #start-btn {
      position: absolute;
      left: 50%;
      transform: translateX(-50%);
      width: fit-content;
      height: auto;
      bottom: 40px;
      right: 240px;
      padding: 12px 28px;
      font-size: var(--fs-cta);
      border-radius: 50px;
      color: #fff;
      background: rgba(123,131,120,0.5);
      backdrop-filter: blur(4px);
      -webkit-backdrop-filter: blur(4px);
      border-bottom: 1.5px solid rgba(255, 255, 255, 0.08);
      box-shadow:
        0 6px 6px rgba(0, 0, 0, 0.05),
        inset 0 1px 1px rgba(255, 255, 255, 0.08);
      cursor: pointer;
      transition: all .2s ease;
      z-index: 120000;
    }

    #start-btn:hover {
      width: fit-content;
      height: auto;
      transform: translateX(-50%) scale(1.08);
      background: rgba(123,131,120,1);
      backdrop-filter: blur(8px);
      -webkit-backdrop-filter: blur(8px);
      box-shadow:
        0 8px 12px rgba(0, 0, 0, 0.15),
        inset 0 1px 1px rgba(255, 255, 255, 0.2);
      transition: all 0.25s ease;
    }

    #start-screen.hide {
      animation: startFadeOut .3s ease forwards;
      pointer-events: none;
    }

    #fullscreen-btn{
      width: 45px;
      height: 45px;
      color: white;
      display: flex;
      justify-content: center;
      align-items: center;
      z-index: 10001;
      cursor: pointer;
      background: rgba(0, 0, 0, 0.1);
      backdrop-filter: blur(4px);
      -webkit-backdrop-filter: blur(4px);
      border-bottom: 1.5px solid rgba(255, 255, 255, 0.08);
      box-shadow:
        0 6px 6px rgba(0, 0, 0, 0.05),
        inset 0 1px 1px rgba(255, 255, 255, 0.08);
      position: fixed;
      top: 12px;
      right: 12px;
      border-radius: 50%;
      transition: all 0.25s ease;
    }

    #fullscreen-btn:hover {
      scale: 1.1;
      background: rgba(0, 0, 0, 0.15);
      backdrop-filter: blur(8px);
      -webkit-backdrop-filter: blur(8px);
    }

    #fullscreen-btn img {
      width: 24px;
      height: 24px;
      pointer-events: none;
    }

    @media (max-width: 480px) {
      #fullscreen-btn {
       display: none;
      }

      #start-screen {
        flex-direction: column;
        justify-content: flex-start;
        width: 100vw;
        padding: 20px 0;
        gap: 0;
      }

      /* Left */
      .start-left {
        width: 100%;
        height: fit-content;
        display: flex;
        flex-direction: column;
        justify-content: flex-start;
        margin-bottom: 0;
        align-items: left;
      }

      .start-description {
        gap: 3px;
        margin: 0 auto;
      }

      .start-logo { margin: 0 auto; font-size: 124px; }
      .logo-bloom { font-size: 124px; }
      .start-lead, .start-sub { font-size: 14px; }
      .start-note { display: none; }

      .start-right {
        margin: 0;
        align-items: center;
        justify-content: space-between;
        width: 100vw;
      }

      #start-cover {
        margin: 0;
        width: 100%;
        height: auto;
      }

      #start-btn {    
        width: 130px;
        height: auto;
        font-size: 24px;
        margin: 0 auto;
        padding: 12px auto;
        left: 50%;
        transform: translateX(-50%);
        transition: all 0.25s ease;
      }

      #start-btn:hover {
        width: 130px;
        height: auto;
        left: 50%;
        transform:scale(1.05) translateX(-50%);
      }

      #start-screen.hide {
        animation: startFadeOut .3s ease forwards;
        pointer-events: none;
      }
    }

    @keyframes startFadeIn {
      from {
        opacity: 0
      }

      to {
        opacity: 1
      }
    }

    @keyframes startFadeOut {
      to {
        opacity: 0;
        transform: scale(.98)
      }
    }