:root {
  --text-main: #2c3e50;
  --text-muted: #7f8c8d;
  --accent-primary: #34495e; /* Elegant dark slate for buttons/accents */
  --accent-primary-hover: #2c3e50;
  --accent-secondary: #27ae60;
  --paper-bg: #fcfcf9; /* Premium warm paper */
  font-family: 'Zen Kaku Gothic New', 'Noto Sans JP', sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0;
  color: var(--text-main);
  min-height: 100vh;
  overflow-x: hidden;
  position: relative;
  background-color: transparent;
}

::selection { background: rgba(52, 73, 94, 0.2); }
:focus-visible { outline: 2px solid var(--accent-primary); outline-offset: 2px; }

/* Dynamic Background */
.bg-fx {
  position: fixed; top: 0; left: 0; width: 100vw; height: 100vh;
  z-index: -1; overflow: hidden; pointer-events: none;
  background-color: #ecf0f1;
}
.bg-image {
  position: absolute; top: 0; left: 0; width: 100%; height: 100%;
  background-size: cover; background-position: center;
  filter: brightness(0.9);
  transform: scale(1.05);
  opacity: 0;
  transition: opacity 3s ease-in-out;
}
.bg-image.active { opacity: 1; }

.bg-cafe { background-image: url('assets/bg_cafe.jpg?v=2'); }
.bg-crowd { background-image: url('assets/bg_crowd.jpg?v=2'); }

.wrap { max-width: 800px; margin: 0 auto; padding: 40px 20px 80px; position: relative; z-index: 1; }

/* Header & Navigation */
.global-header {
  background: #1a252f;
  color: #fff;
  padding: 12px 20px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.2);
  position: sticky; top: 0; z-index: 100;
}
.header-inner {
  max-width: 900px; margin: 0 auto;
  display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 12px;
}
.title-box { display: flex; flex-direction: column; }
h1.title { font-family: 'Zen Maru Gothic', sans-serif; font-weight: 700; font-size: 22px; margin: 0; letter-spacing: 0.05em; }
p.subtitle { margin: 4px 0 0; font-size: 11px; opacity: 0.8; font-weight: 500; }

.header-nav { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.header-nav a { color: #fff; text-decoration: none; font-size: 13px; font-weight: 700; transition: opacity 0.2s; }
.header-nav a:hover { opacity: 0.8; }
.header-nav i { margin-right: 4px; color: var(--accent-secondary); }

.auth-box { display: flex; align-items: center; max-width: 100%; overflow: hidden; }
.user-chip { display: flex; align-items: center; gap: 8px; background: rgba(255,255,255,0.1); padding: 6px 12px; border-radius: 4px; font-size: 12px; font-weight: 500; }
.logout-link { color: #fff; text-decoration: underline; cursor: pointer; font-size: 11px; margin-left: 8px; opacity: 0.9; }
.logout-link:hover { opacity: 1; }

@media (max-width: 600px) {
  .header-inner { flex-direction: column; align-items: flex-start; }
  .header-nav { width: 100%; flex-direction: column; align-items: flex-start; gap: 12px; margin-top: 12px; }
  .nav-links { display: flex; gap: 16px; }
  .auth-box { width: 100%; justify-content: flex-start; }
}

/* Premium Notebook Style (Ruled Paper Texture) */
.notebook {
  background-color: var(--paper-bg);
  background-image: repeating-linear-gradient(transparent, transparent 31px, #e8eaed 31px, #e8eaed 32px);
  border-radius: 4px 16px 16px 4px;
  border-left: 18px solid #2c3e50; /* Elegant cloth binding spine */
  box-shadow: 0 15px 40px rgba(0,0,0,0.15), inset 12px 0 20px rgba(0,0,0,0.03);
  position: relative;
  padding: 50px 40px 50px 60px;
  min-height: 80vh;
}
@media (max-width: 600px) {
  .notebook { padding: 40px 20px 40px 40px; border-left: 12px solid #2c3e50; border-radius: 2px 12px 12px 2px; }
}

/* Notebook Rings (Metallic Refined) */
.notebook-rings {
  position: absolute; left: -10px; top: 0; height: 100%; width: 20px;
  display: flex; flex-direction: column; justify-content: space-evenly;
}
.ring {
  width: 28px; height: 8px;
  background: linear-gradient(180deg, #dcdde1, #f5f6fa 40%, #7f8fa6);
  border-radius: 4px;
  box-shadow: 1px 2px 4px rgba(0,0,0,0.4), inset 0 1px 1px rgba(255,255,255,0.8);
  position: relative; left: -6px;
}

/* Steps */
.step-section { 
  position: relative; margin-bottom: 50px; 
}

.step-header { 
  display: inline-block;
  background: #2c3e50; 
  padding: 8px 16px; 
  border-radius: 6px; 
  margin-bottom: 16px; 
}
.step-header h2 { 
  font-family: 'Zen Maru Gothic', sans-serif; 
  font-size: 18px; 
  margin: 0; 
  color: #fff; 
}
.step-num {
  display: flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; background: var(--text-main); color: #fff;
  border-radius: 50%; font-family: 'Zen Maru Gothic', sans-serif; font-size: 15px; font-weight: 700;
}
.step-desc { font-size: 13.5px; color: var(--text-muted); margin: 0 0 24px 0; line-height: 1.6; }

.notebook-divider { border: 0; height: 1px; background: rgba(0,0,0,0.06); margin: 50px 0; }

/* Input Card */
.input-card {
  background: #fff;
  border: 1px solid rgba(0,0,0,0.04);
  border-radius: 8px;
  padding: 24px;
  margin-left: 44px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.02);
  transition: box-shadow 0.3s ease;
}
.input-card:focus-within { box-shadow: 0 4px 16px rgba(0,0,0,0.05); }
@media (max-width: 600px) { .input-card { margin-left: 0; } .step-desc { margin-left:0; } }

.card-label { display: block; font-size: 12px; font-weight: 700; color: var(--text-muted); margin-bottom: 8px; text-transform: uppercase; letter-spacing: 0.05em; }
textarea, input[type=text] {
  width: 100%; font-family: inherit; font-size: 15px; color: var(--text-main);
  background: transparent; border: none; border-bottom: 1px solid rgba(0,0,0,0.15);
  padding: 8px 4px; margin-bottom: 24px; resize: vertical; line-height: 1.6;
  transition: border-color 0.2s ease;
}
textarea:focus, input[type=text]:focus { outline: none; border-bottom-color: var(--accent-primary); }
textarea::placeholder, input::placeholder { color: #bdc3c7; font-size: 14px; }

/* Buttons */
.action-row { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
button { font-family: inherit; cursor: pointer; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: none; border-radius: 6px; padding: 12px 24px; font-size: 14px; font-weight: 700;
  transition: all 0.2s ease; letter-spacing: 0.02em;
}
.btn i { font-size: 15px; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-write { background: #2980b9; color: #fff; box-shadow: 0 2px 6px rgba(0,0,0,0.1); }
.btn-write:hover:not(:disabled) { background: #2471a3; box-shadow: 0 4px 12px rgba(0,0,0,0.15); }

.draw-area { text-align: center; margin: 40px 0; }
.btn-draw {
  background: #2980b9; color: #fff; font-size: 15px; padding: 16px 40px;
  border-radius: 30px; box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}
.btn-draw:hover:not(:disabled) { background: #2471a3; box-shadow: 0 6px 16px rgba(0,0,0,0.2); transform: translateY(-1px); }
.btn-shuffle { background: transparent; border: 1px solid rgba(0,0,0,0.15); color: var(--text-muted); padding: 10px 20px; border-radius: 20px; font-size: 13px; margin-top: 16px; }
.btn-shuffle:hover:not(:disabled) { background: rgba(0,0,0,0.02); color: var(--text-main); }

.btn-save { background: var(--accent-secondary); color: #fff; }
.btn-save:hover:not(:disabled) { background: #219a52; }

.status-line { font-size: 13px; font-weight: 700; color: var(--accent-secondary); }
.status-line.error { color: #e74c3c; }

/* Match Cards */
.match-row { display: flex; align-items: stretch; gap: 16px; margin: 30px 0; }
@media (max-width: 600px) { .match-row { flex-direction: column; } }
.match-card {
  flex: 1; background: #fff; border: 1px solid rgba(0,0,0,0.06);
  border-radius: 8px; padding: 20px; box-shadow: 0 2px 8px rgba(0,0,0,0.02);
  display: flex; flex-direction: column; position: relative;
}
.match-card .text { font-size: 15px; line-height: 1.7; flex: 1; font-weight: 500; }
.match-x { display: flex; align-items: center; justify-content: center; font-size: 20px; color: #bdc3c7; }

/* Idea Panel */
.idea-panel { background: #fff; border: 1px solid rgba(0,0,0,0.06); border-radius: 8px; padding: 24px; margin-top: 30px; box-shadow: 0 2px 8px rgba(0,0,0,0.02); }
.idea-panel h3 { margin: 0 0 16px; font-size: 15px; color: var(--text-main); font-weight: 700; display: flex; align-items: center; gap: 8px; }

/* Hints */
.hints { margin-bottom: 16px; }
.hint-item {
  font-weight: 500;
  font-size: 14px;
  color: var(--text-main);
  background: #fdfcf9;
  padding: 12px 16px;
  border-left: 4px solid var(--accent-secondary);
  border-radius: 4px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.05);
  line-height: 1.6;
}

/* Hint Board (Clean Paper Style) */
.hint-board {
  background: rgba(255,255,255,0.95);
  border-radius: 8px; padding: 40px;
  box-shadow: 0 4px 24px rgba(0,0,0,0.08);
  margin-top: 40px;
}
.hint-title { font-family: 'Zen Maru Gothic', sans-serif; font-size: 18px; color: var(--text-main); margin: 0 0 10px; display: flex; align-items: center; gap: 8px; }
.hint-title i { color: var(--text-muted); }
.hint-desc { font-size: 14px; color: var(--text-muted); margin-bottom: 24px; line-height: 1.6; }

.hint-carousel {
  display: flex; gap: 20px; overflow-x: auto; scroll-snap-type: x mandatory;
  padding-bottom: 20px;
}
.hint-carousel::-webkit-scrollbar { height: 6px; }
.hint-carousel::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.15); border-radius: 3px; }

.hint-card {
  background-color: #fff;
  background-image: 
    linear-gradient(#f1f5f9 1px, transparent 1px),
    linear-gradient(90deg, #f1f5f9 1px, transparent 1px);
  background-size: 15px 15px; /* 方眼紙の目盛り */
  border: 1px solid rgba(0,0,0,0.1);
  border-radius: 12px; margin-bottom: 0;
  box-shadow: 0 2px 6px rgba(0,0,0,0.04);
  min-width: 85%; scroll-snap-align: center; flex-shrink: 0;
  transition: transform 0.2s ease;
  overflow: hidden; /* 角丸からはみ出ないように */
  display: flex; flex-direction: column;
}
.hint-card:hover { transform: translateY(-2px); box-shadow: 0 6px 16px rgba(0,0,0,0.08); }

@media (max-width: 600px) {
  .hint-board { padding: 24px 16px; margin-top: 30px; }
  .hint-carousel {
    flex-direction: column;
    overflow-x: visible;
    gap: 16px;
    padding-bottom: 0;
  }
  .hint-card {
    min-width: 100%;
    width: 100%;
  }
  .hint-diagram { padding: 16px; }
  .hint-diagram .idea-step, .hint-diagram .idea-result { font-size: 13px; padding: 12px; }
}

.hint-card-title { 
  background: #1a252f; /* 上一段ネイビー背景 */
  color: #fff; /* 白文字 */
  font-weight: 700; font-size: 15px; 
  padding: 16px; margin: 0;
  text-align: center; 
  border-bottom: 1px solid rgba(0,0,0,0.1);
}
.card-author { font-size: 11px; color: #95a5a6; font-weight: normal; display: block; margin-top: 4px; }

.hint-diagram { display: flex; flex-direction: column; align-items: center; gap: 12px; text-align: center; padding: 24px; }
.hint-diagram .seed-row { display: flex; align-items: center; justify-content: center; gap: 10px; width: 100%; }
.hint-diagram .seed { background: #fff; border: 1px solid #bdc3c7; padding: 6px 16px; border-radius: 20px; font-size: 13px; font-weight: 700; color: #2c3e50; box-shadow: 0 2px 4px rgba(0,0,0,0.05); }
.hint-diagram .arrow { color: #bdc3c7; font-size: 16px; }
.hint-diagram .idea-step { background: #f8f9f9; padding: 14px; border-radius: 8px; font-size: 13.5px; line-height: 1.6; width: 100%; color: #7f8c8d; border: 1px solid #f2f4f4; }
.hint-diagram .idea-result { background: #fff; color: var(--text-main); padding: 16px; border-radius: 8px; font-size: 14px; font-weight: 700; width: 100%; line-height: 1.6; border: 1px solid #ecf0f1; text-align: left; box-shadow: 0 1px 4px rgba(0,0,0,0.02); }
.hint-diagram .idea-result i { margin-right: 6px; color: var(--accent-secondary); font-size: 12px; }

/* Details/Summary for Lists */
.recent-list-toggle { margin-top: 24px; font-size: 13.5px; margin-left: 44px; }
@media (max-width: 600px) { .recent-list-toggle { margin-left: 0; } }
details summary { cursor: pointer; font-weight: 700; color: var(--text-muted); padding: 8px 0; display: flex; align-items: center; gap: 8px; transition: color 0.2s; }
details summary:hover { color: var(--text-main); }
details summary::marker { content: ''; }

.card-list { display: flex; flex-direction: column; gap: 10px; max-height: 350px; overflow-y: auto; padding-right: 8px; margin-top: 12px; }
.card-list::-webkit-scrollbar { width: 4px; }
.card-list::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.1); border-radius: 2px; }

.mini-card { background: #fff; border: 1px solid rgba(0,0,0,0.05); padding: 12px 16px; border-radius: 6px; font-size: 13.5px; line-height: 1.6; }
.mini-card .meta { font-size: 11px; color: #95a5a6; margin-top: 6px; }

.idea-entry { background: #fff; border: 1px solid rgba(0,0,0,0.06); padding: 16px; border-radius: 8px; font-size: 14px; line-height: 1.6; margin-bottom: 12px; border-left: 4px solid var(--accent-secondary); box-shadow: 0 2px 6px rgba(0,0,0,0.02); }
.idea-entry .idea-source { font-size: 11.5px; color: #7f8c8d; background: #f8f9f9; padding: 10px; margin-top: 10px; border-radius: 4px; }
.idea-entry .idea-meta { font-size: 11px; color: #95a5a6; margin-top: 10px; }

/* Footer & Top Button */
.global-footer {
  background: #1a252f;
  color: #fff;
  padding: 40px 20px;
  margin-top: 60px;
}
.footer-inner {
  max-width: 800px; margin: 0 auto; text-align: center;
}
.global-footer p {
  color: rgba(255,255,255,0.8); font-size: 13px; margin: 0 0 16px;
}
.footer-links {
  display: flex; align-items: center; justify-content: center; gap: 12px; font-size: 13px;
}
.copyright-link, .admin-link { color: #fff; text-decoration: none; font-weight: 500; opacity: 0.9; transition: opacity 0.2s; }
.copyright-link:hover, .admin-link:hover { opacity: 1; text-decoration: underline; }
.footer-sep { color: rgba(255,255,255,0.3); }

.page-top-btn {
  position: fixed; bottom: 24px; right: 24px;
  width: 48px; height: 48px;
  background: var(--accent-secondary); color: #fff;
  border: none; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; cursor: pointer;
  box-shadow: 0 4px 12px rgba(0,0,0,0.2);
  z-index: 99; opacity: 0.9; transition: all 0.2s ease;
}
.page-top-btn:hover { opacity: 1; transform: translateY(-3px); box-shadow: 0 6px 16px rgba(0,0,0,0.3); }
@media (max-width: 600px) {
  .page-top-btn { bottom: 16px; right: 12px; width: 44px; height: 44px; font-size: 18px; }
  #g_id_signin { transform: scale(0.6); transform-origin: center top; } /* スマホで強制的に60%に縮小してはみ出し防止 */
}
