:root { --bg-1: #e0eafc; --bg-2: #cfdef3; --bg-3: #FFB6C1; --bg-4: #f8bbd0; --primary: #FF4081; --text-main: #2C3E50; --text-sec: #7F8C8D; }
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; font-family: 'Noto Sans JP', sans-serif; }

/* ==========================================
   防護罩：防止反白、拖曳與長按選單
========================================== */
body {
    margin: 0; background: linear-gradient(-45deg, var(--bg-1), var(--bg-2), var(--bg-3), var(--bg-4)); background-size: 400% 400%; animation: gradBG 20s ease infinite; height: 100dvh; color: var(--text-main); overflow: hidden; display: flex; flex-direction: column;
    -webkit-user-select: none; -moz-user-select: none; -ms-user-select: none; user-select: none;
    -webkit-touch-callout: none;
}
img { -webkit-user-drag: none; -khtml-user-drag: none; -moz-user-drag: none; -o-user-drag: none; }
input, textarea { -webkit-user-select: auto; -moz-user-select: auto; -ms-user-select: auto; user-select: auto; }
#exportImgDisplay { -webkit-touch-callout: default; pointer-events: auto; }
/* ========================================== */

@keyframes gradBG { 0% { background-position: 0% 50%; } 50% { background-position: 100% 50%; } 100% { background-position: 0% 50%; } }
@keyframes shake { 0%, 100% { transform: translateX(0); } 20%, 60% { transform: translateX(-8px); } 40%, 80% { transform: translateX(8px); } }

@keyframes floatAnim { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-8px); } }
@keyframes glowBreathe { 0% { box-shadow: 0 0 10px rgba(255,64,129,0.3); } 100% { box-shadow: 0 0 30px rgba(255,64,129,0.8); } }
@keyframes glowTextBreathe { 0% { text-shadow: 0 0 5px rgba(255,64,129,0.4); } 100% { text-shadow: 0 0 20px rgba(255,64,129,0.9); } }
@keyframes ripple { 0% { background-position: 0 0; } 100% { background-position: 60px 60px; } }
@keyframes comboPop { 0% { transform: scale(0.5) rotate(-10deg); opacity: 0; } 50% { transform: scale(1.3) rotate(5deg); opacity: 1; } 100% { transform: scale(1) rotate(0deg); } }
@keyframes blink { 0%, 100% { opacity: 1; } 50% { opacity: 0; } }

.glow-text-breathe { animation: glowTextBreathe 2s infinite alternate; }
.glow-box-breathe { animation: glowBreathe 2s infinite alternate; }
.float-anim { animation: floatAnim 3s ease-in-out infinite; will-change: transform; }
.blink { animation: blink 1.5s infinite; }

.intro-title { font-size: 2.5rem; text-align: center; line-height: 1.2; margin-bottom: 5px;}
.intro-subtitle { font-weight: 700; font-size: 1.1rem; margin-bottom: 20px; color: var(--text-main); text-align: center;}
.intro-stats { background: rgba(255,255,255,0.5); padding: 5px 15px; border-radius: 20px; font-weight: 900; margin-bottom: 30px; font-size: 0.9rem; border: 1px solid #fff; }

.topbar { padding: 10px 15px; display: flex; justify-content: space-between; align-items: center; z-index: 50; flex-shrink: 0; gap: 8px; white-space: nowrap; }
.topbar-left { display: flex; gap: 8px; align-items: center; flex-shrink: 0; }
.header-center { flex: 1; display: flex; justify-content: center; min-width: 0; }
.level-badge { background: var(--primary); color: white; padding: 4px 12px; border-radius: 12px; font-weight: 900; font-size: 0.85rem; box-shadow: 0 4px 10px rgba(255,64,129,0.3); overflow: hidden; text-overflow: ellipsis; max-width: 100%; }

.lang-select { padding: 4px 6px; border-radius: 8px; border: 1px solid rgba(255,255,255,0.5); background: rgba(255,255,255,0.5); font-weight: 700; outline: none; color: var(--text-main); max-width: 120px;}
.score-board { position: relative; font-size: 1rem; font-weight: 900; color: var(--primary); background: rgba(255,255,255,0.9); padding: 4px 12px; border-radius: 20px; box-shadow: 0 4px 10px rgba(0,0,0,0.05); flex-shrink: 0;}

.combo-pop { position: absolute; bottom: -30px; right: 5px; color: #FFD700; font-weight: 900; font-size: 1.2rem; text-shadow: 0 2px 5px rgba(0,0,0,0.5); animation: comboPop 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275); pointer-events: none; white-space: nowrap; z-index: 100;}
.floating-perfect { position: absolute; top: 20%; left: 50%; transform: translate(-50%,-50%); color: #FFD700; font-size: 3rem; font-weight: 900; z-index: 100; pointer-events: none; text-shadow: 0 0 20px #FF4081; animation: comboPop 0.8s forwards; white-space: nowrap; }

/* 🌟 修正：波紋特效加強，透明度提高，加入推色與白色漸變圈 */
.ripple-overlay { position: absolute; inset: 0; pointer-events: none; z-index: 5; opacity: 0.6; background: radial-gradient(circle, transparent 15%, rgba(255,255,255,0.8) 20%, rgba(255,64,129,0.5) 25%, transparent 30%); background-size: 60px 60px; animation: ripple 2s linear infinite; }

.oshi-grid, .album-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; overflow-y: auto; flex: 1; padding: 10px 5px; }
.oshi-item, .album-item { cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 5px; transition: 0.2s; }
.oshi-item img, .album-item img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 50%; border: 3px solid #fff; box-shadow: 0 4px 8px rgba(0,0,0,0.1); }
.oshi-item.selected img { border-color: var(--primary); transform: scale(1.1); box-shadow: 0 0 15px var(--primary); }
.album-item.locked img { filter: grayscale(1) brightness(0.5) blur(2px); }
.album-item span, .oshi-item span { font-size: 0.65rem; font-weight: 700; text-align: center; }

.flex-center { display: flex; justify-content: center; align-items: center; }
.hidden { display: none !important; }
.stage-exit { transform: scale(0.9); filter: blur(10px); opacity: 0; pointer-events: none; transition: all 0.4s ease; }
.stage-active { transform: scale(1); filter: blur(0); opacity: 1; transition: all 0.4s ease; }

.timer-bg { width: calc(100% - 30px); height: 8px; background: rgba(255,255,255,0.5); border-radius: 4px; overflow: hidden; margin: 0 15px 5px; flex-shrink: 0; }
.timer-fill { height: 100%; background: linear-gradient(90deg, #FFB6C1, var(--primary)); width: 100%; transform-origin: left; will-change: transform; }
.timer-danger { background: #F44336; }

.glass-panel { background: rgba(255, 255, 255, 0.6); backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px); border: 1px solid rgba(255,255,255,0.4); border-radius: 20px; box-shadow: 0 10px 30px rgba(0,0,0,0.1); }
.btn { padding: 12px 18px; font-size: 0.95rem; font-weight: 900; color: white; background: var(--primary); border: none; border-radius: 50px; cursor: pointer; display: inline-flex; justify-content: center; align-items: center; gap: 6px; transition: transform 0.2s; white-space: nowrap;}
.btn:hover { transform: scale(1.05); }
.btn-outline { background: transparent; border: 2px solid var(--primary); color: var(--primary); }

.dashboard-menu { width: 100%; max-width: 360px; display: flex; flex-direction: column; gap: 10px; margin: 0 auto;}
.dashboard-blurred { transform: scale(0.95); filter: blur(8px); pointer-events: none; }
.mode-card { width: 100%; padding: 15px; text-align: center; cursor: pointer; transition: transform 0.2s; background: rgba(255,255,255,0.8);}
.mode-card h2 { margin: 0 0 5px; color: var(--primary); font-size: 1.2rem;}
.mode-card p { margin: 0; font-size: 0.85rem; color: var(--text-sec); font-weight: 700;}

.leaderboard-box { width: 100%; max-width: 360px; background: rgba(255,255,255,0.6); border-radius: 15px; padding: 12px; flex-shrink: 0; margin: 0 auto;}
.leaderboard-title { text-align: center; color: var(--text-main); font-weight: 900; margin: 0 0 8px; font-size: 1rem; }
.lb-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 4px; }
.lb-item { display: flex; justify-content: space-between; background: rgba(255,255,255,0.8); padding: 6px 12px; border-radius: 8px; font-weight: 700; font-size: 0.85rem;}
.lb-item.highlight { background: rgba(255, 64, 129, 0.1); border: 1px solid var(--primary); color: var(--primary); }

#view-result { flex: 1; display: flex; flex-direction: column; align-items: center; padding: 10px 15px; overflow-y: auto; width: 100%; max-width: 450px; margin: 0 auto;}
.canvas-preview-wrap { width: 100%; display: flex; justify-content: center; margin-bottom: 12px; flex-shrink: 0; }
.canvas-preview-wrap img { width: auto; max-width: 100%; height: auto; max-height: 48vh; border-radius: 16px; box-shadow: 0 10px 25px rgba(0,0,0,0.2); object-fit: contain;}

.social-panel { width: 100%; display: flex; flex-direction: column; gap: 10px; max-width: 360px; margin: 0 auto;}
.name-input { width: 100%; padding: 10px 14px; border-radius: 12px; border: 2px solid rgba(255,255,255,0.8); background: rgba(255,255,255,0.8); font-size: 0.95rem; font-weight: 700; outline: none; text-align: center; color: var(--text-main);}
.social-panel .row { display: flex; justify-content: center; gap: 8px; width: 100%; }

ruby { ruby-align: center; }
rt { font-size: 0.6em; color: var(--primary); font-weight: 900; transform: translateY(2px); }

.game-wrapper { flex: 1; display: flex; flex-direction: column; max-width: 600px; margin: 0 auto; width: 100%; padding: 0 15px 15px; position: relative; max-height: calc(100dvh - 120px); }

.mem-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; flex: 1; perspective: 1000px; max-height: 55vh; }
.mem-card { position: relative; width: 100%; height: 100%; cursor: pointer; }
.mem-inner { position: absolute; inset: 0; transform-style: preserve-3d; transition: transform 0.4s ease-out; }
.mem-card.flipped .mem-inner { transform: rotateY(180deg); }
.mem-face { position: absolute; inset: 0; backface-visibility: hidden; -webkit-backface-visibility: hidden; border-radius: 12px; overflow: hidden; }
.mem-back { background: rgba(255,255,255,0.6); display: flex; justify-content: center; align-items: center; font-weight: 900; color: rgba(255,64,129,0.6); border: 2px solid #fff;}
.mem-front { transform: rotateY(180deg); background: #fff; border: 3px solid transparent; display: flex; flex-direction: column; justify-content: space-between; }
.mem-front img { width: 100%; height: calc(100% - 35px); object-fit: cover; }
.mem-name-wrap { height: 35px; flex-shrink: 0; background: #fff; display: flex; flex-direction: column; justify-content: center; align-items: center; line-height: 1.1; padding: 2px; }
.mem-name { font-size: 10px; font-weight: 700; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%;}
.mem-nickname { color: var(--primary); font-size: 9px; font-weight: 900; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; margin-top: 1px;}
.mem-card.matched .mem-front { border-color: #4CAF50; box-shadow: 0 0 15px rgba(76, 175, 80, 0.6); }

.sort-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; flex: 1; max-height: 55vh; }
.sort-card { border-radius: 16px; overflow: hidden; border: 3px solid transparent; background: #fff; cursor: pointer; display: flex; flex-direction: column; position: relative;}
.sort-card.selected { border-color: #2196F3; }
.sort-card img { width: 100%; flex: 1 1 auto; object-fit: cover; min-height: 0; }
.sort-badge { position: absolute; top: 8px; right: 8px; width: 26px; height: 26px; border-radius: 50%; background: #2196F3; color: #fff; font-weight: 900; display: flex; justify-content: center; align-items: center; opacity: 0; transform: scale(0); transition: 0.2s; font-size: 14px;}
.sort-card.selected .sort-badge { opacity: 1; transform: scale(1); }
.sort-gen { width: 100%; background: rgba(0,0,0,0.8); color: #fff; text-align: center; font-size: 11px; font-weight: 700; flex: 0 0 auto; height: 0; opacity: 0; transition: opacity 0.3s; overflow: hidden; padding: 0;}
.sort-card.revealed .sort-gen { height: auto; opacity: 1; padding: 4px; }
.sort-name { flex: 0 0 auto; display: flex; align-items: center; justify-content: center; font-weight: 900; font-size: 13px; background: #fff; padding: 6px 4px; text-align: center;}
.sort-card.correct { border-color: #4CAF50; } .sort-card.wrong { border-color: #F44336; }

.fly-arena { flex: 1; position: relative; background: rgba(255,255,255,0.3); border-radius: 20px; overflow: hidden; max-height: 55vh; }
.fly-node { position: absolute; border-radius: 50%; border: 3px solid #fff; cursor: pointer; will-change: transform; box-shadow: 0 4px 10px rgba(0,0,0,0.2); }
.fly-node img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; pointer-events: none;}
.fly-node.correct { z-index: 10; transition: transform 0.5s ease-out, box-shadow 0.3s; }
.fly-arena.dimmed .fly-node:not(.correct) { opacity: 0.2; filter: grayscale(1); pointer-events: none; transition: all 0.5s ease;}

.color-display { width: 100%; max-height: 25vh; aspect-ratio: 2/1; border-radius: 20px; display: flex; gap: 8px; padding: 10px; background: rgba(255,255,255,0.8); margin: 0 auto 15px auto; box-shadow: 0 10px 20px rgba(0,0,0,0.1); }
.color-chunk { flex: 1; height: 100%; border-radius: 12px; border: 1px solid rgba(0,0,0,0.1); box-shadow: inset 0 0 10px rgba(0,0,0,0.05);}

.macro-view, .smile-view, .puz-grid { width: 100%; max-width: 45vh; max-height: 45vh; aspect-ratio: 1; margin: 0 auto 15px auto; border-radius: 20px; position: relative; align-self: center;}
.macro-view, .smile-view { background: #fff; overflow: hidden; }
.puz-grid { background: rgba(255,255,255,0.4); padding: 4px; display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px;}

.macro-img { width: 100%; height: 100%; object-fit: cover; will-change: transform; }
.macro-scan { position: absolute; inset: 0; background: linear-gradient(to bottom, transparent 50%, rgba(255,255,255,0.1) 51%); background-size: 100% 6px; pointer-events: none; }
.opt-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; width: 100%; margin-bottom: auto;}
.opt-btn { padding: 10px; border-radius: 12px; font-weight: 900; background: rgba(255,255,255,0.8); cursor: pointer; border: 3px solid transparent; text-align: center; font-size: 1rem;}
.opt-btn.correct { background: rgba(76, 175, 80, 0.2); border-color: #4CAF50; color: #2E7D32; }
.opt-btn.wrong { background: rgba(244, 67, 54, 0.2); border-color: #F44336; color: #C62828; }

.duel-arena { display: flex; gap: 10px; flex: 1; align-items: stretch; position: relative; max-height: 55vh; }
.duel-vs { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); width: 44px; height: 44px; background: var(--primary); color: #fff; border-radius: 50%; display: flex; justify-content: center; align-items: center; font-weight: 900; z-index: 5; border: 2px solid #fff; animation: pulse 1s infinite alternate; }
.duel-card { flex: 1; border-radius: 20px; overflow: hidden; display: flex; flex-direction: column; cursor: pointer; border: 4px solid transparent; position: relative; transition: 0.3s; background:#fff;}
.duel-card img { width: 100%; flex: 1 1 auto; object-fit: cover; min-height:0;}
.duel-gen { width: 100%; background: rgba(0,0,0,0.8); color: #fff; text-align: center; font-size: 12px; padding: 4px; font-weight: 700; flex: 0 0 auto; height: 0; opacity: 0; transition: 0.3s; overflow: hidden;}
.duel-card.revealed .duel-gen { height: auto; opacity: 1; }
.duel-name { flex: 0 0 auto; min-height: 45px; display: flex; flex-direction: column; justify-content: center; align-items: center; font-weight: 900; font-size: 13px; line-height: 1.2; padding: 4px; text-align: center;}
.duel-card.correct { border-color: #4CAF50; } .duel-card.wrong { border-color: #F44336; filter: grayscale(0.5);}

.smile-sharp { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; pointer-events: none; }
.smile-frosted { position: absolute; inset: 0; backdrop-filter: blur(25px) saturate(1.2); -webkit-backdrop-filter: blur(25px) saturate(1.2); background: rgba(255,255,255,0.6); mask-image: radial-gradient(circle var(--mask-size, 0px) at var(--mask-x, 50%) var(--mask-y, 50%), transparent 85%, black 100%); -webkit-mask-image: radial-gradient(circle var(--mask-size, 0px) at var(--mask-x, 50%) var(--mask-y, 50%), transparent 85%, black 100%); pointer-events: none; transition: opacity 0.5s ease; }
.smile-view.revealed .smile-frosted { opacity: 0; }

.puz-piece { position: relative; border-radius: 8px; overflow: hidden; cursor: pointer; transition: transform 0.2s; border: 2px solid transparent;}
.puz-piece.selected { transform: scale(0.9); border-color: var(--primary); }
.puz-img { width: 100%; height: 100%; background-size: 300% 300%; transition: transform 0.3s; }
.puz-overlay { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; border-radius: 16px; opacity: 0; pointer-events: none; transition: 0.5s; z-index: 10; }

.modal-overlay { position: absolute; inset: 0; background: rgba(255,255,255,0.6); backdrop-filter: blur(15px); z-index: 100; flex-direction: column; padding: 20px;}
.app-footer { text-align: center; padding: 10px; font-size: 0.75rem; color: var(--text-sec); font-weight: 700; flex-shrink: 0; line-height: 1.4;}

@media (max-width: 480px) {
    .topbar { padding: 8px 5px; gap: 4px; }
    .topbar-left { gap: 4px; }
    .lang-select { font-size: 0.7rem; padding: 3px; max-width: 60px; }
    #btnHome { padding: 4px 8px; font-size: 0.75rem; }
    .level-badge { font-size: 0.65rem; padding: 3px 6px; }
    .score-board { font-size: 0.8rem; padding: 4px 8px; }
    .combo-pop { font-size: 0.9rem; bottom: -20px; right: 0; }
    .floating-perfect { font-size: 1.8rem; }
    
    .intro-title { font-size: 1.8rem; }
    .intro-subtitle { font-size: 0.95rem; margin-bottom: 30px; }
    .btn { font-size: 0.85rem; padding: 10px 14px;}
    .mode-card h2 { font-size: 1.1rem; }
    .oshi-grid, .album-grid { grid-template-columns: repeat(3, 1fr); }
    .app-footer { font-size: 0.65rem; padding: 8px; }
}
