/* style.css - 《天台切菜》(Rooftop Chop) Responsive Stylesheet */
/* Chrome 61 Baseline Compatible: No flexbox gap, no aspect-ratio, no inset shorthand */
/* v2 Visual Refresh: layered dusk gradients, glow tokens, per-difficulty accents */

:root {
  --ui-font: "SimHei", "Heiti SC", "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
  --color-bg-dark: #0d1117;
  --color-primary: #00d2d3;
  --color-primary-hover: #48dbfb;
  --color-accent-red: #ff4757;
  --color-accent-gold: #fed330;
  --color-accent-green: #2ed573;
  --color-text-light: #f4f7fb;
  --color-text-muted: #9aa8ba;
  --color-surface: rgba(28, 36, 48, 0.92);
  --color-surface-card: rgba(40, 50, 66, 0.96);
  --glow-primary: 0 6px 24px rgba(0, 210, 211, 0.45);
  --glow-gold: 0 6px 24px rgba(254, 211, 48, 0.40);
  --ring-soft: inset 0 1px 0 rgba(255, 255, 255, 0.14);
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
}

html, body {
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: #070a0d;
  background-image:
    radial-gradient(circle at 50% 50%, rgba(26, 47, 51, 0.4) 0%, rgba(7, 10, 13, 0.95) 80%),
    linear-gradient(#0c1117 1px, transparent 1px),
    linear-gradient(90deg, #0c1117 1px, transparent 1px);
  background-size: 100% 100%, 32px 32px, 32px 32px;
  font-family: var(--ui-font);
  color: var(--color-text-light);
}

button, input, select, textarea { font-family: var(--ui-font); }

/* App Container locked to 19.5:9 Portrait (450x975 design space scaled uniformly) */
#app {
  /* Reserve the strip above the original home settings bottom (1.05% + 5%). */
  --top-safe-area-height: 6.05%;
  --top-safe-area-gap: 8px;
  position: absolute;
  top: 50%;
  left: 50%;
  width: 450px;
  height: 975px;
  max-width: none;
  max-height: none;
  overflow: hidden;
  flex-shrink: 0;
  border-radius: 18px;
  border: 2px solid #5a8579;
  background-color: var(--color-bg-dark);
  box-shadow:
    0 0 0 1px #1d3336,
    0 0 0 6px #0d1a1c,
    0 18px 60px rgba(0, 0, 0, 0.9),
    0 0 80px rgba(45, 95, 85, 0.25);
  transform-origin: center center;
  transform: translate(-50%, -50%) scale(var(--app-scale, 1));
}

/* Safe Area Inset Support (with Chrome 61 fallbacks) */
.safe-area-top {
  padding-top: 16px;
  padding-top: constant(safe-area-inset-top);
  padding-top: env(safe-area-inset-top);
}

.safe-area-bottom {
  padding-bottom: 24px;
  padding-bottom: constant(safe-area-inset-bottom);
  padding-bottom: env(safe-area-inset-bottom);
}

/* Screen Management */
.screen {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  padding: 24px 20px;
  background-size: cover;
  background-position: center;
  z-index: 10;
}

.screen.active {
  display: flex;
}

/* Common Typography & Layout Components */
.brand-title {
  font-size: 40px;
  font-weight: 900;
  letter-spacing: 3px;
  text-align: center;
  background-image: linear-gradient(135deg, #ffffff 20%, #8be9e9 60%, #00d2d3 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: var(--color-text-light); /* fallback when clip unsupported */
  text-shadow: 0 4px 24px rgba(0, 210, 211, 0.25);
  margin-bottom: 6px;
}

.brand-subtitle {
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 5px;
  text-align: center;
  color: var(--color-primary);
  text-transform: uppercase;
  opacity: 0.85;
  margin-bottom: 30px;
}

/* Arcade Buttons (Chrome 61 compatible: margins instead of flex gap) */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 54px;
  padding: 13px 28px;
  border-radius: 27px;
  font-size: 17px;
  font-weight: 800;
  letter-spacing: 1.5px;
  text-align: center;
  cursor: pointer;
  border: none;
  outline: none;
  transition: transform 0.1s ease, background-color 0.2s ease, box-shadow 0.2s ease, filter 0.2s ease;
  margin: 6px 0;
}

.btn:active {
  transform: scale(0.96);
  filter: brightness(1.12);
}

.btn-primary {
  background: linear-gradient(135deg, #38e6e7 0%, #00b8b9 55%, #018a8b 100%);
  color: #06212a;
  box-shadow: var(--glow-primary), var(--ring-soft);
}

.btn-primary:active {
  background: #01a3a4;
}

.btn-primary:disabled {
  background: rgba(255, 255, 255, 0.10);
  color: rgba(255, 255, 255, 0.35);
  box-shadow: none;
  cursor: not-allowed;
}

.btn-secondary {
  background: var(--color-surface-card);
  color: var(--color-text-light);
  border: 1.5px solid rgba(255, 255, 255, 0.14);
  box-shadow: var(--ring-soft);
}

.btn-secondary:active {
  border-color: rgba(0, 210, 211, 0.5);
}

.btn-accent {
  background: linear-gradient(135deg, #ff7b7b 0%, #ee5253 60%, #d63031 100%);
  color: #ffffff;
  box-shadow: 0 6px 20px rgba(238, 82, 83, 0.4), var(--ring-soft);
}

.btn-block {
  width: 100%;
}

.btn-pulse {
  animation: pulse-glow 1.8s infinite;
}

@keyframes pulse-glow {
  0% { box-shadow: 0 0 0 0 rgba(0, 210, 211, 0.55), var(--ring-soft); }
  70% { box-shadow: 0 0 0 16px rgba(0, 210, 211, 0), var(--ring-soft); }
  100% { box-shadow: 0 0 0 0 rgba(0, 210, 211, 0), var(--ring-soft); }
}

/* Card Containers */
.card {
  width: 100%;
  background: var(--color-surface);
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: 20px;
  padding: 20px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.55), var(--ring-soft);
  margin-bottom: 16px;
}

/* Screen: Home */
#screen-home {
  background:
    radial-gradient(circle at 50% 12%, rgba(91, 42, 110, 0.55) 0%, rgba(91, 42, 110, 0) 55%),
    radial-gradient(circle at 50% 105%, rgba(0, 210, 211, 0.16) 0%, rgba(0, 210, 211, 0) 50%),
    linear-gradient(180deg, #141432 0%, #0d1117 78%);
  justify-content: center;
}

.home-hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: 44px;
}

.home-icon-wrap {
  width: 116px;
  height: 116px;
  border-radius: 32px;
  background: linear-gradient(145deg, #38e6e7 0%, #2e86de 90%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 56px;
  margin-bottom: 22px;
  box-shadow: 0 14px 34px rgba(0, 210, 211, 0.40), var(--ring-soft);
  animation: hero-float 3.2s ease-in-out infinite;
}

@keyframes hero-float {
  0% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
  100% { transform: translateY(0); }
}

.home-menu-list {
  width: 100%;
  max-width: 320px;
}

/* Screen: Song Select */
#screen-song-select {
  background:
    radial-gradient(circle at 50% 0%, rgba(43, 16, 85, 0.45) 0%, rgba(43, 16, 85, 0) 60%),
    #10151d;
}

.song-list-scroll {
  width: 100%;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  margin: 16px 0;
  -webkit-overflow-scrolling: touch;
}

.song-item {
  width: 100%;
  background: var(--color-surface);
  border: 2px solid rgba(255, 255, 255, 0.07);
  border-radius: 18px;
  padding: 16px 18px;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  box-shadow: var(--ring-soft);
  transition: border-color 0.15s ease, background-color 0.15s ease, transform 0.1s ease;
}

.song-item:active {
  transform: scale(0.985);
}

.song-item.selected {
  border-color: var(--color-primary);
  background: rgba(0, 210, 211, 0.10);
  box-shadow: 0 0 0 3px rgba(0, 210, 211, 0.18), var(--ring-soft);
}

.song-info h3 {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 4px;
}

.song-meta {
  font-size: 13px;
  color: var(--color-text-muted);
}

/* Difficulty Selector — per-difficulty accent colors */
.difficulty-group {
  display: flex;
  width: 100%;
  margin-bottom: 16px;
}

.diff-btn {
  flex: 1;
  padding: 11px 0;
  margin: 0 4px;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: var(--color-surface-card);
  color: var(--color-text-muted);
  font-size: 14px;
  font-weight: 800;
  letter-spacing: 1px;
  text-align: center;
  cursor: pointer;
  box-shadow: var(--ring-soft);
  transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.diff-btn:first-child { margin-left: 0; }
.diff-btn:last-child { margin-right: 0; }

#btn-diff-easy.selected,
#btn-upload-diff-easy.selected {
  background: linear-gradient(135deg, #55ef9a, #20bf6b);
  color: #062515;
  border-color: transparent;
}

#btn-diff-normal.selected,
#btn-upload-diff-normal.selected {
  background: linear-gradient(135deg, #38e6e7, #01a3a4);
  color: #06212a;
  border-color: transparent;
}

#btn-diff-hard.selected,
#btn-upload-diff-hard.selected {
  background: linear-gradient(135deg, #ff8a8a, #e84118);
  color: #2b0602;
  border-color: transparent;
}

/* Screen: Upload & Analysis */
#screen-upload {
  background:
    radial-gradient(circle at 50% 0%, rgba(43, 16, 85, 0.45) 0%, rgba(43, 16, 85, 0) 60%),
    #10151d;
}

.upload-dropzone {
  position: relative;
  width: 100%;
  border: 2px dashed rgba(0, 210, 211, 0.45);
  border-radius: 22px;
  padding: 32px 20px;
  text-align: center;
  background: rgba(0, 210, 211, 0.05);
  cursor: pointer;
  margin-bottom: 20px;
  transition: background-color 0.15s ease, border-color 0.15s ease;
}

.upload-dropzone:active {
  background: rgba(0, 210, 211, 0.12);
  border-color: rgba(0, 210, 211, 0.8);
}

.upload-icon {
  font-size: 44px;
  margin-bottom: 12px;
}

#audio-file-input {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  margin: 0; padding: 0;
  opacity: 0;
  z-index: 1;
  cursor: pointer;
  font-size: 16px;
}
.upload-dropzone.picker-focused { outline: 3px solid #ffe09a; outline-offset: 3px; }
.upload-picker-message { font-size: 12px; line-height: 1.5; margin: 0 0 10px; }
.upload-picker-message:empty { display: none; }

.progress-container {
  width: 100%;
  height: 12px;
  background: rgba(255, 255, 255, 0.10);
  border-radius: 6px;
  overflow: hidden;
  margin: 14px 0 8px 0;
}

.progress-fill {
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, #00d2d3, #2ed573);
  border-radius: 6px;
  box-shadow: 0 0 12px rgba(0, 210, 211, 0.55);
  transition: width 0.15s ease;
}

.status-label {
  font-size: 13px;
  color: var(--color-text-muted);
  text-align: center;
}

.features-grid {
  display: flex;
  justify-content: space-around;
  margin: 16px 0;
}

.feature-box {
  text-align: center;
}

.feature-val {
  font-size: 22px;
  font-weight: 800;
  color: var(--color-primary);
  font-variant-numeric: tabular-nums;
}

.feature-lbl {
  font-size: 12px;
  color: var(--color-text-muted);
}

/* Screen: Gameplay & Canvas */
#screen-gameplay {
  padding: 0;
  background: #000000;
  overflow: hidden;
}

#game-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: block;
}

/* In-Game HUD Overlays */
.game-hud-top {
  position: absolute;
  top: var(--top-safe-area-height);
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 16px 8px 16px;
  padding-top: max(16px, env(safe-area-inset-top));
  z-index: 20;
  pointer-events: none;
}

.hud-score-box {
  font-size: 28px;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  color: #ffffff;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.85), 0 0 18px rgba(0, 210, 211, 0.35);
}

.hud-progress-bar-wrap {
  flex: 1;
  height: 6px;
  background: rgba(255, 255, 255, 0.18);
  border-radius: 3px;
  margin: 0 16px;
  overflow: hidden;
}

.hud-progress-fill {
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, #00d2d3, #48e5e6);
  border-radius: 3px;
  box-shadow: 0 0 8px rgba(0, 210, 211, 0.7);
}

.btn-icon-pause {
  width: 42px;
  height: 42px;
  border-radius: 21px;
  background: rgba(28, 36, 48, 0.80);
  border: 1px solid rgba(255, 255, 255, 0.22);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  pointer-events: auto;
  color: #ffffff;
  font-size: 16px;
  box-shadow: var(--ring-soft);
}

/* Combo Banner */
.hud-combo-display {
  position: absolute;
  top: 24%;
  left: 0;
  right: 0;
  text-align: center;
  font-size: 36px;
  font-weight: 900;
  letter-spacing: 2px;
  color: var(--color-accent-gold);
  text-shadow: 0 3px 14px rgba(254, 211, 48, 0.65), 0 1px 3px rgba(0, 0, 0, 0.8);
  pointer-events: none;
  z-index: 20;
}

.combo-pulse {
  animation: combo-pop 0.12s ease-out;
}

@keyframes combo-pop {
  0% { transform: scale(1.0); }
  50% { transform: scale(1.25); }
  100% { transform: scale(1.0); }
}

/* Floating Judgment Banner */
.hud-judgment {
  position: absolute;
  top: 64%;
  left: 0;
  right: 0;
  text-align: center;
  font-size: 30px;
  font-weight: 900;
  letter-spacing: 2px;
  pointer-events: none;
  opacity: 0;
  z-index: 20;
}

.hud-judgment.active {
  animation: judgment-fade 0.4s ease-out forwards;
}

.judgment-perfect { color: var(--color-accent-gold); text-shadow: 0 0 14px rgba(254, 211, 48, 0.85), 0 2px 4px rgba(0,0,0,0.7); }
.judgment-great { color: var(--color-primary); text-shadow: 0 0 14px rgba(0, 210, 211, 0.85), 0 2px 4px rgba(0,0,0,0.7); }
.judgment-good { color: var(--color-accent-green); text-shadow: 0 0 14px rgba(46, 213, 115, 0.85), 0 2px 4px rgba(0,0,0,0.7); }
.judgment-miss { color: var(--color-accent-red); text-shadow: 0 0 14px rgba(255, 71, 87, 0.85), 0 2px 4px rgba(0,0,0,0.7); }

@keyframes judgment-fade {
  0% { opacity: 1; transform: translateY(0) scale(1.2); }
  100% { opacity: 0; transform: translateY(-22px) scale(1.0); }
}

/* Multi-touch Lower 55% Touch Hotzones */
.touch-hotzones-container {
  position: absolute;
  top: 45%;
  bottom: 0;
  left: 5%;
  right: 5%;
  display: flex;
  z-index: 25;
}

.touch-hotzone {
  flex: 1;
  height: 100%;
  touch-action: none;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: center;
  padding-bottom: max(20px, env(safe-area-inset-bottom));
  background: transparent;
  transition: background-color 0.08s ease;
  user-select: none;
  -webkit-user-select: none;
}

.touch-hotzone:active {
  background: rgba(0, 210, 211, 0.15);
}

.key-guide-pill {
  width: 50px;
  height: 30px;
  border-radius: 15px;
  background: rgba(20, 26, 36, 0.65);
  border: 1px solid rgba(255, 255, 255, 0.28);
  color: rgba(255, 255, 255, 0.9);
  font-size: 13px;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  box-shadow: var(--ring-soft);
}

/* 3-2-1-GO! Countdown Overlay */
.countdown-overlay {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(4, 6, 10, 0.62);
  z-index: 50;
  pointer-events: none;
}

.countdown-overlay.active {
  display: flex;
}

.countdown-text {
  font-size: 120px;
  font-weight: 900;
  color: var(--color-accent-gold);
  text-shadow: 0 0 36px rgba(254, 211, 48, 0.85), 0 4px 8px rgba(0, 0, 0, 0.6);
  animation: countdown-pop 0.8s infinite;
}

@keyframes countdown-pop {
  0% { transform: scale(0.6); opacity: 0.2; }
  40% { transform: scale(1.15); opacity: 1; }
  100% { transform: scale(1.0); opacity: 0.9; }
}

/* Modal: Pause & Calibration */
.modal-overlay {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(4, 6, 10, 0.78);
  padding: 24px;
  z-index: 60;
}

.modal-overlay.active {
  display: flex;
}

.modal-dialog {
  width: 100%;
  max-width: 360px;
  background: var(--color-surface);
  border: 1px solid rgba(255, 255, 255, 0.13);
  border-radius: 26px;
  padding: 28px 24px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.85), var(--ring-soft);
}

.modal-title {
  font-size: 24px;
  font-weight: 800;
  text-align: center;
  margin-bottom: 20px;
}

.slider-group {
  margin: 20px 0;
}

.slider-header {
  display: flex;
  justify-content: space-between;
  margin-bottom: 8px;
  font-size: 14px;
  color: var(--color-text-muted);
}

.range-slider {
  width: 100%;
  height: 8px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.18);
  outline: none;
  -webkit-appearance: none;
}

.range-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: linear-gradient(135deg, #48e5e6, #01a3a4);
  cursor: pointer;
  box-shadow: 0 0 12px rgba(0, 210, 211, 0.85);
}

/* Screen: Result Settlement */
#screen-result {
  background:
    radial-gradient(circle at 50% 22%, rgba(91, 42, 110, 0.5) 0%, rgba(91, 42, 110, 0) 55%),
    radial-gradient(circle at 50% 100%, rgba(0, 210, 211, 0.12) 0%, rgba(0, 210, 211, 0) 45%),
    linear-gradient(180deg, #141432 0%, #0d1117 80%);
  justify-content: center;
}

.result-card {
  width: 100%;
  max-width: 340px;
  background: var(--color-surface);
  border: 1px solid rgba(255, 255, 255, 0.11);
  border-radius: 26px;
  padding: 28px 20px;
  text-align: center;
  box-shadow: 0 18px 44px rgba(0, 0, 0, 0.65), var(--ring-soft);
  margin-bottom: 24px;
}

.rank-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 104px;
  height: 104px;
  border-radius: 52px;
  font-size: 64px;
  font-weight: 900;
  margin: 10px 0 16px 0;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5), var(--ring-soft);
}

.rank-s { background: linear-gradient(135deg, #ffe082, #f39c12); color: #201400; box-shadow: 0 0 36px rgba(254, 211, 48, 0.65), var(--ring-soft); }
.rank-a { background: linear-gradient(135deg, #48e5e6, #018a8b); color: #04222a; }
.rank-b { background: linear-gradient(135deg, #55ef9a, #159e54); color: #04220f; }
.rank-c { background: linear-gradient(135deg, #ffb26b, #e67e22); color: #2b1400; }
.rank-d { background: linear-gradient(135deg, #8b98a9, #2f3542); color: #eef2f7; }

.result-score-large {
  font-size: 40px;
  font-weight: 900;
  color: #ffffff;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 2px 12px rgba(0, 210, 211, 0.35);
  margin-bottom: 6px;
}

.result-stats-table {
  width: 100%;
  margin: 18px 0;
  border-collapse: collapse;
}

.result-stats-table td {
  padding: 7px 10px;
  font-size: 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.result-stats-table tr:last-child td {
  border-bottom: none;
}

.result-stats-table td:last-child {
  text-align: right;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.stat-p { color: var(--color-accent-gold); }
.stat-g { color: var(--color-primary); }
.stat-gd { color: var(--color-accent-green); }
.stat-m { color: var(--color-accent-red); }

#home-import-notice {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  z-index: 120;
  width: calc(100% - 64px);
  max-width: 360px;
  padding: 18px 22px;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.78);
  color: #fff;
  font-size: 16px;
  line-height: 1.65;
  text-align: center;
  text-shadow: none;
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.18s ease, visibility 0.18s;
}
#home-import-notice.visible { opacity: 1; visibility: visible; }
