/* ========================================
   うたたっぷ (Area Tap) ゲームCSS
   ゲーム画面は常にダーク配色（テーマ非依存）
   ======================================== */

/* --- ゲーム専用カラー変数 --- */
.area-tap {
  --at-bg: #0a0a0f;
  --at-bg2: #14141f;
  --at-bg3: #1a1a2e;
  --at-text: #e0e0e0;
  --at-text2: #888;
  --at-text3: #444;
  --at-accent: #7c6aef;
  --at-accent2: #f0a030;
  --at-accent-hover: #6b5ce0;
  --at-border: #2a2a3a;
  --at-danger: #ff3554;
  --at-success: #1eb450;
}

/* --- コンテナ --- */
.area-tap {
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 720px;
  height: 100%;
  margin: 0 auto;
  position: relative;
  background: var(--at-bg);
  color: var(--at-text);
  overflow: hidden;
}

/* --- YouTube Player --- */
.area-tap-player-wrap {
  position: relative;
  width: 100%;
  padding-bottom: 56.25%; /* 16:9 */
  background: #000;
  flex-shrink: 0;
  overflow: hidden;
}

.area-tap-player-wrap > div {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}

.area-tap-player-wrap iframe {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}

/* Player size variants */
.area-tap-player-wrap.player-medium {
  width: 50%;
  padding-bottom: 28.125%; /* 56.25% * 0.5 */
  margin: 0 auto;
}

.area-tap-player-wrap.player-small {
  width: 30%;
  padding-bottom: 16.875%; /* 56.25% * 0.3 */
  margin: 0 auto;
}

.area-tap-player-wrap.player-none {
  display: none;
}

/* --- 開始画面サムネイル --- */
.area-tap-start-thumb {
  width: 100%;
  max-width: 280px;
}

.area-tap-start-thumb img {
  width: 100%;
  border-radius: 8px;
  display: block;
}

/* --- ステータスバー --- */
.area-tap-status {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 12px;
  background: var(--at-bg2);
  border-bottom: 1px solid var(--at-border);
  font-size: 13px;
  font-weight: 600;
  flex-shrink: 0;
  min-height: 36px;
}

.area-tap-status-score {
  color: var(--at-accent);
  font-variant-numeric: tabular-nums;
}

.area-tap-status-combo {
  color: var(--at-accent2);
  font-variant-numeric: tabular-nums;
}

.area-tap-status-miss {
  color: var(--at-danger);
  font-variant-numeric: tabular-nums;
}

.area-tap-status-line {
  color: var(--at-text2);
  font-variant-numeric: tabular-nums;
}

/* --- ガイドテキスト --- */
.area-tap-guide {
  display: flex;
  align-items: center;
  padding: 6px 12px;
  background: var(--at-bg2);
  border-bottom: 1px solid var(--at-border);
  font-size: 14px;
  min-height: 36px;
  flex-shrink: 0;
  overflow: hidden;
  white-space: nowrap;
}

.area-tap-guide-text {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
}

.area-tap-guide-text .done {
  color: var(--at-text2);
}

.area-tap-guide-text .current {
  color: var(--at-accent);
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.area-tap-guide-text .remaining {
  color: var(--at-text);
}

.area-tap-guide-text .skip-prompt {
  color: var(--at-accent);
  font-weight: 600;
  animation: skip-prompt-blink 1.2s ease-in-out infinite;
}

@keyframes skip-prompt-blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* --- プログレスバー --- */
.area-tap-progress {
  display: flex;
  gap: 2px;
  height: 3px;
  flex-shrink: 0;
}

.area-tap-progress-line,
.area-tap-progress-song {
  flex: 1;
  background: var(--at-bg3);
  overflow: hidden;
}

.area-tap-progress-line-fill,
.area-tap-progress-song-fill {
  height: 100%;
  width: 0%;
  transition: width 0.15s ease;
}

.area-tap-progress-line-fill {
  background: var(--at-accent);
}

.area-tap-progress-song-fill {
  background: var(--at-text2);
}

/* --- ゲームアリーナ --- */
.area-tap-arena {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(var(--zone-cols, 2), 1fr);
  grid-template-rows: repeat(var(--zone-rows, 3), 1fr);
  gap: 1px;
  background: var(--at-border);
  touch-action: manipulation;
  -webkit-touch-callout: none;
  user-select: none;
  min-height: 0;
}

/* --- ゾーン --- */
.area-tap-zone {
  position: relative;
  background: var(--at-bg);
  overflow: hidden;
  cursor: pointer;
  transition: background-color 0.1s ease;
}

.area-tap-zone:active {
  background: var(--at-bg2);
}

/* ゾーン番号ラベル（薄く表示） */
.area-tap-zone-label {
  position: absolute;
  top: 4px;
  right: 6px;
  font-size: 11px;
  color: var(--at-text3);
  pointer-events: none;
  font-variant-numeric: tabular-nums;
}

/* --- 断片テキスト --- */
.area-tap-fragment {
  position: absolute;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 15px;
  font-weight: 600;
  color: var(--at-text);
  background: rgba(124, 106, 239, 0.15);
  border: 1px solid rgba(124, 106, 239, 0.3);
  pointer-events: none;
  white-space: nowrap;
  max-width: calc(100% - 8px);
  overflow: hidden;
  text-overflow: ellipsis;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.area-tap-fragment.collected {
  opacity: 0;
  transform: scale(0.8) translateY(-10px);
}

/* --- タップフィードバック --- */
.area-tap-zone.flash-correct {
  animation: zone-correct 0.2s ease;
}

.area-tap-zone.flash-combo {
  animation: zone-combo 0.15s ease;
}

.area-tap-zone.flash-miss {
  animation: zone-miss 0.3s ease;
}

.area-tap-zone.flash-hint {
  animation: zone-hint 0.4s ease;
}

@keyframes zone-correct {
  0%   { background: rgba(30, 180, 80, 0.4); }
  100% { background: var(--at-bg); }
}

@keyframes zone-combo {
  0%   { background: rgba(30, 200, 80, 0.6); }
  50%  { background: rgba(240, 160, 48, 0.4); }
  100% { background: var(--at-bg); }
}

@keyframes zone-miss {
  0%, 20%, 40% { background: rgba(255, 53, 84, 0.3); transform: translateX(3px); }
  10%, 30%     { transform: translateX(-3px); }
  50%          { transform: translateX(0); }
  100%         { background: var(--at-bg); }
}

@keyframes zone-hint {
  0%   { box-shadow: inset 0 0 0 2px rgba(240, 200, 40, 0.8); }
  100% { box-shadow: inset 0 0 0 2px transparent; }
}

/* --- ライン完成演出 --- */
.area-tap-line-complete {
  animation: line-flash 0.5s ease;
}

@keyframes line-flash {
  0%   { background: rgba(124, 106, 239, 0.2); }
  50%  { background: rgba(124, 106, 239, 0.05); }
  100% { background: var(--at-bg); }
}

/* --- コンボポップアップ --- */
.area-tap-combo-popup {
  position: fixed;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  font-size: 48px;
  font-weight: 900;
  color: var(--at-accent2);
  opacity: 0;
  pointer-events: none;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.6);
  z-index: 100;
}

.area-tap-combo-popup.show {
  animation: combo-pop 0.6s ease forwards;
}

@keyframes combo-pop {
  0%   { opacity: 0; transform: translate(-50%, -50%) scale(0.5); }
  30%  { opacity: 1; transform: translate(-50%, -50%) scale(1.2); }
  60%  { transform: translate(-50%, -50%) scale(1.0); }
  100% { opacity: 0; transform: translate(-50%, -60%) scale(1.0); }
}

/* --- 判定テキスト --- */
.area-tap-judgment {
  position: fixed;
  left: 50%;
  top: 40%;
  transform: translate(-50%, -50%);
  font-size: 28px;
  font-weight: 800;
  opacity: 0;
  pointer-events: none;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
  z-index: 100;
}

.area-tap-judgment.show {
  animation: judgment-pop 0.8s ease forwards;
}

.area-tap-judgment.PERFECT { color: #ffd700; }
.area-tap-judgment.GREAT   { color: #1eff52; }
.area-tap-judgment.GOOD    { color: #4fc3f7; }
.area-tap-judgment.OK      { color: #aaa; }
.area-tap-judgment.MISS    { color: #ff3554; }

@keyframes judgment-pop {
  0%   { opacity: 0; transform: translate(-50%, -50%) scale(0.6); }
  20%  { opacity: 1; transform: translate(-50%, -50%) scale(1.1); }
  50%  { transform: translate(-50%, -50%) scale(1.0); }
  100% { opacity: 0; transform: translate(-50%, -60%); }
}

/* --- 開始前画面 --- */
.area-tap-start-screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: rgba(10, 10, 15, 0.95);
  z-index: 50;
  padding: 24px;
  gap: 16px;
}

.area-tap-start-title {
  font-size: 24px;
  font-weight: 800;
  color: var(--at-accent);
}

.area-tap-start-song {
  font-size: 14px;
  color: var(--at-text2);
  text-align: center;
  max-width: 280px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.area-tap-start-best {
  font-size: 13px;
  color: var(--at-text2);
}

.area-tap-start-options {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
  max-width: 280px;
}

.area-tap-option-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.area-tap-option-label {
  font-size: 12px;
  color: var(--at-text3);
  font-weight: 600;
}

.area-tap-option-buttons {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.area-tap-option-btn {
  padding: 6px 12px;
  border: 1px solid var(--at-border);
  border-radius: 6px;
  background: var(--at-bg2);
  color: var(--at-text2);
  font-size: 13px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.area-tap-option-btn:hover {
  border-color: var(--at-accent);
  color: var(--at-text);
}

.area-tap-option-btn.selected {
  background: var(--at-accent);
  border-color: var(--at-accent);
  color: #fff;
}

.area-tap-start-btn {
  padding: 12px 24px;
  border: none;
  border-radius: 8px;
  background: var(--at-accent);
  color: #fff;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s ease;
  width: 100%;
  max-width: 280px;
}

.area-tap-start-btn:hover {
  background: var(--at-accent-hover);
}

/* --- 結果画面オーバーレイ --- */
.area-tap-result {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: rgba(10, 10, 15, 0.95);
  z-index: 50;
  padding: 24px;
  gap: 12px;
  overflow-y: auto;
}

.area-tap-result-score {
  font-size: 40px;
  font-weight: 900;
  color: var(--at-accent);
  font-variant-numeric: tabular-nums;
}

.area-tap-result-rank {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  font-size: 24px;
  font-weight: 900;
}

.area-tap-result-rank[data-rank="S+"],
.area-tap-result-rank[data-rank="S"] {
  background: linear-gradient(135deg, #ffd700, #ff8c00);
  color: #1a0800;
}
.area-tap-result-rank[data-rank="A"] {
  background: linear-gradient(135deg, #1eff52, #00c853);
  color: #002200;
}
.area-tap-result-rank[data-rank="B"] {
  background: linear-gradient(135deg, #4fc3f7, #0288d1);
  color: #001830;
}
.area-tap-result-rank[data-rank="C"] {
  background: var(--at-bg3);
  color: var(--at-text2);
}
.area-tap-result-rank[data-rank="D"] {
  background: var(--at-bg3);
  color: var(--at-text3);
}

.area-tap-result-judgments {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  width: 100%;
  max-width: 320px;
  text-align: center;
}

.area-tap-result-judgment-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.area-tap-result-judgment-label {
  font-size: 11px;
  font-weight: 700;
}

.area-tap-result-judgment-label.PERFECT { color: #ffd700; }
.area-tap-result-judgment-label.GREAT   { color: #1eff52; }
.area-tap-result-judgment-label.GOOD    { color: #4fc3f7; }
.area-tap-result-judgment-label.MISS    { color: #ff3554; }

.area-tap-result-judgment-count {
  font-size: 20px;
  font-weight: 800;
  color: var(--at-text);
  font-variant-numeric: tabular-nums;
}

.area-tap-result-stats {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 13px;
  color: var(--at-text2);
}

.area-tap-result-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
  max-width: 280px;
  margin-top: 8px;
}

.area-tap-result-btn {
  padding: 10px 20px;
  border: 1px solid var(--at-border);
  border-radius: 8px;
  background: var(--at-bg2);
  color: var(--at-text);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
  transition: all 0.15s ease;
}

.area-tap-result-btn:hover {
  border-color: var(--at-accent);
}

.area-tap-result-btn.primary {
  background: var(--at-accent);
  border-color: var(--at-accent);
  color: #fff;
}

.area-tap-result-btn.primary:hover {
  background: var(--at-accent-hover);
}

/* --- 結果画面: ソーシャル共有 --- */
.area-tap-result-share {
  display: flex;
  gap: 12px;
  justify-content: center;
  margin-top: 12px;
}

.area-tap-share-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid rgba(255,255,255,0.3);
  background: transparent;
  color: rgba(255,255,255,0.7);
  font-size: 18px;
  cursor: pointer;
  transition: all 0.2s;
}

.area-tap-share-btn:hover {
  border-color: var(--at-accent);
  color: var(--at-accent);
  transform: scale(1.1);
}

/* --- 結果画面: サーバー情報（自己ベスト・ランキング位置） --- */
.area-tap-result-server-info {
  text-align: center;
  margin: 8px 0;
  min-height: 20px;
}

.area-tap-result-best-update {
  color: var(--at-accent2);
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 4px;
}

.area-tap-result-ranking-pos {
  color: var(--at-text2);
  font-size: 14px;
}

/* --- 結果画面: 次ランクプログレス --- */
.area-tap-result-next-rank {
  text-align: center;
  margin: 8px 0 12px;
  font-size: 12px;
  color: var(--at-text2);
}

.area-tap-result-next-rank-bar {
  width: 200px;
  max-width: 80%;
  height: 6px;
  background: var(--at-bg3);
  border-radius: 3px;
  margin: 6px auto 0;
  overflow: hidden;
}

.area-tap-result-next-rank-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--at-accent), var(--at-accent2));
  border-radius: 3px;
  transition: width 0.5s ease;
}

/* --- 結果画面: OK判定ラベル色 --- */
.area-tap-result-judgment-label.OK {
  color: #aaa;
}

/* --- 動画エラー表示 --- */
.area-tap-error-message {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 24px 16px;
  text-align: center;
}

.area-tap-error-message i {
  font-size: 32px;
  color: var(--at-accent2);
}

.area-tap-error-message p {
  margin: 0;
  font-size: 14px;
  color: var(--at-text2);
  line-height: 1.5;
}

/* --- レスポンシブ --- */
@media (max-width: 480px) {
  .area-tap-status {
    padding: 4px 8px;
    font-size: 12px;
    min-height: 32px;
  }

  .area-tap-guide {
    padding: 4px 8px;
    font-size: 13px;
    min-height: 32px;
  }

  .area-tap-fragment {
    font-size: 13px;
    padding: 1px 4px;
  }

  .area-tap-result-score {
    font-size: 32px;
  }

  .area-tap-combo-popup {
    font-size: 36px;
  }
}

/* --- カウントダウン --- */
.area-tap-countdown {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(10, 10, 15, 0.8);
  z-index: 60;
  font-size: 72px;
  font-weight: 900;
  color: var(--at-accent);
  pointer-events: none;
}

.area-tap-countdown.fade {
  animation: countdown-fade 0.8s ease forwards;
}

@keyframes countdown-fade {
  0%   { opacity: 1; transform: scale(1); }
  100% { opacity: 0; transform: scale(1.5); }
}

/* === 練習モード ヒント表示 === */
.zone-hint {
  border: 3px solid var(--at-accent) !important;
  animation: hint-pulse 0.8s ease-in-out infinite;
  box-shadow: inset 0 0 20px rgba(255, 215, 0, 0.3);
}

@keyframes hint-pulse {
  0%, 100% { border-color: var(--at-accent); box-shadow: inset 0 0 20px rgba(255, 215, 0, 0.3); }
  50% { border-color: #fff; box-shadow: inset 0 0 30px rgba(255, 215, 0, 0.5); }
}

.practice-hint-text {
  color: var(--at-accent);
  font-size: 0.85em;
  animation: blink 1s ease-in-out infinite;
}

@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* === チャレンジモード === */
.area-tap-status-lives {
  color: #ff6b6b;
  font-weight: bold;
}

.lives-full { color: #ff4757; }
.lives-empty { color: #555; }

.lives-danger {
  animation: lives-shake 0.3s ease-in-out;
}

@keyframes lives-shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-3px); }
  75% { transform: translateX(3px); }
}

.area-tap-gameover-title {
  font-size: 2.5rem;
  font-weight: 900;
  color: #ff4757;
  text-align: center;
  margin-bottom: 16px;
  text-shadow: 0 0 20px rgba(255, 71, 87, 0.5);
  animation: gameover-appear 0.5s ease-out;
}

@keyframes gameover-appear {
  0% { transform: scale(2); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

/* === タイムアタックモード === */
.area-tap-result-ta-info {
  text-align: center;
  font-size: 1.3rem;
  color: #ddd;
  margin: 8px 0;
}

.area-tap-result-ta-info .ta-completed {
  font-size: 2rem;
  font-weight: 900;
  color: var(--at-accent);
}

/* === モード別ランキング サブタブ === */
.ranking-subtabs {
  display: flex;
  gap: 4px;
  margin: 8px 12px 12px;
  padding: 3px;
  background: var(--card-actions-bg);
  border: 1px solid var(--border-color);
  border-radius: 8px;
}

.ranking-subtab {
  flex: 1;
  padding: 6px 8px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 0.8rem;
  font-weight: 600;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s;
}

.ranking-subtab:hover {
  color: var(--text-secondary);
  background: rgba(var(--accent-rgb), 0.06);
}

.ranking-subtab.active {
  color: #fff;
  background: var(--accent);
}
