body, html {
 margin: 0; padding: 0; width: 100%; height: 100%;
 overflow: hidden; background: #0a0a0a; color: #fff;
 font-family: 'Pretendard', sans-serif;
 display: flex; flex-direction: column;
 touch-action: none;
 transition: background-color 0.3s;
}

.hidden { display: none !important; }

.top-nav {
 display: flex; justify-content: space-between; align-items: center;
 padding: 15px 20px; background: rgba(0,0,0,0.8);
 z-index: 100; border-bottom: 1px solid #333;
}
.top-nav button {
 background: none; border: none; color: #aaa; font-size: 1rem; cursor: pointer;
}
.top-nav .title { font-weight: 900; letter-spacing: 2px; color: #fff; }

#game-container {
 flex: 1; min-height: 0; position: relative; width: 100%;
 display: flex; flex-direction: column; align-items: center; justify-content: center;
}

#combo-display {
 position: absolute; top: 20px; left: 20px;
 font-size: 1rem; font-weight: 800; z-index: 10;
 color: #eab308; text-shadow: 0 0 10px rgba(234, 179, 8, 0.5);
 transition: transform 0.2s;
}
#combo-display.bump { transform: scale(1.5); }

#badge-display {
 position: absolute; top: 20px; right: 20px;
 font-size: 1.5rem; z-index: 10;
 animation: float 2s infinite ease-in-out;
}
@keyframes float { 0% { transform: translateY(0px); } 50% { transform: translateY(-5px); } 100% { transform: translateY(0px); } }

#cards-wrapper { position: relative; width: 90%; max-width: 360px; height: 50vh; max-height: 500px; }

.card {
 position: absolute; width: 100%; height: 100%;
 background: #1a1a1a; border-radius: 20px;
 box-shadow: 0 10px 30px rgba(0,0,0,0.8);
 display: flex; flex-direction: column; justify-content: center; align-items: center;
 text-align: center; padding: 30px; padding-bottom: 80px; box-sizing: border-box;
 user-select: none; transition: transform 0.3s ease, opacity 0.3s ease;
 transform-origin: 50% 100%; border: 1px solid #333;
 will-change: transform;
}
.card.top { z-index: 2; cursor: grab; transition: none; }
.card.top:active { cursor: grabbing; }
.card.bottom { z-index: 1; transform: scale(0.95) translateY(15px); opacity: 0; pointer-events: none; }
.card.bottom:nth-last-child(2) { opacity: 0.6; }

.topic-text { font-size: 1.5rem; font-weight: 900; margin-bottom: 40px; word-break: keep-all; line-height: 1.4; pointer-events: none;}

/* ── 뉴 레이아웃: 대각선 분할 (왼아래=파랑/LEFT, 오른위=빨강/RIGHT) ── */
.diag-card { padding: 0 !important; background: transparent !important; border: none !important; overflow: hidden; }
.diag-bg-left {
 position: absolute; inset: 0; background: #08172e;
 clip-path: polygon(0 0, 0 100%, 100% 100%); pointer-events: none;
}
.diag-bg-right {
 position: absolute; inset: 0; background: #210808;
 clip-path: polygon(0 0, 100% 0, 100% 100%); pointer-events: none;
}
.diag-vs-big {
 position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
 font-size: 5rem; font-weight: 900; color: rgba(255,255,255,0.025);
 pointer-events: none; letter-spacing: 4px; white-space: nowrap; z-index: 1;
}
.diag-vs-badge {
 position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
 width: 44px; height: 44px; background: #111; border: 2px solid #555; border-radius: 50%;
 display: flex; align-items: center; justify-content: center;
 font-size: 0.65rem; font-weight: 900; color: #888; z-index: 10; pointer-events: none;
}
.diag-text-left {
 position: absolute; bottom: 13%; left: 7%; width: 48%;
 color: #6bbdff; font-weight: 800; font-size: 1.05rem; line-height: 1.5;
 word-break: keep-all; text-shadow: 0 1px 10px rgba(0,0,0,0.95); z-index: 5; pointer-events: none;
}
.diag-text-right {
 position: absolute; top: 10%; right: 7%; width: 48%;
 color: #ff8080; font-weight: 800; font-size: 1.05rem; line-height: 1.5;
 word-break: keep-all; text-align: right; text-shadow: 0 1px 10px rgba(0,0,0,0.95); z-index: 5; pointer-events: none;
}
.topic-split {
 display: flex; align-items: center; justify-content: center;
 width: 100%; gap: 10px; pointer-events: none;
}
.topic-left, .topic-right {
 flex: 1; font-weight: 900; line-height: 1.35;
 word-break: keep-all; text-align: center;
}
.topic-left { color: #60a5fa; }
.topic-right { color: #f87171; }
.vs-badge {
 font-size: 0.7rem; font-weight: 900; color: #888;
 background: #1a1a1a; border: 1px solid #444; border-radius: 50%;
 width: 30px; height: 30px; flex-shrink: 0;
 display: flex; align-items: center; justify-content: center;
}
.options { display: flex; justify-content: space-between; width: 100%; position: absolute; bottom: 30px; padding: 0 20px; box-sizing: border-box; pointer-events: none;}
.opt-label { font-size: 1.05rem; font-weight: 800; opacity: 0.8; white-space: pre-wrap; word-break: keep-all; line-height: 1.3; max-width: 48%; text-align: center; display: flex; align-items: center; justify-content: center; }
.opt-left { color: #3b82f6; }
.opt-right { color: #ef4444; }

#card-labels {
 display: flex; justify-content: space-between;
 padding: 8px 20px 0; width: 90%; max-width: 360px; box-sizing: border-box;
 flex-shrink: 0;
}
#card-labels.hidden { display: none !important; }
.clabel-left { color: #4a9edd; font-size: 0.9rem; font-weight: 800; }
.clabel-right { color: #dd4a4a; font-size: 0.9rem; font-weight: 800; }

#pivot-debug {
 display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
 padding: 6px 16px; background: rgba(0,0,0,0.6); border-top: 1px solid #222;
 font-size: 0.72rem; color: #666; flex-shrink: 0;
}
#pivot-debug.hidden { display: none !important; }
#pivot-debug span { color: #444; font-weight: 700; }
#pivot-debug label { display: flex; align-items: center; gap: 4px; color: #555; }
#pivot-debug input[type=range] { width: 80px; accent-color: #fff; }
#pivot-debug span[id] { color: #888; min-width: 24px; }

#swipe-hint {
 flex-shrink: 0;
 display: flex; justify-content: space-between; padding: 12px 20px;
 font-size: 0.85rem; color: #666; font-weight: bold;
}

/* Feedback Effects */
#feedback-overlay {
 position: absolute; top: 0; left: 0; width: 100%; height: 100%;
 pointer-events: none; z-index: 50; display: flex; flex-direction: column;
 align-items: center; justify-content: center; font-size: 3rem;
 font-weight: 900; opacity: 0; text-align: center; text-transform: uppercase;
 text-shadow: 0 4px 20px rgba(0,0,0,0.8);
}
.feedback-sub { font-size: 1.5rem; color: #ccc; margin-top: 10px; }

@keyframes flash-clash {
 0% { background: rgba(0, 0, 0, 0); box-shadow: inset 0 0 0px red; }
 30% { background: rgba(255, 255, 255, 0.2); box-shadow: inset 0 0 100px red, inset 0 0 200px blue; }
 100% { background: rgba(0, 0, 0, 0); box-shadow: inset 0 0 0px red; }
}
.clash-effect { animation: flash-clash 0.5s ease-out; }

@keyframes shake {
 0%, 100% { transform: translate(0, 0) rotate(0deg); }
 10%, 30%, 50%, 70%, 90% { transform: translate(-4px, -2px) rotate(-1deg); }
 20%, 40%, 60%, 80% { transform: translate(4px, 2px) rotate(1deg); }
}
.shake { animation: shake 0.5s; }

.bg-red { background: #2a0b0b !important; }
.bg-blue { background: #0b1a2a !important; }

/* UI Enhancements - Minimal */
.header-menu-container { position: relative; display: flex; align-items: center; justify-content: center; gap: 6px; }
.layout-toggle {
 display: flex; background: #222; border: 1px solid #444;
 border-radius: 20px; padding: 3px; gap: 2px;
}
.layout-toggle-btn {
 padding: 4px 13px; cursor: pointer; color: #555;
 font-size: 0.72rem; font-weight: 800; border-radius: 18px;
 transition: all 0.18s; user-select: none; letter-spacing: 0.5px;
 min-width: 38px; text-align: center;
}
.layout-toggle-btn:hover { color: #bbb; }
.layout-toggle-btn.active { background: #fff; color: #000; }
#menu-btn { background: none; border: none; color: #777; font-size: 1.6rem; cursor: pointer; padding: 0 5px; font-weight: bold; transition: color 0.2s; line-height: 1; }
#menu-btn:hover { color: #fff; }
#dropdown-menu {
    position: absolute; top: 35px; right: 0; background: #111; border: 1px solid #333;
    border-radius: 8px; width: 140px; z-index: 200; box-shadow: 0 5px 20px rgba(0,0,0,0.9);
    display: flex; flex-direction: column; overflow: hidden;
}
#dropdown-menu.hidden { display: none !important; }

.menu-item { padding: 12px 15px; font-size: 0.85rem; color: #aaa; cursor: pointer; text-align: left; transition: background 0.2s, color 0.2s; border: none; background: transparent; display: block; width: 100%; box-sizing: border-box; }
.menu-item:hover, .menu-item.active { background: #222; color: #fff; }
.layout-opt.selected { color: #fff; font-weight: 900; }
.layout-opt.selected::before { content: '✓ '; }
.menu-divider { height: 1px; background: #333; margin: 0; }

.overlay { 
    position: fixed; top: 0; left: 0; width: 100%; height: 100%; 
    background: rgba(0,0,0,0.85); z-index: 1000; 
    display: flex; align-items: center; justify-content: center; 
    backdrop-filter: blur(2px); 
}
.overlay.hidden { display: none !important; }

.minimal-modal {
    background: #111; border: 1px solid #333; padding: 25px;
    border-radius: 16px; width: 85%; max-width: 340px;
    display: flex; flex-direction: column; gap: 12px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.9);
}
.preview-modal {
    max-width: 480px; width: 92%;
    max-height: 85vh; overflow-y: auto; padding: 20px;
}
.preview-header {
    font-size: 1rem; font-weight: 900; color: #fff;
    text-align: center; letter-spacing: 1px; margin-bottom: 4px;
}
.field-group { display: flex; flex-direction: column; gap: 4px; }
.field-label { font-size: 0.75rem; color: #666; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; }
.side-block {
    border-radius: 10px; padding: 12px; display: flex;
    flex-direction: column; gap: 8px;
}
.left-side { border: 1px solid #1d4ed8; background: rgba(29,78,216,0.08); }
.right-side { border: 1px solid #b91c1c; background: rgba(185,28,28,0.08); }
.side-header { font-size: 0.8rem; font-weight: 800; }
.left-side .side-header { color: #3b82f6; }
.right-side .side-header { color: #ef4444; }
.logic-input { resize: none; height: 58px; font-size: 0.82rem; }
.edit-input, #keyword-input {
    background: #000; border: 1px solid #333; color: #fff;
    padding: 10px 12px; border-radius: 8px; font-family: inherit;
    font-size: 0.9rem; width: 100%; box-sizing: border-box; outline: none;
}
.edit-select { appearance: none; cursor: pointer; }
#preview-desc { resize: none; height: 54px; font-size: 0.85rem; }
.modal-btns { display: flex; gap: 10px; margin-top: 5px; }
.modal-btns button {
    flex: 1; padding: 12px; border: none; border-radius: 8px;
    cursor: pointer; font-weight: bold; background: #222; color: #aaa;
    transition: filter 0.2s; font-size: 0.9rem;
}
.modal-btns button:hover { filter: brightness(1.2); }
#generate-btn, #save-topic-btn { background: #fff; color: #000; }
#regen-btn { background: #92400e; color: #fbbf24; }
#loading-msg { text-align: center; font-size: 0.85rem; color: #888; }
.style-toggle { display: flex; gap: 8px; }
.style-btn {
    flex: 1; padding: 10px; border: 1px solid #333; border-radius: 8px;
    background: #111; color: #555; cursor: pointer; font-size: 0.88rem;
    font-weight: 600; transition: all 0.2s;
}
.style-btn:hover { border-color: #555; color: #aaa; }
.style-btn.active[data-style="spicy"] { border-color: #ef4444; color: #ef4444; background: rgba(239,68,68,0.08); }
.style-btn.active[data-style="logic"] { border-color: #3b82f6; color: #3b82f6; background: rgba(59,130,246,0.08); }
.vs-input-row { display: flex; flex-direction: column; gap: 0; }
.vs-textarea { resize: none; height: 64px; font-size: 1rem; line-height: 1.4; }
.vs-divider {
    text-align: center; font-size: 0.75rem; font-weight: 900;
    color: #555; padding: 6px 0; letter-spacing: 2px;
}
#save-toast { 
    position: fixed; bottom: 80px; left: 50%; transform: translateX(-50%); 
    background: rgba(255,255,255,0.95); color: #000; padding: 12px 24px; 
    border-radius: 30px; font-size: 0.9rem; font-weight: bold; z-index: 2000; 
    box-shadow: 0 5px 15px rgba(0,0,0,0.5); 
}
#save-toast.hidden { display: none !important; }
