* {
    box-sizing: border-box;
}

/* 커스텀 폰트 정의 */
@font-face {
    font-family: 'BookkGothic';
    src: url('./BookkGothic_Bold.ttf') format('truetype');
    font-weight: bold;
    font-style: normal;
}

@font-face {
    font-family: 'BookkMyungjo';
    src: url('./BookkMyungjo_Bold.ttf') format('truetype');
    font-weight: bold;
    font-style: normal;
}

@font-face {
    font-family: 'Regulator Nova';
    src: url('./fonnts.com-Regulator_Nova_Heavy.otf') format('opentype');
    font-weight: 900;
    font-style: normal;
}

body {
    font-family: 'BookkGothic', 'Noto Sans KR', sans-serif;
    margin: 0;
    padding: 0;
    overflow: hidden;
}

/* 폰트 설정 */
.font-nanum {
    font-family: 'BookkGothic', serif;
    font-weight: bold;
}

.font-hahmlet {
    font-family: 'BookkMyungjo', serif;
}

.font-nanum-extrabold {
    font-family: 'BookkGothic', serif;
}

.font-pretendard {
    font-family: 'BookkGothic', sans-serif;
}

/* 종이 질감 */
.paper-texture {
    background-image: 
        url("data:image/svg+xml,%3Csvg width='100' height='100' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)' opacity='0.05'/%3E%3C/svg%3E");
    background-repeat: repeat;
}

.book-texture {
    background-image: 
        url("data:image/svg+xml,%3Csvg width='100' height='100' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='paper'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.04' numOctaves='5'/%3E%3CfeColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.02 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23paper)' opacity='0.3'/%3E%3C/svg%3E");
    background-repeat: repeat;
}

.envelope-shadow {
    box-shadow: 0px -1px 8px 0px rgba(0, 0, 0, 0.25);
}

.page-shadow {
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.book-cover-shadow {
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.4);
}

.fade-in {
    animation: fadeIn 0.5s ease-in;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.slide-in {
    animation: slideIn 0.6s ease-out;
}

@keyframes slideIn {
    from { transform: translateX(-100px); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

/* 카드 슬라이드 업 애니메이션 */
.card-slide-up {
    animation: slideUp 1s ease-out forwards;
}

@keyframes slideUp {
    from { 
        transform: translateY(100px);
        opacity: 0;
    }
    to { 
        transform: translateY(0);
        opacity: 1;
    }
}

/* Glassmorphism 효과 */
.glassmorphism {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    pointer-events: none; /* 클릭 이벤트 통과 */
}

/* A4 비율 */
.a4-ratio {
    aspect-ratio: 210 / 297;
}

/* 종이 같은 그림자 */
.paper-like-shadow {
    box-shadow: 
        0 2px 4px rgba(0, 0, 0, 0.1),
        0 4px 8px rgba(0, 0, 0, 0.08),
        0 8px 16px rgba(0, 0, 0, 0.06),
        0 16px 32px rgba(0, 0, 0, 0.04);
}

/* 반응형 디자인 */
/* 피그마 기준: envelope_back width=804, height=500, envelope_front height=333 */
.envelope-wrapper {
    width: 100%;
    max-width: 820px;
    aspect-ratio: 820 / 865;
    position: relative;
    margin: 0 auto;
    margin-top: -200px;
}

.envelope-back-container {
    width: 100%;
    aspect-ratio: 820 / 516;
    position: relative;
    z-index: 10;
}

.envelope-front-container {
    width: 100%;
    aspect-ratio: 820 / 349;
    position: absolute;
    bottom: 0;
    left: 0;
    z-index: 30;
}

.envelope-back-container img,
.envelope-front-container img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

/* Tag 컴포넌트 스타일 */
/* 피그마: Tag width=326, height=496, x=557, y=414(초기), y=78(최종) */
.tag-container {
    position: absolute;
    width: calc(326 / 804 * 100%);
    aspect-ratio: 326 / 496;
    left: calc((557 - 318) / 804 * 100%);
    /* 초기 위치: envelope_back과 겹치는 상태 */
    /* 피그마: Tag y=414, envelope_back y=412.45 */
    /* envelope-wrapper 높이(865px) 기준으로 계산 */
    top: calc((414 - 412.45 + 450) / 865 * 100%);
    /* z-index: envelope-back(10) < tag(20) < envelope-front(30) */
    z-index: 20;
    animation: tagSlideUp 1.2s ease-out 0.5s forwards;
    pointer-events: none; /* 컨테이너는 클릭 이벤트 차단 */
}

.tag-container .tag-input-overlay {
    pointer-events: auto; /* input 영역만 클릭 가능 */
}

/* Tag 슬라이드 업 애니메이션 */
/* 초기: y=414+200, 최종: y=78 (피그마 기준) */
/* 거리를 줄여서 화면을 벗어나지 않도록 조정 */
@keyframes tagSlideUp {
    from {
        transform: translateY(0);
        opacity: 0.9;
    }
    to {
        /* 피그마 기준: 414에서 78로 이동 = 336px */
        /* 하지만 초기 위치가 +200이므로, 실제 이동 거리는 조정 필요 */
        /* 화면을 벗어나지 않도록 거리 제한 */
        transform: translateY(calc(-1 * 500 / 865 * 100%));
        opacity: 1;
    }
}

.tag-svg-background {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

/* Input 필드 위치: 피그마에서 "이름을 입력하세요" 텍스트 위치 */
/* SVG 내부 좌표 기준: text-container는 left-[44.16px] top-[224px] width-[240px] */
/* "For" 섹션은 justify-between으로 배치, "이름을 입력하세요"는 오른쪽 정렬 */
.tag-input-overlay {
    position: absolute;
    /* text-container 시작: 44.16px, 너비: 240px */
    /* "이름을 입력하세요"는 text-container 내부 오른쪽에 위치 */
    /* For 텍스트 너비: 18.156px, Input은 그 오른쪽부터 text-container 끝까지 */
    left: calc((44.16 + 18.156 + 16) / 326 * 100%); /* 44.16 + 18.156 + gap(16px) */
    top: calc((224 + 70 + 16) / 496 * 100%); /* title(70px) + gap(16px) 후 */
    width: calc((240 - 18.156 - 16) / 326 * 100%); /* text-container 너비 - For 너비 - gap */
    height: calc(21.378 / 496 * 100%); /* For 텍스트 높이와 동일 */
    z-index: 25; /* tag(20)보다 위, envelope-front(30)보다 아래 */
    pointer-events: auto;
}

.tag-input-overlay input {
    width: 100%;
    height: 100%;
    background: transparent;
    border: none;
    color: #ffffff;
    font-size: 1rem;
    text-align: right;
    font-family: 'BookkGothic', 'Noto Sans KR', sans-serif;
    letter-spacing: -0.2px;
    outline: none;
    padding: 0;
    pointer-events: auto;
    z-index: 25;
}

.tag-input-overlay input::placeholder {
    color: rgba(189, 255, 23, 0.2);
}

/* 시작하기 버튼 스타일 - 엽서 하단 배치 */
.start-button {
    position: fixed;
    left: 50%;
    transform: translateX(-50%);
    bottom: 8%;
    font-family: 'Hahmlet', serif;
    font-weight: 400;
    font-size: 20px;
    color: #ffffff;
    text-align: center;
    letter-spacing: -0.64px;
    /* text-shadow 깜빡임 애니메이션 (5초 주기) */
    animation: textGlow 5s ease-in-out infinite;
    cursor: pointer;
    /* 기본값: 숨김 (JavaScript에서 인라인 스타일로 제어) */
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease-in-out, visibility 0.3s ease-in-out;
    white-space: nowrap;
    z-index: 10000;
    visibility: hidden;
    background: transparent;
    border: none;
    padding: 0;
    margin: 0;
}

.start-button.visible {
    opacity: 1 !important;
    visibility: visible !important;
    pointer-events: auto !important;
}

/* text-shadow 깜빡임 애니메이션 (5초 주기) */
@keyframes textGlow {
    0% {
        text-shadow: 0px 0px 12px #ffffff;
    }
    50% {
        text-shadow: 0px 0px 0px transparent;
    }
    100% {
        text-shadow: 0px 0px 12px #ffffff;
    }
}

/* 디버깅 스타일 제거됨 - 정상 작동 확인 */

.start-button:hover.visible {
    opacity: 0.8;
}

@media (max-width: 1024px) {
    #game .pages-container {
        flex-direction: column;
        gap: 2rem;
    }
}

/* 스크롤바 스타일링 */
.story-output::-webkit-scrollbar {
    width: 6px;
}

.story-output::-webkit-scrollbar-track {
    background: transparent;
}

.story-output::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.2);
}

/* Game Page 스타일 (피그마 기준) */
.game-page-container {
    position: relative;
    width: 100%;
    height: 100%;
}

/* Output 영역 (스토리 출력) - 피그마: top 40px, 520x634, padding 12px */
.game-story-output {
    position: absolute;
    left: 40px;
    top: 40px;
    width: 520px;
    height: 634px;
    padding: 12px;
    box-sizing: border-box;
    font-family: 'BookkMyungjo', serif;
    font-weight: bold;
    font-size: 16px;
    line-height: 1.5;
    color: #0f100f;
    letter-spacing: -0.24px;
    word-wrap: break-word;
    word-break: keep-all;
    overflow-wrap: break-word;
    overflow-y: auto;
}

/* Text Field 영역 (유저 입력) - 피그마: top 681px, 520x132, padding 0 12 12 100 */
.game-action-input-container {
    position: absolute;
    left: 40px;
    top: 681px;
    width: 520px;
    height: 132px;
    padding: 0 12px 12px 40px;
    box-sizing: border-box;
    display: flex;
    align-items: flex-start;
}

.game-action-input {
    font-family: 'BookkGothic', 'Noto Sans KR', sans-serif;
    font-weight: 400;
    font-size: 16px;
    line-height: 1.5;
    color: #6b1a1a;
    letter-spacing: -0.24px;
    background: transparent;
    border: none;
    outline: none;
    padding: 0;
    margin: 0;
    width: 100%;
    height: 100%;
}

.game-action-input::placeholder {
    color: rgba(107, 26, 26, 0.5);
}

/* 네비게이션 화살표 - 피그마 위치 */
.game-nav-arrow-left {
    left: 180px;
    top: 50%;
    transform: translateY(-50%);
    width: 28px;
    height: 28px;
}

.game-nav-arrow-right {
    right: 180px;
    top: 50%;
    transform: translateY(-50%);
    width: 28px;
    height: 28px;
}

.game-go-home-button {
    right: 100px;
    bottom: 100px;
    width: 72px;
    height: 72px;
    padding: 15px 23px;
    border-radius: 36px;
    animation: rotateButton 8s linear infinite;
}

@keyframes rotateButton {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

.game-go-home-button:hover {
    animation-play-state: paused;
}

.game-go-home-button-text {
    font-weight: 400;
    letter-spacing: -0.24px;
    white-space: nowrap;
}

/* 유저 액션 텍스트 스타일 (하단 Text Field 영역) - 피그마: 빨간색 */
.user-action-text {
    font-family: 'BookkGothic', 'Noto Sans KR', sans-serif;
    font-weight: 400;
    font-size: 16px;
    color: #6b1a1a;
    letter-spacing: -0.24px;
    line-height: 1.5;
    margin: 0;
    padding: 0;
    width: 100%;
}

/* Result Page 스타일 */
.result-page-container {
    width: 100%;
    height: 100vh;
    /* max-width 제거하여 전체 화면 배경색 적용 */
    /* max-width: 1440px; */
    /* margin: 0 auto; */
    overflow: hidden; /* 스크롤 방지 */
}

.result-book-cover {
    left: calc(50% - 270px);
    top: 80px;
    width: 540px;
    height: 860px;
    position: absolute;
}

/* 제목 스타일 (피그마 기준) */
.result-title-container {
    width: auto;
    white-space: nowrap;
}

.result-title-h2 {
    font-family: 'Regulator Nova', sans-serif;
    font-weight: 900;
    font-size: 40px;
    letter-spacing: -0.6px;
    line-height: 1;
    margin: 0;
    padding: 0;
}

.result-title-h1 {
    font-family: 'Regulator Nova', sans-serif;
    font-weight: 900;
    font-size: 96px;
    letter-spacing: -1.44px;
    line-height: 0.8;
    margin: 0;
    padding: 0;
    white-space: pre;
}

/* 정렬 아이콘 컨테이너 */
.result-alignment-icon {
    width: 300px !important;
    height: 200px !important;
}

.result-image-container {
    height: 200px !important;
    margin: 0 auto;
    position: relative;
}

.result-image-container img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    mix-blend-mode: multiply;
    image-rendering: auto;
}

/* 설명 텍스트 (SVG 아래) */
.result-description-container {
    width: 440px;
    top: 520px;
    max-height: 200px;
    overflow-y: auto;
}

.result-description {
    font-family: 'BookkGothic', 'Noto Sans KR', sans-serif;
    font-weight: 400;
    font-size: 13px;
    line-height: 1.8;
    letter-spacing: -0.2px;
    margin: 0;
    padding: 0 10px;
}

.result-description p {
    margin: 0;
    padding: 0;
}

/* QR코드 스타일 */
.result-qr-frame {
    position: absolute;
    left: 50%;
    bottom: 25px;
    transform: translateX(-50%);
    display: flex;
    justify-content: center;
}

.result-qr {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.result-qr-image {
    width: 60px !important;
    height: 60px !important;
    max-width: 60px !important;
    max-height: 60px !important;
    display: block;
    background: white;
    padding: 4px;
    border-radius: 4px;
    object-fit: contain;
}

.result-qr-text {
    font-family: 'BookkGothic', 'Noto Sans KR', sans-serif;
    font-size: 12px;
    line-height: 1.4;
    color: #bdff17;
    text-align: center;
    margin: 0;
    padding: 0;
}

/* 처음으로 버튼 (피그마 기준) */
.result-go-home-container {
    left: calc(50% - 540px);
    top: 0.46px;
    width: 1080px;
    height: 80px;
    display: flex;
    align-items: center;
}

.result-go-home-button {
    font-family: 'Galmuri11', monospace;
    font-weight: 400;
    font-size: 16px;
    letter-spacing: -0.24px;
    line-height: 1.4;
    color: #000;
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 0;
    margin: 0;
}

.result-go-home-button:hover {
    text-decoration: underline;
}

/* 페이지 프레임 전환 애니메이션 */
@keyframes frameSlideOutLeft {
    from {
        transform: translateX(0);
    }
    to {
        transform: translateX(-200%);
    }
}

@keyframes frameSlideInFromTop {
    from {
        transform: translateY(-150%);
    }
    to {
        transform: translateY(0);
    }
}

/* 게임 프레임 래퍼 */
.game-frame-wrapper {
    position: relative;
    width: 600px;
    height: 860px;
}

/* 개별 페이지 프레임 */
.game-page-frame {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    will-change: transform;
}

.game-page-frame.slide-out {
    animation: frameSlideOutLeft 0.8s ease-in-out forwards;
    z-index: 1;
}

.game-page-frame.slide-in {
    animation: frameSlideInFromTop 0.8s ease-in-out forwards;
    z-index: 2;
}

/* 새 페이지 프레임 초기 상태 */
.game-page-frame.new-frame {
    transform: translateY(-150%);
    z-index: 2;
}

/* storyOutput에 상대 위치 설정 */
.story-output {
    position: relative;
}

/* ============================================
   방명록 스타일
   ============================================ */

.guestbook-container {
    position: absolute;
    right: 40px;
    top: 80px;
    width: 300px;
    max-height: calc(100vh - 160px);
    background: #ffffff;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    z-index: 100;
}

.guestbook-header {
    padding: 16px 20px;
    background: #0f100f;
    color: white;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: background 0.2s;
}

.guestbook-header:hover {
    background: #1a1b1a;
}

.guestbook-title {
    font-family: 'BookkGothic', 'Noto Sans KR', sans-serif;
    font-size: 14px;
    font-weight: bold;
    margin: 0;
    letter-spacing: 0.5px;
}

.guestbook-toggle {
    font-size: 10px;
    transition: transform 0.3s ease;
    opacity: 0.6;
}

.guestbook-toggle.expanded {
    transform: rotate(180deg);
}

/* 방명록 본문 (접기/펼치기) */
.guestbook-body {
    max-height: calc(100vh - 200px);
    overflow-y: auto;
    transition: max-height 0.4s ease, opacity 0.3s ease;
}

.guestbook-body.collapsed {
    max-height: 0;
    overflow: hidden;
    opacity: 0;
}

/* 부제목 컨테이너 */
.guestbook-subtitle-container {
    padding: 14px 20px;
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
    border-bottom: 1px solid #e2e8f0;
}

.guestbook-subtitle {
    font-family: 'BookkGothic', 'Noto Sans KR', sans-serif;
    font-size: 11px;
    line-height: 1.7;
    color: #64748b;
    margin: 0;
}

/* 방명록 폼 */
.guestbook-form {
    padding: 16px 20px;
    background: #ffffff;
    border-bottom: 1px solid #f1f5f9;
}

.guestbook-input-row {
    margin-bottom: 12px;
}

.guestbook-input-row:last-of-type {
    margin-bottom: 14px;
}

.guestbook-input {
    width: 100%;
    padding: 12px 14px;
    border: 1.5px solid #e2e8f0;
    border-radius: 10px;
    font-family: 'BookkGothic', 'Noto Sans KR', sans-serif;
    font-size: 13px;
    transition: all 0.2s ease;
    background: #fafbfc;
    box-sizing: border-box;
}

.guestbook-input:focus {
    outline: none;
    border-color: #0f100f;
    box-shadow: 0 0 0 3px rgba(15, 16, 15, 0.08);
    background: white;
}

.guestbook-input::placeholder {
    font-family: 'BookkGothic', 'Noto Sans KR', sans-serif;
    color: #94a3b8;
    font-size: 12px;
}

.guestbook-nickname-input {
    font-weight: 600;
}

.guestbook-email-input::placeholder {
    font-size: 10px;
}

.guestbook-message-input {
    resize: none;
    min-height: 70px;
}

.guestbook-submit-btn {
    width: 100%;
    padding: 12px 16px;
    background: #0f100f;
    border: none;
    border-radius: 10px;
    font-family: 'BookkGothic', 'Noto Sans KR', sans-serif;
    font-size: 13px;
    font-weight: bold;
    color: white;
    cursor: pointer;
    transition: all 0.2s ease;
}

.guestbook-submit-btn:hover {
    background: #2a2b2a;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(15, 16, 15, 0.2);
}

.guestbook-submit-btn:active {
    transform: translateY(0);
}

.guestbook-submit-btn:disabled {
    background: #e2e8f0;
    color: #94a3b8;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* 방명록 목록 */
.guestbook-list {
    flex: 1;
    overflow-y: auto;
    padding: 16px 20px;
    max-height: 350px;
    background: linear-gradient(180deg, #f8fafc 0%, #f1f5f9 100%);
}

.guestbook-loading,
.guestbook-empty {
    text-align: center;
    color: #94a3b8;
    font-family: 'BookkGothic', 'Noto Sans KR', sans-serif;
    font-size: 12px;
    padding: 32px 0;
}

/* 방명록 개별 항목 */
.guestbook-entry {
    background: white;
    border-radius: 12px;
    padding: 14px 16px;
    margin-bottom: 10px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
    border: 1px solid #f1f5f9;
    transition: all 0.2s ease;
}

.guestbook-entry:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
    border-color: #e2e8f0;
}

.guestbook-entry:last-child {
    margin-bottom: 0;
}

.guestbook-entry-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.guestbook-nickname {
    font-family: 'BookkGothic', 'Noto Sans KR', sans-serif;
    font-size: 13px;
    font-weight: bold;
    color: #0f100f;
}

.guestbook-alignment {
    font-family: 'BookkGothic', 'Noto Sans KR', sans-serif;
    font-size: 9px;
    font-weight: 600;
    color: #0f100f;
    background: #bdff17;
    padding: 3px 8px;
    border-radius: 12px;
}

.guestbook-message {
    font-family: 'BookkGothic', 'Noto Sans KR', sans-serif;
    font-size: 12px;
    color: #475569;
    line-height: 1.7;
    margin: 0 0 10px 0;
    word-break: keep-all;
}

.guestbook-date {
    font-family: 'BookkGothic', sans-serif;
    font-size: 10px;
    color: #94a3b8;
}

/* 스크롤바 스타일 */
.guestbook-list::-webkit-scrollbar {
    width: 5px;
}

.guestbook-list::-webkit-scrollbar-track {
    background: transparent;
}

.guestbook-list::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.12);
    border-radius: 4px;
}

.guestbook-list::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.2);
}

/* 반응형 - 작은 화면에서는 방명록을 하단에 배치 */
@media (max-width: 1200px) {
    .guestbook-container {
        right: 20px;
        width: 280px;
    }
}

@media (max-width: 900px) {
    .guestbook-container {
        position: fixed;
        right: auto;
        left: 50%;
        transform: translateX(-50%);
        top: auto;
        bottom: 20px;
        width: calc(100% - 40px);
        max-width: 500px;
        max-height: 50vh;
        z-index: 100;
    }
    
    .result-book-cover {
        transform: scale(0.8);
        transform-origin: top center;
    }
}

@media (max-width: 600px) {
    .guestbook-container {
        bottom: 10px;
        width: calc(100% - 20px);
        max-height: 45vh;
        border-radius: 8px;
    }
    
    .guestbook-header {
        padding: 14px;
    }
    
    .guestbook-title {
        font-size: 16px;
    }
    
    .guestbook-form {
        padding: 12px;
    }
    
    .guestbook-list {
        max-height: 200px;
    }
}


