* {
  box-sizing: border-box;
}

body {
  font-family: "Hiragino Sans", "Yu Gothic", "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at 20% 10%, rgba(212, 83, 126, 0.14), transparent 45%),
    radial-gradient(circle at 85% 30%, rgba(46, 196, 160, 0.12), transparent 40%),
    #1a0f2b;
  color: #ece3ff;
  margin: 0;
  padding: 24px;
  min-height: 100vh;
}

/* ランダムに瞬く星レイヤー */
.starfield {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  overflow: hidden;
}

.star {
  position: absolute;
  background: #f0cc3f;
  clip-path: polygon(50% 0%, 61% 35%, 98% 35%, 68% 57%, 79% 91%, 50% 70%, 21% 91%, 32% 57%, 2% 35%, 39% 35%);
  opacity: 0.15;
  filter: drop-shadow(0 0 4px rgba(240, 204, 63, 0.7));
  animation: twinkle var(--dur, 3s) ease-in-out var(--delay, 0s) infinite;
}

@keyframes twinkle {
  0%, 100% { opacity: 0.1; transform: scale(0.8); }
  50% { opacity: 0.95; transform: scale(1.15); }
}

@media (prefers-reduced-motion: reduce) {
  .star {
    animation: none;
    opacity: 0.2;
  }
}

/* ジョースターの星をちりばめた背景 */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='340' height='340' viewBox='0 0 340 340'%3E%3Cdefs%3E%3Cpath id='s' d='M12 2 14.09 8.26 20.66 8.26 15.28 12.14 17.37 18.4 12 14.52 6.63 18.4 8.72 12.14 3.34 8.26 9.91 8.26Z'/%3E%3C/defs%3E%3Cg fill='%23e8b923'%3E%3Cuse href='%23s' transform='translate(28,44) scale(1.5)' opacity='0.16'/%3E%3Cuse href='%23s' transform='translate(250,66) scale(0.9)' opacity='0.11'/%3E%3Cuse href='%23s' transform='translate(150,150) scale(2.3)' opacity='0.08'/%3E%3Cuse href='%23s' transform='translate(60,250) scale(1.1)' opacity='0.13'/%3E%3Cuse href='%23s' transform='translate(295,255) scale(1.5)' opacity='0.12'/%3E%3Cuse href='%23s' transform='translate(205,20) scale(0.75)' opacity='0.10'/%3E%3Cuse href='%23s' transform='translate(115,305) scale(0.95)' opacity='0.11'/%3E%3Cuse href='%23s' transform='translate(320,140) scale(0.8)' opacity='0.10'/%3E%3C/g%3E%3C/svg%3E");
  background-repeat: repeat;
  background-size: 340px 340px;
}

.container {
  max-width: 960px;
  margin: 0 auto;
}

/* --- 見出し（スタンド／荒木風） --- */
h1 {
  margin: 0 0 6px;
  font-family: "Reggae One", "Hiragino Sans", serif;
  font-size: 34px;
  font-style: italic;
  letter-spacing: 2px;
  color: #f0cc3f;
  text-shadow: 3px 3px 0 #5d2b7a, 5px 5px 0 rgba(0, 0, 0, 0.4);
  transform: skewX(-4deg);
}

.app-tagline {
  margin: 0 0 22px;
  font-size: 13px;
  letter-spacing: 4px;
  color: #b9a8e0;
  font-weight: 700;
}

.app-tagline .gogo {
  color: #e8b923;
  margin-left: 6px;
}

h2 {
  margin-top: 0;
  font-family: "Reggae One", "Hiragino Sans", serif;
  font-style: italic;
  letter-spacing: 1px;
}

/* --- ダッシュボード --- */
.dashboard {
  display: flex;
  gap: 16px;
  margin-bottom: 24px;
}

.stat {
  flex: 1;
  background: #2a1745;
  border: 1.5px solid #4b2d73;
  border-radius: 10px;
  padding: 16px;
  text-align: center;
}

.stat-num {
  font-size: 30px;
  font-weight: 800;
  color: #e8b923;
  font-style: italic;
}

.stat-label {
  font-size: 13px;
  color: #b9a8e0;
  margin-top: 4px;
}

.stat-highlight {
  background: #3a1230;
  border: 2px solid #d4537e;
  box-shadow: 0 0 14px rgba(212, 83, 126, 0.4);
  transform: scale(1.04);
}

.stat-highlight .stat-num {
  color: #ff7aa8;
}

.stat-highlight .stat-label {
  color: #f4b9cf;
  font-weight: 700;
}

/* --- 最新の振り返り --- */
.latest-reflection {
  background: #241238;
  border: 1.5px solid #e8b923;
  border-radius: 10px;
  padding: 14px 18px;
  margin-bottom: 24px;
}

.latest-reflection-label {
  font-size: 13px;
  font-weight: 700;
  color: #e8b923;
  margin-bottom: 4px;
  letter-spacing: 1px;
}

.latest-reflection-label span {
  font-weight: 400;
  color: #d9b3ff;
  margin-left: 6px;
}

.latest-reflection-body {
  font-size: 14px;
  color: #ece3ff;
  white-space: pre-wrap;
}

/* --- パネル --- */
.columns {
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
}

.panel {
  flex: 1;
  min-width: 320px;
  background: #241238;
  border: 1.5px solid #4b2d73;
  border-top: 4px solid transparent;
  border-radius: 10px;
  padding: 20px;
}

.panel-notes {
  border-top-color: #7f77dd;
}

.panel-notes h2 {
  color: #b3aef4;
}

.panel-tasks {
  border-top-color: #2ec4a0;
}

.panel-tasks h2 {
  color: #5dcaa5;
}

.panel-reflection {
  flex-basis: 100%;
  border-top-color: #e8b923;
}

.panel-reflection h2 {
  color: #e8b923;
}

/* --- フォーム --- */
.field-label {
  font-size: 12px;
  color: #b9a8e0;
  font-weight: 600;
}

.date-field {
  position: relative;
  display: flex;
}

.date-field input[type="date"] {
  width: 100%;
  color: transparent;
}

.date-field input[type="date"]::-webkit-datetime-edit,
.date-field input[type="date"]::-webkit-datetime-edit-fields-wrapper,
.date-field input[type="date"]::-webkit-datetime-edit-text,
.date-field input[type="date"]::-webkit-datetime-edit-year-field,
.date-field input[type="date"]::-webkit-datetime-edit-month-field,
.date-field input[type="date"]::-webkit-datetime-edit-day-field {
  color: transparent;
}

.date-field input[type="date"]::-webkit-calendar-picker-indicator {
  filter: invert(1) sepia(1) saturate(5) hue-rotate(5deg);
}

.date-field-value {
  position: absolute;
  left: 11px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 14px;
  color: #ece3ff;
  pointer-events: none;
}

.form {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 16px;
}

.form input,
.form textarea {
  padding: 8px 10px;
  background: #1c1030;
  border: 1px solid #4b2d73;
  border-radius: 6px;
  font-size: 14px;
  font-family: inherit;
  color: #ece3ff;
  resize: vertical;
}

.form input::placeholder,
.form textarea::placeholder {
  color: #7a6aa0;
}

.form input:focus,
.form textarea:focus,
.edit-form input:focus,
.edit-form textarea:focus {
  outline: none;
  border-color: #e8b923;
  box-shadow: 0 0 0 2px rgba(232, 185, 35, 0.3);
}

/* スタンド発現ボタン（金） */
.form button {
  align-self: flex-start;
  padding: 8px 18px;
  background: #e8b923;
  color: #241238;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 800;
  font-style: italic;
  letter-spacing: 1px;
  transition: transform 0.08s ease, background 0.15s ease;
}

.form button:hover {
  background: #f0cc3f;
}

.form button:active {
  transform: scale(0.96);
}

.panel-notes .form button {
  background: #7f77dd;
  color: #fff;
}

.panel-notes .form button:hover {
  background: #948dee;
}

.panel-tasks .form button {
  background: #2ec4a0;
  color: #04342c;
}

.panel-tasks .form button:hover {
  background: #4dd6b5;
}

/* --- リスト --- */
.list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 480px;
  overflow-y: auto;
}

.item {
  background: #2f1a4a;
  border: 1px solid #4b2d73;
  border-radius: 8px;
  padding: 10px 12px;
}

.item.genie-in {
  transform-origin: top center;
  animation: genie-in 0.8s cubic-bezier(0.22, 1, 0.36, 1);
}

/* スタンド発現フラッシュ（金） */
.screen-flash {
  position: fixed;
  inset: 0;
  z-index: 9999;
  pointer-events: none;
  background: #f0cc3f;
  opacity: 0;
  animation: screen-flash 0.3s ease-out forwards;
}

@keyframes screen-flash {
  0% { opacity: 0; }
  16.7% { opacity: 0.5; }
  33.3% { opacity: 0; }
  50% { opacity: 0.5; }
  66.7% { opacity: 0; }
  83.3% { opacity: 0.5; }
  100% { opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .screen-flash {
    animation: none;
  }
}

@keyframes genie-in {
  0% {
    opacity: 0;
    transform: perspective(700px) translateY(-28px) scaleX(0.55) scaleY(0.04);
  }
  45% {
    opacity: 1;
    transform: perspective(700px) translateY(-4px) scaleX(1) scaleY(1.06);
  }
  72% {
    transform: perspective(700px) translateY(0) scaleX(1) scaleY(0.96);
  }
  100% {
    transform: perspective(700px) translateY(0) scaleX(1) scaleY(1);
  }
}

@media (prefers-reduced-motion: reduce) {
  .item.genie-in {
    animation: none;
  }
}

/* オラオラ・バースト（タスク完了時） */
.burst {
  position: fixed;
  left: 50%;
  top: 42%;
  transform: translate(-50%, -50%) rotate(-8deg);
  z-index: 10000;
  pointer-events: none;
  font-family: "Reggae One", "Hiragino Sans", serif;
  font-size: 64px;
  font-style: italic;
  font-weight: 800;
  color: #e8b923;
  text-shadow: 4px 4px 0 #5d2b7a, 6px 6px 0 rgba(0, 0, 0, 0.5);
  animation: burst 0.7s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

@keyframes burst {
  0% { opacity: 0; transform: translate(-50%, -50%) rotate(-8deg) scale(0.3); }
  30% { opacity: 1; transform: translate(-50%, -50%) rotate(-8deg) scale(1.15); }
  70% { opacity: 1; transform: translate(-50%, -50%) rotate(-8deg) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -55%) rotate(-8deg) scale(1.05); }
}

@media (prefers-reduced-motion: reduce) {
  .burst {
    animation: none;
    display: none;
  }
}

/* --- 編集フォーム --- */
.edit-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.edit-form input,
.edit-form textarea {
  padding: 8px 10px;
  background: #1c1030;
  border: 1px solid #4b2d73;
  border-radius: 6px;
  font-size: 14px;
  font-family: inherit;
  color: #ece3ff;
  resize: vertical;
}

.edit-form .item-actions button[type="submit"] {
  background: #e8b923;
  color: #241238;
  border: none;
  font-weight: 700;
}

.edit-form .item-actions button[type="submit"]:hover {
  background: #f0cc3f;
}

/* --- 項目 --- */
.item-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
}

.item-title {
  font-weight: 700;
  color: #f4eeff;
}

.item-title.done {
  text-decoration: line-through;
  color: #7a6aa0;
}

.item-body {
  margin-top: 6px;
  font-size: 14px;
  color: #d3c7ee;
  white-space: pre-wrap;
}

.item-meta {
  margin-top: 6px;
  font-size: 12px;
  color: #9284b8;
}

.item-due {
  margin-top: 6px;
  font-size: 13px;
  font-weight: 700;
  color: #e8b923;
}

/* 期限が近い未完了タスクを3段階で強調（3日前→2日前→当日以前） */
.item.due-1 {
  background: #3a2b1a;
  border-color: #e8b923;
}
.item.due-2 {
  background: #43231a;
  border-color: #f0997b;
}
.item.due-3 {
  background: #4a1622;
  border-color: #ff4d6d;
  box-shadow: 0 0 12px rgba(255, 77, 109, 0.45);
}

.item-due.due-1 { color: #f0cc3f; }
.item-due.due-2 { color: #f5a98c; }
.item-due.due-3 { color: #ff8099; }

.item-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

.item-actions button {
  border: 1px solid #4b2d73;
  background: #1c1030;
  color: #d3c7ee;
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 12px;
  cursor: pointer;
}

.item-actions button:hover {
  background: #33205a;
}

.item-actions .delete-btn {
  color: #ff8099;
  border-color: #6b2440;
}

.badge {
  display: inline-block;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 10px;
  background: #4b2d73;
  color: #e7dcff;
  font-weight: 700;
}

.badge.done {
  background: #0f6e56;
  color: #9fe1cb;
}

.empty {
  color: #9284b8;
  font-size: 14px;
  font-style: italic;
}
