:root {
  --row-height: 18px;
  --cell-gap: 1px;
}

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

body {
  font-family: 'DM Sans', -apple-system, sans-serif;
  min-height: 100vh;
  overflow-x: auto;
  background: linear-gradient(160deg, rgba(254, 202, 87, 0.25) 0%, rgba(255, 159, 67, 0.25) 50%, rgba(255, 107, 107, 0.25) 100%), #ffffff;
  background-attachment: fixed;
  color: #2d3436;
}

#app {
  min-height: 100vh;
}

.step {
  display: none;
  min-height: 100vh;
  align-items: center;
  justify-content: center;
  padding: 2rem;
}

.step.active {
  display: flex;
}

.step-content {
  width: 100%;
  max-width: 420px;
  margin: 0 auto;
}

.step-content.card {
  background: white;
  padding: 3rem;
  border-radius: 24px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
  text-align: center;
  border: 4px solid #ff6b6b;
  max-width: 480px;
  min-height: 400px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.step-content h1 {
  font-size: 2.75rem;
  font-weight: 800;
  text-align: center;
  margin-bottom: 0.5rem;
  background: linear-gradient(135deg, #ff6b6b, #ee5a5a);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.step-content h2 {
  font-size: 1.75rem;
  font-weight: 700;
  text-align: center;
  margin-bottom: 2rem;
  color: #e17055;
}

.tagline {
  text-align: center;
  color: #636e72;
  margin-bottom: 2.5rem;
  font-size: 1.1rem;
}

.form {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  align-items: stretch;
}

.form input {
  padding: 1rem 1.5rem;
  font-size: 1rem;
  font-family: inherit;
  background: #fff5f5;
  border: 3px solid #ff6b6b;
  border-radius: 16px;
  color: #2d3436;
  transition: all 0.2s;
}

.form input:focus {
  outline: none;
  border-color: #ee5a5a;
  box-shadow: 0 0 0 6px rgba(255, 107, 107, 0.3);
}

.form input::placeholder {
  color: #b2bec3;
}

.form button {
  padding: 1rem 1.5rem;
  font-size: 1rem;
  font-family: inherit;
  font-weight: 700;
  background: linear-gradient(135deg, #ff6b6b 0%, #ee5a5a 100%);
  border: none;
  border-radius: 16px;
  color: white;
  cursor: pointer;
  box-shadow: 0 8px 25px rgba(255, 107, 107, 0.5);
  transition: transform 0.2s, box-shadow 0.2s;
}

.hidden {
  display: none !important;
}

.auth-switch {
  margin-top: 1.5rem;
  font-size: 0.9rem;
  color: #636e72;
}

.auth-switch a {
  color: #ff6b6b;
  font-weight: 600;
  text-decoration: none;
}

.auth-switch a:hover {
  text-decoration: underline;
}

.auth-error {
  margin-top: 1rem;
  font-size: 0.9rem;
  color: #ff6b6b;
  min-height: 1.2em;
}

.verify-hint {
  margin-bottom: 1rem;
  font-size: 0.95rem;
  color: #636e72;
}

#verify-code {
  text-align: center;
  font-size: 1.5rem;
  letter-spacing: 0.5em;
}

.form button:hover {
  transform: translateY(-3px);
  box-shadow: 0 12px 35px rgba(255, 107, 107, 0.6);
}

/* Matrix */
#step-matrix {
  display: none;
  padding: 2rem;
  align-items: flex-start;
  justify-content: center;
}

#step-matrix.active {
  display: flex;
}

.matrix-container {
  width: 100%;
  max-width: 1400px;
  margin: 0 auto;
  background: white;
  padding: 2.5rem;
  border-radius: 24px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
  text-align: center;
}

.logo {
  display: block;
  max-width: 600px;
  height: auto;
  margin: 0 auto 1rem;
}

.step-content .logo {
  max-width: 350px;
}

#matrix-title {
  font-size: 1.5rem;
  margin-bottom: 0.75rem;
  text-align: center;
  color: #e17055;
  font-weight: 700;
}

.lived-stats {
  font-size: 1.1rem;
  color: #2d3436;
  margin-bottom: 1.5rem;
  line-height: 1.7;
  max-width: 600px;
  margin-left: auto;
  margin-right: auto;
  font-weight: 500;
}

.matrix-wrapper {
  display: flex;
  gap: 1.5rem;
  align-items: flex-start;
  justify-content: center;
  overflow-x: auto;
  padding-bottom: 1rem;
}

#matrix {
  display: grid;
  grid-template-columns: repeat(52, 18px);
  grid-auto-rows: 18px;
  gap: 1px;
  background: #dfe6e9;
  border: 3px solid #b2bec3;
  border-radius: 10px;
  overflow: hidden;
  width: fit-content;
  min-width: calc(52 * 18px + 51 * 1px);
}

.matrix-cell {
  width: 18px;
  height: 18px;
  min-width: 18px;
  min-height: 18px;
  background: #dfe6e9;
  border-radius: 2px;
}

.matrix-cell.filled {
  background: linear-gradient(135deg, #ff6b6b, #ee5a5a);
}

.matrix-cell.birthday-cell {
  box-shadow: 0 0 0 3px #feca57;
}

.matrix-inner {
  position: relative;
}

.birthday-tooltip {
  position: absolute;
  top: 0;
  left: 0;
  transform: translateY(-100%);
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  background: #fff;
  border: 3px solid #ff6b6b;
  border-radius: 12px;
  box-shadow: 0 8px 30px rgba(255, 107, 107, 0.4);
  z-index: 10;
  animation: tooltipAppear 0.2s ease;
}

.birthday-tooltip-hidden {
  display: none;
}

.birthday-tooltip-text {
  margin: 0;
  font-size: 0.9rem;
  color: #2d3436;
}

.birthday-tooltip-close {
  flex-shrink: 0;
  width: 24px;
  height: 24px;
  padding: 0;
  font-size: 1.25rem;
  line-height: 1;
  color: #636e72;
  background: transparent;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: color 0.2s, background 0.2s;
}

.birthday-tooltip-close:hover {
  color: #ff6b6b;
  background: #fff5f5;
}

@keyframes tooltipAppear {
  from {
    opacity: 0;
    transform: translateY(-90%);
  }
  to {
    opacity: 1;
    transform: translateY(-100%);
  }
}

#year-scale {
  position: relative;
  width: 36px;
  min-width: 36px;
  flex-shrink: 0;
  height: calc(100 * (var(--row-height) + var(--cell-gap)) - var(--cell-gap));
}

.year-label {
  position: absolute;
  left: 0;
  width: 36px;
  height: calc(var(--row-height) + var(--cell-gap));
  display: flex;
  align-items: center;
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  color: #636e72;
}

.year-label.milestone {
  font-weight: 700;
  color: #e17055;
}

.year-label.current-age {
  color: #feca57;
  font-weight: 700;
}

.matrix-legend {
  display: flex;
  gap: 2rem;
  justify-content: center;
  margin-top: 1.5rem;
  font-size: 0.9rem;
  color: #636e72;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.legend-item.red {
  color: #feca57;
}

.legend-box {
  width: 18px;
  height: 18px;
  background: #dfe6e9;
  border-radius: 4px;
}

.legend-box.filled {
  background: linear-gradient(135deg, #ff6b6b, #ee5a5a);
}

.legend-box.current {
  background: #feca57;
}

.profile-btn-fixed {
  position: fixed;
  top: 100px;
  right: 100px;
  padding: 0.8rem 1.8rem;
  font-size: 1rem;
  font-family: inherit;
  font-weight: 600;
  background: linear-gradient(135deg, #ff6b6b 0%, #ee5a5a 100%);
  border: none;
  border-radius: 12px;
  color: white;
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: 0 8px 25px rgba(255, 107, 107, 0.4);
  z-index: 1000;
}

.profile-btn-fixed:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 30px rgba(255, 107, 107, 0.5);
}

.matrix-actions,
.profile-actions {
  display: flex;
  gap: 1rem;
  justify-content: center;
  margin-top: 2rem;
}

.action-btn {
  padding: 0.6rem 1.5rem;
  font-size: 0.9rem;
  font-family: inherit;
  font-weight: 600;
  background: linear-gradient(135deg, #ff6b6b 0%, #ee5a5a 100%);
  border: none;
  border-radius: 12px;
  color: white;
  cursor: pointer;
  transition: all 0.2s;
}

.action-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(255, 107, 107, 0.4);
}

.logout-btn {
  padding: 0.6rem 1.5rem;
  font-size: 0.9rem;
  font-family: inherit;
  font-weight: 600;
  background: transparent;
  border: 3px solid #ff6b6b;
  border-radius: 12px;
  color: #ff6b6b;
  cursor: pointer;
  transition: all 0.2s;
}

.logout-btn:hover {
  background: #ff6b6b;
  color: white;
}

/* Profile */
#step-profile {
  display: none;
  padding: 2rem;
  align-items: flex-start;
  justify-content: center;
}

#step-profile.active {
  display: flex;
}

.profile-container {
  width: 100%;
  max-width: 500px;
  margin: 0 auto;
  background: white;
  padding: 2.5rem;
  border-radius: 24px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
  text-align: center;
}

.profile-container h2 {
  font-size: 1.75rem;
  margin-bottom: 1.5rem;
  color: #e17055;
  font-weight: 700;
}

.profile-card {
  background: #fff5f5;
  border: 2px solid #ffcccc;
  border-radius: 16px;
  padding: 1.5rem;
  text-align: left;
}

.profile-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 0;
  border-bottom: 1px solid #ffe0e0;
}

.profile-item:last-child {
  border-bottom: none;
}

.profile-label {
  font-weight: 600;
  color: #636e72;
  font-size: 0.9rem;
}

.profile-value {
  font-weight: 700;
  color: #2d3436;
  font-size: 1rem;
}

@media (max-width: 768px) {
  :root {
    --row-height: 8px;
  }

  .matrix-cell {
    width: 8px;
    height: 8px;
    min-width: 8px;
    min-height: 8px;
  }

  #matrix {
    grid-template-columns: repeat(52, 8px);
    grid-auto-rows: 8px;
    min-width: calc(52 * 8px + 51 * 1px);
  }

  .year-label {
    font-size: 8px;
  }
}
