:root {
  --bg: #0e0e10;
  --card: #1a1a1d;
  --card-border: rgba(213, 169, 90, 0.28);
  --gold: #d5a95a;
  --gold-soft: rgba(213, 169, 90, 0.55);
  --gold-dim: rgba(213, 169, 90, 0.3);
  --text: #f2f0eb;
  --text-dim: #9a968c;
  --serif: Georgia, "Times New Roman", "Hiragino Mincho ProN", "Yu Mincho", serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Hiragino Sans", "Noto Sans JP", sans-serif;
}

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

html, body { height: 100%; }

body {
  background: radial-gradient(120% 70% at 50% 0%, #17171a 0%, var(--bg) 60%) var(--bg);
  color: var(--text);
  font-family: var(--sans);
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: 100dvh;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
}

button {
  font-family: inherit;
  color: inherit;
  background: none;
  border: none;
  cursor: pointer;
}

/* ---------- header ---------- */

.app-header {
  position: relative;
  width: 100%;
  max-width: 560px;
  text-align: center;
  padding: 2.2rem 1rem 0;
  color: var(--gold);
}

.header-clock {
  width: 56px;
  height: 56px;
  stroke: var(--gold);
}

.app-title {
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(2.4rem, 10vw, 3.2rem);
  letter-spacing: 0.04em;
  color: var(--gold);
  margin-top: 0.4rem;
  text-shadow: 0 0 24px rgba(213, 169, 90, 0.25);
}

.title-divider {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.7rem;
  margin-top: 0.9rem;
}

.title-divider .line {
  width: 88px;
  height: 1px;
  background: var(--gold-soft);
}

.title-divider .diamond { font-size: 0.9rem; color: var(--gold); }

.header-curve {
  width: 100%;
  height: 34px;
  margin-top: 0.8rem;
  stroke: var(--gold-dim);
  display: block;
}

.sparkle {
  position: absolute;
  color: var(--gold);
  font-size: 1.1rem;
  opacity: 0.9;
}

.s1 { left: 8%; top: 3.2rem; font-size: 0.85rem; }
.s2 { right: 7%; top: 9.5rem; }

.dot {
  position: absolute;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--gold-soft);
}

.d1 { left: 14%; top: 8.5rem; }
.d2 { right: 12%; top: 4rem; width: 3px; height: 3px; }

/* ---------- main / timer list ---------- */

.app-main {
  width: 100%;
  max-width: 560px;
  flex: 1;
  padding: 1.6rem 1.1rem 0.5rem;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.timer-list {
  list-style: none;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.timer-card {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 0.45rem;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.025), rgba(255, 255, 255, 0)) var(--card);
  border: 1px solid var(--card-border);
  border-radius: 22px;
  padding: 0.8rem 0.55rem 0.8rem 0.8rem;
  min-height: 88px;
}

.timer-card.finished { animation: finish-flash 0.6s ease-in-out 4; }

@keyframes finish-flash {
  50% { border-color: var(--gold); box-shadow: 0 0 18px rgba(213, 169, 90, 0.45); }
}

.play-btn {
  width: 54px;
  height: 54px;
  border-radius: 50%;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: inset 0 2px 3px rgba(255, 255, 255, 0.35), inset 0 -3px 4px rgba(0, 0, 0, 0.25), 0 2px 6px rgba(0, 0, 0, 0.4);
  flex-shrink: 0;
}

.play-btn svg { width: 30px; height: 30px; }
.play-btn .icon-play { margin-left: 3px; }
.play-btn .icon-pause { display: none; margin-left: 0; }
.timer-card.running .icon-play { display: none; }
.timer-card.running .icon-pause { display: block; }

.c0 .play-btn { background: linear-gradient(180deg, #f0b04a, #d98f2b); }
.c1 .play-btn { background: linear-gradient(180deg, #7ec95e, #57a83b); }
.c2 .play-btn { background: linear-gradient(180deg, #57a4e8, #3579c4); }
.c3 .play-btn { background: linear-gradient(180deg, #ab63d6, #8440b0); }
.c4 .play-btn { background: linear-gradient(180deg, #a0a0a6, #77777d); }

.name-area {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  min-width: 0;
  padding: 0.4rem 0;
  text-align: left;
}

.name-text {
  font-size: 1.02rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.name-text.placeholder { color: var(--text-dim); }

.icon-pencil {
  width: 19px;
  height: 19px;
  color: var(--gold);
  flex-shrink: 0;
}

.time-display {
  font-size: clamp(1.35rem, 5.6vw, 1.75rem);
  font-weight: 300;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
  padding: 0.4rem 0.1rem;
}

.timer-card.running .time-display { color: var(--gold); }

.menu-btn {
  width: 32px;
  height: 48px;
  color: var(--gold);
  display: flex;
  align-items: center;
  justify-content: center;
}

.menu-btn svg { width: 22px; height: 22px; }

/* ---------- add button ---------- */

.add-btn {
  width: 62px;
  height: 62px;
  border-radius: 50%;
  border: 1.5px solid var(--gold-soft);
  color: var(--gold);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 1.4rem 0 0.8rem;
  transition: background 0.2s;
}

.add-btn:active { background: rgba(213, 169, 90, 0.15); }
.add-btn svg { width: 28px; height: 28px; }

.add-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

/* ---------- footer ---------- */

.app-footer {
  position: relative;
  width: 100%;
  max-width: 560px;
  height: 74px;
  color: var(--gold);
  margin-top: auto;
}

.footer-waves {
  width: 100%;
  height: 54px;
  stroke: var(--gold-dim);
  display: block;
  margin-top: 14px;
}

.footer-hourglass {
  position: absolute;
  right: 1.4rem;
  bottom: 1rem;
  width: 30px;
  height: 30px;
}

.fd1 { left: 10%; bottom: 12px; }
.fd2 { left: 30%; bottom: 38px; width: 3px; height: 3px; }

/* ---------- corner settings button ---------- */

.icon-btn { color: var(--gold-soft); }

.corner-btn {
  position: fixed;
  top: calc(0.7rem + env(safe-area-inset-top));
  right: calc(0.8rem + env(safe-area-inset-right));
  width: 42px;
  height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 5;
}

.corner-btn svg { width: 23px; height: 23px; }

/* ---------- card menu popup ---------- */

.card-menu {
  position: absolute;
  z-index: 20;
  background: #232326;
  border: 1px solid var(--card-border);
  border-radius: 14px;
  overflow: hidden;
  min-width: 140px;
  box-shadow: 0 6px 22px rgba(0, 0, 0, 0.55);
}

.card-menu button {
  display: block;
  width: 100%;
  padding: 0.85rem 1.1rem;
  text-align: left;
  font-size: 1rem;
}

.card-menu button:active { background: rgba(255, 255, 255, 0.06); }
.card-menu .danger { color: #e07a6a; }

/* ---------- dialogs ---------- */

.app-dialog {
  background: #1d1d20;
  color: var(--text);
  border: 1px solid var(--card-border);
  border-radius: 22px;
  padding: 1.5rem 1.4rem;
  width: min(92vw, 380px);
  margin: auto;
}

.app-dialog::backdrop { background: rgba(0, 0, 0, 0.6); }

.app-dialog h2 {
  font-family: var(--serif);
  font-weight: 400;
  font-size: 1.35rem;
  color: var(--gold);
  text-align: center;
  margin-bottom: 1.2rem;
}

.field { display: block; margin-bottom: 1rem; }

.field > span {
  display: block;
  font-size: 0.85rem;
  color: var(--text-dim);
  margin-bottom: 0.35rem;
}

.field input[type="text"],
.field input[type="number"],
.field select {
  width: 100%;
  background: #131316;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 12px;
  color: var(--text);
  font-size: 1.15rem;
  padding: 0.7rem 0.8rem;
  font-family: inherit;
}

.field input:focus, .field select:focus {
  outline: none;
  border-color: var(--gold-soft);
}

.field.row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.field.row > span { margin-bottom: 0; font-size: 1rem; color: var(--text); }

.time-fields {
  display: flex;
  align-items: flex-end;
  gap: 0.6rem;
}

.time-fields .field { flex: 1; margin-bottom: 1rem; }

.time-fields input {
  text-align: center;
  font-size: 1.5rem;
  font-variant-numeric: tabular-nums;
}

.time-colon {
  font-size: 1.5rem;
  padding-bottom: 1.55rem;
  color: var(--text-dim);
}

.dialog-actions {
  display: flex;
  gap: 0.7rem;
  margin-top: 0.4rem;
}

.btn {
  flex: 1;
  padding: 0.8rem;
  border-radius: 14px;
  font-size: 1.05rem;
}

.btn.gold {
  background: linear-gradient(180deg, #e0b666, #c99a45);
  color: #1a1508;
  font-weight: 600;
}

.btn.ghost { border: 1px solid rgba(255, 255, 255, 0.18); }

/* ---------- switch ---------- */

.switch {
  appearance: none;
  width: 52px;
  height: 30px;
  border-radius: 15px;
  background: #3a3a3f;
  position: relative;
  transition: background 0.2s;
  flex-shrink: 0;
}

.switch::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #fff;
  transition: left 0.2s;
}

.switch:checked { background: var(--gold); }
.switch:checked::after { left: 25px; }

/* ---------- wider screens ---------- */

@media (min-width: 700px) {
  .app-header { padding-top: 3rem; }
  .timer-card { padding: 0.9rem 0.8rem 0.9rem 1rem; }
}
