* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: #0a2219; overflow: hidden; touch-action: manipulation; overscroll-behavior: none;
  -webkit-text-size-adjust: 100%; -webkit-touch-callout: none;
  font-family: -apple-system, "Apple SD Gothic Neo", "Malgun Gothic", sans-serif; user-select: none; -webkit-user-select: none; }
#wrap { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; }
#stage { position: absolute; left: 0; top: 0; width: 720px; height: 1280px; transform-origin: 0 0; overflow: hidden;
  background: #1d5a33 url(../assets/ui/bg_tile_background.png) repeat; background-size: 96px; }
#table { position: absolute; inset: 0;
  background: radial-gradient(ellipse at 50% 40%, rgba(255,255,255,.10), rgba(0,0,0,.35) 75%); }

/* 상단 바 · 정보 줄 (원작 세로 화면 구성) */
.hud, .info { position: absolute; left: 0; width: 720px; display: flex; align-items: center; gap: 10px; padding: 0 12px; color: #fff; z-index: 5; }
#topbar { top: 0; height: 58px; background: linear-gradient(#123a2a, #0c2a1e); border-bottom: 2px solid #08190f; }
.lv { position: relative; width: 52px; height: 52px; }
.lv img { width: 52px; height: 52px; }
.lv b { position: absolute; left: 0; right: 0; bottom: 6px; text-align: center; font-size: 20px; color: #fff; text-shadow: 0 2px 2px #000; }
.pill { background: #0008; border-radius: 16px; padding: 5px 16px; font-size: 20px; font-weight: 800; }
#menuBtn { margin-left: auto; border: 0; background: none; padding: 0; height: 48px; cursor: pointer; }
#menuBtn img { height: 48px; }
.info { height: 60px; padding: 0 10px; }
.info .tab { min-width: 220px; height: 56px; padding: 3px 14px; border-radius: 0 14px 14px 0; margin-left: -10px;
  background: linear-gradient(90deg, rgba(0,0,0,.55), rgba(0,0,0,.25)); display: flex; flex-direction: column; justify-content: center; }
.info .name { font-size: 20px; font-weight: 800; display: flex; align-items: center; gap: 6px; }
.info .money { font-size: 21px; color: #ffd84a; font-weight: 800; }
.info .icons { display: flex; gap: 2px; align-items: center; margin-left: auto; }
.info .icons img { height: 34px; }
.info .icons img.off { opacity: .35; }
.info .score { min-width: 120px; text-align: right; font-size: 24px; font-weight: 800; color: #ffef6a; text-shadow: 0 2px 3px #000; }
.info .score b { font-size: 42px; margin-right: 2px; }
.info.turn .tab { box-shadow: inset 0 0 0 3px #ffe44d, 0 0 18px rgba(255, 228, 77, .5); }
#info1 .icons { margin-left: 140px; }
.sun { font-style: normal; font-size: 16px; background: #d0261b; color: #fff; border: 2px solid #fff; border-radius: 4px; padding: 0 3px; line-height: 20px; }
.hidden { display: none !important; }

.eatbox { position: absolute; left: 6px; width: 708px; height: 96px; border-radius: 12px;
  background: rgba(0, 25, 12, .45); box-shadow: inset 0 0 0 2px rgba(255,255,255,.06); }
#groupLabels span { position: absolute; min-width: 22px; height: 22px; line-height: 20px; text-align: center; font-size: 15px; font-weight: 900;
  color: #222; background: #fff; border: 1px solid #555; border-radius: 4px; z-index: 600; pointer-events: none; }

/* 바닥 위 정보: 점당 · 배판 · 미션 */
#stake { position: absolute; left: 12px; font-size: 22px; font-weight: 800; color: #cfe9c8; background: rgba(0,0,0,.25);
  padding: 2px 12px; border-radius: 12px; z-index: 4; }
#bae { position: absolute; left: 12px; width: 140px; padding: 8px 4px; text-align: center; font-size: 30px; line-height: 1.05; font-weight: 900;
  color: #2a7d2a; background: rgba(140, 230, 140, .25); border: 3px solid rgba(160, 255, 160, .5); border-radius: 14px;
  -webkit-text-stroke: 1px #0b3d0b; z-index: 4; }
#missionBox { position: absolute; right: 12px; width: 220px; height: 104px; padding: 4px 8px; border-radius: 14px; z-index: 4;
  background: linear-gradient(#2e6b3b, #1d4f29); border: 3px solid #9fdc8c; box-shadow: 0 4px 10px #0007; }
#missionBox .mt { height: 26px; display: block; margin: 0 auto 2px; }
#missionBox .mcards { display: flex; gap: 4px; align-items: center; }
#missionBox .mc { position: relative; }
#missionBox .mc img { width: 44px; border-radius: 4px; display: block; }
#missionBox .mc .arw { position: absolute; width: 30px; left: 7px; top: 18px; }
#missionBox .mx { position: absolute; right: 6px; bottom: 6px; height: 46px; }
#missionBox .mres { position: absolute; left: 50%; top: 50%; width: 76px; transform: translate(-50%, -50%); }
#missionBox.done .mcards { opacity: .6; }

/* 손패 표시 아이콘 */
.card .mark { position: absolute; left: var(--mx, 50%); top: -36px; width: 84px; height: 84px; transform: translateX(-50%);
  background-size: contain; background-repeat: no-repeat; background-position: center; pointer-events: none; }

#deckCount { position: absolute; text-align: center; color: #fff; font-weight: 800;
  font-size: 18px; text-shadow: 0 2px 3px #000; z-index: 400; }

/* 카드 */
#cards { position: absolute; inset: 0; }
.card { position: absolute; left: 0; top: 0; width: 176px; height: 266px; transform-origin: 0 0;
  background-size: 100% 100%; border-radius: 14px; box-shadow: 0 6px 10px rgba(0,0,0,.45);
  transition: transform .32s cubic-bezier(.3,.8,.35,1), opacity .3s; will-change: transform; }
.card.instant { transition: none; }
.card.mine { cursor: pointer; }
.card.mine.match::after { content: ""; position: absolute; inset: -6px; border-radius: 18px; border: 7px solid #ffe44d;
  box-shadow: 0 0 22px #ffe44d; pointer-events: none; }
.card.mine.disabled { filter: brightness(.55); }
.card.pick::after { content: ""; position: absolute; inset: -8px; border-radius: 18px; border: 9px solid #4dfcff;
  box-shadow: 0 0 26px #4dfcff; animation: blink .6s infinite alternate; }
.card.hint::after { content: ""; position: absolute; inset: -6px; border-radius: 18px; border: 7px solid #fff6; }
.card.gone { opacity: 0; }
@keyframes blink { from { opacity: .45; } to { opacity: 1; } }

#fx { position: absolute; left: 0; top: 0; width: 720px; height: 1280px; pointer-events: none; z-index: 800; }

#banner { position: absolute; left: 0; right: 0; top: 470px; text-align: center; font-size: 76px; font-weight: 900; color: #fff;
  -webkit-text-stroke: 3px #7a1d00; text-shadow: 0 6px 0 #3a0e00, 0 0 30px #ff9b2b; z-index: 820; pointer-events: none;
  opacity: 0; transform: scale(.6); transition: opacity .2s, transform .25s cubic-bezier(.2,1.6,.4,1); }
#banner.show { opacity: 1; transform: scale(1); }
#toast { position: absolute; left: 50%; top: 720px; transform: translateX(-50%); background: #000c; color: #fff; padding: 10px 22px;
  border-radius: 24px; font-size: 22px; font-weight: 700; opacity: 0; transition: opacity .25s; z-index: 830; pointer-events: none; white-space: nowrap; }
#toast.show { opacity: 1; }

/* 팝업 */
#popup { position: absolute; inset: 0; background: rgba(0,0,0,.55); z-index: 900; display: flex; align-items: center; justify-content: center; }
#popup.hidden { display: none; }
.panel { width: 600px; background: linear-gradient(#fdf6e3, #efe1bf); border: 6px solid #7a3b12; border-radius: 26px; padding: 26px 30px;
  color: #3a1d08; text-align: center; box-shadow: 0 20px 50px #000a; }
.panel h2 { margin: 0 0 14px; font-size: 40px; color: #b5340f; }
.panel p { font-size: 24px; margin: 8px 0; }
.panel .cards { display: flex; gap: 12px; justify-content: center; margin: 16px 0; }
.panel .cards img { width: 110px; border-radius: 10px; box-shadow: 0 4px 8px #0006; cursor: pointer; }
.panel .btns { display: flex; gap: 18px; justify-content: center; margin-top: 18px; }
.btn { font: inherit; font-size: 30px; font-weight: 900; padding: 14px 34px; border-radius: 18px; border: 0; color: #fff; cursor: pointer;
  box-shadow: 0 6px 0 rgba(0,0,0,.3); }
.btn:active { transform: translateY(3px); box-shadow: 0 3px 0 rgba(0,0,0,.3); }
.btn.go { background: linear-gradient(#ff8a3d, #e2470e); font-size: 46px; padding: 18px 50px; }
.btn.stop { background: linear-gradient(#4aa3ff, #1660c9); font-size: 46px; padding: 18px 50px; }
.btn.green { background: linear-gradient(#5fd35f, #23912c); }
.btn.gray { background: linear-gradient(#999, #666); }
.result table { width: 100%; font-size: 23px; border-collapse: collapse; margin: 10px 0; }
.result td { padding: 5px 4px; border-bottom: 1px dashed #c9b083; }
.result td:last-child { text-align: right; font-weight: 800; }
.result .total { font-size: 34px; font-weight: 900; color: #b5340f; margin-top: 10px; }
.result .money { font-size: 30px; font-weight: 900; }
.result .money.plus { color: #1b7d1b; } .result .money.minus { color: #c0392b; }
.title-logo { width: 420px; margin: -10px auto 4px; display: block; }
.menu .row { display: flex; justify-content: space-between; align-items: center; font-size: 26px; margin: 14px 0; }
.small { font-size: 19px; color: #7a5a3a; }

/* 휴대폰 가로 화면 안내 */
#rotate { display: none; position: fixed; inset: 0; z-index: 9999; background: #0a2219; color: #fff; font-size: 22px; font-weight: 800;
  align-items: center; justify-content: center; }
@media (orientation: landscape) and (pointer: coarse) and (max-height: 540px) { #rotate { display: flex; } }
.legend { text-align: left; font-size: 20px; margin: 14px 0 4px; padding: 10px 12px; background: #0000000d; border-radius: 12px; }
.legend div { display: flex; align-items: center; gap: 10px; margin: 6px 0; }
.legend img { width: 36px; flex: none; }
.login input { display: block; width: 100%; font: inherit; font-size: 34px; padding: 12px 16px; margin: 10px 0; border-radius: 14px;
  border: 3px solid #c9a46a; background: #fffdf6; color: #3a1d08; text-align: center; }
.err { color: #c0392b; font-weight: 800; min-height: 1em; }
.login .names { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin: 8px 0; }
.login .chip, .panel .chip { font: inherit; font-size: 22px; padding: 6px 14px; border-radius: 16px; border: 2px solid #c9a46a; background: #fff6e0; color: #5a3410; }
#rankBtn { margin-left: auto; border: 0; color: #fff; cursor: pointer; font-family: inherit; }
#rankBtn + #menuBtn { margin-left: 8px; }
.ranking .rankwrap { max-height: 760px; overflow-y: auto; margin: 8px 0; }
.ranking table { width: 100%; border-collapse: collapse; font-size: 22px; }
.ranking td { padding: 8px 4px; border-bottom: 1px dashed #c9b083; text-align: left; }
.ranking td.rk { width: 50px; text-align: center; font-weight: 900; }
.ranking td.nm { font-weight: 800; }
.ranking td.mn { text-align: right; font-weight: 800; color: #b5340f; }
.ranking td.lvl, .ranking td.wl { text-align: right; font-size: 18px; color: #7a5a3a; white-space: nowrap; }
.ranking tr.me { background: #ffe9a8; }
.menu .who { display: flex; align-items: center; gap: 10px; font-weight: 800; }
#admin { position: absolute; inset: 0; background: rgba(0,0,0,.45); z-index: 950; display: flex; align-items: center; justify-content: center; }
.linkbtn { font: inherit; font-size: 22px; background: none; border: 0; color: #7a5a3a; text-decoration: underline; cursor: pointer; }
.adminp h2 { color: #3b4cc0; }
.sw-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 6px; border-bottom: 1px dashed #c9b083; text-align: left; cursor: pointer; }
.sw-row span { display: flex; flex-direction: column; font-size: 26px; }
.sw-row small { font-size: 18px; color: #7a5a3a; }
.sw-row input { display: none; }
.sw-row .sw { position: relative; flex: none; width: 96px; height: 52px; border-radius: 26px; background: #b9b2a3; transition: background .2s; }
.sw-row .sw::after { content: ""; position: absolute; left: 5px; top: 5px; width: 42px; height: 42px; border-radius: 50%; background: #fff;
  box-shadow: 0 2px 4px #0005; transition: transform .2s; }
.sw-row input:checked + .sw { background: #34c759; }
.sw-row input:checked + .sw::after { transform: translateX(44px); }
.adminp .edit { display: flex; align-items: center; gap: 10px; margin: 12px 0; font-size: 24px; font-weight: 800; }
.adminp .edit span { width: 96px; text-align: left; }
.adminp .edit input { flex: 1; min-width: 0; font: inherit; font-size: 28px; padding: 8px 12px; border-radius: 12px; border: 3px solid #c9a46a; background: #fffdf6; }
.adminp .edit .btn { font-size: 24px; padding: 10px 18px; }
#record { cursor: pointer; }

/* ── 인트로 (원작 타이틀 장면) ── */
#intro { position: absolute; inset: 0; z-index: 990; overflow: hidden; background: #140f2e; transition: opacity .45s; }
#intro.out { opacity: 0; pointer-events: none; }
#intro img { position: absolute; pointer-events: none; }
.i-sky { position: absolute; inset: 0; background: url(../assets/ui/back_ground.png) repeat; background-size: 425px;
  box-shadow: inset 0 -400px 300px -200px #0b0820; }
.i-tw { width: 70px; animation: twinkle 2.6s ease-in-out infinite; opacity: 0; }
@keyframes twinkle { 0%, 100% { opacity: 0; transform: scale(.5); } 50% { opacity: 1; transform: scale(1); } }
.i-moon { width: 64%; left: 18%; top: 6%; filter: drop-shadow(0 0 40px rgba(255, 250, 220, .55)); animation: moonglow 5s ease-in-out infinite; }
@keyframes moonglow { 50% { filter: drop-shadow(0 0 70px rgba(255, 250, 220, .8)); } }
.i-rock { width: 36%; bottom: 17%; }
.i-rock.l { left: -9%; }
.i-rock.r { right: -9%; transform: scaleX(-1); }
.i-hill { width: 136%; left: -18%; bottom: -3%; }
.i-plant.a { width: 14%; left: 16%; bottom: 21%; }
.i-plant.b { width: 15%; right: 15%; bottom: 20%; }
.i-flower { width: 9%; left: 66%; bottom: 17%; }
.i-char { bottom: 13%; }
.i-char.a { width: 13%; left: 28%; }
.i-char.b { width: 9%; left: 45%; bottom: 14.5%; }
.i-char.c { width: 10%; left: 57%; }
/* 매화 조각은 한쪽이 잘린 '가장자리용' 이미지 — 잘린 면이 화면 끝에 붙게 둔다 (필요하면 좌우 반전) */
.i-cherry.tl { width: 46%; left: -2%; top: 1%; }
.i-cherry.tr { width: 30%; right: 0; top: 0; transform: scaleX(-1); }
.i-cherry.bl { width: 19%; left: 0; bottom: 27%; }
.i-cherry.br { width: 28%; right: 0; bottom: 25%; transform: scaleX(-1); }
#intro .i-logo { position: absolute; left: 0; right: 0; top: 33%; text-align: center; }
#intro .i-logo img { position: static; display: block; margin: 0 auto; filter: drop-shadow(0 6px 10px #0009); }
#intro .i-logo .go { width: 66%; animation: logo-in .8s cubic-bezier(.2, 1.5, .4, 1) both; }
#intro .i-logo .mat { width: 50%; margin-top: -6px; animation: logo-in .8s .2s cubic-bezier(.2, 1.5, .4, 1) both; }
@keyframes logo-in { from { opacity: 0; transform: scale(.5); } }
.i-start { position: absolute; left: 20%; width: 60%; bottom: 7%; height: 112px; border: 0; border-radius: 56px; cursor: pointer;
  font: inherit; font-size: 48px; font-weight: 900; color: #fff; letter-spacing: 4px; -webkit-text-stroke: 1px #8a2a00;
  background: linear-gradient(#ffb347, #f06414); box-shadow: 0 8px 0 #a33a06, 0 0 30px rgba(255, 170, 60, .6); animation: pulse 1.6s ease-in-out infinite; }
.i-start:active { transform: translateY(4px); box-shadow: 0 4px 0 #a33a06; }
@keyframes pulse { 50% { box-shadow: 0 8px 0 #a33a06, 0 0 50px rgba(255, 190, 80, .95); } }
.i-note { position: absolute; left: 0; right: 0; bottom: 1.6%; margin: 0; text-align: center; font-size: 18px; color: #fff9; }

/* ── 로비: 이벤트·보석 ── */
.panel.lobby { width: 660px; padding: 20px 22px; }
.lobby-top { display: flex; justify-content: space-between; align-items: center; gap: 10px; font-size: 22px; margin-bottom: 12px; }
.lobby-top .wallet { display: flex; gap: 10px; }
.lobby-top .wallet span { background: #3a1d08; color: #ffd84a; font-weight: 900; padding: 6px 14px; border-radius: 16px; }
.lobby-top .wallet .gem { color: #9fe7ff; }
.tabs { display: flex; gap: 6px; margin-bottom: 10px; }
.tabs .tab { position: relative; flex: 1; font: inherit; font-size: 23px; font-weight: 800; padding: 12px 4px; border: 0; border-radius: 14px 14px 0 0;
  background: #d9c49b; color: #6b4a22; cursor: pointer; }
.tabs .tab.on { background: #7a3b12; color: #fff; }
.tabs .dot { position: absolute; top: -8px; right: 6px; min-width: 28px; height: 28px; line-height: 28px; border-radius: 14px; background: #e8332a;
  color: #fff; font-style: normal; font-size: 17px; }
.quests { text-align: left; }
.q { display: flex; align-items: center; gap: 12px; padding: 10px 6px; border-bottom: 1px dashed #c9b083; }
.q.done { opacity: .5; }
.q .qn { flex: 1; font-size: 22px; font-weight: 800; }
.q .qn small { font-size: 16px; color: #7a5a3a; font-weight: 700; }
.q .bar { height: 10px; background: #e5d5b3; border-radius: 5px; margin: 6px 0 2px; overflow: hidden; }
.q .bar i { display: block; height: 100%; background: linear-gradient(90deg, #4fc3f7, #1e88e5); }
.q .qr { font-size: 22px; font-weight: 900; color: #1565c0; white-space: nowrap; }
.q .qb { font-size: 22px; padding: 10px 18px; }
.q .qd { font-size: 20px; font-weight: 800; color: #2e7d32; padding: 0 14px; }
.btn:disabled { filter: grayscale(.6) brightness(.85); cursor: default; }
.shop .gemrate { font-size: 32px; margin: 18px 0 4px; }
.shop .btn { font-size: 24px; }
.vs { margin-top: 14px; font-size: 20px; color: #5a3410; }
.evnote { background: #e3f4ff; color: #0d5a8c; border-radius: 12px; padding: 8px; font-size: 20px !important; font-weight: 800; }
#popup.lobbybg { background: url(../assets/ui/moon_40p.png) no-repeat 50% 4% / 70% auto, url(../assets/ui/back_ground.png) repeat 0 0 / 425px; }
