@import url('https://fonts.googleapis.com/css2?family=Helvetica+Neue:wght@300;400;500&display=swap');

:root {
  --bg-color: #121212;
  --text-main: #E0E0E0;
  --text-dim: #777777;
  --accent-red: #D9381E;
  --accent-gray: #4A4A4A;
  --filter-color: #C19A6B;
  --paper-color: #F8F8F8;
  
  /* 動的変数（JSから制御） */
  --progress: 1; /* 1〜0 */
  --ash-progress: 0; /* 0〜1 */
  --fire-opacity: 0;
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Helvetica Neue', Arial, sans-serif;
  color: var(--text-main);
  background-color: var(--bg-color);
  min-height: 100vh;
  overflow: hidden;
  display: flex;
  justify-content: center;
  -webkit-font-smoothing: antialiased;
}

.app {
  width: 100%;
  max-width: 600px;
  height: 100vh;
  display: flex;
  flex-direction: column;
  position: relative;
}

/* ヘッダー周り */
.header {
  padding: 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  z-index: 10;
  width: 100%;
}

.back-link {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--text-dim);
  text-decoration: none;
  font-size: 0.9rem;
  transition: color 0.2s;
  background: none;
  border: none;
  font-family: inherit;
  cursor: pointer;
}

.back-link:hover {
  color: var(--text-main);
}

.timer-display {
  font-family: monospace;
  font-size: 1.1rem;
  color: var(--text-dim);
  letter-spacing: 0.1em;
  opacity: 0.3; /* デジタル表示は極力目立たせない */
}

/* ==============================================
   画面切り替え
=============================================== */
.screen {
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  width: 100%;
  animation: fade-in 0.4s ease forwards;
}

/* ==============================================
   時間設定メニュー
=============================================== */
.menu-content {
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 2rem;
}

.theme-title {
  font-size: 2rem;
  font-weight: 300;
  letter-spacing: 0.1em;
  color: var(--text-main);
  margin-bottom: 1rem;
}

.time-settings {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 3rem;
  width: 100%;
  max-width: 400px;
  padding: 0 1rem;
}

.setting-group {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.6rem;
  flex: 1 1 auto;
  min-width: 140px;
}

.setting-label {
  font-size: 0.75rem;
  letter-spacing: 0.15em;
  color: var(--text-dim);
}

.setting-control {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.setting-value {
  font-size: 2.2rem;
  font-weight: 300;
  min-width: 2.5ch;
  text-align: center;
  color: var(--text-main);
}

.setting-unit {
  font-size: 0.8rem;
  color: var(--text-dim);
  margin-right: 0.2rem;
}

.adj-btn {
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-main);
  font-size: 1.1rem;
  cursor: pointer;
  display: flex;
  justify-content: center;
  align-items: center;
  transition: background 0.2s;
}

.adj-btn:hover {
  background: rgba(255, 255, 255, 0.1);
}

.adj-btn:active {
  background: rgba(255, 255, 255, 0.15);
  transform: scale(0.95);
}

/* タバコエリア */
.cigarette-area {
  flex-grow: 1;
  display: flex;
  justify-content: center;
  align-items: center;
  position: relative;
  padding: 0 2rem;
}

.cigarette-wrapper {
  position: relative;
  width: 100%;
  max-width: 320px;
  display: flex;
  justify-content: center;
}

.cigarette {
  display: flex;
  align-items: center;
  height: 20px;
  width: 100%;
  filter: drop-shadow(0 4px 10px rgba(0,0,0,0.5));
  transition: opacity 0.5s ease;
}

.cig-filter {
  width: 25%;
  height: 100%;
  background: var(--filter-color);
  border-radius: 4px 0 0 4px;
  flex-shrink: 0;
  position: relative;
}

.cig-filter::after {
  content: '';
  position: absolute;
  right: 0;
  top: 0;
  width: 4px;
  height: 100%;
  background: rgba(0,0,0,0.1);
}

.cig-body {
  /* JSの変数で幅を制御 */
  width: calc(var(--progress) * 75%);
  height: 100%;
  background: var(--paper-color);
  transition: width 0.1s linear; /* 滑らかに短くなる */
}

.cig-fire {
  width: 8px;
  height: 100%;
  background: var(--accent-red);
  border-radius: 0 3px 3px 0;
  opacity: var(--fire-opacity);
  box-shadow: 0 0 15px var(--accent-red), 0 0 5px #fff inset;
  transition: opacity 0.5s ease;
  position: relative;
}

/* 煙のアニメーション */
.smoke {
  position: absolute;
  bottom: 50%;
  left: 50%;
  width: 2px;
  height: 2px;
  background: rgba(255,255,255,0.4);
  border-radius: 50%;
  filter: blur(4px);
  opacity: 0;
}

.smoke.active {
  animation: smoking 3s infinite ease-out;
}

@keyframes smoking {
  0% { transform: translate(-50%, 0) scale(1); opacity: 0.8; }
  50% { transform: translate(calc(-50% + 15px), -50px) scale(8); opacity: 0.4; }
  100% { transform: translate(calc(-50% - 10px), -100px) scale(15); opacity: 0; }
}

/* 灰エリア */
.ashtray-area {
  height: 30vh;
  min-height: 150px;
  position: relative;
  display: flex;
  justify-content: center;
  align-items: flex-end;
  border-top: 1px solid rgba(255,255,255,0.05);
  background: linear-gradient(to top, rgba(255,255,255,0.02), transparent);
  overflow: hidden; /* 灰が横にはみ出さないように */
}

/* 落ちる灰のコンテナ */
.falling-ash-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 5;
}

.ash-particle {
  position: absolute;
  width: 10px;
  height: 10px;
  background: #bbb;
  border-radius: 50%;
  opacity: 0.85;
  /* 速度をゆっくり（2.5s）落下するように変更 */
  animation: fall 2.5s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
}

@keyframes fall {
  0% { transform: translateY(0) rotate(0deg); opacity: 0.85; }
  100% { transform: translateY(30vh) translateX(-20px) rotate(360deg); opacity: 0; }
}

/* 掃除中に吹き飛ぶ灰 */
.ash-particle.swept {
  background: #888;
  width: 12px;
  height: 12px;
  filter: blur(2px);
  animation: sweepAway 2s ease-out forwards;
}

@keyframes sweepAway {
  0% { transform: translate(0, 0) rotate(0deg); opacity: 0.6; }
  100% { transform: translate(calc(var(--sweep-dir) * 200px), -100px) rotate(720deg) scale(3); opacity: 0; }
}

/* 溜まった灰 */
.ash-pile {
  width: 100%; /* 横いっぱいに広げる */
  height: calc(var(--ash-progress) * 30vh); /* 最大30vhまで迫ってくる */
  background: #777;
  /* 上部を少しだけ丸く、または平坦に */
  border-radius: 20px 20px 0 0;
  filter: blur(2px);
  transition: height 0.1s linear, opacity 1s ease;
  margin-bottom: 0;
  opacity: 0.9;
}

/* 操作パネル */
.controls {
  padding: 2rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.5rem;
  z-index: 10;
}

.status-msg {
  font-size: 0.9rem;
  letter-spacing: 0.1em;
  color: var(--text-dim);
}

.main-btn {
  background: transparent;
  color: var(--text-main);
  border: 1px solid var(--text-dim);
  padding: 1rem 3rem;
  border-radius: 999px;
  font-size: 1rem;
  letter-spacing: 0.1em;
  cursor: pointer;
  transition: all 0.3s ease;
  outline: none;
}

.main-btn:hover {
  background: rgba(255,255,255,0.05);
  border-color: var(--text-main);
}

.main-btn:active {
  transform: scale(0.98);
}

/* 状態ごとのボタンスタイル変更 */
.main-btn.btn-burn {
  color: #ff9e80;
  border-color: #ff9e80;
}
.main-btn.btn-burn:hover {
  background: rgba(255, 158, 128, 0.1);
}

.main-btn.btn-clean {
  color: #80cbc4;
  border-color: #80cbc4;
}
.main-btn.btn-clean:hover {
  background: rgba(128, 203, 196, 0.1);
}

/* 一時休止オーバーレイ */
.pause-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(18, 18, 18, 0.8);
  backdrop-filter: blur(4px);
  z-index: 50;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 2rem;
}

.pause-text {
  font-size: 1.2rem;
  letter-spacing: 0.2em;
}

.pause-buttons {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  align-items: center;
}

.resume-btn, .pause-btn {
  border: none;
  padding: 0.8rem 2.5rem;
  border-radius: 999px;
  font-size: 1rem;
  cursor: pointer;
  transition: transform 0.2s, background 0.2s;
}

.resume-btn {
  background: #fff;
  color: #000;
  font-weight: 500;
}

.resume-btn:hover {
  transform: scale(1.05);
}

.pause-btn-break {
  background: var(--accent-gray);
  color: #fff;
}

.pause-btn-break:hover {
  background: #555;
}

.pause-btn-menu {
  background: transparent;
  color: var(--text-dim);
  border: 1px solid var(--text-dim);
}

.pause-btn-menu:hover {
  background: rgba(255,255,255,0.05);
  color: var(--text-main);
}

.hidden {
  display: none !important;
}

@keyframes fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* スマホ対応 */
@media (max-width: 400px) {
  .cigarette-wrapper { max-width: 250px; }
  .controls { padding: 1rem; }
  .main-btn { padding: 0.8rem 2rem; }
}

/* 言語切り替えトグル */
.lang-toggle {
  position: fixed;
  top: 20px;
  right: 20px;
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-dim);
  border: none;
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  cursor: pointer;
  z-index: 100;
  transition: all 0.2s ease;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  -webkit-appearance: none;
  appearance: none;
}
.lang-toggle:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-main);
  transform: translateY(-2px);
}
