@font-face { font-family: 'ITC Avant Garde Gothic Std Extra Light'; src: url('fonts/ITC Avant Garde Gothic Std Extra Light.woff2') format('woff2'); }
@font-face { font-family: 'AR ADGothicJP'; src: url('fonts/jadhei01m.woff2') format('woff2'); }
@font-face { font-family: 'KozGoPr6N'; src: url('fonts/KozGoPr6N-Medium.woff2') format('woff2'); }

:root { --bg-1: #e0eafc; --bg-2: #cfdef3; --bg-3: #FFB6C1; --bg-4: #f8bbd0; --primary: #F676A6; --primary-hover: #E55A8C; --text-main: #2C3E50; --text-sec: #7F8C8D; --tool48-account-bg: rgba(255,255,255,0.58); --tool48-account-border: rgba(255,255,255,0.6); }
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; font-family: 'KozGoPr6N', 'AR ADGothicJP', '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; }
.tool48-home-link { display: inline-flex; align-items: center; justify-content: center; min-height: 34px; padding: 6px 11px; border-radius: 999px; border: 1px solid var(--tool48-account-border); background: var(--tool48-account-bg); color: var(--primary); box-shadow: 0 8px 22px rgba(246,118,166,0.14); font-size: 0.78rem; font-weight: 900; text-decoration: none; }
.tool48-home-link:hover { transform: translateY(-1px); }
.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;}
.topbar-right { display: flex; align-items: center; justify-content: flex-end; gap: 6px; flex-shrink: 0; min-width: 0; }
.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;}
.account-toggle { min-height: 38px; padding: 7px 12px; border-radius: 999px; border: 1px solid var(--tool48-account-border); background: var(--tool48-account-bg); color: var(--primary); box-shadow: 0 8px 22px rgba(246,118,166,0.14); cursor: pointer; display: inline-flex; align-items: center; justify-content:center; gap: 6px; font-weight: 800; font-size: 0.82rem; max-width: 170px; }
.account-toggle:hover { transform: translateY(-1px); }
.account-toggle-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-toggle-icon { width: 18px; height: 18px; flex-shrink: 0; background: currentColor; -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='10'/%3E%3Ccircle cx='12' cy='10' r='3'/%3E%3Cpath d='M7 20.7c1.2-2.1 3-3.2 5-3.2s3.8 1.1 5 3.2'/%3E%3C/svg%3E") center / contain no-repeat; mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='10'/%3E%3Ccircle cx='12' cy='10' r='3'/%3E%3Cpath d='M7 20.7c1.2-2.1 3-3.2 5-3.2s3.8 1.1 5 3.2'/%3E%3C/svg%3E") center / contain no-repeat; }

.account-popover[hidden], .cloud-login-form[hidden], .cloud-actions[hidden] { display: none !important; }
.account-popover { position: fixed; top: 54px; right: 12px; width: min(340px, calc(100vw - 24px)); max-height: calc(100dvh - 66px); overflow: auto; z-index: 220; padding: 14px; border-radius: 18px; background: rgba(255,255,255,0.96); color: var(--text-main); }
.cloud-popover-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; margin-bottom: 8px; }
.cloud-title { font-size: 0.98rem; font-weight: 900; color: var(--primary); line-height: 1.2; }
.cloud-status { margin-top: 3px; font-size: 0.78rem; font-weight: 900; color: var(--text-sec); }
.cloud-close-btn { border: none; background: rgba(255,64,129,0.1); color: var(--primary); width: 28px; height: 28px; border-radius: 50%; font-size: 1.25rem; font-weight: 900; cursor: pointer; line-height: 1; display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; }
.cloud-message { margin: 8px 0 12px; color: var(--text-sec); font-size: 0.78rem; line-height: 1.45; font-weight: 700; }
.cloud-login-form { display: grid; gap: 8px; }
.cloud-input { width: 100%; min-height: 36px; padding: 8px 10px; border-radius: 12px; border: 1px solid rgba(255,64,129,0.24); background: rgba(255,255,255,0.88); color: var(--text-main); font-weight: 700; outline: none; }
.cloud-input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(255,64,129,0.12); }
.cloud-form-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.cloud-actions { display: grid; gap: 10px; }
.cloud-user-pill { padding: 7px 10px; border-radius: 12px; background: rgba(255,64,129,0.09); color: var(--primary); font-size: 0.78rem; font-weight: 900; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cloud-auto-note { margin: 0; padding: 8px 10px; border-radius: 12px; background: rgba(255,255,255,0.7); color: var(--text-sec); font-size: 0.76rem; font-weight: 700; line-height: 1.45; }
.cloud-action-btn { min-height: 34px; padding: 8px 10px; border-radius: 12px; border: 1px solid rgba(255,64,129,0.28); background: rgba(255,255,255,0.88); color: var(--primary); font-size: 0.76rem; font-weight: 900; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; text-align: center; line-height: 1.2; }
.cloud-action-btn.primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.cloud-action-btn.danger { color: #C62828; border-color: rgba(198,40,40,0.25); }
.cloud-action-btn:disabled, .cloud-input:disabled { opacity: 0.55; cursor: not-allowed; }

.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; }

/* Enhanced ripple with clearer contrast and a white gradient ring. */
.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); }
.tool-icon { width: 1.05em; height: 1.05em; display: inline-block; flex: 0 0 auto; color: currentColor; background: currentColor; -webkit-mask: var(--tool-icon) center/contain no-repeat; mask: var(--tool-icon) center/contain no-repeat; }
.intro-signal { width: 28px; height: 28px; color: var(--primary); animation: blink 1.5s infinite; }
.mode-card h2, .leaderboard-title { display: inline-flex; align-items: center; justify-content: center; gap: 8px; }
.mode-icon { width: 1.15em; height: 1.15em; }
.tool-icon-home { --tool-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='black'%3E%3Cpath d='M3 11 12 3l9 8h-3v9h-5v-6h-2v6H6v-9H3z'/%3E%3C/svg%3E"); }
.tool-icon-book { --tool-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='black'%3E%3Cpath d='M5 4c2.8 0 4.7.5 6 1.5V20c-1.3-1-3.2-1.5-6-1.5V4Zm14 0v14.5c-2.8 0-4.7.5-6 1.5V5.5C14.3 4.5 16.2 4 19 4Z'/%3E%3C/svg%3E"); }
.tool-icon-download { --tool-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='black'%3E%3Cpath d='M11 3h2v9l3-3 1.4 1.4L12 15.8l-5.4-5.4L8 9l3 3V3Zm-6 14h14v4H5v-4Z'/%3E%3C/svg%3E"); }
.tool-icon-link { --tool-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='3' stroke-linecap='round'%3E%3Cpath d='M9 7H7a5 5 0 0 0 0 10h2'/%3E%3Cpath d='M15 7h2a5 5 0 0 1 0 10h-2'/%3E%3Cpath d='M8 12h8'/%3E%3C/svg%3E"); }
.tool-icon-rank, .mode-icon-classic { --tool-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='black'%3E%3Cpath d='M7 4h10v4a5 5 0 0 1-4 4.9V16h3v2H8v-2h3v-3.1A5 5 0 0 1 7 8V4Zm-4 1h3v2H5v2H3V5Zm15 0h3v4h-2V7h-1V5Z'/%3E%3C/svg%3E"); }
.tool-icon-spark { --tool-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='black'%3E%3Cpath d='M12 2 9.8 8.8 3 11l6.8 2.2L12 20l2.2-6.8L21 11l-6.8-2.2L12 2Z'/%3E%3C/svg%3E"); }
.mode-icon-casual { --tool-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='black'%3E%3Cpath d='M5 8h14v5a6 6 0 0 1-12 0V8Zm14 2h2v2a3 3 0 0 1-3 3v-2a1 1 0 0 0 1-1v-2ZM6 20h12v2H6v-2Z'/%3E%3C/svg%3E"); }
.mode-icon-custom { --tool-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='black'%3E%3Cpath d='M4 7h10v2H4V7Zm12-2h4v6h-4V5ZM10 15h10v2H10v-2Zm-6-2h4v6H4v-6Z'/%3E%3C/svg%3E"); }
.mode-icon-challenge { --tool-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='black'%3E%3Cpath d='M13 2c1 4-2 5.1-2 8 1.3-.7 2-1.9 2.2-3.4C16 8.2 18 11 18 14.4A6 6 0 0 1 6 14c0-2.7 1.8-5.2 4.2-6.8C10 10 12 11 12 11c-.3-3.2 2.2-5 1-9Z'/%3E%3C/svg%3E"); }

.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 { display: flex; align-items: center; justify-content: space-between; gap: 14px; text-align: left; padding: 12px 14px; font-size: 0.75rem; color: var(--text-sec); font-weight: 700; flex-shrink: 0; line-height: 1.4; background: rgba(255,255,255,0.46); border: 1px solid rgba(255,255,255,0.68); border-radius: 18px; box-shadow: 0 10px 28px rgba(44,62,80,0.08); margin: 0 10px 10px; }
.app-footer p { margin: 0; }
.app-footer p + p { margin-top: 3px; font-weight: 900; }
.footer-copy { min-width: 0; flex: 1 1 300px; }
.footer-links { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-start; gap: 10px 14px; flex: 0 0 auto; }
.footer-links a { display: inline-flex; align-items: center; gap: 6px; color: var(--primary-hover); font-weight: 900; text-decoration: none; white-space: nowrap; }
.footer-link-icon { width: 14px; height: 14px; flex: 0 0 auto; background: currentColor; -webkit-mask: var(--footer-icon) center/contain no-repeat; mask: var(--footer-icon) center/contain no-repeat; }
.footer-link-icon-bug { --footer-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m8 2 1.9 1.9'/%3E%3Cpath d='M14.1 3.9 16 2'/%3E%3Cpath d='M9 7h6'/%3E%3Cpath d='M8 7v8a4 4 0 0 0 8 0V7'/%3E%3Cpath d='M3 13h4'/%3E%3Cpath d='M17 13h4'/%3E%3Cpath d='m5 19 3-3'/%3E%3Cpath d='m19 19-3-3'/%3E%3C/svg%3E"); }
.footer-link-icon-heart { --footer-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='black'%3E%3Cpath d='M12 21s-7.5-4.4-10-9.2C.3 8.5 2.3 4.5 6 4.2c2.1-.2 3.7.9 4.7 2.2.4.5 1 .5 1.4 0 1-1.3 2.6-2.4 4.7-2.2 3.7.3 5.7 4.3 4 7.6C19.5 16.6 12 21 12 21z'/%3E%3C/svg%3E"); }

@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; }
    .topbar-right { gap: 4px; }
    .tool48-home-link { min-height: 32px; padding: 5px 8px; font-size: 0.7rem; }
    .account-toggle { min-width: 32px; max-width: 40px; padding: 4px 8px; }
    .account-toggle-label { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
    .account-popover { top: 48px; right: 8px; width: calc(100vw - 16px); padding: 12px; }
    .cloud-form-actions { grid-template-columns: 1fr; }
    .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 {
        align-items: center;
        flex-direction: row;
        flex-wrap: wrap;
        gap: 6px 10px;
        text-align: left;
        font-size: 0.58rem;
        line-height: 1.35;
        padding: 8px 10px;
    }
    .footer-copy { flex: 1 1 220px; }
    .footer-copy p { display: inline; }
    .footer-copy p + p { margin-top: 0; }
    .footer-copy p + p::before { content: " "; }
    .footer-links { width: auto; gap: 8px 10px; flex: 0 0 auto; }
    .footer-link-icon { width: 12px; height: 12px; }
}
