/* 새 게임 넷: 마디 테트리스 · 기호 짝 맞추기 · 리듬 달리기 · 화음 요리사 (games/tetris.js 가 불러 붙인다) */

/* 공통 버튼 줄 */
.gpad { display: flex; gap: 10px; }
.gpad .gp { flex: 1; min-height: 66px; border: 0; border-radius: 20px; background: #fff; box-shadow: 0 6px 0 #D8CDB6; font-size: 30px; touch-action: manipulation; color: var(--ink); }
.gpad .gp.big { flex: 1.4; background: linear-gradient(#FFDB63, #FFC43D); box-shadow: 0 6px 0 #E0A21A; }
.gpad .gp:active { transform: translateY(5px); box-shadow: 0 1px 0 #D8CDB6; }
.gpad .gp:disabled { opacity: .35; }

/* ───── 🧱 마디 테트리스 ───── */
.tt-stage { display: flex; flex-direction: column; gap: 8px; padding: 10px; background: linear-gradient(#F3EEFF, #E7F1FF); min-height: 0; }
.tt-side { display: flex; gap: 8px; align-items: stretch; }
.tt-box { flex: 0 0 auto; min-width: 84px; background: #fff; border-radius: 14px; padding: 4px 8px; box-shadow: 0 3px 0 #D9D2F0; display: flex; flex-direction: column; align-items: center; gap: 2px; }
.tt-box small, .tt-order small { font-size: 12px; font-weight: 800; color: #6A5FA0; }
.tt-box.off > div { visibility: hidden; }
.tt-box.off::after { content: '🙈'; font-size: 22px; margin-top: -30px; }
.tt-box > div { min-height: 40px; display: grid; place-items: center; }
.tt-order { flex: 1; min-width: 0; background: #FFF8DC; border-radius: 14px; padding: 2px 8px 4px; box-shadow: 0 3px 0 #EBD58E; display: flex; flex-wrap: wrap; align-items: center; align-content: center; gap: 0 8px; overflow: hidden; }
.tt-order small { flex: 0 0 100%; white-space: nowrap; }
.tt-order[hidden] { display: none; }
.tt-order:not([hidden]) ~ .tt-box { margin-left: 0; }
.tt-side .tt-box[data-next] { margin-left: auto; }
.tt-song { display: flex; align-items: center; gap: 2px; height: 36px; min-width: 0; }
.tt-song svg { height: 36px; width: auto; max-width: 100%; }
.tt-song .tt-ts { flex-basis: 20px; font-size: 11px; box-shadow: none; }
.tt-board { flex: 1; display: flex; flex-direction: column; gap: 6px; min-height: 0; touch-action: none; }
.tt-sky { position: relative; height: 54px; margin-left: 34px; flex: 0 0 auto; }
.tt-timer { position: absolute; left: 0; right: 0; bottom: -4px; height: 4px; border-radius: 3px; background: #8B5CF6; transform-origin: left; }
.tt-rows { flex: 1; display: flex; flex-direction: column; gap: 5px; min-height: 0; }
.tt-row { flex: 1; display: flex; align-items: stretch; gap: 6px; min-height: 30px; max-height: 60px; transition: transform .2s; }
.tt-row.gold .tt-track { background: linear-gradient(#FFF6CC, #FFE680); box-shadow: 0 0 0 3px #FFD23F, 0 3px 0 #E3B41E; }
.tt-row.done .tt-track { animation: ttDone .35s ease-out; }
@keyframes ttDone { 50% { background: #D8F5DB; transform: scale(1.03); } }
.tt-ts { flex: 0 0 28px; display: flex; flex-direction: column; align-items: center; justify-content: center; font-weight: 900; font-size: 15px; line-height: 1; color: #2B2340; background: #fff; border-radius: 10px; box-shadow: 0 2px 0 #D9D2F0; }
.tt-ts b:first-child { border-bottom: 2px solid #2B2340; padding: 0 3px 1px; margin-bottom: 1px; }
.tt-track { position: relative; flex: 1; background: #fff; border-radius: 12px; box-shadow: inset 0 2px 0 rgba(30,42,74,.05), 0 2px 0 #DCD5EE; overflow: hidden; }
.tt-tick { position: absolute; top: 20%; bottom: 20%; width: 0; border-left: 1px dotted #D5CEE8; }
.tt-tick.beat { border-left: 2px solid #E4DEF2; top: 10%; bottom: 10%; }
.tt-tick.grp { border-left: 3px dashed #B9A8F0; top: 0; bottom: 0; }
.tt-dead { position: absolute; top: 0; bottom: 0; background: repeating-linear-gradient(45deg, #EEE9F7 0 6px, #E2DBF1 6px 12px); }
.tt-ghost { position: absolute; top: 3px; bottom: 3px; display: none; border: 2px dashed #8B5CF6; border-radius: 10px; background: rgba(139,92,246,.08); pointer-events: none; }
.tt-block { position: absolute; top: 3px; bottom: 3px; border-radius: 10px; display: flex; align-items: center; justify-content: center; overflow: hidden; box-shadow: inset 0 -4px 0 rgba(0,0,0,.1), inset 0 3px 0 rgba(255,255,255,.55); }
.tt-block .tt-cell { height: 100%; width: 100%; }
.tt-block.v-w { background: #E6DAFF; } .tt-block.v-dh, .tt-block.v-h { background: #D5E9FF; }
.tt-block.v-dq, .tt-block.v-q { background: #D6F5DC; } .tt-block.v-e { background: #FFE3C4; }
.tt-block.rest { background: #ECEFF4; } .tt-block.cell { background: #FFF1B8; } .tt-block.star { background: linear-gradient(#FFF6C8, #FFE27A); }
.tt-beats { position: absolute; right: 4px; top: 2px; font-size: 11px; font-weight: 900; color: #6A5FA0; background: rgba(255,255,255,.8); border-radius: 6px; padding: 0 4px; line-height: 15px; }
.tt-star { position: absolute; left: 3px; top: 1px; font-size: 12px; }
.tt-piece { top: 0; bottom: 6px; z-index: 2; transition: left .08s ease-out; box-shadow: inset 0 -4px 0 rgba(0,0,0,.1), 0 6px 14px rgba(60,40,140,.22); }
.tt-piece.nofit { opacity: .6; outline: 3px dashed #FF6B6B; outline-offset: -3px; }
.tt-piece.shake { animation: ttShake .3s; }
.tt-piece.gust { animation: ttGust .4s; }
@keyframes ttShake { 25% { translate: -6px 0; } 75% { translate: 6px 0; } }
@keyframes ttGust { 0% { filter: none; } 50% { filter: drop-shadow(-8px 0 0 rgba(120,180,255,.6)); } }
.tt-mini { position: relative; top: auto; bottom: auto; height: 40px; min-width: 30px; }
.tt-pop { position: absolute; left: 50%; top: 40%; transform: translateX(-50%); z-index: 5; white-space: nowrap; font-weight: 900; font-size: clamp(16px, 4.2vw, 22px); color: #2E7D32; text-shadow: 0 2px 0 #fff, 0 0 10px #fff; pointer-events: none; animation: ttPop 1.1s ease-out forwards; }
.tt-pop.big { color: #C27C00; font-size: clamp(18px, 4.8vw, 26px); }
.tt-pop.bad { color: #D94F4F; }
@keyframes ttPop { 0% { opacity: 0; transform: translate(-50%, 10px) scale(.85); } 15% { opacity: 1; transform: translate(-50%, 0) scale(1.05); } 100% { opacity: 0; transform: translate(-50%, -34px); } }
.tt-fever, .g4-fever { position: absolute; top: 6px; left: 50%; transform: translateX(-50%); z-index: 4; background: #FF6B6B; color: #fff; font-weight: 800; border-radius: 999px; padding: 3px 12px; box-shadow: 0 3px 0 #D94F4F; display: none; white-space: nowrap; }
.tt-fever.show, .g4-fever.show { display: block; }

/* 폰 가로: 무대 왼쪽 넓게, 버튼 오른쪽 */
@media (orientation: landscape) and (max-height: 520px) {
  .screen:has(> .g4-stage) { display: grid; grid-template-columns: minmax(0, 1.9fr) minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr); }
  .screen:has(> .g4-stage) > .hud { grid-column: 1 / -1; }
  .screen > .g4-stage { grid-column: 1; grid-row: 2; }
  .screen > .g4-side { grid-column: 2; grid-row: 2; align-self: center; }
  .screen > .tt-pad { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
  .screen > .tt-pad .gp { min-height: 58px; }
  .screen > .tt-pad .gp.big { grid-column: 1 / -1; order: -1; }
  .screen > .tt-pad .gp[data-a="right"] { order: 1; }
  .screen > .tt-pad .gp[data-a="swap"] { order: 2; grid-column: 1 / -1; min-height: 48px; }
  .tt-stage { flex-direction: row; padding: 6px; }
  .tt-side { flex-direction: column; width: 92px; flex: 0 0 auto; }
  .tt-side .tt-box[data-next] { margin-left: 0; margin-top: auto; }
  .tt-order { flex: 0 0 auto; flex-direction: column; align-items: stretch; }
  .tt-order .tt-song svg { height: 30px; max-width: 70px; }
  .tt-sky { height: 40px; }
  .tt-row { min-height: 22px; }
}
@media (max-width: 400px) { .tt-box { min-width: 70px; } .tt-ts { flex-basis: 24px; font-size: 13px; } .tt-sky { margin-left: 30px; } }

/* ───── 🃏 기호 짝 맞추기 ───── */
.mm-stage { display: flex; flex-direction: column; padding: 10px; background: linear-gradient(#FFF4E4, #FDE8F0); min-height: 0; }
.mm-grid { flex: 1; min-height: 360px; display: grid; grid-template-columns: repeat(var(--mc, 4), minmax(0, 1fr)); grid-template-rows: repeat(var(--mr, 3), minmax(0, 1fr)); gap: 8px; }
.mm-grid.flipx { animation: mmFlipX .5s ease-in-out; }
@keyframes mmFlipX { 50% { transform: scaleX(.2); } }
.mm-card { border: 0; padding: 0; background: none; perspective: 700px; min-width: 0; min-height: 0; touch-action: manipulation; cursor: pointer; }
.mm-card.swap .mm-in { animation: mmSwap .45s ease-out; }
@keyframes mmSwap { 0% { transform: scale(.6) rotate(-8deg); } 100% { transform: none; } }
.mm-in { position: relative; display: block; width: 100%; height: 100%; transition: transform .32s; transform-style: preserve-3d; }
.mm-card.up .mm-in { transform: rotateY(180deg); }
.mm-back, .mm-face { position: absolute; inset: 0; border-radius: 14px; backface-visibility: hidden; -webkit-backface-visibility: hidden; display: grid; place-items: center; overflow: hidden; }
.mm-back { background: linear-gradient(135deg, #8B5CF6, #5B8DEF); box-shadow: 0 4px 0 #5B3FC4, inset 0 2px 0 rgba(255,255,255,.35); }
.mm-back i { font-style: normal; font-size: clamp(20px, 6vmin, 36px); color: rgba(255,255,255,.85); }
.mm-face { transform: rotateY(180deg); background: #fff; box-shadow: 0 4px 0 #E6DCCB; padding: 4px; }
.mm-card.done .mm-face { background: #EFFFF1; box-shadow: 0 4px 0 #9AD9A4; }
.mm-card.done { animation: mmDone .4s ease-out; }
.mm-card.done .mm-face > * { opacity: .75; }
@keyframes mmDone { 50% { transform: scale(1.08); } }
.mm-card.gold .mm-back { background: linear-gradient(135deg, #FFD23F, #FFA41B); box-shadow: 0 4px 0 #D98B00, 0 0 12px #FFD23F; }
.mm-face svg { width: 88%; height: 78%; }
.mm-face .gsvg { width: auto !important; height: 72% !important; max-width: 90%; }
.mm-staff, .mm-inst { width: 100%; height: 100%; display: grid; place-items: center; }
.mm-staff svg { width: 96%; height: auto; max-height: 90%; }
.mm-inst svg { width: 84%; height: 84%; }
.mm-jam svg { width: 80%; height: 80%; }
.mm-txt { font-weight: 800; font-size: clamp(12px, 3.3vmin, 19px); line-height: 1.2; text-align: center; color: #2B2340; word-break: keep-all; padding: 0 2px; }
.mm-txt.big { font-size: clamp(18px, 6vmin, 34px); }
.mm-txt.it { font-style: italic; font-family: Georgia, 'Times New Roman', serif; font-size: clamp(13px, 3.8vmin, 22px); }
.mm-snd { font-size: clamp(24px, 7vmin, 40px); }
.mm-ts { display: flex; flex-direction: column; align-items: center; font-weight: 900; font-size: clamp(20px, 6vmin, 34px); line-height: 1; }
.mm-ts b:first-child { border-bottom: 3px solid #2B2340; padding: 0 4px; }
@media (orientation: landscape) and (max-height: 520px) { .mm-stage { padding: 6px; } .mm-grid { min-height: 0; gap: 6px; } }

/* ───── 🏃 리듬 달리기 ───── */
.rn-stage { position: relative; min-height: 360px; background: #EAF7FF; touch-action: none; }
.rn-stage canvas { position: absolute; inset: 0; display: block; }
.rn-strip { position: absolute; left: 8px; right: 8px; top: 8px; z-index: 2; display: flex; align-items: center; gap: 6px; background: rgba(255,255,255,.92); border-radius: 14px; padding: 2px 8px; box-shadow: 0 3px 0 #CFE2F0; min-height: 56px; pointer-events: none; }
.rn-staff { flex: 1; min-width: 0; display: flex; align-items: center; }
.rn-staff svg { width: 100%; height: auto; max-height: 64px; }
.rn-staff.peek { animation: rnPeek 1.6s ease-in forwards; }
@keyframes rnPeek { 0%, 60% { opacity: 1; } 100% { opacity: 0; } }
.rn-ts { display: flex; flex-direction: column; align-items: center; font-weight: 900; font-size: 15px; line-height: 1; }
.rn-ts b:first-child { border-bottom: 2px solid #2B2340; padding: 0 2px; }
.rn-tag { font-size: 12px; font-weight: 800; background: #EEF0F6; color: #6A6F85; border-radius: 999px; padding: 2px 8px; white-space: nowrap; }
.rn-tag.go { background: #FFE9F3; color: #C0306E; }
.rn-sign { position: absolute; right: 12px; top: 74px; z-index: 3; font-weight: 900; font-size: 18px; font-style: italic; background: #FFF6D6; border-radius: 10px; padding: 3px 10px; box-shadow: 0 3px 0 #E9D08A; opacity: 0; pointer-events: none; }
.rn-sign.show { animation: rnSign 2.6s ease-out forwards; }
@keyframes rnSign { 0% { opacity: 0; transform: translateY(-8px); } 12%, 75% { opacity: 1; transform: none; } 100% { opacity: 0; } }
.rn-pad .gp.big { min-height: 72px; font-size: 26px; font-weight: 800; }
.rn-pad small { font-size: 13px; opacity: .6; }
@media (orientation: landscape) and (max-height: 520px) {
  .rn-stage { min-height: 0; }
  .rn-strip { min-height: 44px; top: 4px; }
  .rn-staff svg { max-height: 48px; }
  .rn-sign { top: 54px; }
  .screen:has(> .rn-stage) > .rn-pad { position: absolute; right: max(16px, env(safe-area-inset-right)); bottom: max(12px, env(safe-area-inset-bottom)); width: min(34vw, 220px); z-index: 5; }
  .screen:has(> .rn-stage) { position: relative; }
  .rn-pad .gp.big { min-height: 64px; opacity: .92; }
}

/* ───── 👩‍🍳 화음 요리사 ───── */
.cf-stage { display: flex; flex-direction: column; gap: 8px; padding: 10px; background: linear-gradient(#FFF3E0, #FFE8D6); min-height: 300px; }
.cf-orders { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; }
.cf-ticket { position: relative; flex: 1 1 0; min-width: 140px; border: 0; border-radius: 16px; background: #fff; box-shadow: 0 4px 0 #E9D2B6; padding: 8px 10px 12px; text-align: left; display: flex; flex-direction: column; gap: 4px; touch-action: manipulation; color: var(--ink); }
.cf-ticket.sel { box-shadow: 0 0 0 3px #FF8A5B, 0 4px 0 #E06A3B; }
.cf-ticket.gold { background: linear-gradient(#FFF8D6, #FFE9A0); }
.cf-guest { font-size: 26px; line-height: 1; }
.cf-dish { display: flex; flex-direction: column; gap: 2px; opacity: .55; }
.cf-dish.now { opacity: 1; }
.cf-dish.done { opacity: .4; text-decoration: line-through; }
.cf-dname { font-weight: 900; font-size: clamp(15px, 4.2vw, 20px); line-height: 1.25; word-break: keep-all; }
.cf-recipe { display: flex; gap: 6px; flex-wrap: wrap; }
.cf-recipe b { font-size: clamp(16px, 4.4vw, 21px); background: #FFF6EC; border-radius: 8px; padding: 0 6px; }
.cf-staffs { display: flex; gap: 2px; }
.cf-staffs svg { height: 48px; width: auto; }
.cf-pat { position: absolute; left: 10px; right: 10px; bottom: 4px; height: 5px; border-radius: 3px; background: #6BCB77; transform-origin: left; }
.cf-pat.low { background: #FF6B6B; }
.cf-kitchen { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; min-height: 0; }
.cf-potbox { display: flex; align-items: center; gap: 10px; background: #fff; border-radius: 22px; padding: 10px 14px; box-shadow: 0 5px 0 #E9D2B6; flex-wrap: wrap; justify-content: center; }
.cf-potem { font-size: 44px; }
.cf-ings { display: flex; gap: 8px; }
.cf-ing { width: 50px; height: 50px; border-radius: 50%; display: grid; place-items: center; font-style: normal; font-weight: 900; font-size: 18px; color: #fff; background: var(--c); box-shadow: inset 0 -5px 0 rgba(0,0,0,.15), inset 0 4px 0 rgba(255,255,255,.35); animation: cfDrop .25s ease-out; }
.cf-ing.empty { background: #F3EBDD; box-shadow: inset 0 3px 6px rgba(120,90,50,.15); animation: none; }
@keyframes cfDrop { 0% { transform: translateY(-20px) scale(.6); } 100% { transform: none; } }
.cf-clear { border: 0; background: #F3EBDD; border-radius: 12px; padding: 6px 10px; font-weight: 800; font-size: 15px; color: #7A6450; }
.cf-msg { min-height: 26px; font-weight: 800; font-size: clamp(15px, 4vw, 19px); color: #2E7D32; text-align: center; }
.cf-msg.bad { color: #D94F4F; }
.cf-jars { display: flex; gap: 12px; flex-wrap: wrap; justify-content: center; }
.cf-jar { width: 74px; height: 88px; border: 0; border-radius: 22px 22px 28px 28px; background: radial-gradient(circle at 35% 30%, #fff8, transparent 40%), var(--c); box-shadow: 0 6px 0 rgba(0,0,0,.18); font-size: 34px; touch-action: manipulation; transition: transform .12s; }
.cf-jar:active { transform: scale(.94) rotate(-4deg); }
.cf-jar.sel { outline: 4px solid #FF8A5B; outline-offset: 3px; transform: translateY(-6px); }
.cf-jar.dark { background: #5A4E66; }
.cf-cook { width: 100%; }
.cf-shelf { min-height: 0; }
.cf-shelf .keyboard { max-width: 760px; }
.cf-served { position: absolute; left: 50%; top: 45%; font-size: 60px; transform: translateX(-50%); animation: cfServe .9s ease-in forwards; pointer-events: none; z-index: 5; }
@keyframes cfServe { 0% { opacity: 0; transform: translate(-50%, 20px) scale(.6); } 30% { opacity: 1; transform: translate(-50%, 0) scale(1.1); } 100% { opacity: 0; transform: translate(-50%, -140px) scale(.8); } }
@media (orientation: landscape) and (max-height: 520px) {
  .screen:has(> .cf-stage) { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr); grid-template-rows: auto minmax(0, 1fr); }
  .screen:has(> .cf-stage) > .hud { grid-column: 1 / -1; }
  .screen > .cf-stage { grid-column: 1; grid-row: 2; min-height: 0; padding: 6px; }
  .screen > .cf-shelf { grid-column: 2; grid-row: 2; align-self: center; }
  .cf-ticket { min-width: 110px; padding: 4px 8px 10px; }
  .cf-guest { font-size: 20px; }
  .cf-potem { font-size: 30px; }
  .cf-ing { width: 40px; height: 40px; font-size: 15px; }
  .cf-jar { width: 60px; height: 70px; font-size: 28px; }
}

/* 좁은 폰: 위 알림 줄이 넘치지 않게 */
@media (max-width: 480px) {
  .g4-hud { gap: 5px; font-size: 18px; }
  .g4-hud .pill { padding: 3px 9px; white-space: nowrap; }
  .g4-hud .icon-btn { flex: 0 0 auto; }
}
