/* 1. Custom Font */
@font-face {
  font-family: 'NewRodin';
  src: url('./FOT-NewRodin Pro EB.otf') format('opentype');
  font-weight: bold; font-style: normal; font-display: swap;
}

:root {
  --bg: #0b0f12; --surface: #12171c; --surface-2: #1c242c; --text: #ffffff;
  --muted: #a0a0a0; --accent: #5ad1ff; --border: #2c363f; --shadow: 0 10px 50px rgba(0,0,0,0.8);
}

.lv-0 { background-color: #053d87 !important; }
.lv-1 { background-color: #3e8a24 !important; }
.lv-2 { background-color: #6a6a21 !important; }
.lv-3 { background-color: #950000 !important; }
.lv-4 { background-color: #7c157c !important; }
.lv-5 { background-color: #f48df4 !important; color: #000 !important; }
.lv-6 { background-color: #cc7400 !important; }

html, body { background-color: #0b0f12; color: #ffffff; margin: 0; padding: 0; width: 100%; min-height: 100%; }
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
body { font-family: 'NewRodin', sans-serif; line-height: 1.4; overflow-x: hidden; }
a { text-decoration: none; color: inherit; }

/* Header & Navigation */
.site-header { position: relative; z-index: 100; background: rgba(11, 15, 18, 0.95); border-bottom: 1px solid var(--border); width: 100%; padding: 15px 0; }
.header-inner { max-width: 1500px; margin: 0 auto; padding: 0 16px; display: flex; flex-direction: column; gap: 15px; }
.brand { display: flex; flex-direction: column; width: 100%; }
.logo { font-size: 20px; font-weight: bold; color: #fff; margin-bottom: 4px; }
.song-header-actions { display: flex; align-items: center; gap: 12px; }
.song-header-actions .logo { margin-bottom: 0; }
.header-fullscreen-btn { display: none; min-width: 110px; width: auto; }
.subtitle { font-size: 10px; color: var(--muted); line-height: 1.4; word-break: break-all; }
.subtitle a { color: var(--accent); text-decoration: underline; }

.user-status { font-size: 11px; margin-top: 6px; color: var(--muted); border-top: 1px solid var(--border); padding-top: 6px; }
.user-status b { color: #fff; }
.user-status a { color: var(--accent); font-weight: bold; }

/* Controls Area */
.controls-area { display: flex; flex-direction: column; gap: 10px; width: 100%; }
.top-row { display: flex; align-items: flex-end; justify-content: flex-start; gap: 4px; flex-wrap: wrap; }
.bottom-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.bottom-row input[type="search"] { grid-column: span 2; }

.btn-tool, .tool-select, .search-bar input {
  background: var(--surface-2); border: 1px solid var(--border); color: #fff;
  padding: 8px 10px; border-radius: 8px; font-family: 'NewRodin'; font-size: 13px; outline: none; width: 100%;
  display: flex; align-items: center; justify-content: center; text-align: center;
  white-space: pre-line; line-height: 1.1;
}
.btn-tool { cursor: pointer; transition: 0.2s; min-width: 65px; width: auto; }
.btn-tool:hover:not(:disabled) { background: var(--accent); color: #000; }
.btn-tool:disabled { opacity: 0.3; cursor: not-allowed; }

body.lang-zh .btn-tool { font-size: 11px; }
body.lang-en .btn-tool { font-size: 9px; }

.video-setting { display: flex; flex-direction: column; align-items: center; gap: 1px; font-size: 9px; color: var(--muted); min-width: 38px; margin-left: 0px; }
.top-row .video-setting + .video-setting { margin-left: 2px; }

.switch { position: relative; width: 32px; height: 16px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider { position: absolute; cursor: pointer; inset: 0; background: var(--border); border-radius: 34px; transition: 0.4s; }
.slider:before { position: absolute; content: ""; height: 12px; width: 12px; left: 2px; bottom: 2px; background: white; border-radius: 50%; transition: 0.4s; }
input:checked + .slider { background: var(--accent); }
input:checked + .slider:before { transform: translateX(16px); }

/* Grid & Cards */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; }
.card-wrapper { position: relative; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; overflow: hidden; transition: 0.3s; display: block; }
.img-container { width: 100%; aspect-ratio: 1 / 1; overflow: hidden; background: #000; contain: paint; }
.cover { width: 100%; height: 100%; object-fit: cover; transition: 0.5s; }
.card:hover { transform: translateY(-5px); border-color: var(--accent); box-shadow: 0 10px 30px rgba(0,0,0,0.5); }
.card:hover .cover { transform: scale(1.1); }
.meta { padding: 12px; }
.title { font-size: 13px; font-weight: bold; margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sub { font-size: 11px; color: var(--muted); margin-top: 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.badges { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 10px; }
.badge { font-size: 8px; padding: 2px 6px; border-radius: 4px; font-weight: bold; color: #fff; }

.pagination { display: flex; justify-content: center; align-items: center; gap: 10px; margin: 40px 0; padding: 0 16px; }
.page-info { font-size: 13px; color: var(--muted); font-weight: bold; }
.page-jump { display: flex; align-items: center; gap: 6px; }
.page-jump-input {
  width: 68px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: 8px 10px;
  font-family: 'NewRodin';
  font-size: 12px;
  text-align: center;
}
.page-jump-btn { min-width: 52px; }

/* Favorites */
.fav-click-area { cursor: pointer; display: flex; align-items: center; justify-content: center; transition: 0.2s; user-select: none; z-index: 5; }
.heart-icon { fill: #333; transition: fill 0.3s; }
.fav-click-area.active .heart-icon { fill: #ff4e4e; }
.card-fav { position: absolute; top: 10px; right: 10px; filter: drop-shadow(0 2px 4px rgba(0,0,0,0.8)); }
.card-fav .heart-icon { width: 36px; height: 36px; }

.back-to-top { position: fixed; bottom: 30px; right: 20px; width: 50px; height: 50px; background-color: var(--accent); color: #000; border: none; border-radius: 50%; display: none; align-items: center; justify-content: center; font-size: 24px; font-weight: bold; cursor: pointer; z-index: 999; box-shadow: 0 4px 15px rgba(0, 0, 0, 0.4); }

@media (min-width: 768px) {
  .site-header { position: sticky; top: 0; }
  .header-inner { flex-direction: row; align-items: center; padding: 0 24px; gap: 30px; }
  .controls-area { width: auto; align-items: flex-end; margin-left: auto; min-width: 650px; }
  .top-row { justify-content: flex-end; gap: 12px; }
  .video-setting { min-width: 50px; gap: 4px; margin-left: 5px; }
  .bottom-row { display: flex; gap: 10px; width: 100%; justify-content: flex-end; }
  #sortSelect { width: 120px; flex-shrink: 0; }
  #lvFilter { width: 140px; flex-shrink: 0; }
  .bottom-row input[type="search"] { width: 300px; flex-shrink: 1; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 20px; }
}

/* Player & Guess Mode Layout */
.player-page { display: flex; flex-direction: column; width: 100vw; height: auto; overflow: hidden; }
.unity-wrapper { width: 100%; aspect-ratio: 1 / 1; background: #000; position: relative; flex-shrink: 0; overflow: hidden; max-width: 100vw; max-height: 100vh; }
#unity-canvas { width: 100% !important; height: 100% !important; max-width: 100% !important; max-height: 100% !important; display: block; }
.info-panel { width: 100%; padding: 40px 20px; display: flex; flex-direction: column; justify-content: center; align-items: center; text-align: center; gap: 24px; background: var(--bg); }

.loading-overlay { position: absolute; inset: 0; background-color: #0b0f12; z-index: 100; display: flex; flex-direction: column; align-items: center; justify-content: center; pointer-events: none; }
.progress-container { width: 60%; max-width: 400px; height: 6px; background: var(--surface-2); border-radius: 10px; overflow: hidden; margin-bottom: 15px; border: 1px solid var(--border); }
.progress-bar { width: 0%; height: 100%; background: var(--accent); transition: width 0.3s ease; box-shadow: 0 0 10px var(--accent); }
.progress-text { font-size: 16px; color: var(--text); font-weight: bold; }

.info-panel .heart-icon { width: 64px; height: 64px; }
.song-main-stats { display: flex; gap: 30px; background: var(--surface); padding: 15px 25px; border-radius: 12px; border: 1px solid var(--border); width: fit-content; }
.stat-item { display: flex; flex-direction: column; gap: 4px; }
.stat-label { font-size: 10px; color: var(--muted); text-transform: uppercase; }
.stat-value { font-size: 20px; font-weight: bold; color: var(--accent); }

.level-grid { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }
.btn-lv { padding: 12px 20px; border: none; border-radius: 8px; color: #fff; font-weight: bold; cursor: pointer; transition: 0.2s; }
.btn-download { padding: 15px; border: 2px solid var(--accent); border-radius: 10px; background: transparent; color: var(--accent); font-weight: bold; cursor: pointer; width: 100%; max-width: 320px; }
.btn-play { width: 40px; height: 40px; border-radius: 50%; border: 2px solid var(--accent); background: transparent; color: var(--accent); font-size: 34px; cursor: pointer; transition: 0.2s; display: flex; align-items: center; justify-content: center; }
.btn-play:hover { background: var(--accent); color: #000; }
.btn-ctrl { width: 40px; height: 40px; border-radius: 50%; border: 2px solid var(--muted); background: transparent; color: var(--muted); cursor: pointer; transition: 0.2s; display: flex; align-items: center; justify-content: center; }
.btn-ctrl:hover { border-color: var(--accent); color: var(--accent); }

/* Player controls overlay */
.player-controls { position: absolute; bottom: 0; left: 0; right: 0; z-index: 10; width: 100%; max-width: none; margin-top: 0; padding: 23px 23px 18px; box-sizing: border-box; display: flex; flex-direction: column; gap: 11px; background: linear-gradient(transparent, rgba(0,0,0,0.75)); pointer-events: auto; }
.player-time-row { display: flex; align-items: center; gap: 14px; }
.time-label { font-size: 18px; color: #fff; min-width: 52px; text-align: center; font-variant-numeric: tabular-nums; text-shadow: 0 1px 3px rgba(0,0,0,0.8); }
.seek-bar { flex: 1; -webkit-appearance: none; appearance: none; height: 9px; border-radius: 5px; background: var(--border); outline: none; cursor: pointer; }
.seek-bar::-webkit-slider-thumb { -webkit-appearance: none; appearance: none; width: 20px; height: 20px; border-radius: 50%; background: var(--accent); cursor: pointer; border: none; }
.seek-bar::-moz-range-thumb { width: 20px; height: 20px; border-radius: 50%; background: var(--accent); cursor: pointer; border: none; }
.player-buttons-row { display: flex; align-items: center; justify-content: center; gap: 23px; }
.player-controls--panel { position: relative; bottom: auto; left: auto; right: auto; width: 100%; max-width: 500px; background: none; padding-left: 0; padding-right: 0; }
.player-controls--panel .time-label { color: var(--text); text-shadow: none; }

/* Guess Mode Specific Styles */
.guess-clues { 
    display: flex; 
    gap: 30px; 
    background: var(--surface); 
    padding: 15px 25px; 
    border-radius: 12px; 
    border: 1px solid var(--border); 
    margin-bottom: 20px;
    flex-wrap: wrap; /* 关键修复：允许换行 */
    justify-content: center;
}

/* 手机端线索区纵向排列 */
@media (max-width: 480px) {
    .guess-clues {
        flex-direction: column;
        gap: 15px;
        width: 100%;
        align-items: flex-start;
    }
    .guess-clues .stat-item {
        width: 100%;
        border-bottom: 1px solid var(--border);
        padding-bottom: 8px;
    }
    .guess-clues .stat-item:last-child {
        border-bottom: none;
    }
}

.options-grid { 
    display: grid; 
    grid-template-columns: 1fr 1fr; 
    gap: 12px; 
    width: 100%; 
    max-width: 500px;
    order: -1; 
    margin-bottom: 20px;
}
.option-btn { background: var(--surface-2); border: 1px solid var(--border); color: #fff; padding: 15px 10px; border-radius: 8px; font-family: 'NewRodin'; font-size: 14px; cursor: pointer; transition: 0.2s; height: 60px; display: flex; align-items: center; justify-content: center; text-align: center; overflow: hidden; }
.option-btn:hover:not(.correct):not(.wrong) { border-color: var(--accent); }
.option-btn.correct { background: #3e8a24 !important; border-color: #5ad1ff !important; color: #fff !important; }
.option-btn.wrong { background: #950000 !important; border-color: #ff4e4e !important; color: #fff !important; }

@media (min-width: 1024px) {
  .header-fullscreen-btn { display: inline-flex; }
  .player-page { flex-direction: row-reverse; height: calc(100vh - 70px); align-items: center; justify-content: center; }
  #playerControlsMobileAnchor { display: none !important; }
  .unity-wrapper { height: 100%; width: auto; aspect-ratio: 1 / 1; }
  .info-panel { flex: 1; height: 100%; padding: 60px; overflow-y: auto; scrollbar-width: none; display: flex; flex-direction: column; justify-content: flex-start; }
  .info-panel::-webkit-scrollbar { display: none; }
  .info-panel > * { flex-shrink: 0; }
}

/* Settings Modal */
.settings-gear-btn { font-size: 18px !important; min-width: 36px !important; width: 36px !important; height: 36px; padding: 0 !important; display: flex !important; align-items: center; justify-content: center; }
.settings-modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.7); z-index: 10000; display: flex; align-items: center; justify-content: center; }
.settings-modal { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; width: 90%; max-width: 500px; max-height: 85vh; display: flex; flex-direction: column; }
.settings-modal--index { transform: scale(0.8); transform-origin: center center; }
.settings-modal-header { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.settings-modal-header h2 { margin: 0; font-size: 18px; color: var(--accent); }
.settings-close-btn { background: none; border: none; color: var(--muted); font-size: 20px; cursor: pointer; padding: 4px 8px; }
.settings-close-btn:hover { color: #fff; }
.settings-modal-body { padding: 20px; overflow-y: auto; flex: 1; }
.settings-group { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.settings-group label { font-size: 13px; color: var(--muted); min-width: 120px; flex-shrink: 0; }
.settings-group input[type="range"] { flex: 1; accent-color: var(--accent); }
.settings-value { font-size: 13px; color: var(--accent); font-weight: bold; min-width: 40px; text-align: right; }
.settings-number-input { width: 80px; background: var(--surface-2); border: 1px solid var(--border); color: #fff; padding: 6px 8px; border-radius: 6px; font-family: 'NewRodin'; font-size: 13px; text-align: center; }
.settings-select { flex: 1; max-width: 220px; }
.settings-section-title { font-size: 14px; color: var(--accent); font-weight: bold; margin: 18px 0 10px; border-top: 1px solid var(--border); padding-top: 14px; }
.settings-volumes-grid { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; }
.vol-group { flex-direction: column; align-items: center; gap: 4px; }
.vol-group label { min-width: unset; font-size: 11px; text-align: center; }
.vol-group input[type="range"] { width: 100%; accent-color: var(--accent); }
.vol-group .settings-number-input { width: 60px; }
.vol-group .vol-value { font-size: 10px; min-width: unset; text-align: center; }
.settings-modal-footer { display: flex; gap: 10px; padding: 16px 20px; border-top: 1px solid var(--border); justify-content: flex-end; }
.settings-save-btn { background: var(--accent) !important; color: #000 !important; font-weight: bold; }

/* Song page settings panel */
.song-settings-toggle { background: none; border: 1px solid var(--border); color: var(--accent); padding: 8px 16px; border-radius: 8px; cursor: pointer; font-family: 'NewRodin'; font-size: 13px; transition: 0.2s; }
.song-settings-toggle:hover { background: var(--surface-2); }
.song-settings-panel { width: 100%; max-width: 500px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 20px; margin-top: 12px; display: none; overflow-y: auto; flex-shrink: 0; }
.song-settings-panel.open { display: block; }

.fullscreen-side-progress {
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: min(18vw, 220px);
  min-width: 140px;
  flex-shrink: 0;
}
.fullscreen-controls-anchor { width: 100%; display: flex; justify-content: center; }

.fullscreen-exit-btn {
  position: fixed;
  top: 14px;
  right: 14px;
  z-index: 10001;
  width: auto;
  min-width: 130px;
}

.player-page:fullscreen {
  width: 100vw;
  height: 100vh;
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  gap: min(4vw, 48px);
  padding: 20px;
  background: #0b0f12;
}
.player-page.force-fullscreen {
  width: 100vw;
  height: 100vh;
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  gap: min(4vw, 48px);
  padding: 20px;
  background: #0b0f12;
}

.player-page:fullscreen .info-panel {
  display: none;
}
.player-page.force-fullscreen .info-panel {
  display: none;
}

.player-page:fullscreen .fullscreen-side-progress {
  display: flex !important;
}
.player-page.force-fullscreen .fullscreen-side-progress {
  display: flex !important;
}

.player-page:fullscreen .unity-wrapper {
  width: min(calc(100vw - min(18vw, 220px) - min(4vw, 48px) - 40px), calc(100vh - 40px));
  height: min(calc(100vw - min(18vw, 220px) - min(4vw, 48px) - 40px), calc(100vh - 40px));
  max-width: calc(100vh - 40px);
  max-height: calc(100vh - 40px);
  aspect-ratio: 1 / 1;
}
.player-page.force-fullscreen .unity-wrapper {
  width: min(calc(100vw - min(18vw, 220px) - min(4vw, 48px) - 40px), calc(100vh - 40px));
  height: min(calc(100vw - min(18vw, 220px) - min(4vw, 48px) - 40px), calc(100vh - 40px));
  max-width: calc(100vh - 40px);
  max-height: calc(100vh - 40px);
  aspect-ratio: 1 / 1;
}

.player-page:fullscreen .loading-overlay {
  background: transparent;
}
.player-page.force-fullscreen .loading-overlay {
  background: transparent;
}

.player-page:fullscreen .loading-overlay .progress-container,
.player-page:fullscreen .loading-overlay .progress-text {
  display: none;
}
.player-page.force-fullscreen .loading-overlay .progress-container,
.player-page.force-fullscreen .loading-overlay .progress-text {
  display: none;
}
.player-controls--fullscreen-panel {
  max-width: 320px;
  background: rgba(0, 0, 0, 0.5);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px;
  box-sizing: border-box;
}
.player-controls--fullscreen-panel .time-label { color: #fff; text-shadow: 0 1px 2px rgba(0,0,0,0.8); }
.fallback-fullscreen-active .site-header { display: none; }

@media (orientation: portrait) {
  .player-page:fullscreen {
    flex-direction: column;
    gap: 16px;
    padding: 12px;
  }
  .player-page.force-fullscreen {
    flex-direction: column;
    gap: 16px;
    padding: 12px;
  }
  .player-page:fullscreen .fullscreen-side-progress {
    width: min(80vw, 360px);
    min-width: auto;
    order: 1;
  }
  .player-page.force-fullscreen .fullscreen-side-progress {
    width: min(80vw, 360px);
    min-width: auto;
    order: 1;
  }
  .player-page:fullscreen .unity-wrapper {
    width: min(calc(100vw - 24px), calc(100vh - 140px));
    height: min(calc(100vw - 24px), calc(100vh - 140px));
    max-width: none;
    max-height: none;
  }
  .player-page.force-fullscreen .unity-wrapper {
    width: min(calc(100vw - 24px), calc(100vh - 140px));
    height: min(calc(100vw - 24px), calc(100vh - 140px));
    max-width: none;
    max-height: none;
  }
  .player-controls--fullscreen-panel { max-width: min(80vw, 360px); }
}

@media (max-width: 480px) {
  .settings-modal { width: 95%; max-height: 90vh; }
  .settings-group label { min-width: 90px; font-size: 12px; }
  .settings-volumes-grid { grid-template-columns: 1fr 1fr; }
  .fullscreen-exit-btn { min-width: 108px; }
}
