/* ===========================================
   つるつるいっぱい - 和モダン料亭カウンター風
=========================================== */

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

html, body {
  width: 100%;
  min-height: 100vh;
  overflow-x: hidden;
  overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: 'Shippori Mincho', 'Noto Serif JP', serif;
  color: #f2e8d2;
  background: #0a0706;
  position: relative;
  user-select: none;
  -webkit-user-select: none;
  letter-spacing: 0.02em;
}

/* ===========================================
   背景レイヤー
=========================================== */
.bg-layer {
  position: fixed; inset: 0; z-index: 0;
  background:
    radial-gradient(ellipse at 50% 0%, #1c1410 0%, #0a0706 60%),
    linear-gradient(180deg, #120c08 0%, #0a0706 50%, #120c08 100%);
}

.bg-washi {
  position: fixed; inset: 0; z-index: 0; opacity: 0.07; pointer-events: none;
  background-image:
    radial-gradient(circle at 20% 30%, transparent 0%, #fff 0.4%, transparent 0.8%),
    radial-gradient(circle at 70% 40%, transparent 0%, #fff 0.3%, transparent 0.7%),
    radial-gradient(circle at 40% 70%, transparent 0%, #fff 0.35%, transparent 0.75%),
    radial-gradient(circle at 85% 85%, transparent 0%, #fff 0.3%, transparent 0.7%),
    radial-gradient(circle at 10% 90%, transparent 0%, #fff 0.4%, transparent 0.8%);
  background-size: 120px 120px, 150px 150px, 180px 180px, 100px 100px, 200px 200px;
}

.bg-seigaiha {
  position: fixed; inset: 0; z-index: 0; opacity: 0.025; pointer-events: none;
  background-image:
    radial-gradient(circle at 0 30px, transparent 28px, #d4af37 29px, transparent 30px),
    radial-gradient(circle at 30px 30px, transparent 28px, #d4af37 29px, transparent 30px),
    radial-gradient(circle at 60px 30px, transparent 28px, #d4af37 29px, transparent 30px);
  background-size: 60px 60px;
}

/* ===========================================
   戻るリンク（フッター控えめ）
=========================================== */
.back-link-footer {
  margin-top: 28px;
  color: rgba(138, 122, 90, 0.7);
  font-size: 0.72rem;
  letter-spacing: 0.1em;
  text-decoration: none;
  transition: color 0.2s;
  padding: 6px 10px;
}
.back-link-footer:hover {
  color: #d4af37;
}

/* ===========================================
   ステージ・画面切替
=========================================== */
#stage {
  position: relative;
  z-index: 10;
  min-height: 100vh;
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px 40px;
}

.screen {
  display: none;
  width: 100%;
  max-width: 720px;
  animation: fadeIn 0.6s ease-out;
}
.screen.active { display: flex; flex-direction: column; align-items: center; }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ===========================================
   タイトル画面
=========================================== */
.title-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 26px;
  padding: 30px 0;
}

.title-seal {
  width: 80px; height: 80px;
  background: #c62828;
  color: #f5e9d0;
  font-size: 2.4rem;
  font-weight: 900;
  font-family: 'Shippori Mincho', serif;
  display: flex; align-items: center; justify-content: center;
  border-radius: 2px;
  box-shadow:
    0 0 0 2px #0a0706,
    0 0 0 4px #c62828,
    0 4px 20px rgba(198, 40, 40, 0.3);
  transform: rotate(-3deg);
}

.game-title {
  font-size: clamp(2.8rem, 8vw, 4.6rem);
  font-weight: 900;
  line-height: 1;
  letter-spacing: 0.05em;
  color: #f5e9d0;
  display: flex;
  flex-direction: column;
  gap: 4px;
  text-shadow:
    0 0 30px rgba(212, 175, 55, 0.3),
    0 2px 0 #c62828;
}
.game-title .t1 { color: #f5e9d0; }
.game-title .t2 {
  color: #d4af37;
  font-size: 1.1em;
  background: linear-gradient(180deg, #f0c96b 0%, #d4af37 50%, #a07f1e 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.subtitle {
  font-family: 'Noto Serif JP', serif;
  font-size: 0.75rem;
  letter-spacing: 0.4em;
  color: #8a7a5a;
  margin-top: -6px;
}

.tagline-row {
  display: flex; align-items: center; gap: 16px;
  margin-top: 10px;
}
.tagline-row .line {
  width: 40px; height: 1px;
  background: linear-gradient(90deg, transparent, #d4af37, transparent);
}
.tagline {
  font-size: 1.05rem;
  letter-spacing: 0.15em;
  color: #d4af37;
}

.description {
  margin-top: 14px;
  line-height: 2;
  color: #c8b88e;
  font-size: 0.95rem;
}

.btn-main {
  margin-top: 18px;
  min-width: 220px;
  padding: 18px 34px;
  background: linear-gradient(180deg, #c62828 0%, #8b1818 100%);
  color: #f5e9d0;
  border: none;
  border-radius: 2px;
  font-family: 'Shippori Mincho', serif;
  cursor: pointer;
  position: relative;
  box-shadow:
    0 0 0 1px rgba(212, 175, 55, 0.4),
    0 0 0 4px #0a0706,
    0 0 0 5px rgba(212, 175, 55, 0.4),
    0 6px 20px rgba(198, 40, 40, 0.4);
  transition: all 0.2s;
}
.btn-main:hover {
  transform: translateY(-2px);
  box-shadow:
    0 0 0 1px rgba(212, 175, 55, 0.6),
    0 0 0 4px #0a0706,
    0 0 0 5px rgba(212, 175, 55, 0.6),
    0 10px 28px rgba(198, 40, 40, 0.5);
}
.btn-main:active { transform: translateY(0); }

.btn-main .btn-label {
  display: block;
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: 0.25em;
}
.btn-main .btn-sub {
  display: block;
  font-size: 0.65rem;
  letter-spacing: 0.3em;
  margin-top: 4px;
  color: rgba(245, 233, 208, 0.6);
}

.btn-ghost {
  margin-top: 20px;
  padding: 10px 22px;
  background: transparent;
  color: #8a7a5a;
  border: 1px solid rgba(138, 122, 90, 0.4);
  border-radius: 2px;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.2s;
}
.btn-ghost:hover {
  color: #d4af37;
  border-color: rgba(212, 175, 55, 0.5);
}

/* ===========================================
   選択画面（器/酒）
=========================================== */
.screen-header {
  text-align: center;
  margin-bottom: 30px;
}
.step-badge {
  display: inline-block;
  padding: 4px 16px;
  background: #c62828;
  color: #f5e9d0;
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0.2em;
  margin-bottom: 14px;
}
.screen-header h2 {
  font-size: clamp(1.8rem, 5vw, 2.4rem);
  font-weight: 900;
  color: #f5e9d0;
  letter-spacing: 0.1em;
  margin-bottom: 8px;
}
.screen-desc {
  color: #8a7a5a;
  font-size: 0.9rem;
  letter-spacing: 0.05em;
}

.grid-select {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
  width: 100%;
  padding: 0 4px;
}

.select-card {
  background: linear-gradient(180deg, rgba(40, 28, 20, 0.8) 0%, rgba(20, 14, 10, 0.9) 100%);
  border: 1px solid rgba(212, 175, 55, 0.2);
  padding: 18px 16px;
  cursor: pointer;
  transition: all 0.2s;
  position: relative;
  overflow: hidden;
  border-radius: 2px;
}
.select-card:hover {
  border-color: rgba(212, 175, 55, 0.6);
  transform: translateY(-3px);
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.5);
}
.select-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0;
  width: 3px; height: 100%;
  background: linear-gradient(180deg, #c62828 0%, #d4af37 100%);
  opacity: 0;
  transition: opacity 0.2s;
}
.select-card:hover::before { opacity: 1; }

.card-illust {
  width: 100%;
  height: 120px;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  margin-bottom: 12px;
}
.card-name {
  font-size: 1.15rem;
  font-weight: 700;
  color: #f5e9d0;
  letter-spacing: 0.08em;
  margin-bottom: 2px;
}
.card-sub {
  font-size: 0.7rem;
  color: #8a7a5a;
  letter-spacing: 0.2em;
  margin-bottom: 8px;
}
.card-desc {
  font-size: 0.85rem;
  color: #c8b88e;
  line-height: 1.5;
  min-height: 2.6em;
}
.card-diff {
  margin-top: 10px;
  display: flex; gap: 3px;
  align-items: center;
}
.card-diff .label {
  font-size: 0.7rem;
  color: #8a7a5a;
  margin-right: 6px;
}
.diff-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: rgba(138, 122, 90, 0.3);
}
.diff-dot.on { background: #d4af37; box-shadow: 0 0 6px rgba(212, 175, 55, 0.6); }

/* ===========================================
   プレイ画面
=========================================== */
.play-header {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
  margin-bottom: 20px;
  padding: 0 10px;
}

.play-info {
  display: flex; gap: 30px;
  font-size: 0.9rem;
}
.info-row {
  display: flex; flex-direction: column;
  align-items: center; gap: 2px;
}
.info-label {
  font-size: 0.7rem;
  color: #8a7a5a;
  letter-spacing: 0.2em;
}
.info-value {
  color: #d4af37;
  font-weight: 700;
  font-size: 1rem;
}

.play-stage {
  width: 100%;
  max-width: 520px;
  aspect-ratio: 1 / 1.1;
  margin: 10px auto;
  position: relative;
  background:
    radial-gradient(ellipse at 50% 100%, rgba(198, 40, 40, 0.1) 0%, transparent 60%),
    radial-gradient(ellipse at 50% 40%, rgba(212, 175, 55, 0.06) 0%, transparent 70%);
  border-radius: 4px;
  touch-action: none;
}
#canvas {
  width: 100%; height: 100%;
  display: block;
}

.play-hint {
  margin-top: 12px;
  display: flex; gap: 10px;
  align-items: baseline;
  color: #c8b88e;
  font-size: 0.95rem;
  padding: 10px 22px;
  border: 1px dashed rgba(212, 175, 55, 0.3);
  border-radius: 2px;
  animation: hintPulse 2s ease-in-out infinite;
}
.play-hint.hidden { opacity: 0; }

@keyframes hintPulse {
  0%, 100% { opacity: 0.8; }
  50% { opacity: 1; }
}
.hint-key {
  font-weight: 900;
  color: #d4af37;
  font-size: 1.1rem;
  letter-spacing: 0.1em;
}

/* ===========================================
   結果画面（認定書）
=========================================== */
.certificate {
  width: 100%;
  max-width: 480px;
  background:
    radial-gradient(ellipse at 50% 0%, rgba(245, 233, 208, 0.08) 0%, transparent 40%),
    linear-gradient(180deg, #f2e3c3 0%, #e8d6ad 100%);
  color: #3a2a1a;
  padding: 0;
  margin: 20px auto;
  border-radius: 2px;
  box-shadow:
    0 0 0 1px #c62828,
    0 0 0 3px #f2e3c3,
    0 0 0 4px #c62828,
    0 10px 40px rgba(0, 0, 0, 0.6);
  position: relative;
  animation: certReveal 1s cubic-bezier(0.2, 0.8, 0.3, 1.1);
}

@keyframes certReveal {
  from {
    opacity: 0;
    transform: scale(0.85) rotateX(-20deg);
  }
  to {
    opacity: 1;
    transform: scale(1) rotateX(0deg);
  }
}

.cert-border-top, .cert-border-bottom {
  height: 14px;
  background:
    linear-gradient(90deg, #c62828 0 33%, #d4af37 33% 66%, #c62828 66% 100%);
}

.cert-content {
  padding: 34px 30px 28px;
  text-align: center;
  font-family: 'Shippori Mincho', serif;
}

.cert-label {
  font-size: 0.8rem;
  letter-spacing: 0.35em;
  color: #8b1818;
  margin-bottom: 2px;
}
.cert-title {
  font-size: 1.8rem;
  font-weight: 900;
  color: #3a2a1a;
  letter-spacing: 0.15em;
  margin-bottom: 20px;
  position: relative;
}
.cert-title::after {
  content: '';
  display: block;
  width: 100px;
  height: 2px;
  background: linear-gradient(90deg, transparent, #8b1818, transparent);
  margin: 10px auto 0;
}

.rank-display {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  margin-bottom: 16px;
}
.rank-letter {
  font-size: 5.5rem;
  font-weight: 900;
  color: #d4af37;
  line-height: 1;
  font-family: 'Shippori Mincho', serif;
  text-shadow:
    0 0 2px #8b1818,
    0 2px 0 #8b1818,
    0 4px 12px rgba(0, 0, 0, 0.2);
  letter-spacing: 0;
}
.rank-name {
  font-size: 1.3rem;
  font-weight: 700;
  color: #3a2a1a;
  letter-spacing: 0.2em;
}

.score-display {
  display: flex;
  justify-content: center;
  align-items: baseline;
  gap: 4px;
  margin-bottom: 22px;
  color: #8b1818;
  font-variant-numeric: tabular-nums;
}
.score-num {
  font-size: 3rem;
  font-weight: 900;
  line-height: 1;
}
.score-unit {
  font-size: 1.4rem;
  font-weight: 700;
}

.cert-details {
  display: flex;
  justify-content: center;
  gap: 20px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.cert-row {
  display: flex; gap: 8px;
  align-items: baseline;
  font-size: 0.9rem;
}
.cert-key {
  color: #8b1818;
  font-weight: 700;
  letter-spacing: 0.2em;
}
.cert-val {
  color: #3a2a1a;
  font-weight: 700;
}

.cert-comment {
  padding: 14px 16px;
  background: rgba(139, 24, 24, 0.05);
  border-left: 3px solid #8b1818;
  font-size: 1rem;
  color: #3a2a1a;
  line-height: 1.6;
  margin-bottom: 20px;
  text-align: left;
}

.cert-sig {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 14px;
  border-top: 1px dashed rgba(139, 24, 24, 0.3);
}
.sig-date {
  font-size: 0.85rem;
  color: #8b1818;
  letter-spacing: 0.1em;
}
.sig-seal {
  width: 42px; height: 42px;
  background: #8b1818;
  color: #f5e9d0;
  font-size: 1.3rem;
  font-weight: 900;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%;
  box-shadow: 0 0 0 2px #f2e3c3, 0 0 0 3px #8b1818;
  transform: rotate(-6deg);
}

.result-actions {
  margin-top: 30px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

/* ===========================================
   レスポンシブ
=========================================== */
@media (max-width: 480px) {
  #stage { padding: 50px 14px 30px; }
  .title-seal { width: 64px; height: 64px; font-size: 2rem; }
  .game-title { font-size: clamp(2.4rem, 11vw, 3.6rem); }
  .grid-select { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .select-card { padding: 14px 10px; }
  .card-illust { height: 100px; }
  .card-name { font-size: 1rem; }
  .cert-content { padding: 28px 20px 22px; }
  .rank-letter { font-size: 4.6rem; }
  .score-num { font-size: 2.4rem; }
}

@media (min-width: 760px) {
  .play-stage { max-width: 480px; }
}
