* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, Roboto, 'Noto Sans KR', sans-serif;
    background: linear-gradient(135deg, #a1c4fd 0%, #c2e9fb 100%);
    background-size: 200% 200%;
    animation: gradientShift 10s ease infinite;
    color: #333;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    position: relative;
    overflow-x: hidden;
}

/* 배경 별들 */
.star {
    position: absolute;
    background: rgba(255, 255, 255, 0.7);
    clip-path: polygon(50% 0%, 61% 35%, 98% 35%, 68% 57%, 79% 91%, 50% 70%, 21% 91%, 32% 57%, 2% 35%, 39% 35%);
    animation: twinkle 5s ease-in-out infinite;
}

.star:nth-child(1) {
    top: 10%;
    left: 10%;
    width: 15px;
    height: 15px;
    animation-delay: 0s;
}

.star:nth-child(2) {
    top: 20%;
    right: 15%;
    width: 10px;
    height: 10px;
    animation-delay: 1.5s;
}

.star:nth-child(3) {
    bottom: 30%;
    left: 20%;
    width: 20px;
    height: 20px;
    animation-delay: 3s;
}

.star:nth-child(4) {
    bottom: 15%;
    right: 10%;
    width: 12px;
    height: 12px;
    animation-delay: 0.8s;
}

.star:nth-child(5) {
    top: 40%;
    left: 5%;
    width: 8px;
    height: 8px;
    animation-delay: 2.2s;
}

.star:nth-child(6) {
    top: 60%;
    right: 25%;
    width: 18px;
    height: 18px;
    animation-delay: 4s;
}

.container {
    background: rgba(255, 255, 255, 0.96);
    backdrop-filter: blur(10px);
    border-radius: 30px;
    padding: 40px;
    width: 100%;
    max-width: 650px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.3);
    text-align: center;
    position: relative;
    animation: containerBounce 0.8s ease-out;
}

.header {
    margin-bottom: 30px;
}

h1 {
    font-size: 2.5rem;
    background: linear-gradient(135deg, #ff9a8b 0%, #ff6a88 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 15px;
    font-weight: 800;
}

.guide {
    color: #555;
    font-size: 1.2rem;
    margin-bottom: 8px;
    font-weight: 500;
}

/* BEGIN UX: onboarding popup */
.onboarding-overlay {
    position: fixed;
    inset: 0;
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: rgba(40, 50, 70, 0.55);
    backdrop-filter: blur(4px);
}

.onboarding-overlay[hidden] {
    display: none;
}

.onboarding-modal {
    width: 100%;
    max-width: 360px;
    background: #fff;
    border-radius: 24px;
    padding: 28px 24px 22px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.25);
    text-align: left;
    animation: fadeIn 0.35s ease-out;
}

.onboarding-title {
    color: #3d6fb8;
    font-weight: 800;
    font-size: 1.25rem;
    margin-bottom: 18px;
    text-align: center;
}

.onboarding-steps {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 14px;
    margin-bottom: 22px;
}

.onboarding-steps li {
    display: flex;
    align-items: center;
    gap: 12px;
    color: #3a4a5c;
    font-size: 1.05rem;
    font-weight: 600;
    line-height: 1.4;
}

.step-num {
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, #ff9a44, #ff6347);
    color: #fff;
    font-size: 1rem;
    font-weight: 800;
    display: flex;
    align-items: center;
    justify-content: center;
}

.onboarding-dismiss {
    display: block;
    width: 100%;
    border: none;
    border-radius: 14px;
    padding: 14px 16px;
    background: linear-gradient(135deg, #ff9a44, #ff6347);
    color: #fff;
    font-size: 1.05rem;
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    box-shadow: 0 6px 18px rgba(255, 99, 71, 0.28);
}

.onboarding-dismiss:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 22px rgba(255, 99, 71, 0.35);
}
/* END UX: onboarding popup */

.tips {
    background: rgba(255, 229, 153, 0.4);
    border: 1px solid rgba(255, 229, 153, 0.8);
    border-radius: 20px;
    padding: 20px;
    margin-top: 30px;
    text-align: left;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.05);
}

.tips-title {
    color: #f39c12;
    font-weight: 700;
    font-size: 1.1rem;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.tips-content {
    color: #594a26;
    font-size: 0.95rem;
    line-height: 1.6;
    font-weight: 500;
}

#result-box {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 30px;
    background: rgba(255, 255, 255, 0.7);
    border-radius: 25px;
    padding: 35px 25px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.6);
}

.text-container {
    padding: 25px;
    border-radius: 20px;
    background: #ffffff;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.06);
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    min-height: 120px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    position: relative;
    border: 2px solid transparent;
}

.text-container.active {
    transform: translateY(-6px) scale(1.02);
    box-shadow: 0 12px 40px rgba(255, 154, 68, 0.3);
    border: 2px solid rgba(255, 154, 68, 0.5);
}

.text-container h2 {
    font-size: 1rem;
    color: #ff9a44;
    margin-bottom: 15px;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.text-container p {
    font-size: 1.4rem;
    font-weight: 600;
    color: #34495e;
    min-height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1.4;
    word-break: keep-all;
    overflow-wrap: break-word;
    text-align: center;
}

.text-container p.placeholder {
    color: #8a9aa6;
    font-weight: 500;
}

.text-container p.loading {
    color: #ff9a44;
    animation: pulse 1.5s ease-in-out infinite;
}

.arrow-container {
    display: inline-flex;
    align-self: center;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin: 12px 0;
    padding: 7px 20px 7px 7px;
    cursor: pointer;
    font-family: inherit;
    background: #ffffff;
    border: 2px solid rgba(255, 154, 68, 0.55);
    border-radius: 999px;
    box-shadow: 0 6px 16px rgba(255, 99, 71, 0.18);
    transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.arrow-container:hover {
    transform: translateY(-2px);
    border-color: #ff9a44;
    box-shadow: 0 10px 22px rgba(255, 99, 71, 0.28);
}

.arrow-container:active {
    transform: translateY(0) scale(0.96);
    box-shadow: 0 3px 10px rgba(255, 99, 71, 0.2);
}

.arrow-container:focus-visible {
    outline: 3px solid #3d6fb8;
    outline-offset: 3px;
}

.direction-label {
    color: #e8663d;
    font-size: 1rem;
    font-weight: 800;
    white-space: nowrap;
}

.arrow {
    width: 44px;
    height: 44px;
    background: linear-gradient(135deg, #ff9a44, #ff6347);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 2rem;
    font-weight: bold;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 4px 12px rgba(255, 99, 71, 0.35);
    transform: rotate(90deg);
}

.arrow.reverse {
    transform: rotate(-90deg);
}

.listen-btn {
    position: absolute;
    top: 15px;
    right: 15px;
    background: #fff0e6;
    border: none;
    border-radius: 50%;
    width: 45px;
    height: 45px;
    display: none;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.listen-btn svg {
    width: 22px;
    height: 22px;
    color: #ff9a44;
}

.listen-btn:hover {
    transform: scale(1.15);
    background: #ffe0cc;
}

.controls {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 25px;
}

#record-btn {
    background: linear-gradient(135deg, #ff9a44, #ff6347);
    border: none;
    border-radius: 50%;
    width: 140px;
    height: 140px;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 15px 50px rgba(255, 99, 71, 0.4);
    position: relative;
    overflow: hidden;
    border: 4px solid rgba(255, 255, 255, 0.3);
}

#record-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.3), rgba(255, 255, 255, 0.1));
    border-radius: 50%;
}

#record-btn:hover {
    transform: translateY(-8px) scale(1.05);
    box-shadow: 0 20px 60px rgba(255, 99, 71, 0.5);
}

#record-btn:active {
    transform: translateY(-4px) scale(1.02);
}

#record-btn svg {
    width: 55px;
    height: 55px;
    color: #ffffff;
    transition: all 0.3s ease;
    z-index: 1;
    position: relative;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.2));
}

#record-btn.recording {
    background: linear-gradient(135deg, #48c774, #34a853);
    animation: recordingPulse 1.2s infinite;
}

#record-btn.recording svg {
    animation: micBounce 0.6s ease-in-out infinite alternate;
}

#status-text {
    font-size: 1.2rem;
    color: #555;
    font-weight: 600;
    min-height: 32px;
    margin-top: 4px;
    transition: all 0.3s ease;
}

#status-text.recording {
    color: #48c774;
    font-weight: 700;
}

#status-text.translating {
    color: #ff9a44;
    font-weight: 700;
}

.install-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-top: 14px;
    padding: 10px 18px;
    border: none;
    border-radius: 999px;
    background: #3d6fb8;
    color: #fff;
    font-size: 0.95rem;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 8px 20px rgba(61, 111, 184, 0.28);
}

.install-btn[hidden] {
    display: none;
}

.install-btn:hover {
    transform: translateY(-1px);
}

.install-help {
    margin-top: 12px;
    color: #555;
    font-size: 0.95rem;
    line-height: 1.5;
}

.install-help[hidden] {
    display: none;
}

/* 애니메이션들 */
@keyframes gradientShift {
    0% {
        background-position: 0% 50%;
    }

    50% {
        background-position: 100% 50%;
    }

    100% {
        background-position: 0% 50%;
    }
}

@keyframes twinkle {

    0%,
    100% {
        opacity: 0.3;
        transform: scale(1);
    }

    50% {
        opacity: 1;
        transform: scale(1.2);
    }
}

@keyframes containerBounce {
    0% {
        transform: scale(0.9) translateY(40px);
        opacity: 0;
    }

    100% {
        transform: scale(1) translateY(0);
        opacity: 1;
    }
}

@keyframes recordingPulse {
    0% {
        box-shadow: 0 15px 50px rgba(72, 199, 116, 0.4);
    }

    50% {
        box-shadow: 0 15px 50px rgba(72, 199, 116, 0.7), 0 0 0 20px rgba(72, 199, 116, 0.2);
    }

    100% {
        box-shadow: 0 15px 50px rgba(72, 199, 116, 0.4);
    }
}

@keyframes micBounce {
    0% {
        transform: scale(1);
    }

    100% {
        transform: scale(1.1);
    }
}

@keyframes pulse {

    0%,
    100% {
        opacity: 0.7;
    }

    50% {
        opacity: 1;
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px) scale(0.98);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.fade-in {
    animation: fadeIn 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

/* 반응형 디자인 */
@media (max-width: 768px) {
    body {
        padding: 10px;
    }

    .container {
        padding: 20px 15px;
        margin: 0;
        width: 100%;
        border-radius: 25px;
    }

    .header {
        margin-bottom: 20px;
    }

    h1 {
        font-size: 1.8rem;
        margin-bottom: 10px;
    }

    .guide {
        font-size: 1.1rem;
        margin-bottom: 15px;
    }

    #status-text {
        font-size: 1.1rem;
        min-height: 28px;
    }

    #result-box {
        padding: 20px 15px;
        gap: 15px;
        margin-bottom: 20px;
    }

    .text-container {
        min-height: 90px;
        padding: 18px;
    }

    .text-container h2 {
        font-size: 0.95rem;
        margin-bottom: 12px;
    }

    .text-container p {
        font-size: 1.25rem;
        min-height: 40px;
    }

    .arrow-container {
        margin: 6px 0;
    }

    .controls {
        gap: 20px;
    }

    #record-btn {
        width: 110px;
        height: 110px;
    }

    #record-btn svg {
        width: 40px;
        height: 40px;
    }

    .tips {
        text-align: center;
        margin-top: 25px;
        padding: 18px;
        font-size: 0.95rem;
    }
}

@media (max-width: 480px) {
    .container {
        padding: 25px 15px;
    }

    h1 {
        font-size: 1.7rem;
    }

    .guide {
        font-size: 1.1rem;
    }
}

@media (min-width: 1000px) and (orientation: landscape) {
    .container {
        max-width: 960px;
    }

    #result-box {
        display: grid;
        grid-template-columns: 1fr auto 1fr;
        gap: 25px;
        align-items: center;
    }

    .arrow-container {
        flex-direction: column;
        gap: 6px;
        margin: 0;
        padding: 8px 12px 10px;
        border-radius: 24px;
    }

    .direction-label {
        font-size: 0.9rem;
    }

    .arrow {
        transform: none;
    }

    .arrow svg {
        transform: none;
    }

    .arrow.reverse {
        transform: rotate(180deg);
    }
}

#browser-notice {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background-color: rgba(0, 0, 0, 0.8);
    color: white;
    text-align: center;
    padding: 15px;
    font-size: 1rem;
    font-weight: 500;
    z-index: 100;
    transform: translateY(100%);
    transition: transform 0.5s ease-in-out;
}

#browser-notice.visible {
    transform: translateY(0);
}

#browser-notice.hidden {
    display: none;
}

.donation {
    margin-top: 40px;
    padding-top: 30px;
    border-top: 1px dashed #ddd;
    text-align: center;
}

.donation-guide {
    color: #555;
    font-size: 0.9rem;
    line-height: 1.6;
    margin-bottom: 25px;
}

.donation-method {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

.qr-code {
    width: 160px;
    height: 160px;
    border-radius: 12px;
    border: 1px solid #eee;
}

.donation-title-pc {
    font-size: 1.1rem;
    color: #333;
}

.donation-guide-pc {
    font-size: 0.9rem;
    color: #777;
}

.kakaopay-button {
    display: none;
}

/* 모바일 화면에서는 QR과 PC용 텍스트를 숨기고, 카카오페이 버튼을 카드로 디자인 */
@media (max-width: 768px) {

    .qr-code,
    .donation-title-pc,
    .donation-guide-pc {
        display: none;
    }

    .kakaopay-button {
        display: flex;
        width: 100%;
        background: #FFDE00;
        border-radius: 12px;
        padding: 15px 20px;
        align-items: center;
        text-decoration: none;
        color: #3C1E1E;
        box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
        transition: all 0.2s ease-in-out;
    }

    .kakaopay-button:hover {
        transform: translateY(-2px);
        box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
    }

    .kakaopay-logo {
        width: 40px;
        height: 40px;
        background-color: white;
        border-radius: 50%;
        display: flex;
        align-items: center;
        justify-content: center;
        margin-right: 15px;
    }

    .kakaopay-logo svg {
        width: 24px;
        height: 24px;
    }

    .kakaopay-text {
        text-align: left;
        flex-grow: 1;
    }

    .kakaopay-text strong {
        font-size: 1.1rem;
        font-weight: bold;
    }

    .kakaopay-text span {
        font-size: 0.9rem;
        color: rgba(60, 30, 30, 0.7);
    }

    .kakaopay-arrow {
        font-size: 1.5rem;
        font-weight: bold;
        color: rgba(60, 30, 30, 0.5);
    }
}

/* 데스크탑 화면에서는 카카오페이 버튼을 숨김 */
@media (min-width: 769px) {
    .kakaopay-button {
        display: none;
    }
}