@import url('https://fonts.googleapis.com/css2?family=Klee+One:wght@400;600&display=swap');

/* ===== リセット & 変数 ===== */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

[hidden] { display: none !important; }

:root {
  --bg: #f7f4ec;
  --surface: #fdfbf5;
  --surface2: #ece8db;
  --border: #c8bfa8;
  --text: #1e1a14;
  --text-sub: #3d3020;
  --primary: #3d6b4f;
  --primary-dark: #2d5238;
  --primary-light: #daeee3;
  --error: #b04040;
  --error-bg: #fdf0f0;
  --radius: 3px;
  --radius-sm: 2px;
  --shadow: 2px 3px 8px rgba(0,0,0,0.12);
  --font: 'Klee One', 'Hiragino Maru Gothic ProN', 'BIZ UDPGothic', sans-serif;
  --line-h: 32px;
  --line-color: #c8d9ea;
  --margin-color: rgba(200, 80, 80, 0.35);
}

body {
  font-family: var(--font);
  font-weight: 600;
  background-color: var(--bg);
  background-image: repeating-linear-gradient(
    transparent 0px,
    transparent calc(var(--line-h) - 1px),
    var(--line-color) calc(var(--line-h) - 1px),
    var(--line-color) var(--line-h)
  );
  color: var(--text);
  line-height: 1.75;
  min-height: 100dvh;
}

/* ===== ページ共通 ===== */
.screen {
  max-width: 480px;
  margin: 0 auto;
  padding-bottom: 3rem;
  position: relative;
  overflow: hidden;
  min-height: 100dvh;
}

/* 赤い余白線 */
.screen::before {
  content: '';
  position: absolute;
  left: 2.6rem;
  right: auto;
  top: 0;
  bottom: 0;
  width: 1.5px;
  background: var(--margin-color);
  z-index: 1;
  pointer-events: none;
  transition: left 0.28s ease, right 0.28s ease;
}

.screen.margin-right::before {
  left: auto;
  right: 2.6rem;
}

.drawing-bg {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  perspective: 600px;
}

.page-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  transform-origin: center center;
  backface-visibility: hidden;
}

@keyframes flipOutNext {
  from { transform: rotateY(0deg);   opacity: 1;   }
  to   { transform: rotateY(-90deg); opacity: 0.1; }
}
@keyframes flipInNext {
  from { transform: rotateY(90deg);  opacity: 0.1; }
  to   { transform: rotateY(0deg);   opacity: 1;   }
}
@keyframes flipOutPrev {
  from { transform: rotateY(0deg);  opacity: 1;   }
  to   { transform: rotateY(90deg); opacity: 0.1; }
}
@keyframes flipInPrev {
  from { transform: rotateY(-90deg); opacity: 0.1; }
  to   { transform: rotateY(0deg);   opacity: 1;   }
}

.flip-out-next { animation: flipOutNext 0.28s ease-in  forwards; }
.flip-in-next  { animation: flipInNext  0.28s ease-out 0.28s backwards; }
.flip-out-prev { animation: flipOutPrev 0.28s ease-in  forwards; }
.flip-in-prev  { animation: flipInPrev  0.28s ease-out 0.28s backwards; }

/* ページナビ */
.page-nav {
  position: fixed;
  bottom: 1rem;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  z-index: 10;
  background: rgba(253,251,245,0.88);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 0.3rem 0.9rem;
  font-family: var(--font);
  box-shadow: 0 2px 8px rgba(0,0,0,0.13);
  backdrop-filter: blur(4px);
}

.page-nav.hidden { display: none; }

.page-nav__btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1rem;
  color: var(--primary);
  padding: 0.15rem 0.4rem;
  -webkit-tap-highlight-color: transparent;
  line-height: 1;
}

.page-nav__btn:disabled { opacity: 0.25; cursor: default; }

.page-nav__label {
  font-size: 0.82rem;
  color: var(--text-sub);
  min-width: 3.2rem;
  text-align: center;
  letter-spacing: 0.05em;
}

.drawing-bg-item {
  position: absolute;
  width: 130px;
  opacity: 0.25;
  border-radius: 2px;
  transform-origin: center;
}

.drawing-bg-item img {
  display: block;
  width: 100%;
  max-height: 82px;
  object-fit: cover;
  border-radius: 2px;
}

.tape {
  position: absolute;
  top: -10px;
  left: 50%;
  width: 46px;
  height: 15px;
  border-radius: 1px;
  z-index: 1;
  box-shadow: 0 1px 2px rgba(0,0,0,0.1);
}

.app-header {
  position: relative;
  z-index: 2;
  background: #2b4f38;
  color: #f0ede4;
  text-align: center;
  padding: 1.4rem 1rem 1.2rem;
  border-bottom: 4px solid #1a3325;
}

.container {
  position: relative;
  z-index: 2;
  padding: 1.2rem 1rem 1.2rem 3.2rem;
}

.app-title {
  font-size: 1.4rem;
  font-weight: 600;
  letter-spacing: 0.08em;
}

.app-cottage {
  font-size: 0.85rem;
  opacity: 0.8;
  margin-top: 0.2rem;
  letter-spacing: 0.05em;
}

.section {
  margin-bottom: 1.8rem;
}

.section-title {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  font-weight: 600;
  color: #3d2b00;
  background: linear-gradient(to right, #dba830 0px, #dba830 10px, #fef08a 10px);
  padding: 0.28rem calc(0.7rem + 14px) 0.28rem 0.7rem;
  margin-bottom: 1rem;
  letter-spacing: 0.06em;
  clip-path: polygon(0 0, 100% 0, calc(100% - 14px) 50%, 100% 100%, 0 100%);
  filter: drop-shadow(1px 2px 3px rgba(0,0,0,0.13));
  transform: rotate(-0.5deg);
  transform-origin: left center;
}

/* ===== メッセージカード ===== */
.message-card {
  background: rgba(255,254,248,0.72);
  border: 1px solid #d4cbb8;
  border-radius: var(--radius);
  padding: 0.85rem 1rem;
  margin-bottom: 0.75rem;
  box-shadow: 2px 3px 6px rgba(0,0,0,0.09);
  backdrop-filter: blur(1px);
}

.message-card__header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 0.4rem;
  gap: 0.5rem;
}

.message-card__author {
  font-weight: 600;
  font-size: 0.88rem;
  color: var(--primary-dark);
}

.message-card__date {
  font-size: 0.75rem;
  color: var(--text-sub);
  flex-shrink: 0;
}

.message-card__cottage {
  display: inline-block;
  font-size: 0.75rem;
  color: var(--text-sub);
  background: var(--surface2);
  border-radius: 2px;
  padding: 0.1em 0.5em;
  margin-bottom: 0.4rem;
}

.message-card__text {
  font-size: 0.93rem;
  white-space: pre-wrap;
  color: var(--text);
}

.loading-text,
.empty-text {
  text-align: center;
  color: var(--text-sub);
  font-size: 0.9rem;
  padding: 1.5rem;
  background: rgba(255,255,248,0.6);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
}

/* ===== フォーム ===== */
.visit-greeting {
  font-size: 0.95rem;
  font-weight: 600;
  color: #5a4200;
  background: #fff9cc;
  border-left: 3px solid #e0b830;
  border-radius: 0 var(--radius) var(--radius) 0;
  padding: 0.6rem 0.9rem;
  margin-bottom: 1rem;
  box-shadow: 1px 2px 4px rgba(0,0,0,0.08);
}

.visit-greeting:empty {
  display: none;
}

.form-group {
  margin-bottom: 1.2rem;
}

.form-label {
  display: block;
  font-size: 0.88rem;
  font-weight: 600;
  margin-bottom: 0.3rem;
  color: var(--text-sub);
  letter-spacing: 0.03em;
}

.required {
  color: var(--error);
  margin-left: 0.15rem;
}

.form-input {
  width: 100%;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 0.45rem 0.7rem;
  font-size: 1rem;
  font-family: var(--font);
  font-weight: 600;
  background: #fff;
  color: var(--text);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.form-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(61,107,79,0.15);
}

.form-textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.65rem 0.85rem;
  font-size: 1rem;
  font-family: var(--font);
  background: rgba(255,255,248,0.72);
  color: var(--text);
  outline: none;
  resize: vertical;
  min-height: 110px;
  line-height: 1.75;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.form-textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(61,107,79,0.15);
}

.char-count {
  display: block;
  text-align: right;
  font-size: 0.78rem;
  color: var(--text-sub);
  margin-top: 0.25rem;
}

/* ===== ボタン ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.7rem 1.4rem;
  border-radius: var(--radius);
  font-size: 0.95rem;
  font-weight: 600;
  font-family: var(--font);
  border: none;
  cursor: pointer;
  text-decoration: none;
  letter-spacing: 0.03em;
  transition: background 0.15s, transform 0.1s, box-shadow 0.1s;
  -webkit-tap-highlight-color: transparent;
}

.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

.btn--full { width: 100%; }

.btn--primary {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}
.btn--primary:hover { background: var(--primary-dark); }

.btn--secondary {
  background: var(--surface);
  color: var(--primary);
  border: 1.5px solid var(--primary);
}
.btn--secondary:hover { background: var(--primary-light); }

.btn--outline {
  background: rgba(255,255,248,0.7);
  color: var(--text-sub);
  border: 1px solid var(--border);
}
.btn--outline:hover { background: var(--surface2); }

/* ===== チェックイン後：3ゾーンレイアウト ===== */
#screen-checkin {
  display: flex;
  flex-direction: column;
}

#screen-checkin .container {
  flex: 1;
  display: flex;
  flex-direction: column;
}

#after-checkin {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding-bottom: 1.5rem;
}

.after-checkin__top {
  padding-top: 2rem;
  text-align: center;
}

.welcome-title {
  font-size: 1.7rem;
  font-weight: 600;
  color: var(--primary-dark);
  margin-bottom: 0.5rem;
}

.welcome-sub {
  font-size: 0.9rem;
  color: var(--text-sub);
  line-height: 1.6;
}

.after-checkin__middle {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.after-checkin__bottom {
  padding-top: 1rem;
}

.action-buttons {
  display: flex;
  gap: 0.75rem;
}

.action-buttons .btn {
  flex: 1;
}

.btn--green {
  background: #2f4a2f;
  color: #fff;
  box-shadow: 0 2px 6px rgba(0,0,0,0.2);
}

.btn--green:hover { background: #1e3420; }

.btn--action {
  padding-top: 0.9rem;
  padding-bottom: 0.9rem;
  font-size: 1rem;
}

/* ===== 完了画面 ===== */
.completion {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 80dvh;
  padding: 2rem;
  text-align: center;
  gap: 1rem;
  position: relative;
  z-index: 2;
}

.completion__icon {
  font-size: 4rem;
}

.completion__title {
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--primary);
  letter-spacing: 0.05em;
}

.completion__message {
  font-size: 0.98rem;
  color: var(--text-sub);
  line-height: 2;
}

/* ===== 付箋ナビ（完了画面） ===== */
.sticky-nav {
  display: flex;
  gap: 1.2rem;
  justify-content: center;
  margin: 0.5rem 0 1.2rem;
}

.sticky-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 110px;
  height: 110px;
  border-radius: 2px;
  text-decoration: none;
  box-shadow: 3px 4px 10px rgba(0,0,0,0.18), inset 0 -3px 0 rgba(0,0,0,0.08);
  transform: rotate(-2deg);
  transition: transform 0.15s, box-shadow 0.15s;
  position: relative;
  gap: 0.4rem;
}

.sticky-btn:nth-child(2) {
  transform: rotate(1.5deg);
}

.sticky-btn:active {
  transform: rotate(0deg) scale(0.96);
  box-shadow: 1px 2px 5px rgba(0,0,0,0.18);
}

.sticky-btn--yellow {
  background: #fff176;
}

.sticky-btn--blue {
  background: #b3e5fc;
}

.sticky-btn__icon {
  font-size: 2rem;
  line-height: 1;
}

.sticky-btn__label {
  font-size: 0.82rem;
  font-weight: 600;
  color: #333;
  font-family: var(--font);
  letter-spacing: 0.03em;
}

/* ===== エラー ===== */
.error-text {
  color: var(--error);
  background: var(--error-bg);
  border: 1px solid #f0c0c0;
  border-radius: var(--radius);
  padding: 0.55rem 0.8rem;
  font-size: 0.88rem;
  margin-bottom: 0.75rem;
}

.error-text:empty {
  display: none;
}

/* ===== 描画キャンバス ===== */
.canvas-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.6rem;
  gap: 0.5rem;
}

.color-palette {
  display: flex;
  gap: 0.5rem;
}

.color-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 3px solid transparent;
  cursor: pointer;
  transition: border-color 0.15s, transform 0.1s;
  -webkit-tap-highlight-color: transparent;
  flex-shrink: 0;
}

.color-btn.active {
  border-color: var(--text);
  transform: scale(1.15);
}

#drawing-canvas {
  display: block;
  width: 100%;
  aspect-ratio: 8 / 5;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  background: #f7f4ec;
  cursor: crosshair;
  touch-action: none;
  margin-bottom: 0.75rem;
  box-shadow: 2px 3px 6px rgba(0,0,0,0.1);
}

/* ===== 絵ギャラリー ===== */
.drawing-gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: 0.5rem;
}

.drawing-thumb {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: #fffef8;
  box-shadow: 1px 2px 4px rgba(0,0,0,0.08);
}

.drawing-thumb img {
  display: block;
  width: 100%;
  aspect-ratio: 8 / 5;
  object-fit: contain;
}

.history-photo {
  display: block;
  width: 100%;
  border-radius: var(--radius);
  margin-bottom: 0.5rem;
  object-fit: cover;
  max-height: 200px;
}

.drawing-thumb__label {
  font-size: 0.7rem;
  color: var(--text-sub);
  padding: 0.2rem 0.4rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
