/* 
  Design System for Memory Palace App
*/

:root {
  --bg-color: #f4f7f6;
  --card-color: #ffffff;
  --text-primary: #2c3e50;
  --text-secondary: #7f8c8d;
  --accent-color: #3498db;
  --accent-hover: #2980b9;
  --danger-color: #e74c3c;
  --success-color: #2ecc71;
  --border-radius: 16px;
  --transition: 0.3s ease;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  overflow: hidden; /* Prevent all native scrolling */
}

body {
  font-family: 'Inter', 'Noto Sans JP', sans-serif;
  background-color: var(--bg-color);
  color: var(--text-primary);
  display: flex;
  justify-content: center;
  align-items: center;
}

.app-container {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  margin: auto;
  width: 100%;
  max-width: 400px;
  height: 100%;
  max-height: 100dvh; /* Lock to dynamic viewport height */
  overflow: hidden; /* Lock container size */
  background-color: var(--card-color);
  box-shadow: 0 10px 30px rgba(0,0,0,0.05);
  display: flex;
  flex-direction: column;
}

@media (min-width: 450px) {
  .app-container {
    height: 85vh;
    max-height: 800px;
    border-radius: var(--border-radius);
  }
}

/* Views Common */
.view {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 20px 15px; /* Compact padding */
  animation: fadeIn 0.4s ease forwards;
  overflow-y: auto; /* Allow scrolling inside the view if needed */
}

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

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

.header h1 {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--text-primary);
}

.header .subtitle {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-top: 5px;
}

.stats-container {
  display: flex;
  justify-content: space-around;
  margin-bottom: 25px;
  padding: 10px;
  background: var(--bg-color);
  border-radius: var(--border-radius);
}

.stat-box {
  text-align: center;
}

.stat-value {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--accent-color);
}

.stat-label {
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.btn {
  width: 100%;
  padding: 12px;
  border: none;
  border-radius: var(--border-radius);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  font-family: inherit;
}

.btn-primary {
  background-color: var(--accent-color);
  color: white;
  box-shadow: 0 4px 15px rgba(52, 152, 219, 0.3);
}

.btn-primary:active {
  background-color: var(--accent-hover);
  transform: translateY(2px);
  box-shadow: 0 2px 10px rgba(52, 152, 219, 0.3);
}

.btn-danger {
  background-color: var(--bg-color);
  color: var(--danger-color);
  margin-top: 15px;
}

.btn-danger:active {
  background-color: #ffeaea;
}

/* Memory Phase */
.memory-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
}

.word-display {
  font-size: 2.5rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 20px;
  text-align: center;
  min-height: 90px; /* Accommodate two lines to prevent shifting */
  display: flex;
  align-items: center;
  justify-content: center;
  animation: scaleIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

@keyframes scaleIn {
  from { transform: scale(0.8); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.progress-bar-container {
  width: 100%;
  height: 6px;
  background: var(--bg-color);
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 20px;
}

.progress-bar {
  height: 100%;
  background: var(--accent-color);
  width: 100%;
  transition: width linear;
}

.word-counter {
  color: var(--text-secondary);
  font-size: 0.9rem;
  margin-bottom: 15px;
}

/* Recall Phase */
.recall-content {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.instruction {
  text-align: center;
  margin-bottom: 15px;
  font-size: 1rem;
  color: var(--text-primary);
  font-weight: 500;
}

.options-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 15px;
}

.option-btn {
  padding: 10px 8px;
  border: 2px solid var(--bg-color);
  background: white;
  border-radius: 12px;
  font-size: 1rem;
  font-weight: 500;
  color: var(--text-primary);
  cursor: pointer;
  transition: all 0.2s ease;
}

.option-btn:active {
  background: var(--bg-color);
}

.option-btn.selected {
  border-color: var(--accent-color);
  background: rgba(52, 152, 219, 0.05);
}

.answer-slots {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  margin-bottom: 20px;
}

.answer-slot {
  width: auto;
  min-width: 50px;
  height: 35px;
  border-bottom: 2px dashed var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 1rem;
  padding: 0 8px;
}

.answer-slot.filled {
  border-bottom: 2px solid var(--accent-color);
  color: var(--accent-color);
}

/* Result Phase */
.result-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
}

.result-icon {
  font-size: 3rem;
  margin-bottom: 15px;
}

.result-title {
  font-size: 1.8rem;
  font-weight: 700;
  margin-bottom: 10px;
}

.result-score {
  font-size: 1.1rem;
  color: var(--text-secondary);
  margin-bottom: 20px;
}

.level-up-msg {
  color: var(--success-color);
  font-weight: 600;
  font-size: 1.1rem;
  margin-bottom: 15px;
  animation: bounceIn 0.5s ease;
}

@keyframes bounceIn {
  0% { transform: scale(0.8); opacity: 0; }
  50% { transform: scale(1.1); opacity: 1; }
  100% { transform: scale(1); opacity: 1; }
}

.correct-list {
  text-align: left;
  width: 100%;
  background: var(--bg-color);
  padding: 12px;
  border-radius: 12px;
  margin-bottom: 20px;
}

.correct-item {
  display: flex;
  justify-content: space-between;
  margin-bottom: 6px;
  font-size: 0.9rem;
}

.correct-item:last-child {
  margin-bottom: 0;
}

.mark-correct { color: var(--success-color); font-weight: 600; }
.mark-wrong { color: var(--danger-color); font-weight: 600; }
