/* W2 검색엔진 - 옛날 컴퓨터 창 안의 검색 사이트 */
* { box-sizing: border-box; }
body {
    margin: 0;
    min-height: 100vh;
    background: #0d1220;
    background-image: radial-gradient(circle at 50% 30%, #1b2440 0%, #0d1220 70%);
    font-family: -apple-system, 'Apple SD Gothic Neo', 'Malgun Gothic', sans-serif;
    color: #222;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}
.hidden { display: none !important; }
button { font-family: inherit; cursor: pointer; }

#window {
    width: 100%;
    max-width: 820px;
    height: min(640px, calc(100vh - 32px));
    background: #f2f2ee;
    border: 2px solid #9aa0aa;
    border-radius: 6px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.5);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
#titlebar {
    background: linear-gradient(#3b5998, #2c4479);
    color: #fff;
    font-size: 14px;
    padding: 6px 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.tb-btns { display: flex; gap: 6px; }
.tb-btns button, .tb-btns a {
    background: #dcdcd6; border: 1px solid #777; border-radius: 3px;
    width: 26px; height: 22px; font-size: 12px; line-height: 20px; text-align: center;
    color: #222; text-decoration: none; padding: 0;
}

#page { flex: 1; overflow-y: auto; padding: 20px; }
#status {
    background: #dcdcd6; border-top: 1px solid #aaa;
    font-size: 12px; padding: 4px 10px; color: #444;
}

/* 처음 화면 */
#home { text-align: center; padding-top: 70px; transition: padding 0.3s; }
body.searched #home { padding-top: 0; text-align: left; display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.logo {
    font-size: 96px; font-weight: 900; letter-spacing: -4px; line-height: 1;
    cursor: pointer; user-select: none; display: inline-block;
}
.logo .w { color: #3b5998; }
.logo .two { color: #e8a33a; }
body.searched .logo { font-size: 40px; letter-spacing: -2px; }
.sub { color: #666; margin: 6px 0 22px; }
body.searched .sub, body.searched .maker { display: none; }

#search-form { display: flex; gap: 8px; justify-content: center; max-width: 520px; margin: 0 auto; flex: 1; }
body.searched #search-form { margin: 0; }
#q {
    flex: 1; min-width: 0;
    font-size: 18px; padding: 10px 14px;
    border: 2px solid #9aa0aa; border-radius: 4px; background: #fff;
}
#q:focus { outline: none; border-color: #3b5998; }
#search-form button {
    font-size: 16px; padding: 0 16px;
    background: #e9e9e3; border: 2px solid #9aa0aa; border-radius: 4px;
}
#search-form button:active { background: #d4d4cc; }
.maker { margin-top: 60px; color: #999; font-size: 13px; }

/* 검색 결과 */
#results { margin-top: 18px; }
.r-head { color: #666; font-size: 13px; border-bottom: 1px solid #ccc; padding-bottom: 6px; margin-bottom: 12px; }
.loading { color: #666; }
.dots::after { content: ''; animation: dots 1s steps(4) infinite; }
@keyframes dots { 0% { content: ''; } 25% { content: '.'; } 50% { content: '..'; } 75% { content: '...'; } }
.nothing { color: #777; padding: 20px 0; }
.result { margin-bottom: 20px; }
.r-name { color: #3b5998; font-size: 18px; font-weight: bold; }
.result.done .r-name { color: #5a3b98; }
.r-game { color: #2e7d32; font-size: 13px; margin: 2px 0; }
.r-snip { color: #444; font-family: Menlo, Consolas, monospace; font-size: 14px; word-break: break-all; }
.result button {
    margin-top: 6px; font-size: 13px; padding: 5px 12px;
    background: #fff4dc; border: 1px solid #e8a33a; border-radius: 3px;
}
.result.done button { background: #eef1f8; border-color: #3b5998; }

/* 파일 창 */
.overlay {
    position: fixed; inset: 0; background: rgba(0,0,0,0.55);
    display: flex; align-items: center; justify-content: center; padding: 16px;
}
.vbox {
    width: 100%; max-width: 760px; max-height: calc(100vh - 32px);
    background: #10140f; border: 2px solid #9aa0aa; border-radius: 6px;
    display: flex; flex-direction: column; overflow: hidden;
}
.vbar {
    background: linear-gradient(#3b5998, #2c4479); color: #fff; font-size: 14px;
    padding: 6px 10px; display: flex; justify-content: space-between; align-items: center;
}
.vbar button { background: #dcdcd6; border: 1px solid #777; border-radius: 3px; width: 26px; height: 22px; font-size: 12px; padding: 0; }
.vmeta { color: #7fbf7f; font-size: 12px; padding: 8px 14px 0; }
#v-text {
    margin: 0; padding: 12px 14px 16px; overflow-y: auto;
    color: #b8f5b8; font-family: Menlo, Consolas, monospace; font-size: 15px; line-height: 1.6;
    white-space: pre-wrap; word-break: break-all; min-height: 160px;
}
#v-text .dead { color: #c0504d; }
#v-progress { position: relative; height: 26px; margin: 0 14px 14px; border: 1px solid #4a6a4a; background: #0a0d0a; }
#v-fill { height: 100%; width: 0; background: #2e7d32; }
#v-pct { position: absolute; inset: 0; text-align: center; line-height: 24px; color: #fff; font-size: 13px; }

#s-list { padding: 10px; overflow-y: auto; }
.s-item {
    display: block; width: 100%; text-align: left; margin-bottom: 6px;
    background: #1a2119; color: #b8f5b8; border: 1px solid #3a5a3a; border-radius: 3px;
    padding: 8px 10px; font-size: 14px;
}
.s-item span { display: block; color: #7fbf7f; font-size: 12px; }

/* 휴대폰 */
@media (max-width: 560px) {
    #home { padding-top: 40px; }
    .logo { font-size: 72px; }
    #page { padding: 14px; }
    #search-form button { padding: 0 10px; font-size: 14px; }
}

/* 왼쪽 종류 버튼 5개 */
#body { flex: 1; display: flex; min-height: 0; }
#cats {
    width: 136px; flex-shrink: 0;
    background: #e6e6e0; border-right: 1px solid #b8b8b0;
    padding: 12px 8px; display: flex; flex-direction: column; gap: 6px;
}
.cat {
    display: flex; align-items: center; gap: 6px;
    background: #f7f7f3; border: 1px solid #b0b0a8; border-radius: 4px;
    padding: 8px 8px; font-size: 14px; text-align: left; color: #222; white-space: nowrap;
}
.cat:hover { background: #fff; border-color: #3b5998; }
.cat .cn { flex: 1; }
.cat .cc { font-size: 12px; color: #fff; background: #8a90a0; border-radius: 9px; padding: 1px 7px; }
.cat.imp { border-color: #e8a33a; }
.cat.imp .cc { background: #e8a33a; }

@media (max-width: 560px) {
    #body { flex-direction: column; }
    #cats { width: auto; flex-direction: row; flex-wrap: wrap; border-right: none; border-bottom: 1px solid #b8b8b0; padding: 8px; }
    .cat { flex-shrink: 0; padding: 6px 8px; font-size: 13px; }
}

#v-media { padding: 10px 14px 0; text-align: center; }
#v-media:empty { display: none; }
#v-media img, #v-media video { max-width: 100%; max-height: 50vh; border: 1px solid #3a5a3a; }

#v-link {
    margin: 0 14px 14px; padding: 9px; font-size: 15px;
    background: #1f3a5f; color: #cfe3ff; border: 1px solid #5a8acb; border-radius: 4px;
}
#v-link:hover { background: #2a4d7d; }
#v-media:not(:empty) + #v-text { min-height: 0; }
#v-pages { display: flex; align-items: center; justify-content: center; gap: 14px; padding: 8px 0 0; color: #b8f5b8; font-size: 14px; }
#v-pages button { background: #1a2119; color: #b8f5b8; border: 1px solid #3a5a3a; border-radius: 4px; width: 44px; height: 32px; font-size: 14px; }
#v-pages button:disabled { opacity: 0.3; cursor: default; }
#v-media img { height: auto; object-fit: contain; }
#v-media video { width: 100%; height: auto; background: #000; }

/* 미니게임: 틀린 그림 찾기 */
.odd-game { color: #b8f5b8; padding: 4px 0 8px; user-select: none; }
.odd-top { display: flex; justify-content: space-between; font-size: 14px; margin-bottom: 4px; }
.odd-name { font-size: 13px; color: #7fbf7f; min-height: 18px; margin-bottom: 8px; }
.odd-cards { display: flex; gap: 10px; justify-content: center; min-height: 150px; align-items: center; }
.odd-card { flex: 1; max-width: 180px; aspect-ratio: 1; background: #e8ece6; border: 3px solid #3a5a3a; border-radius: 8px; padding: 8px; display: flex; align-items: center; justify-content: center; overflow: hidden; }
button.odd-card:hover { border-color: #b8f5b8; }
.odd-card img { width: 100%; height: 100%; object-fit: contain; border: none !important; max-height: none !important; }
.odd-card.right { border-color: #4cd964; box-shadow: 0 0 0 3px #4cd964; }
.odd-card.wrong { border-color: #ff5c5c; animation: odd-shake 0.35s; }
@keyframes odd-shake { 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }
.odd-msg { text-align: center; margin-top: 10px; font-size: 15px; min-height: 22px; }
.odd-end { text-align: center; font-size: 16px; line-height: 1.8; padding: 20px 0; }
.odd-end b { font-size: 22px; color: #fff; }
.odd-again { background: #1f3a5f; color: #cfe3ff; border: 1px solid #5a8acb; border-radius: 4px; padding: 8px 18px; font-size: 15px; }

/* 파일을 불러오는 코드명 */
.code-tag { display: inline-block; margin-left: 8px; padding: 0 6px; border-radius: 3px; font-family: Menlo, Consolas, monospace, "Apple Color Emoji", "Segoe UI Emoji"; font-size: 12px; background: rgba(232,163,58,0.18); color: #e8a33a; }
.s-item span.code-tag { display: inline-block; margin-left: 6px; }

/* 사운드 파일: 그림 없이 동영상처럼 재생 */
.sound-box { display: inline-flex; flex-direction: column; width: 100%; max-width: 640px; }
.sound-box canvas { width: 100%; height: auto; border: 1px solid #3a5a3a; display: block; }
.sound-box audio { width: 100%; margin-top: 4px; }

/* 글 밑에 그림·영상이 나오는 파일 (mediaBelow) */
.vbox.media-below #v-text { order: 1; min-height: 0; flex-shrink: 0; }
.vbox.media-below #v-progress { order: 2; }
.vbox.media-below #v-media { order: 3; padding-bottom: 10px; }
.vbox.media-below #v-pages { order: 4; }
.vbox.media-below #v-link { order: 5; }
.vbox.media-below { overflow-y: auto; }

/* 스티커 모으기: 비어 있는 당근이 모은 만큼 왼쪽부터 채워진다 */
.sticker-box { display: inline-flex; flex-direction: column; align-items: center; gap: 8px; padding: 6px 0; }
.sb-pic { position: relative; width: min(360px, 70vw); aspect-ratio: 382 / 200; }
.sb-pic img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; border: none !important; max-height: none !important; }
.sb-empty { filter: brightness(0) invert(1); opacity: 0.12; }
.sb-count { color: #b8f5b8; font-family: Menlo, Consolas, monospace; font-size: 26px; font-weight: bold; letter-spacing: 2px; }

/* 해금 버튼 */
#v-unlock {
    margin: 0 14px 14px; padding: 10px; font-size: 16px; font-weight: bold;
    background: #5a3b98; color: #fff; border: 1px solid #b89af0; border-radius: 4px;
}
#v-unlock.locked { background: #2a2a30; color: #888; border-color: #555; cursor: not-allowed; }
#v-unlock.shake { animation: odd-shake 0.35s; }
.vbox.media-below #v-unlock { order: 6; }

/* 설명 밑에 나타나는 스티커 (누르면 줍는다) */
#v-sticker { padding: 0 14px 12px; }
.vbox.media-below #v-sticker { order: 1; }
.sticker { background: none; border: none; padding: 0; transform: rotate(-8deg); filter: drop-shadow(0 3px 4px rgba(0,0,0,0.5)); transition: transform 0.15s; }
.sticker:hover { transform: rotate(-2deg) scale(1.08); }
.sticker.got { animation: sticker-got 0.7s ease-in forwards; }
@keyframes sticker-got { 30% { transform: rotate(0) scale(1.25); } 100% { transform: rotate(20deg) scale(0); opacity: 0; } }
/* 스티커가 있으면 설명 바로 밑에 붙게 */
#v-text:has(+ #v-sticker:not(.hidden)) { min-height: 0; padding-bottom: 6px; }

/* 그림을 글 옆에 두는 파일 (mediaSide) */
.vbox.media-side { display: grid; grid-template-columns: 1fr auto; grid-template-areas: "bar bar" "meta meta" "text media" "sticker media" "prog prog"; grid-template-rows: auto auto auto 1fr auto; }
.vbox.media-side .vbar { grid-area: bar; }
.vbox.media-side .vmeta { grid-area: meta; }
.vbox.media-side #v-text { grid-area: text; min-height: 0; }
.vbox.media-side #v-sticker { grid-area: sticker; }
.vbox.media-side #v-media { grid-area: media; padding: 12px 24px 12px 0; display: flex; align-items: center; }
.vbox.media-side #v-progress { grid-area: prog; }
.vbox.media-side #v-text:has(+ #v-sticker:not(.hidden)) { padding-bottom: 6px; }

/* 춤추는 당근 */
.dance-carrot { width: 120px; height: 200px; display: flex; align-items: flex-end; justify-content: center; }
.dance-carrot img { width: 84px; height: 160px; border: none !important; max-height: none !important; transform-origin: 50% 90%; animation: carrot-dance 0.8s ease-in-out infinite; }
@keyframes carrot-dance {
    0%   { transform: translateY(0) rotate(-14deg); }
    25%  { transform: translateY(-18px) rotate(0deg) scaleY(1.05); }
    50%  { transform: translateY(0) rotate(14deg); }
    75%  { transform: translateY(-18px) rotate(0deg) scaleY(1.05); }
    100% { transform: translateY(0) rotate(-14deg); }
}

/* 즐겨찾기 */
.cat.fav .cc { background: #e8b800; }
.s-row { display: flex; gap: 6px; margin-bottom: 6px; }
.s-row .s-item { margin-bottom: 0; flex: 1; min-width: 0; }
.s-star { flex-shrink: 0; width: 44px; background: #1a2119; color: #7f8f7f; border: 1px solid #3a5a3a; border-radius: 3px; font-size: 22px; line-height: 1; padding: 0; }
.s-star:hover { border-color: #ffd23f; }
.s-star.on { color: #ffd23f; border-color: #ffd23f; background: #2a2a12; }

/* 상점 (힌트 파일) */
.shop { display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 4px 0 10px; width: 100%; }
.shop-npc { display: flex; align-items: center; gap: 14px; }
#v-media .shop-npc img { height: 130px; width: auto; flex: none; max-width: none; border: none !important; }
.shop-say { position: relative; background: #fff; color: #222; border: 2px solid #333; border-radius: 12px; padding: 10px 14px; font-size: 16px; max-width: 300px; text-align: left; }
.shop-say::before { content: ''; position: absolute; left: -10px; top: 50%; margin-top: -8px; border: 8px solid transparent; border-right: 10px solid #333; border-left: 0; }
.shop-info { display: flex; gap: 14px; flex-wrap: wrap; justify-content: center; font-size: 15px; color: #cfe8cf; }
.shop-coins { color: #ffd34d; font-weight: bold; }
.shop-items { display: grid; grid-template-columns: repeat(3, minmax(0, 190px)); gap: 10px; width: 100%; justify-content: center; }
.shop-item { background: #1d2a1d; border: 2px solid #3a5a3a; border-radius: 8px; padding: 8px; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.shop-item.special { border-color: #8a2be2; background: #241a33; }
.si-name { font-weight: bold; color: #e8f5e8; font-size: 15px; }
.si-lock { width: 100%; aspect-ratio: 640 / 440; display: flex; align-items: center; justify-content: center; background: #0e150e; border-radius: 4px; font: bold 36px Menlo, monospace; color: #3a5a3a; }
.si-buy { width: 100%; padding: 6px 4px; background: #ffd34d; border: none; border-radius: 4px; font-weight: bold; font-size: 14px; color: #3a2a00; }
.si-buy:hover { background: #ffe27f; }
.si-pic { padding: 0; border: none; background: none; width: 100%; }
#v-media .si-pic img { width: 100%; height: auto; display: block; border-radius: 4px; max-height: none !important; }
.hint-zoom { position: fixed; inset: 0; z-index: 100; background: rgba(0,0,0,.8); display: flex; align-items: center; justify-content: center; padding: 16px; cursor: zoom-out; }
.hint-zoom img { max-width: 100%; max-height: 100%; border-radius: 6px; }
@media (max-width: 560px) {
    .shop-items { grid-template-columns: minmax(0, 260px); }
    #v-media .shop-npc img { height: 100px; }
}

/* 마트 (공짜 배추·사과·당근, 당근은 스티커) */
.mi-pic { width: 100%; height: 110px; display: flex; align-items: center; justify-content: center; background: #0e150e; border-radius: 4px; }
#v-media .mi-pic img { height: 90px; width: auto; max-height: none; border: none; }
.mi-pic .sticker svg { width: 90px; height: 90px; }
/* 진열대에 있을 땐 그냥 당근처럼 보이게 (스티커 효과 없이) */
.mi-pic .sticker.fake { pointer-events: none; transform: none; filter: none; }
.mi-note { font-size: 13px; color: #ffd34d; padding: 6px 0; }
