/* ============================================
   魔女の恋薬工房 - スタイルシート
   ============================================ */

:root {
  --primary: #8b6ba3;
  --primary-dark: #6b4f7a;
  --secondary: #e8d4c4;
  --accent: #f4a6b0;
  --accent-green: #7cb69d;
  --bg-light: #faf5f0;
  --bg-dark: #4a3f55;
  --text-dark: #3d3248;
  --text-light: #f5f0eb;
  --shadow: rgba(75, 60, 90, 0.2);
}

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

body {
  font-family: 'Zen Maru Gothic', sans-serif;
  background: linear-gradient(135deg, #e8d4c4 0%, #d4c4b0 100%);
  min-height: 100vh;
  overflow: hidden;
}

#game-container {
  width: 100%;
  max-width: 480px;
  height: 100vh;
  margin: 0 auto;
  position: relative;
  background: var(--bg-light);
  box-shadow: 0 0 30px var(--shadow);
  overflow: hidden;
}

/* ============================================
   共通スクリーンスタイル
   ============================================ */

.screen {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: none;
  flex-direction: column;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.screen.active {
  display: flex;
  opacity: 1;
}

/* ============================================
   ピクセル風ボタン
   ============================================ */

.pixel-btn {
  font-family: 'Zen Maru Gothic', sans-serif;
  font-size: 1rem;
  font-weight: 700;
  padding: 12px 24px;
  background: linear-gradient(180deg, var(--primary) 0%, var(--primary-dark) 100%);
  color: var(--text-light);
  border: 3px solid var(--primary-dark);
  border-radius: 8px;
  cursor: pointer;
  box-shadow: 
    0 4px 0 var(--primary-dark),
    0 6px 10px var(--shadow);
  transition: all 0.1s ease;
  text-shadow: 1px 1px 2px rgba(0,0,0,0.3);
}

.pixel-btn:hover {
  transform: translateY(-2px);
  box-shadow: 
    0 6px 0 var(--primary-dark),
    0 8px 15px var(--shadow);
}

.pixel-btn:active {
  transform: translateY(2px);
  box-shadow: 
    0 2px 0 var(--primary-dark),
    0 3px 5px var(--shadow);
}

.pixel-btn:disabled {
  background: #aaa;
  border-color: #888;
  box-shadow: 0 2px 0 #888;
  cursor: not-allowed;
  opacity: 0.7;
}

.back-btn {
  background: none;
  border: none;
  color: var(--primary);
  font-size: 1rem;
  cursor: pointer;
  padding: 8px;
}

/* ============================================
   タイトル画面
   ============================================ */

#title-screen {
  background: linear-gradient(180deg, #e8d4f4 0%, #f4e8d4 50%, #d4e8d4 100%);
  justify-content: center;
  align-items: center;
  text-align: center;
}

.title-content {
  padding: 20px;
}

.title-decoration {
  font-size: 1.2rem;
  color: var(--primary);
  margin: 10px 0;
  animation: sparkle 2s ease-in-out infinite;
}

@keyframes sparkle {
  0%, 100% { opacity: 0.5; }
  50% { opacity: 1; }
}

.game-title {
  font-size: 2.2rem;
  color: var(--primary-dark);
  text-shadow: 2px 2px 4px var(--shadow);
  margin: 10px 0;
}

.game-subtitle {
  font-size: 1rem;
  color: var(--primary);
  margin-bottom: 20px;
}

.witch-image {
  margin: 20px 0;
  animation: float 3s ease-in-out infinite;
}

.witch-sprite {
  width: 180px;
  height: auto;
  image-rendering: pixelated;
  filter: drop-shadow(4px 4px 8px rgba(0,0,0,0.3));
}

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

.start-btn, .continue-btn {
  display: block;
  width: 200px;
  margin: 10px auto;
}

/* ============================================
   ストーリー画面
   ============================================ */

#story-screen {
  background: linear-gradient(180deg, #3d3248 0%, #5a4a6a 100%);
  justify-content: flex-end;
  padding: 20px;
  position: relative;
}

.story-background {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 60%;
  background: url('/static/images/workshop.png') center center / cover no-repeat;
  opacity: 0.3;
  filter: blur(2px);
}

.story-box {
  background: rgba(255, 255, 255, 0.95);
  border-radius: 16px;
  padding: 20px;
  position: relative;
  box-shadow: 0 -5px 30px rgba(0,0,0,0.3);
}

.character-portrait {
  position: absolute;
  top: -70px;
  left: 20px;
  background: white;
  border-radius: 12px;
  width: 90px;
  height: 90px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 15px var(--shadow);
  border: 3px solid var(--primary);
  overflow: hidden;
}

.portrait-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  image-rendering: pixelated;
}

.portrait-emoji {
  font-size: 3rem;
  display: none;
  width: 100%;
  height: 100%;
  align-items: center;
  justify-content: center;
}

.story-content {
  margin-top: 30px;
  min-height: 120px;
}

.character-name {
  font-weight: 700;
  color: var(--primary-dark);
  font-size: 1.1rem;
  margin-bottom: 10px;
}

.story-text {
  color: var(--text-dark);
  line-height: 1.8;
  font-size: 1rem;
}

.next-btn {
  margin-top: 15px;
  width: 100%;
}

/* ============================================
   マップ画面
   ============================================ */

#map-screen {
  background: linear-gradient(180deg, #87ceeb 0%, #98d4a0 50%, #c4b896 100%);
  padding: 20px;
}

.map-header {
  text-align: center;
  margin-bottom: 20px;
}

.map-header h2 {
  color: var(--text-dark);
  font-size: 1.3rem;
}

.quest-hint {
  color: var(--primary-dark);
  font-size: 0.9rem;
  margin-top: 5px;
  padding: 8px 16px;
  background: rgba(255,255,255,0.8);
  border-radius: 20px;
  display: inline-block;
}

.map-locations {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 15px;
  flex: 1;
}

.location-btn {
  background: white;
  border: 3px solid var(--primary);
  border-radius: 16px;
  padding: 20px 10px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  transition: all 0.2s ease;
  box-shadow: 0 4px 10px var(--shadow);
}

.location-btn:hover {
  transform: translateY(-5px);
  box-shadow: 0 8px 20px var(--shadow);
}

.location-icon {
  font-size: 2.5rem;
}

.location-name {
  font-weight: 700;
  color: var(--text-dark);
  font-size: 1rem;
}

.location-herbs {
  font-size: 0.75rem;
  color: var(--primary);
}

.location-btn.forest { border-color: #4a7c59; }
.location-btn.meadow { border-color: #e8a0b0; }
.location-btn.mountain { border-color: #8b7355; }
.location-btn.river { border-color: #5b8fa8; }

.map-footer {
  margin-top: 20px;
  text-align: center;
}

/* ============================================
   フィールド画面（薬草採取）
   ============================================ */

#field-screen {
  background: linear-gradient(180deg, #87ceeb 0%, #7cb69d 100%);
}

.field-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 15px 20px;
  background: rgba(255,255,255,0.9);
}

.field-header h2 {
  color: var(--text-dark);
  font-size: 1.2rem;
}

.field-area {
  flex: 1;
  position: relative;
  overflow: hidden;
  background-image: 
    radial-gradient(circle at 20% 80%, rgba(120, 180, 120, 0.3) 0%, transparent 30%),
    radial-gradient(circle at 80% 20%, rgba(120, 180, 120, 0.3) 0%, transparent 30%),
    radial-gradient(circle at 50% 50%, rgba(120, 180, 120, 0.2) 0%, transparent 40%);
}

.herb-item {
  position: absolute;
  font-size: 2.5rem;
  cursor: pointer;
  transition: transform 0.2s ease;
  animation: sway 3s ease-in-out infinite;
  filter: drop-shadow(2px 4px 6px rgba(0,0,0,0.2));
}

.herb-item:hover {
  transform: scale(1.2);
}

@keyframes sway {
  0%, 100% { transform: rotate(-3deg); }
  50% { transform: rotate(3deg); }
}

.field-footer {
  padding: 15px 20px;
  background: rgba(255,255,255,0.9);
  text-align: center;
}

.inventory-preview {
  font-size: 1rem;
  color: var(--text-dark);
}

/* ============================================
   工房画面
   ============================================ */

#workshop-screen {
  background: linear-gradient(180deg, #5a4a6a 0%, #3d3248 100%);
  position: relative;
}

.workshop-bg {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  overflow: hidden;
}

.workshop-bg-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0.25;
  image-rendering: pixelated;
}

.workshop-header,
.workshop-content,
.workshop-footer {
  position: relative;
  z-index: 1;
}

.workshop-header {
  padding: 15px 20px;
  text-align: center;
  color: var(--text-light);
}

.workshop-header h2 {
  font-size: 1.3rem;
}

.workshop-content {
  flex: 1;
  overflow-y: auto;
  padding: 0 20px;
}

.cauldron-area {
  text-align: center;
  margin-bottom: 20px;
}

.cauldron {
  position: relative;
  padding: 20px;
}

.cauldron-slots {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-bottom: 10px;
}

.slot {
  width: 60px;
  height: 60px;
  background: rgba(255,255,255,0.9);
  border: 3px dashed var(--primary);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.8rem;
  transition: all 0.2s ease;
}

.slot.filled {
  border-style: solid;
  background: white;
  cursor: pointer;
}

.slot.filled:hover {
  transform: scale(1.1);
}

.cauldron-pot {
  font-size: 4rem;
  margin: 10px 0;
}

.brew-effect {
  font-size: 2rem;
  height: 40px;
}

.brew-btn {
  margin-top: 10px;
}

.inventory-area {
  background: rgba(255,255,255,0.1);
  border-radius: 12px;
  padding: 15px;
  margin-bottom: 15px;
}

.inventory-area h3 {
  color: var(--text-light);
  font-size: 1rem;
  margin-bottom: 10px;
}

.inventory-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}

.herb-inv-item {
  background: white;
  border-radius: 10px;
  padding: 8px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s ease;
  border: 2px solid transparent;
}

.herb-inv-item:hover {
  transform: scale(1.1);
  border-color: var(--accent);
}

.herb-inv-item.selected {
  border-color: var(--accent);
  background: #fff5f7;
}

.herb-inv-icon {
  font-size: 1.5rem;
}

.herb-inv-count {
  font-size: 0.7rem;
  color: var(--primary);
}

.recipe-hint {
  background: rgba(255,255,255,0.1);
  border-radius: 12px;
  padding: 15px;
}

.recipe-hint h3 {
  color: var(--text-light);
  font-size: 1rem;
  margin-bottom: 10px;
}

#recipe-hint-content {
  color: var(--secondary);
  font-size: 0.9rem;
  line-height: 1.6;
}

.workshop-footer {
  padding: 15px 20px;
  display: flex;
  gap: 10px;
  justify-content: center;
}

.workshop-footer .pixel-btn {
  flex: 1;
  font-size: 0.9rem;
  padding: 10px;
}

/* ============================================
   薬完成画面
   ============================================ */

#potion-result-screen {
  background: linear-gradient(180deg, #f4a6b0 0%, #e8d4f4 100%);
  justify-content: center;
  align-items: center;
  text-align: center;
}

.result-content {
  padding: 40px;
}

.result-effect {
  font-size: 3rem;
  animation: sparkle-burst 1s ease-out;
}

@keyframes sparkle-burst {
  0% { transform: scale(0); opacity: 0; }
  50% { transform: scale(1.5); opacity: 1; }
  100% { transform: scale(1); opacity: 1; }
}

#potion-name {
  font-size: 1.8rem;
  color: var(--primary-dark);
  margin: 20px 0;
}

.potion-icon {
  font-size: 5rem;
  margin: 20px 0;
  animation: float 2s ease-in-out infinite;
}

.potion-description {
  color: var(--text-dark);
  font-size: 1rem;
  margin-bottom: 30px;
}

/* ============================================
   薬一覧画面
   ============================================ */

#potions-screen {
  background: linear-gradient(180deg, #5a4a6a 0%, #3d3248 100%);
}

.potions-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 15px 20px;
  color: var(--text-light);
}

.potions-header h2 {
  font-size: 1.3rem;
}

.potions-header .back-btn {
  color: var(--text-light);
}

.potions-grid {
  flex: 1;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 15px;
}

.potion-card {
  background: white;
  border-radius: 16px;
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 15px;
  transition: all 0.2s ease;
}

.potion-card.locked {
  opacity: 0.6;
  filter: grayscale(0.5);
}

.potion-card.completed {
  box-shadow: 0 0 20px var(--accent);
}

.potion-card .potion-icon {
  font-size: 2.5rem;
}

.potion-card .potion-name {
  font-weight: 700;
  color: var(--text-dark);
  font-size: 1.1rem;
}

.potion-card .potion-status {
  font-size: 0.85rem;
  color: var(--primary);
}

.potions-footer {
  padding: 20px;
  text-align: center;
}

/* ============================================
   エンディング画面
   ============================================ */

#ending-screen {
  background: linear-gradient(180deg, #ffd700 0%, #f4a6b0 50%, #e8d4f4 100%);
  justify-content: center;
  align-items: center;
  text-align: center;
  padding: 40px;
}

.ending-witch {
  width: 150px;
  height: auto;
  image-rendering: pixelated;
  filter: drop-shadow(4px 4px 8px rgba(0,0,0,0.3));
  margin-bottom: 20px;
  animation: float 3s ease-in-out infinite;
}

.ending-content h2 {
  font-size: 2rem;
  color: var(--primary-dark);
  margin-bottom: 30px;
}

.ending-text {
  color: var(--text-dark);
  line-height: 2;
  font-size: 1rem;
  margin-bottom: 40px;
}

/* ============================================
   ポップアップ
   ============================================ */

.popup {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0);
  background: white;
  border-radius: 16px;
  padding: 30px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.3);
  z-index: 100;
  text-align: center;
  transition: transform 0.3s ease;
}

.popup.show {
  transform: translate(-50%, -50%) scale(1);
}

.popup-herb {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--accent-green);
}

/* ============================================
   レスポンシブ対応
   ============================================ */

@media (min-height: 800px) {
  .game-title {
    font-size: 2.5rem;
  }
  
  .witch-sprite {
    width: 220px;
  }
}

@media (max-height: 600px) {
  .game-title {
    font-size: 1.8rem;
  }
  
  .witch-sprite {
    width: 140px;
  }
  
  .story-content {
    min-height: 80px;
  }
  
  .character-portrait {
    width: 70px;
    height: 70px;
    top: -50px;
  }
}
