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

:root {
  --bg1: #0a1628;
  --bg2: #101e3a;
  --surface: rgba(255,255,255,0.06);
  --surface-hover: rgba(255,255,255,0.11);
  --border: rgba(255,255,255,0.1);
  --ice: #48cae4;
  --ice-dim: #1a7a9a;
  --text: #ddeeff;
  --text-dim: #7a9abc;
  --timer: #f0e68c;
  --alarm: #ff4444;
  --gold: #ffd700;
  --btn-time: #1c3a5e;
  --btn-start: #1a5276;
  --btn-stop: #7b1818;
  --btn-closing: #2d2d5a;
  --radius: 14px;
  --font: 'M PLUS Rounded 1c', 'Hiragino Maru Gothic ProN', sans-serif;
}

html, body {
  min-height: 100%;
  background: var(--bg1);
  font-family: var(--font);
  color: var(--text);
}

body {
  background: linear-gradient(160deg, #0a1628 0%, #0d1f42 50%, #091520 100%);
  min-height: 100vh;
}

/* ===== App layout ===== */
.app {
  max-width: 480px;
  margin: 0 auto;
  padding: 16px 16px 32px;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: 100vh;
}

/* ===== Header ===== */
.app-header {
  text-align: center;
  padding: 20px 0 12px;
  width: 100%;
}

.header-ice {
  font-size: 2rem;
  display: block;
  animation: iceFloat 3s ease-in-out infinite;
}

.app-title {
  font-size: 2rem;
  font-weight: 900;
  color: var(--ice);
  letter-spacing: 0.04em;
  text-shadow: 0 0 20px rgba(72,202,228,0.5);
}

.app-subtitle {
  font-size: 0.95rem;
  color: var(--text-dim);
  letter-spacing: 0.12em;
  margin-top: 2px;
}

.app-tagline {
  font-size: 0.82rem;
  color: rgba(120,160,200,0.7);
  margin-top: 6px;
  letter-spacing: 0.05em;
}

/* ===== Cat area ===== */
.cat-area {
  width: 100%;
  display: flex;
  justify-content: center;
  margin: 12px 0 4px;
  position: relative;
}

.cat-container {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
}


/* 写真フレーム */
.cat-photo-wrap {
  width: 200px;
  height: 200px;
  border-radius: 50%;
  overflow: hidden;
  border: 3px solid rgba(72,202,228,0.35);
  box-shadow: 0 0 24px rgba(72,202,228,0.18), 0 6px 20px rgba(0,0,0,0.5);
  flex-shrink: 0;
}

.cat-photo {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center center;
  transition: opacity 0.4s ease;
  display: block;
}

/* アラーム時：シェイク */
.cat-container.state-alarm .cat-photo-wrap {
  animation: catShake 0.18s linear infinite;
}
/* 知恵時：ゴールドグロー */
.cat-container.state-wisdom .cat-photo-wrap {
  border-color: rgba(255,215,0,0.5);
  box-shadow: 0 0 30px rgba(255,215,0,0.3), 0 6px 20px rgba(0,0,0,0.5);
}

/* Speech bubble */
.bubble {
  background: white;
  color: #222;
  border-radius: 16px;
  padding: 10px 16px;
  font-size: 0.88rem;
  line-height: 1.5;
  text-align: center;
  max-width: 240px;
  position: relative;
  margin-bottom: 6px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.3);
  order: -1; /* bubble above cat */
}
.bubble::after {
  content: '';
  position: absolute;
  bottom: -10px;
  left: 50%;
  transform: translateX(-50%);
  border: 6px solid transparent;
  border-top-color: white;
}
.bubble small {
  display: block;
  color: #888;
  font-size: 0.8em;
}

/* ===== Timer ===== */
.timer-section {
  text-align: center;
  margin: 8px 0;
  width: 100%;
}

.timer-display {
  font-size: 5rem;
  font-weight: 900;
  color: var(--timer);
  letter-spacing: 0.05em;
  text-shadow: 0 0 30px rgba(240,230,140,0.4);
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
  transition: color 0.4s;
}
.timer-display.alarm-pulse {
  animation: timerPulse 0.5s ease-in-out infinite;
}

.timer-status {
  font-size: 0.88rem;
  color: var(--text-dim);
  margin-top: 4px;
  min-height: 1.4em;
  transition: color 0.3s;
}
.timer-status.running { color: var(--ice); }
.timer-status.alarm   { color: var(--alarm); font-weight: 700; }

/* ===== Buttons ===== */
.btn-row {
  width: 100%;
  display: flex;
  gap: 10px;
  justify-content: center;
  margin: 8px 0;
}

.btn {
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  font-family: var(--font);
  font-weight: 700;
  transition: transform 0.12s, background 0.2s, box-shadow 0.2s;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}
.btn:active { transform: scale(0.94); }

/* 時間追加ボタン */
.btn-time {
  flex: 1;
  padding: 14px 4px;
  font-size: 1rem;
  background: var(--btn-time);
  color: var(--ice);
  border: 1px solid rgba(72,202,228,0.2);
}
.btn-time:hover {
  background: #254d78;
  box-shadow: 0 0 12px rgba(72,202,228,0.25);
}

/* スタート/ストップ */
.btn-start {
  flex: 2;
  padding: 16px;
  font-size: 1.2rem;
  background: var(--btn-start);
  color: #aef;
  border: 1px solid rgba(72,202,228,0.3);
}
.btn-start:hover {
  background: #226694;
  box-shadow: 0 0 16px rgba(72,202,228,0.3);
}
.btn-start.alarm-mode {
  background: var(--btn-stop);
  color: #ffaaaa;
  border-color: rgba(255,80,80,0.4);
  animation: btnAlarmPulse 0.8s ease-in-out infinite;
}

/* リセット */
.btn-reset {
  flex: 1;
  padding: 16px;
  font-size: 1rem;
  background: rgba(255,255,255,0.07);
  color: var(--text-dim);
  border: 1px solid var(--border);
}
.btn-reset:hover { background: rgba(255,255,255,0.12); }

/* 今日の一言 */
.btn-closing {
  width: 100%;
  padding: 15px;
  font-size: 1.05rem;
  background: var(--btn-closing);
  color: #c8c8ff;
  border: 1px solid rgba(180,180,255,0.2);
}
.btn-closing:hover {
  background: #3a3a7a;
  box-shadow: 0 0 14px rgba(150,150,255,0.25);
}
.closing-hint {
  font-size: 0.78em;
  font-weight: 400;
  color: rgba(200,200,255,0.5);
  margin-left: 4px;
}

/* ===== Footer ===== */
.app-footer {
  margin-top: auto;
  padding-top: 24px;
  font-size: 0.75rem;
  color: rgba(120,160,200,0.45);
  text-align: center;
}

/* ===== Modal ===== */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.88);
  z-index: 100;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.modal-overlay.show {
  display: flex;
  animation: modalFadeIn 0.35s ease;
}

.modal-box {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 32px 28px 28px;
  max-width: 440px;
  width: 100%;
  text-align: center;
  box-shadow: 0 8px 40px rgba(0,0,0,0.6);
  position: relative;
  animation: modalSlideUp 0.35s cubic-bezier(0.34,1.56,0.64,1);
}
.modal-box.wisdom-mode {
  border-color: rgba(255,215,0,0.4);
  box-shadow: 0 8px 40px rgba(255,215,0,0.15);
  background: linear-gradient(160deg, #1a1a0a, #0d1628);
}

.modal-badge {
  display: inline-block;
  padding: 4px 16px;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 700;
  background: rgba(72,202,228,0.15);
  color: var(--ice);
  border: 1px solid rgba(72,202,228,0.3);
  margin-bottom: 16px;
  letter-spacing: 0.08em;
}
.modal-badge.wisdom {
  background: rgba(255,215,0,0.15);
  color: var(--gold);
  border-color: rgba(255,215,0,0.4);
}

.modal-face {
  margin-bottom: 14px;
  animation: faceBouncein 0.5s cubic-bezier(0.34,1.56,0.64,1);
}

.modal-cat-img {
  width: 130px;
  height: 130px;
  object-fit: cover;
  object-position: center center;
  border-radius: 50%;
  border: 3px solid rgba(72,202,228,0.4);
  box-shadow: 0 4px 16px rgba(0,0,0,0.5);
  display: block;
  margin: 0 auto;
}
.modal-box.wisdom-mode .modal-cat-img {
  border-color: rgba(255,215,0,0.5);
  box-shadow: 0 0 20px rgba(255,215,0,0.3), 0 4px 16px rgba(0,0,0,0.5);
}

.modal-text {
  font-size: 1.55rem;
  font-weight: 700;
  line-height: 1.55;
  color: #eef8ff;
  margin-bottom: 24px;
  white-space: pre-line;
}
.modal-box.wisdom-mode .modal-text {
  color: #fff8e0;
  font-size: 1.25rem;
  line-height: 1.7;
}

.btn-stop {
  padding: 14px 48px;
  font-size: 1.1rem;
  background: var(--btn-stop);
  color: #ffaaaa;
  border: 1px solid rgba(255,80,80,0.35);
}
.btn-stop:hover {
  background: #9b2020;
  box-shadow: 0 0 16px rgba(255,80,80,0.3);
}

/* ===== Keyframes ===== */
@keyframes iceFloat {
  0%,100% { transform: translateY(0); }
  50%      { transform: translateY(-5px); }
}

@keyframes catBob {
  0%,100% { transform: translateY(0px) rotate(0deg); }
  25%     { transform: translateY(-5px) rotate(0.5deg); }
  75%     { transform: translateY(-2px) rotate(-0.5deg); }
}

@keyframes catLean {
  0%,100% { transform: translateY(0) rotate(-1deg); }
  50%     { transform: translateY(-3px) rotate(1deg); }
}

@keyframes catShake {
  0%,100% { transform: translateX(0); }
  25%     { transform: translateX(-6px) rotate(-2deg); }
  75%     { transform: translateX(6px) rotate(2deg); }
}

@keyframes catBounce {
  0%,100% { transform: translateY(0) scale(1); }
  45%     { transform: translateY(-14px) scale(1.04, 0.97); }
}

@keyframes wisdomGlow {
  0%,100% { filter: drop-shadow(0 4px 12px rgba(0,0,0,0.5)) drop-shadow(0 0 8px rgba(255,215,0,0.1)); }
  50%     { filter: drop-shadow(0 4px 12px rgba(0,0,0,0.5)) drop-shadow(0 0 22px rgba(255,215,0,0.45)); }
}

@keyframes tailWag {
  0%,100% { transform: rotate(0deg); }
  50%     { transform: rotate(18deg); }
}

@keyframes timerPulse {
  0%,100% { opacity: 1; color: var(--alarm); }
  50%     { opacity: 0.5; }
}

@keyframes btnAlarmPulse {
  0%,100% { box-shadow: 0 0 8px rgba(255,60,60,0.3); }
  50%     { box-shadow: 0 0 22px rgba(255,60,60,0.7); }
}

@keyframes modalFadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes modalSlideUp {
  from { transform: translateY(40px) scale(0.94); opacity: 0; }
  to   { transform: translateY(0) scale(1); opacity: 1; }
}

@keyframes faceBouncein {
  from { transform: scale(0.4) rotate(-15deg); opacity: 0; }
  to   { transform: scale(1) rotate(0deg); opacity: 1; }
}

/* ===== Responsive ===== */
@media (max-width: 420px) {
  .app-title { font-size: 1.7rem; }
  .timer-display { font-size: 4rem; }
  .btn-time { font-size: 0.9rem; padding: 12px 2px; }
  .modal-text { font-size: 1.3rem; }
  .modal-box.wisdom-mode .modal-text { font-size: 1.1rem; }
}
