:root {
  /* Colors from Stitch Design Spec */
  --bg-color: #05050a;
  --primary-accent: #00f7ff;
  --danger-color: #ff003c;
  --secondary-color: #64748b;
  --surface-glass: rgba(255, 255, 255, 0.03);
  --border-glass: rgba(255, 255, 255, 0.1);
  --text-primary: #ffffff;
  --text-secondary: #94a3b8;
  
  /* Target Colors */
  --normal-target: #00f7ff;
  --rare-target: #c6c6c6;
  --bomb-target: #ff003c;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  touch-action: manipulation;
}

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background-color: var(--bg-color);
  color: var(--text-primary);
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
  min-height: 100vh;
}

#app {
  width: 100%;
  max-width: 1000px;
  margin: 0 auto;
  height: 100vh;
  position: relative;
  background-color: var(--bg-color);
  /* Grid Background */
  background-image: 
    radial-gradient(circle at center, rgba(0, 247, 255, 0.05) 0%, transparent 70%),
    linear-gradient(rgba(255, 255, 255, 0.02) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.02) 1px, transparent 1px);
  background-size: 100% 100%, 64px 64px, 64px 64px;
}

/* 画面共通スタイル */
.screen {
  display: none;
  width: 100%;
  height: 100%;
  flex-direction: column;
  position: absolute;
  top: 0;
  left: 0;
  padding: 2rem;
  z-index: 10;
}

.screen.active {
  display: flex;
}

/* タイトル・リザルト画面 */
#title-screen, #result-screen {
  justify-content: center;
  align-items: center;
  text-align: center;
  background: radial-gradient(circle at center, rgba(0, 247, 255, 0.03) 0%, transparent 80%);
}

h1 {
  font-size: clamp(3rem, 10vw, 5rem);
  font-weight: 900;
  font-style: italic;
  letter-spacing: -0.05em;
  color: var(--primary-accent);
  text-transform: uppercase;
  margin-bottom: 0.5rem;
  filter: drop-shadow(0 0 15px rgba(0, 247, 255, 0.5));
}

.subtitle {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.3em;
  color: rgba(0, 247, 255, 0.5);
  margin-bottom: 3rem;
}

/* ボタン */
.btn {
  position: relative;
  display: inline-block;
  padding: 1rem 3rem;
  font-size: 1.2rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.2em;
  border: 1px solid rgba(0, 247, 255, 0.3);
  border-radius: 8px;
  background: rgba(0, 247, 255, 0.05);
  color: var(--primary-accent);
  cursor: pointer;
  backdrop-filter: blur(4px);
  transition: all 0.3s ease;
  box-shadow: 0 0 20px rgba(0, 247, 255, 0.1);
}

.btn:hover {
  background: rgba(0, 247, 255, 0.15);
  border-color: var(--primary-accent);
  box-shadow: 0 0 30px rgba(0, 247, 255, 0.3);
  transform: translateY(-2px);
}

.btn:active {
  transform: translateY(0);
}

.btn-secondary {
  background: transparent;
  border-color: var(--secondary-color);
  color: var(--text-secondary);
  font-size: 0.9rem;
  padding: 0.8rem 2rem;
  margin-top: 1rem;
}

/* ランキングボード */
.ranking-container {
  margin-top: 2rem;
  margin-bottom: 2rem;
  width: 100%;
  max-width: 450px;
  background: rgba(15, 23, 42, 0.4);
  border: 1px solid var(--border-glass);
  backdrop-filter: blur(12px);
  border-radius: 12px;
  padding: 1.5rem;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
}

.ranking-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border-glass);
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-secondary);
  letter-spacing: 0.1em;
}

#ranking-list {
  list-style: none;
  max-height: 250px;
  overflow-y: auto;
}

#ranking-list li {
  display: flex;
  justify-content: space-between;
  padding: 0.75rem 0.5rem;
  border-radius: 4px;
  transition: background 0.2s;
}

#ranking-list li:hover {
  background: rgba(255, 255, 255, 0.03);
}

#ranking-list li span:last-child {
  font-family: 'JetBrains Mono', monospace;
  color: var(--primary-accent);
}

/* プレイ画面：HUD */
#play-header {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  padding: 2rem 3rem;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  pointer-events: none;
  z-index: 100;
}

.hud-item {
  display: flex;
  flex-direction: column;
}

.hud-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.2em;
  color: var(--text-secondary);
  margin-bottom: 0.25rem;
}

.hud-value {
  font-family: 'JetBrains Mono', monospace;
  font-size: 2.5rem;
  font-weight: 800;
  color: var(--text-primary);
  text-shadow: 0 0 15px rgba(255, 255, 255, 0.3);
}

/* 中央タイマーとゲージ */
.hud-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 250px;
}

.timer-value {
  font-size: 3rem;
  font-weight: 800;
  color: var(--text-primary);
}

.timer-gauge {
  width: 100%;
  height: 4px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 2px;
  margin-top: 0.5rem;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

#timer-bar {
  height: 100%;
  background: var(--text-primary);
  box-shadow: 0 0 10px var(--text-primary);
  transition: width 0.1s linear;
}

/* プレイ領域 */
#play-area {
  width: 100%;
  height: 100%;
  position: relative;
  cursor: crosshair;
  overflow: hidden;
  container-type: size;
}

/* ターゲットデザイン */
.target {
  position: absolute;
  transform: translate(-50%, -50%);
  cursor: crosshair;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.1s;
}

/* 共通の十字線 */
.target::before, .target::after {
  content: '';
  position: absolute;
  background: currentColor;
  opacity: 0.3;
}

.target-normal {
  width: max(40px, 8cqmin);
  height: max(40px, 8cqmin);
  border: 2px solid var(--normal-target);
  border-radius: 50%;
  color: var(--normal-target);
  box-shadow: 0 0 15px rgba(0, 247, 255, 0.2);
}

.target-normal::before { width: 1px; height: 100%; }
.target-normal::after { width: 100%; height: 1px; }

.target-normal .dot {
  width: 6px;
  height: 6px;
  background: var(--normal-target);
  border-radius: 50%;
  box-shadow: 0 0 8px var(--normal-target);
}

.target-rare {
  width: max(25px, 4.5cqmin);
  height: max(25px, 4.5cqmin);
  border: 2px solid var(--rare-target);
  transform: translate(-50%, -50%) rotate(45deg);
  color: var(--rare-target);
  box-shadow: 0 0 20px rgba(255, 255, 255, 0.3);
}

.target-rare .dot {
  width: 8px;
  height: 8px;
  background: var(--rare-target);
  transform: rotate(-45deg);
  box-shadow: 0 0 10px var(--rare-target);
}

.target-bomb {
  width: max(50px, 10cqmin);
  height: max(50px, 10cqmin);
  border: 2px solid var(--danger-color);
  border-radius: 8px;
  background: rgba(255, 0, 60, 0.05);
  color: var(--danger-color);
}

.target-bomb::before {
  content: '!';
  font-weight: 900;
  font-size: 1.5rem;
  opacity: 1;
}

/* スコアポップアップ */
.score-popup {
  position: absolute;
  font-family: 'JetBrains Mono', monospace;
  font-weight: 800;
  font-size: 1.5rem;
  color: var(--primary-accent);
  pointer-events: none;
  animation: floatUp 0.8s cubic-bezier(0, 0, 0.2, 1) forwards;
  text-shadow: 0 0 10px rgba(0, 247, 255, 0.5);
  z-index: 200;
}

@keyframes floatUp {
  0% { transform: translate(-50%, -50%) scale(1.5); opacity: 0; }
  20% { transform: translate(-50%, -80%) scale(1); opacity: 1; }
  100% { transform: translate(-50%, -150%) scale(1); opacity: 0; }
}

/* リザルト詳細 */
.result-stats {
  display: grid;
  grid-template-columns: repeat(3, 150px);
  gap: 1rem;
  margin-bottom: 2rem;
}

.stat-box {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-glass);
  padding: 1rem;
  border-radius: 8px;
}

.stat-label {
  font-size: 0.6rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  margin-bottom: 0.5rem;
}

.stat-value {
  font-family: 'JetBrains Mono', monospace;
  font-size: 1.5rem;
  font-weight: 700;
}

input[type="text"] {
  width: 100%;
  max-width: 300px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-glass);
  border-radius: 8px;
  padding: 1rem;
  color: white;
  text-align: center;
  font-family: 'JetBrains Mono', monospace;
  letter-spacing: 0.1em;
  outline: none;
  margin-bottom: 1.5rem;
}

input[type="text"]:focus {
  border-color: var(--primary-accent);
  background: rgba(255, 255, 255, 0.08);
}

/* 広告バナー */
.ad-banner {
  width: 100%;
  max-width: 728px;
  height: 90px;
  background-color: rgba(255, 255, 255, 0.03);
  border: 1px dashed rgba(0, 247, 255, 0.3);
  display: flex;
  justify-content: center;
  align-items: center;
  color: rgba(0, 247, 255, 0.5);
  font-size: 0.875rem;
  border-radius: 8px;
  flex-shrink: 0;
  z-index: 1;
  margin: 1rem auto 0;
}

@media (max-width: 768px) {
  .ad-banner {
    display: none;
  }
}

