:root {
  --bg: #b7e3ff;
  --panel: rgba(206, 233, 249, 0.42);
  --line: rgba(123, 193, 229, 0.72);
  --accent: #49a9df;
  --accent-strong: #2f95d1;
  --text: #123455;
  --ok: #56b3df;
  --glass-shadow: 0 10px 30px rgba(18, 80, 122, 0.2);
  --glass-blur: blur(14px);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Hiragino Kaku Gothic ProN", "Yu Gothic", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at 8% 0%, rgba(198, 232, 255, 0.95) 0%, transparent 40%),
    radial-gradient(circle at 95% 100%, rgba(170, 220, 250, 0.9) 0%, transparent 38%),
    linear-gradient(135deg, #a9dcff 0%, #84c9f3 45%, #9fd7ff 100%),
    var(--bg);
  min-height: 100vh;
}

.app {
  width: min(920px, 92vw);
  margin: 24px auto 40px;
  display: grid;
  gap: 16px;
}

.hero {
  text-align: center;
  padding: 16px;
}

.hero h1 {
  margin: 0;
  font-size: clamp(2rem, 4vw, 3rem);
  letter-spacing: 0.04em;
}

.hero p {
  margin: 8px 0 0;
  opacity: 0.8;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 16px;
  box-shadow: var(--glass-shadow);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
}

h2 {
  margin-top: 0;
}

.row {
  display: flex;
  gap: 8px;
}

input,
textarea,
button {
  font: inherit;
}

input,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px;
  background: rgba(214, 238, 252, 0.62);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

button {
  border: 1px solid rgba(255, 255, 255, 0.5);
  border-radius: 10px;
  padding: 10px 14px;
  background: linear-gradient(135deg, rgba(86, 178, 230, 0.9), rgba(54, 157, 216, 0.88));
  color: white;
  cursor: pointer;
  box-shadow: 0 6px 16px rgba(54, 157, 216, 0.24);
}

button:hover {
  background: linear-gradient(135deg, rgba(86, 178, 230, 1), rgba(54, 157, 216, 1));
}

.task-list {
  list-style: none;
  padding: 0;
  margin: 14px 0 0;
  display: grid;
  gap: 8px;
}

.task-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(202, 232, 250, 0.5);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.task-item.done .task-text {
  text-decoration: line-through;
  opacity: 0.6;
}

.task-text {
  margin: 0;
  flex: 1;
}

.task-actions {
  display: flex;
  gap: 6px;
}

.task-actions button {
  padding: 6px 10px;
}

.done-btn {
  background: var(--ok);
}

.timer-panel {
  text-align: center;
}

.timer-display {
  font-size: clamp(2.2rem, 7vw, 4rem);
  font-weight: 700;
  margin: 8px 0 12px;
}

.timer-modes {
  display: inline-flex;
  gap: 6px;
  padding: 4px;
  margin-bottom: 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(187, 223, 245, 0.42);
}

.timer-mode-btn {
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 0.85rem;
  box-shadow: none;
  background: rgba(107, 183, 228, 0.45);
  border-color: rgba(255, 255, 255, 0.55);
}

.timer-mode-btn.active {
  background: linear-gradient(135deg, rgba(86, 178, 230, 0.95), rgba(54, 157, 216, 0.95));
  box-shadow: 0 4px 10px rgba(54, 157, 216, 0.22);
}

.controls {
  justify-content: center;
}

.hint {
  opacity: 0.75;
}

.xp-card,
.streak-card,
.achievement-panel {
  border: 1px solid var(--line);
  border-radius: 12px;
  margin-bottom: 14px;
  box-shadow: var(--glass-shadow);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
}

.xp-card {
  position: relative;
  overflow: hidden;
  padding: 12px;
  background: rgba(197, 229, 250, 0.45);
}

.xp-card.level-up-active {
  animation: levelCardFlash 1s ease;
}

.level-up-effect {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  opacity: 0;
}

.xp-card.level-up-active .level-up-effect {
  animation: levelUpPop 0.9s ease;
}

.level-up-text {
  margin: 0;
  padding: 6px 12px;
  border-radius: 999px;
  font-size: clamp(1rem, 3vw, 1.3rem);
  font-weight: 800;
  letter-spacing: 0.08em;
  color: #0f4d70;
  background: rgba(225, 244, 255, 0.75);
  border: 1px solid rgba(160, 216, 245, 0.7);
  box-shadow: 0 8px 24px rgba(45, 159, 218, 0.2);
}

.xp-title {
  margin: 0;
  font-size: 0.8rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  opacity: 0.75;
}

.xp-level {
  margin: 4px 0;
  font-size: clamp(1.5rem, 5vw, 2.2rem);
  font-weight: 800;
}

.xp-total {
  margin: 0 0 8px;
  font-weight: 600;
}

.streak-card {
  position: relative;
  overflow: hidden;
  padding: 12px;
  background: rgba(194, 227, 249, 0.45);
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.streak-title {
  margin: 0;
  font-size: 0.8rem;
  letter-spacing: 0.08em;
  opacity: 0.75;
  text-transform: uppercase;
}

.streak-count {
  margin: 4px 0;
  font-size: clamp(1.6rem, 5vw, 2.4rem);
  font-weight: 800;
}

.streak-status {
  margin: 0 0 8px;
  font-weight: 600;
}

.streak-progress {
  width: 100%;
  height: 8px;
  border-radius: 999px;
  background: rgba(193, 230, 250, 0.62);
  overflow: hidden;
}

.level-progress-fill,
.streak-progress-fill {
  height: 100%;
  width: 3%;
  border-radius: 999px;
  background: linear-gradient(90deg, #89cef4, #4da7dc);
  transition: width 0.35s ease;
}

.streak-badges {
  margin-top: 8px;
  letter-spacing: 0.2em;
  min-height: 20px;
  color: #3c93c8;
}

.streak-tier-1 {
  box-shadow: 0 0 0 3px rgba(154, 215, 245, 0.2), var(--glass-shadow);
}

.streak-tier-2,
.streak-tier-3,
.streak-tier-4,
.streak-tier-5,
.streak-tier-6,
.streak-tier-7,
.streak-tier-8,
.streak-tier-9,
.streak-tier-10 {
  animation: tierPulse 2s ease-in-out infinite;
}

.streak-tier-10 {
  animation: tierPulse 0.58s ease-in-out infinite, tierGlow 1.05s ease-in-out infinite;
}

.fold-tab {
  padding: 0;
  overflow: hidden;
  background: rgba(192, 225, 247, 0.45);
}

.fold-tab-head {
  list-style: none;
  cursor: pointer;
  padding: 12px;
  font-size: 1rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(182, 219, 244, 0.4);
}

.fold-tab-head::-webkit-details-marker {
  display: none;
}

.fold-tab-head::after {
  content: "▸";
  font-size: 0.9rem;
  opacity: 0.8;
  transition: transform 0.2s ease;
}

.fold-tab[open] .fold-tab-head::after {
  transform: rotate(90deg);
}

.fold-tab-body {
  padding: 0 12px 12px;
  border-top: 1px solid rgba(138, 195, 228, 0.38);
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.stat-card,
.achievement-item,
.collection-card,
.ranking-item {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 10px;
  background: rgba(198, 229, 248, 0.5);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.stat-card {
  padding: 10px;
}

.stat-label {
  margin: 0;
  font-size: 0.85rem;
  opacity: 0.75;
}

.stat-value {
  margin: 6px 0 0;
  font-size: 1.4rem;
  font-weight: 700;
}

.achievement-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 8px;
}

.achievement-item.unlocked {
  border-color: #84cbed;
  box-shadow: 0 0 0 2px rgba(132, 203, 237, 0.2);
}

.achievement-item.hidden {
  border-color: #d6c5f3;
  background: linear-gradient(135deg, #fbf8ff 0%, #f3ebff 100%);
}

.achievement-item.hidden.unlocked {
  border-color: #b58af0;
  background: linear-gradient(135deg, #f7f0ff 0%, #ebdeff 100%);
  box-shadow: 0 0 0 2px rgba(181, 138, 240, 0.24);
}

.achievement-head {
  display: flex;
  align-items: center;
  gap: 8px;
}

.achievement-title {
  margin: 0;
  font-weight: 700;
}

.achievement-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  height: 28px;
  padding: 0 8px;
  border-radius: 999px;
  border: 1px solid #b8dff4;
  background: #f2faff;
  font-size: 0.9rem;
}

.achievement-badge.collection {
  min-width: 58px;
  height: 34px;
  font-size: 1.05rem;
}

.achievement-badge.locked {
  opacity: 0.55;
  filter: grayscale(0.9);
}

.achievement-badge.rarity-common.unlocked {
  background: linear-gradient(135deg, #f5fbff, #e5f5ff);
}

.achievement-badge.rarity-uncommon.unlocked {
  background: linear-gradient(135deg, #eefcff, #d8f3ff);
}

.achievement-badge.rarity-rare.unlocked {
  background: linear-gradient(135deg, #ecf9ff, #cdeeff, #e7f8ff);
}

.achievement-badge.rarity-epic.unlocked {
  background: linear-gradient(135deg, #e8f7ff, #bfe7ff, #dff4ff);
}

.achievement-badge.rarity-legendary.unlocked {
  background: linear-gradient(135deg, #fff8ec, #ffe0b2, #fff0d7);
  animation: badgeShine 2.2s ease-in-out infinite;
}

.achievement-badge.hidden-theme {
  border-color: #c7a9f8;
  background: linear-gradient(135deg, #f5eaff, #ebdcff);
}

.achievement-badge.hidden-theme.unlocked {
  border-color: #a06cf0;
  background: linear-gradient(135deg, #f1e2ff, #dbc1ff, #eddfff);
  animation: hiddenGlow 2.1s ease-in-out infinite;
}

.achievement-meta,
.record-meta,
.collection-status {
  margin: 2px 0 0;
  font-size: 0.82rem;
  opacity: 0.75;
}

.collection-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(145px, 1fr));
  gap: 10px;
}

.collection-card {
  min-height: 132px;
}

.collection-card.hidden {
  border-color: #d6c5f3;
  background: linear-gradient(135deg, #fbf8ff 0%, #f3ebff 100%);
}

.collection-card.hidden.unlocked {
  border-color: #b58af0;
  background: linear-gradient(135deg, #f7f0ff 0%, #ebdeff 100%);
}

.collection-badge-wrap {
  display: flex;
  justify-content: center;
  margin-bottom: 6px;
}

.collection-name {
  margin: 0;
  text-align: center;
  font-size: 0.9rem;
  font-weight: 700;
}

.ranking-list {
  margin: 0;
  padding-left: 1.2rem;
  display: grid;
  gap: 8px;
}

.ranking-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.ranking-item.top1 {
  background: linear-gradient(135deg, rgba(191, 227, 250, 0.76), rgba(168, 213, 243, 0.66));
}

.ranking-item.top2 {
  background: linear-gradient(135deg, rgba(186, 223, 248, 0.76), rgba(160, 208, 242, 0.66));
}

.ranking-item.top3 {
  background: linear-gradient(135deg, rgba(180, 219, 247, 0.76), rgba(152, 203, 240, 0.66));
}

.ranking-date,
.ranking-minutes {
  margin: 0;
}

.chart-wrap h3,
.panel h3 {
  margin: 8px 0;
  font-size: 1rem;
}

.focus-chart {
  display: grid;
  grid-template-columns: repeat(14, minmax(0, 1fr));
  align-items: end;
  gap: 6px;
  height: 190px;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 8px;
  background: rgba(189, 223, 247, 0.45);
  margin-bottom: 14px;
}

.bar-wrap {
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: center;
  min-width: 0;
}

.bar {
  width: 100%;
  max-width: 26px;
  border-radius: 6px 6px 3px 3px;
  background: linear-gradient(180deg, #9ad7f5, #66b8e8);
  transition: height 0.25s ease;
}

.bar-label {
  margin-top: 4px;
  font-size: 0.65rem;
  opacity: 0.8;
}

#share-data-text {
  margin-top: 8px;
  min-height: 120px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, "Courier New", monospace;
  font-size: 0.8rem;
  line-height: 1.4;
}

#sync-status {
  margin-top: 6px;
}

@keyframes tierPulse {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-2px);
  }
}

@keyframes tierGlow {
  0%,
  100% {
    filter: saturate(1);
  }
  50% {
    filter: saturate(1.1);
  }
}

@keyframes levelCardFlash {
  0% {
    box-shadow: 0 0 0 rgba(45, 159, 218, 0);
  }
  35% {
    box-shadow: 0 0 0 12px rgba(45, 159, 218, 0.22);
  }
  100% {
    box-shadow: 0 0 0 rgba(45, 159, 218, 0);
  }
}

@keyframes levelUpPop {
  0% {
    opacity: 0;
    transform: scale(0.7) translateY(8px);
  }
  20% {
    opacity: 1;
    transform: scale(1.05) translateY(0);
  }
  70% {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
  100% {
    opacity: 0;
    transform: scale(0.96) translateY(-4px);
  }
}

@keyframes badgeShine {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-1px);
  }
}

@keyframes hiddenGlow {
  0%,
  100% {
    filter: saturate(1);
  }
  50% {
    filter: saturate(1.14);
  }
}

@media (max-width: 640px) {
  .row {
    flex-direction: column;
  }

  .focus-chart {
    height: 170px;
    gap: 4px;
  }
}
