/* ============================================================
   룰렛 이미지 생성기 — 정적 PNG 출력
   - 검은 배경 + 노란 강조 (다른 도구와 동일 톤)
   - 좌측 사이드바(컨트롤) + 우측 캔버스 미리보기
   ============================================================ */

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
}

.roulette-body {
    background: #000;
    color: #fff;
    font-family: 'NanumSquare', 'Pretendard', 'Helvetica Neue', sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow: hidden;
}

/* === 코너 버튼 === */
.roulette-corner-btn {
    position: fixed;
    z-index: 50;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.95rem;
    border: 1px solid rgba(255, 255, 255, 0.25);
    background: rgba(0, 0, 0, 0.6);
    color: rgba(255, 255, 255, 0.7);
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    text-decoration: none;
    border-radius: 999px;
    backdrop-filter: blur(8px);
    transition: opacity 0.2s, color 0.2s, background 0.2s, border-color 0.2s;
}
.roulette-corner-btn:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.12);
    border-color: rgba(255, 255, 255, 0.4);
}
.roulette-corner-btn--top-left { top: 18px; left: 18px; }
.roulette-corner-btn--top-right { top: 18px; right: 18px; }
.roulette-brand { font-family: 'Space Grotesk', sans-serif; }

/* === 메인 레이아웃 === */
.roulette-main {
    display: grid;
    grid-template-columns: 380px 1fr;
    height: 100vh;
}

@media (max-width: 900px) {
    .roulette-body { overflow: auto; }
    .roulette-main {
        grid-template-columns: 1fr;
        height: auto;
    }
}

.roulette-aside {
    background: rgba(255, 255, 255, 0.02);
    border-right: 1px solid rgba(255, 255, 255, 0.08);
    padding: 5.5rem 1.5rem 2rem;
    overflow-y: auto;
}

/* === 미니멀 스크롤바 (다크 테마) === */
.roulette-aside,
.roulette-textarea {
    /* Firefox */
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.15) transparent;
}

.roulette-aside::-webkit-scrollbar,
.roulette-textarea::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
.roulette-aside::-webkit-scrollbar-track,
.roulette-textarea::-webkit-scrollbar-track {
    background: transparent;
}
.roulette-aside::-webkit-scrollbar-thumb,
.roulette-textarea::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.14);
    border-radius: 999px;
    border: 1px solid transparent;
    background-clip: padding-box;
}
.roulette-aside::-webkit-scrollbar-thumb:hover,
.roulette-textarea::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 0, 0.45);
}
.roulette-aside::-webkit-scrollbar-corner,
.roulette-textarea::-webkit-scrollbar-corner {
    background: transparent;
}

.roulette-header {
    margin-bottom: 1.5rem;
}

.roulette-eyebrow {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.22em;
    color: rgba(255, 255, 0, 0.65);
    margin-bottom: 0.6rem;
}

.roulette-title {
    font-size: 1.45rem;
    font-weight: 900;
    letter-spacing: -0.025em;
    color: #fff;
    margin: 0 0 0.4rem;
}

.roulette-sub {
    font-size: 0.78rem;
    color: rgba(255, 255, 255, 0.45);
    margin: 0;
    line-height: 1.5;
    letter-spacing: -0.005em;
}

/* === 섹션 === */
.roulette-section {
    margin-bottom: 1.4rem;
}
.roulette-section h2 {
    font-family: 'Space Grotesk', monospace;
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.18em;
    color: rgba(255, 255, 255, 0.4);
    margin: 0 0 0.6rem;
    font-weight: 700;
}

.roulette-label {
    display: block;
    font-size: 0.72rem;
    color: rgba(255, 255, 255, 0.5);
    margin-bottom: 0.35rem;
    letter-spacing: 0.02em;
}
.roulette-label code {
    font-family: 'Space Grotesk', monospace;
    color: rgba(255, 255, 0, 0.85);
    background: rgba(255, 255, 0, 0.08);
    padding: 1px 5px;
    border-radius: 3px;
    font-size: 0.7rem;
}

.roulette-hint {
    font-size: 0.7rem;
    color: rgba(255, 255, 255, 0.35);
    margin-top: 0.35rem;
    letter-spacing: 0.01em;
}
.roulette-hint code {
    font-family: 'Space Grotesk', monospace;
    color: rgba(255, 255, 0, 0.75);
    font-size: 0.68rem;
}

/* === 입력 요소 공통 === */
.roulette-textarea,
.roulette-select,
.roulette-input {
    width: 100%;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.12);
    color: #fff;
    border-radius: 6px;
    padding: 0.5rem 0.7rem;
    font-family: inherit;
    font-size: 0.85rem;
    outline: none;
    transition: border-color 0.15s, background 0.15s;
}
.roulette-textarea:focus,
.roulette-select:focus,
.roulette-input:focus {
    border-color: rgba(255, 255, 0, 0.5);
    background: rgba(255, 255, 255, 0.06);
}
.roulette-textarea {
    resize: vertical;
    min-height: 160px;
    font-family: 'Space Grotesk', ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 0.85rem;
    line-height: 1.5;
}

/* number 인풋의 기본 스피너 버튼 숨김 (다크 테마에 안 어울림).
   값은 직접 입력하거나 ↑↓ 키로 조정 가능. */
.roulette-input[type="number"]::-webkit-inner-spin-button,
.roulette-input[type="number"]::-webkit-outer-spin-button {
    -webkit-appearance: none;
    appearance: none;
    margin: 0;
}
.roulette-input[type="number"] {
    -moz-appearance: textfield;
    appearance: textfield;
}
.roulette-select {
    appearance: none;
    -webkit-appearance: none;
    cursor: pointer;
    background-image:
        linear-gradient(45deg, transparent 50%, rgba(255,255,255,0.45) 50%),
        linear-gradient(135deg, rgba(255,255,255,0.45) 50%, transparent 50%);
    background-position: calc(100% - 14px) 50%, calc(100% - 9px) 50%;
    background-size: 5px 5px;
    background-repeat: no-repeat;
    padding-right: 26px;
}
.roulette-select option { background: #111; color: #fff; }

.roulette-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.6rem;
    margin-bottom: 0.6rem;
}
.roulette-row:last-child { margin-bottom: 0; }

.roulette-swatch {
    width: 100%;
    height: 36px;
    padding: 2px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    background: rgba(255, 255, 255, 0.04);
    border-radius: 6px;
    cursor: pointer;
}

/* range slider */
input[type=range] {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 28px;
    background: transparent;
    padding: 0;
    border: 0;
    cursor: pointer;
}
input[type=range]:focus { outline: none; }
input[type=range]::-webkit-slider-runnable-track {
    height: 4px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 999px;
}
input[type=range]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 14px; height: 14px;
    border-radius: 50%;
    background: #FFFF00;
    margin-top: -6px;
    border: 2px solid #000;
    cursor: pointer;
    box-shadow: 0 0 6px rgba(255, 255, 0, 0.4);
}
input[type=range]::-moz-range-track {
    height: 4px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 999px;
}
input[type=range]::-moz-range-thumb {
    width: 12px; height: 12px;
    border-radius: 50%;
    background: #FFFF00;
    border: 2px solid #000;
    cursor: pointer;
}

/* === 토글 === */
.roulette-toggle {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.82rem;
    color: rgba(255, 255, 255, 0.85);
    user-select: none;
    cursor: pointer;
    margin-bottom: 0.5rem;
}
.roulette-toggle input { accent-color: #FFFF00; }

/* === 팔레트 === */
.roulette-palette {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 6px;
}
.roulette-palette button {
    aspect-ratio: 1;
    border-radius: 6px;
    border: 2px solid transparent;
    cursor: pointer;
    padding: 0;
    background: linear-gradient(135deg, var(--c1), var(--c2));
    transition: transform 0.1s, border-color 0.15s;
}
.roulette-palette button:hover { transform: scale(1.05); }
.roulette-palette button.active { border-color: #FFFF00; box-shadow: 0 0 0 1px rgba(255, 255, 0, 0.5); }

/* === 액션 버튼 === */
.roulette-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.roulette-btn {
    flex: 1;
    min-width: 110px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.7rem 1rem;
    border-radius: 6px;
    font-family: inherit;
    font-size: 0.82rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    cursor: pointer;
    transition: all 0.15s;
    border: 1px solid transparent;
}

.roulette-btn--primary {
    background: rgba(255, 255, 0, 0.12);
    border-color: rgba(255, 255, 0, 0.4);
    color: rgba(255, 255, 0, 0.95);
}
.roulette-btn--primary:hover {
    background: rgba(255, 255, 0, 0.22);
    border-color: rgba(255, 255, 0, 0.7);
    color: #fff;
}

.roulette-btn--secondary {
    background: rgba(255, 255, 255, 0.04);
    border-color: rgba(255, 255, 255, 0.18);
    color: rgba(255, 255, 255, 0.7);
}
.roulette-btn--secondary:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.35);
    color: #fff;
}

.roulette-btn.is-success {
    background: rgba(74, 222, 128, 0.12);
    border-color: rgba(74, 222, 128, 0.45);
    color: #4ade80;
}

.roulette-footer-note {
    font-size: 0.7rem;
    color: rgba(255, 255, 255, 0.35);
    line-height: 1.55;
    margin: 0;
}

/* === 캔버스 영역 === */
.roulette-canvas-wrap {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: clamp(1rem, 3vw, 2.5rem);
    overflow: hidden; /* 스테이지가 항상 부모 안에 맞춰지므로 스크롤 불필요 */
    background:
        radial-gradient(circle at 50% 40%, rgba(255, 255, 0, 0.05), transparent 60%),
        #000;
    position: relative;
    min-height: 0; /* flex item이 부모보다 작아질 수 있도록 */
}

.roulette-canvas-wrap::before {
    content: '';
    position: absolute;
    inset: 1.2rem;
    border: 1px dashed rgba(255, 255, 255, 0.05);
    border-radius: 16px;
    pointer-events: none;
}

/* 스테이지 = 캔버스 + 오버레이(포인터·컨페티·당첨카드)를 묶는 정사각형 박스.
   aspect-ratio + height:100% + max-width:100% → 부모의 짧은 변에 맞춰 정사각형 크기 결정.
   부모 1000×600 → 600×600 / 부모 600×1000 → 600×600 / 부모 800×800 → 800×800 */
.roulette-stage {
    position: relative;
    aspect-ratio: 1 / 1;
    height: 100%;
    max-width: 100%;
}

#canvas {
    display: block;
    width: 100%;
    height: 100%;
    background: transparent;
    border-radius: 12px;
    /* 그림자는 padding 안에서 잘리지 않도록 작게 — overflow:hidden이라 부모 밖은 어차피 잘림 */
    box-shadow: 0 8px 28px rgba(0, 0, 0, 0.55);
}

/* 포인터 (12시 방향에서 휠 안쪽으로 ▼) */
.roulette-pointer {
    position: absolute;
    top: -2px;
    left: 50%;
    transform: translateX(-50%);
    width: 30px;
    height: 38px;
    background: #FFFF00;
    clip-path: polygon(50% 100%, 0 0, 100% 0);
    z-index: 2;
    filter: drop-shadow(0 3px 6px rgba(0, 0, 0, 0.6));
    pointer-events: none;
}

/* 컨페티 캔버스 — 휠 위에 합성 (PNG 저장에는 X) */
.roulette-confetti {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 3;
}

/* 당첨 카드 — 휠 가운데에 슬라이드 업하며 등장 */
.roulette-winner {
    position: absolute;
    left: 50%;
    bottom: 14%;
    transform: translateX(-50%) translateY(20px) scale(0.92);
    z-index: 4;
    min-width: clamp(220px, 50%, 420px);
    max-width: 80%;
    padding: 1.1rem 2.6rem 1.2rem 1.6rem;
    background: rgba(0, 0, 0, 0.85);
    border: 2px solid #FFFF00;
    border-radius: 14px;
    box-shadow:
        0 0 0 1px rgba(255, 255, 0, 0.3),
        0 12px 40px rgba(255, 255, 0, 0.25),
        0 20px 50px rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(8px);
    text-align: center;
    line-height: 1.2;
    opacity: 0;
    transition: opacity 0.35s ease, transform 0.45s cubic-bezier(0.2, 1.2, 0.3, 1);
}
.roulette-winner.is-show {
    opacity: 1;
    transform: translateX(-50%) translateY(0) scale(1);
}

.roulette-winner-tag {
    display: block;
    font-family: 'Space Grotesk', sans-serif;
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.22em;
    color: rgba(255, 255, 0, 0.95);
    margin-bottom: 0.5rem;
    text-transform: uppercase;
}

.roulette-winner-name {
    font-size: clamp(1.2rem, 2.4vw, 2rem);
    font-weight: 900;
    color: #fff;
    word-break: keep-all;
    letter-spacing: -0.02em;
}

.roulette-winner-close {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 28px;
    height: 28px;
    padding: 0;
    border: none;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.08);
    color: rgba(255, 255, 255, 0.65);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.78rem;
    transition: background 0.15s, color 0.15s;
}
.roulette-winner-close:hover {
    background: rgba(255, 255, 255, 0.16);
    color: #fff;
}

/* 추첨 버튼 — 강조 변형 (PNG 저장과 시각 분리) */
.roulette-btn--accent {
    background: rgba(255, 105, 180, 0.12);
    border-color: rgba(255, 105, 180, 0.45);
    color: #ff8fc5;
}
.roulette-btn--accent:hover {
    background: rgba(255, 105, 180, 0.22);
    border-color: rgba(255, 105, 180, 0.7);
    color: #fff;
}
.roulette-btn--accent:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* === 모바일 === */
@media (max-width: 900px) {
    .roulette-corner-btn {
        padding: 0.4rem 0.7rem;
        font-size: 0.65rem;
    }
    .roulette-corner-btn span { display: none; }
    .roulette-aside {
        padding: 5rem 1.2rem 2rem;
        border-right: none;
        border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    }
    .roulette-canvas-wrap {
        padding: 1.2rem;
        min-height: 60vh;
    }
}
