:root {
  /* Colors */
  --color-primary: #10B981;
  /* Libe-like Green */
  --color-primary-dark: #059669;
  --color-secondary: #F3F4F6;
  --color-secondary-dark: #E5E7EB;
  --color-text-main: #1F2937;
  --color-text-muted: #6B7280;
  --color-bg-start: #ecfdf5;
  --color-bg-end: #d1fae5;
  --color-card-bg: rgba(255, 255, 255, 0.95);
  --color-border: #D1D5DB;

  --color-danger: #EF4444;
  --color-danger-light: #FEE2E2;
  --color-warning: #F59E0B;
  --color-warning-light: #FEF3C7;

  --color-focus: rgba(16, 185, 129, 0.4);

  /* Typography */
  --font-base: 'Inter', 'Noto Sans JP', sans-serif;

  /* Shadows */
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);

  /* Transitions */
  --transition-fast: 0.15s ease-in-out;
  --transition-normal: 0.3s ease;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-base);
  color: var(--color-text-main);
  background: linear-gradient(135deg, var(--color-bg-start), var(--color-bg-end));
  min-height: 100vh;
  line-height: 1.6;
  padding-bottom: 80px;
  /* Space for fixed footer */
  -webkit-font-smoothing: antialiased;
}

/* Layout */
.app-container {
  max-width: 600px;
  /* Mobile first, single column */
  margin: 0 auto;
  padding: 20px;
}

header.app-header {
  text-align: center;
  margin-bottom: 24px;
}

.logo {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--color-primary-dark);
  margin-bottom: 16px;
}

/* Progress Bar */
.progress-container {
  margin-bottom: 20px;
}

.progress-text {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--color-text-muted);
  margin-bottom: 8px;
  text-align: left;
}

.progress-bar {
  background: var(--color-secondary);
  height: 8px;
  border-radius: 4px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--color-primary);
  width: 25%;
  transition: width var(--transition-normal);
}

/* Template Assistant */
.template-assistant {
  background: var(--color-card-bg);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 24px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--color-border);
}

.template-title {
  font-size: 0.875rem;
  font-weight: 600;
  margin-bottom: 12px;
  color: var(--color-text-main);
}

.template-buttons {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.btn-template {
  background: #fff;
  border: 1px solid var(--color-border);
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 0.875rem;
  cursor: pointer;
  transition: all var(--transition-fast);
  color: var(--color-text-main);
  font-weight: 500;
}

.btn-template:hover {
  background: var(--color-primary-dark);
  color: white;
  border-color: var(--color-primary-dark);
}

/* Main Card (Glassmorphism effect) */
.card {
  background: var(--color-card-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.4);
  border-radius: 16px;
  padding: 24px;
  box-shadow: var(--shadow-md);
  margin-bottom: 24px;
}

/* Steps */
.step {
  display: none;
  animation: fadeIn var(--transition-normal);
}

.step.active {
  display: block;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

h2 {
  font-size: 1.25rem;
  margin-bottom: 20px;
  color: var(--color-text-main);
  border-bottom: 2px solid var(--color-secondary);
  padding-bottom: 8px;
}

/* Hint Accordion */
.hint-accordion {
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: 8px;
  margin-bottom: 24px;
  overflow: hidden;
}

.hint-accordion summary {
  padding: 12px 16px;
  font-weight: 600;
  color: #1e40af;
  cursor: pointer;
  list-style: none;
  /* Hide default arrow */
  position: relative;
}

.hint-accordion summary::-webkit-details-marker {
  display: none;
}

.hint-accordion summary::after {
  content: '+';
  position: absolute;
  right: 16px;
  font-size: 1.2rem;
}

.hint-accordion[open] summary::after {
  content: '−';
}

.hint-content {
  padding: 0 16px 16px;
  font-size: 0.9rem;
  color: #1e3a8a;
}

/* Forms */
.form-group {
  margin-bottom: 20px;
}

label {
  display: block;
  font-weight: 600;
  margin-bottom: 8px;
  font-size: 0.95rem;
}

textarea,
input[type="number"] {
  width: 100%;
  padding: 12px;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  font-family: inherit;
  font-size: 1rem;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
  background: #f9fafb;
}

textarea {
  min-height: 100px;
  resize: vertical;
}

textarea:focus,
input[type="number"]:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px var(--color-focus);
  background: #fff;
}

/* Preview Box */
.madlibs-preview {
  background: var(--color-secondary);
  border-left: 4px solid var(--color-primary);
  padding: 16px;
  border-radius: 0 8px 8px 0;
  margin-top: 12px;
}

.madlibs-preview h4 {
  font-size: 0.85rem;
  color: var(--color-text-muted);
  margin-bottom: 8px;
}

.madlibs-preview p {
  font-size: 0.95rem;
  font-style: italic;
}

.highlight {
  background: #fef08a;
  /* Yellow highlight */
  padding: 0 4px;
  border-radius: 2px;
  font-weight: 600;
}

/* Alerts */
.alert {
  padding: 12px;
  border-radius: 8px;
  margin-top: 8px;
  font-size: 0.9rem;
}

.alert-warning {
  background: var(--color-warning-light);
  color: #92400e;
  border: 1px solid #fcd34d;
}

.alert-error {
  background: var(--color-danger-light);
  color: #991b1b;
  border: 1px solid #fca5a5;
}

.hidden {
  display: none;
}

/* Checkboxes */
.checkbox-instruction {
  font-weight: 600;
  margin-bottom: 16px;
}

.checkbox-group {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.custom-checkbox {
  display: flex;
  align-items: flex-start;
  position: relative;
  cursor: pointer;
  padding-left: 32px;
  font-size: 0.95rem;
  user-select: none;
}

.custom-checkbox input {
  position: absolute;
  opacity: 0;
  cursor: pointer;
  height: 0;
  width: 0;
}

.checkmark {
  position: absolute;
  top: 2px;
  left: 0;
  height: 22px;
  width: 22px;
  background-color: #fff;
  border: 2px solid var(--color-border);
  border-radius: 4px;
  transition: all var(--transition-fast);
}

.custom-checkbox:hover input~.checkmark {
  border-color: var(--color-primary);
}

.custom-checkbox input:checked~.checkmark {
  background-color: var(--color-primary);
  border-color: var(--color-primary);
}

.checkmark:after {
  content: "";
  position: absolute;
  display: none;
}

.custom-checkbox input:checked~.checkmark:after {
  display: block;
}

.custom-checkbox .checkmark:after {
  left: 7px;
  top: 3px;
  width: 5px;
  height: 10px;
  border: solid white;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

/* Result Sheet Details */
.result-header {
  text-align: center;
  margin-bottom: 24px;
}

.sheet-container {
  background: #fff;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  padding: 20px;
  margin-bottom: 24px;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.02);
}

.sheet-section {
  margin-bottom: 16px;
  padding-bottom: 16px;
  border-bottom: 1px dashed var(--color-border);
}

.sheet-section:last-child {
  border-bottom: none;
  margin-bottom: 0;
  padding-bottom: 0;
}

.sheet-label {
  font-size: 0.85rem;
  color: var(--color-text-muted);
  font-weight: 600;
  margin-bottom: 4px;
}

.sheet-value {
  font-size: 1.05rem;
  font-weight: 500;
}

/* Action Buttons */
.action-buttons {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* Footer & Buttons */
.app-footer {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--color-card-bg);
  backdrop-filter: blur(10px);
  border-top: 1px solid var(--color-border);
  padding: 16px 20px;
  display: flex;
  justify-content: space-between;
  z-index: 100;
  box-shadow: 0 -4px 6px -1px rgba(0, 0, 0, 0.05);
}

.spacer {
  flex-grow: 1;
}

.btn {
  padding: 12px 24px;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all var(--transition-fast);
  text-align: center;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--color-primary);
  color: white;
  box-shadow: 0 4px 6px rgba(16, 185, 129, 0.2);
}

.btn-primary:hover:not(:disabled) {
  background: var(--color-primary-dark);
}

.btn-secondary {
  background: var(--color-secondary);
  color: var(--color-text-main);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--color-secondary-dark);
}

.btn-outline {
  background: transparent;
  border: 2px solid var(--color-primary);
  color: var(--color-primary-dark);
}

.btn-outline:hover {
  background: var(--color-bg-start);
}

/* Toast */
.toast {
  position: fixed;
  bottom: 100px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: #333;
  color: #fff;
  padding: 10px 20px;
  border-radius: 20px;
  font-size: 0.9rem;
  opacity: 0;
  transition: opacity 0.3s, transform 0.3s;
  pointer-events: none;
  z-index: 1000;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* Chat UI */
.chat-container {
  display: flex;
  flex-direction: column;
  gap: 16px;
  max-height: 55vh;
  overflow-y: auto;
  padding: 12px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.7);
  border: 1px solid var(--color-border);
  margin-bottom: 16px;
}

.chat-msg {
  max-width: 85%;
  padding: 12px 16px;
  border-radius: 16px;
  font-size: 0.95rem;
  animation: chatFadeIn 0.3s forwards;
  opacity: 0;
  transform: translateY(10px);
}

@keyframes chatFadeIn {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.chat-msg.bot {
  background: #f0fdf4;
  color: var(--color-text-main);
  border: 1px solid #bbf7d0;
  align-self: flex-start;
  border-bottom-left-radius: 4px;
}

.chat-msg.user {
  background: var(--color-primary);
  color: white;
  align-self: flex-end;
  border-bottom-right-radius: 4px;
}

.chat-options {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 12px;
}

.chat-btn {
  background: white;
  border: 2px solid var(--color-primary);
  color: var(--color-primary-dark);
  padding: 10px 16px;
  border-radius: 20px;
  font-weight: 600;
  font-size: 0.9rem;
  text-align: left;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.chat-btn:hover {
  background: var(--color-primary);
  color: white;
}

.chat-result-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: #1d4ed8;
  margin-bottom: 12px;
  background: #eff6ff;
  padding: 12px;
  border-radius: 8px;
  text-align: center;
}

/* Power Words Button */
.btn-powerword {
  background: white;
  border: 1px solid var(--color-primary);
  color: var(--color-primary-dark);
  padding: 6px 12px;
  border-radius: 12px;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all var(--transition-fast);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.btn-powerword:hover {
  background: var(--color-primary);
  color: white;
  transform: translateY(-1px);
}

.btn-powerword:active {
  transform: translateY(0);
}

/* Venn Diagram */
.venn-container {
  display: flex;
  justify-content: center;
  position: relative;
  height: 180px;
  margin-bottom: 24px;
}

.venn-circle {
  position: absolute;
  width: 120px;
  height: 120px;
  border-radius: 50%;
  opacity: 0.6;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  color: #fff;
  font-size: 0.95rem;
  box-shadow: var(--shadow-sm);
}

.venn-will {
  background: #ef4444;
  top: 0;
  left: calc(50% - 60px);
}

.venn-can {
  background: #3b82f6;
  bottom: 10px;
  left: calc(50% - 100px);
}

.venn-need {
  background: #10b981;
  bottom: 10px;
  right: calc(50% - 100px);
}

.venn-center {
  position: absolute;
  top: 70px;
  left: calc(50% - 30px);
  width: 60px;
  text-align: center;
  font-size: 0.8rem;
  font-weight: bold;
  color: #fff;
  z-index: 10;
}

/* Positioning Map */
.position-map {
  position: relative;
  width: 100%;
  height: 280px;
  border: 2px solid #e5e7eb;
  background: #f9fafb;
  margin-top: 16px;
  border-radius: 8px;
  overflow: hidden;
  cursor: crosshair;
}

.pos-axis-x {
  position: absolute;
  top: 50%;
  left: 0;
  width: 100%;
  border-top: 2px dashed #cbd5e1;
}

.pos-axis-y {
  position: absolute;
  top: 0;
  left: 50%;
  height: 100%;
  border-left: 2px dashed #cbd5e1;
}

.pos-label {
  position: absolute;
  font-size: 0.75rem;
  color: #64748b;
  font-weight: 600;
  padding: 2px 6px;
  background: rgba(255, 255, 255, 0.8);
  border-radius: 4px;
  z-index: 2;
  pointer-events: none;
}

.pos-label-top {
  top: 4px;
  left: 50%;
  transform: translateX(-50%);
}

.pos-label-bottom {
  bottom: 4px;
  left: 50%;
  transform: translateX(-50%);
}

.pos-label-left {
  top: 50%;
  left: 4px;
  transform: translateY(-50%);
}

.pos-label-right {
  top: 50%;
  right: 4px;
  transform: translateY(-50%);
}

.pos-marker {
  position: absolute;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  color: white;
  font-weight: bold;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  transform: translate(-50%, -50%);
  box-shadow: var(--shadow-md);
  z-index: 10;
  transition: left 0.2s ease, top 0.2s ease;
}

.pos-marker.rival {
  background: #ef4444;
  border: 2px solid white;
}

.pos-marker.self {
  background: #3b82f6;
  border: 2px solid white;
}