:root {
  --bg: #0a0f1a;
  --card-bg: #17232c;
  --card-border: #24333d;
  --text: #eef3f6;
  --text-muted: #9db0bb;
  --accent-work: #f97316;
  --accent-break: #14b8a6;
  --accent-idle: #3b4a56;
  --accent-primary: #f97316;
  --danger: #ef4444;
  --yt-red: #ff0000;
  --star-glow: #fff8e7;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Hiragino Kaku Gothic ProN", "Yu Gothic", system-ui, -apple-system, sans-serif;
  /* 満天の星空 -> 稜線に沈む夕陽/朝焼けの光、というチャンネルのサムネイル世界観 */
  background:
    radial-gradient(ellipse 90% 45% at 50% 100%, rgba(255, 168, 92, 0.18), transparent 62%),
    linear-gradient(180deg, #03050b 0%, #070c1d 28%, #0d1a34 52%, #17294a 74%, #223c58 100%);
  background-attachment: fixed;
  color: var(--text);
  display: flex;
  justify-content: center;
  padding: 24px 16px 64px;
  position: relative;
}

/* ---- 星空レイヤー(背景の演出。操作を邪魔しないよう固定・クリック無効) ---- */

.sky {
  position: fixed;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  pointer-events: none;
}

.milkyway {
  position: absolute;
  inset: -25%;
  background: linear-gradient(
    112deg,
    transparent 32%,
    rgba(180, 195, 255, 0.08) 45%,
    rgba(220, 210, 255, 0.14) 50%,
    rgba(180, 195, 255, 0.08) 55%,
    transparent 68%
  );
  filter: blur(20px);
  transform: rotate(-10deg);
}

.stars {
  position: absolute;
  inset: 0;
}

.star {
  position: absolute;
  background: var(--star-glow);
  border-radius: 50%;
  opacity: 0.4;
  animation-name: twinkle;
  animation-timing-function: ease-in-out;
  animation-iteration-count: infinite;
}

@keyframes twinkle {
  0%, 100% { opacity: 0.15; }
  50% { opacity: 1; }
}

.shooting-star {
  position: absolute;
  width: 130px;
  height: 2px;
  background: linear-gradient(90deg, rgba(255, 255, 255, 0.95), rgba(255, 255, 255, 0));
  border-radius: 999px;
  transform-origin: right center;
  filter: drop-shadow(0 0 5px rgba(255, 255, 255, 0.85));
  animation-name: shooting;
  animation-timing-function: ease-in;
  animation-fill-mode: forwards;
}

@keyframes shooting {
  0% { transform: translate(0, 0) rotate(-35deg); opacity: 0; }
  8% { opacity: 1; }
  100% { transform: translate(-420px, 290px) rotate(-35deg); opacity: 0; }
}

.mountains {
  position: absolute;
  left: 0;
  bottom: 0;
  width: 100%;
  height: 20vh;
  min-height: 150px;
}

.ridge-back {
  fill: #16283f;
  opacity: 0.8;
}

.ridge-front,
.pines {
  fill: #04060d;
}

main {
  width: 100%;
  max-width: 480px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.app-header {
  text-align: center;
  margin-bottom: 4px;
}

.app-header h1 {
  margin: 0;
  font-size: 1.75rem;
  letter-spacing: 0.02em;
  text-shadow: 0 0 22px rgba(255, 210, 150, 0.35);
}

.app-header .tagline {
  margin: 4px 0 0;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.timer-tabs {
  display: flex;
  gap: 8px;
  justify-content: center;
  flex-wrap: wrap;
}

.tab-btn {
  padding: 8px 16px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(23, 35, 44, 0.55);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  color: var(--text-muted);
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.15s ease;
}

.tab-btn.active {
  background: var(--accent-primary);
  border-color: var(--accent-primary);
  color: #1a1006;
  font-weight: 600;
}

.tab-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.timer-card,
.music-card,
.stats-card {
  background: rgba(23, 35, 44, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 20px;
  padding: 24px;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.35);
}

.timer-phase {
  text-align: center;
  font-size: 0.95rem;
  color: var(--text-muted);
  margin-bottom: 12px;
  min-height: 1.2em;
}

.timer-ring-wrap {
  position: relative;
  width: 100%;
  max-width: 260px;
  margin: 0 auto;
  aspect-ratio: 1 / 1;
  touch-action: none;
  user-select: none;
}

.timer-ring-wrap.active {
  cursor: grab;
}

.timer-ring-wrap.active:active {
  cursor: grabbing;
}

.ring-handle {
  position: absolute;
  width: 22px;
  height: 22px;
  margin: -11px 0 0 -11px;
  border-radius: 50%;
  background: var(--accent-idle);
  border: 3px solid #0b1218;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
  pointer-events: none;
  display: none;
  transition: background 0.3s ease;
}

.ring-handle.visible {
  display: block;
}

.ring-handle.phase-work {
  background: var(--accent-work);
}

.ring-handle.phase-break {
  background: var(--accent-break);
}

.timer-ring {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.ring-track {
  fill: none;
  stroke: var(--card-border);
  stroke-width: 12;
}

.ring-progress {
  fill: none;
  stroke: var(--accent-idle);
  stroke-width: 12;
  stroke-linecap: round;
  transition: stroke-dashoffset 0.25s linear, stroke 0.3s ease;
}

.ring-progress.phase-work {
  stroke: var(--accent-work);
}

.ring-progress.phase-break {
  stroke: var(--accent-break);
}

.timer-display {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.4rem;
  font-variant-numeric: tabular-nums;
  font-weight: 700;
}

.free-settings {
  display: flex;
  gap: 16px;
  justify-content: center;
  margin: 18px 0 4px;
  flex-wrap: wrap;
}

.free-settings label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.free-settings input {
  width: 80px;
  padding: 6px 8px;
  border-radius: 8px;
  border: 1px solid var(--card-border);
  background: var(--bg);
  color: var(--text);
  font-size: 1rem;
}

.seek-controls {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin-top: 14px;
}

.timer-controls {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 20px;
}

.btn {
  padding: 10px 20px;
  border-radius: 12px;
  border: 1px solid var(--card-border);
  background: #202f39;
  color: var(--text);
  font-size: 0.9rem;
  cursor: pointer;
  transition: transform 0.1s ease, opacity 0.15s ease;
}

.btn:hover {
  opacity: 0.9;
}

.btn:active {
  transform: scale(0.97);
}

.btn.primary {
  background: var(--accent-primary);
  border-color: var(--accent-primary);
  color: #1a1006;
  font-weight: 700;
}

.btn.ghost {
  background: transparent;
}

.music-card h2,
.stats-card h2 {
  margin: 0 0 12px;
  font-size: 1rem;
  color: var(--text-muted);
  font-weight: 600;
}

.video-info {
  display: flex;
  gap: 12px;
  align-items: center;
  font-size: 0.85rem;
  color: var(--text-muted);
  min-height: 48px;
}

.video-info img {
  width: 80px;
  height: 45px;
  border-radius: 8px;
  object-fit: cover;
  flex-shrink: 0;
}

.video-info .video-title {
  color: var(--text);
}

.music-toggle {
  display: flex;
  gap: 20px;
  align-items: center;
  flex-wrap: wrap;
  margin-top: 14px;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.music-toggle label {
  display: flex;
  align-items: center;
  gap: 6px;
}

.yt-player {
  margin-top: 14px;
  border-radius: 12px;
  overflow: hidden;
  max-width: 320px;
}

.subscribe-banner {
  background: linear-gradient(135deg, rgba(36, 22, 58, 0.75), rgba(10, 8, 22, 0.85));
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 20px;
  padding: 20px 24px;
  text-align: center;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.35);
}

.subscribe-banner p {
  margin: 0 0 12px;
  font-size: 0.9rem;
  color: #f4dfb0;
}

.subscribe-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--yt-red);
  color: #fff;
  text-decoration: none;
  padding: 10px 22px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 0.9rem;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.stat-tile {
  background: var(--bg);
  border: 1px solid var(--card-border);
  border-radius: 14px;
  padding: 14px;
  text-align: center;
}

.stat-tile .value {
  font-size: 1.4rem;
  font-weight: 700;
}

.stat-tile .label {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 4px;
}

@media (max-width: 380px) {
  .timer-display {
    font-size: 1.9rem;
  }
}

/* ---- PC表示: 横長レイアウトでチャンネル登録までスクロールなしで見えるように ---- */
@media (min-width: 860px) {
  body {
    padding: 20px 24px 40px;
    align-items: flex-start;
  }

  main {
    max-width: 1080px;
    display: grid;
    grid-template-columns: minmax(360px, 460px) 1fr;
    grid-template-areas:
      "tabs tabs"
      "timer music"
      "timer subscribe"
      "timer stats";
    gap: 16px 20px;
  }

  .timer-tabs {
    grid-area: tabs;
  }

  .timer-card {
    grid-area: timer;
    display: flex;
    flex-direction: column;
    justify-content: center;
  }

  .music-card {
    grid-area: music;
  }

  .subscribe-banner {
    grid-area: subscribe;
  }

  .stats-card {
    grid-area: stats;
  }
}
