:root {
  color-scheme: light;
  --bg-top: #eef6ff;
  --bg-bottom: #fff8ef;
  --card: rgba(255, 255, 255, 0.94);
  --card-border: #d9e3f0;
  --text: #233247;
  --muted: #59708d;
  --accent: #4c88ff;
  --accent-strong: #2e6de6;
  --shadow: 0 18px 40px rgba(77, 113, 164, 0.14);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: Arial, Helvetica, sans-serif;
  color: var(--text);
  background: linear-gradient(180deg, var(--bg-top), var(--bg-bottom));
}

button,
input {
  font: inherit;
}

.app {
  width: min(1080px, calc(100% - 2rem));
  margin: 0 auto;
  padding: 1.5rem 0 2rem;
  display: grid;
  grid-template-columns: 1.15fr 0.85fr;
  gap: 1.25rem;
}

.card {
  background: var(--card);
  border: 2px solid var(--card-border);
  border-radius: 28px;
  box-shadow: var(--shadow);
}

.face-card {
  padding: 1.25rem;
}

.controls-card {
  padding: 1.5rem;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(1.7rem, 2.5vw, 2.25rem);
}

h2 {
  font-size: 1.45rem;
  margin-bottom: 1rem;
}

.intro {
  margin-top: 0.5rem;
  color: var(--muted);
  font-size: 1.05rem;
}

.secondary-button {
  border: 0;
  border-radius: 999px;
  padding: 0.8rem 1rem;
  background: #dce9ff;
  color: var(--accent-strong);
  font-weight: 700;
  cursor: pointer;
}

.secondary-button:hover,
.secondary-button:focus-visible {
  background: #cfe0ff;
  outline: none;
}

.face-stage {
  margin-top: 1rem;
  background: linear-gradient(180deg, #f5fbff, #fff8f2);
  border-radius: 24px;
  padding: 0.75rem;
}

.emotion-face {
  display: block;
  width: min(100%, 480px);
  margin: 0 auto;
}

.face-skin {
  fill: #ffd699;
}

.cheek {
  fill: #ff9ab0;
  opacity: 0.08;
  transition: opacity 0.15s ease;
}

.brow,
.mouth {
  fill: none;
  stroke: #60391d;
  stroke-linecap: round;
}

.brow {
  stroke-width: 8;
}

.mouth {
  stroke-width: 10;
}

.upper-lip {
  stroke: #6d3a23;
}

.lower-lip {
  stroke: #8c5336;
  stroke-width: 7;
}

.mouth-fill {
  fill: #7f2840;
  opacity: 0;
  transition: opacity 0.15s ease;
}

.mouth-teeth {
  fill: #fffdf7;
  opacity: 0;
  transition: opacity 0.15s ease;
}

.eye-white {
  fill: #ffffff;
}

.pupil {
  fill: #253347;
}

.tear {
  fill: none;
  stroke: #7bc7ff;
  stroke-linecap: round;
  stroke-width: 7;
  opacity: 0;
  transition: opacity 0.15s ease;
}

.emotion-card {
  position: relative;
  overflow: hidden;
  margin-top: 1rem;
  padding: 1rem 1.1rem 1.1rem;
  border-radius: 22px;
  border: 2px solid #d9e8ff;
  background: linear-gradient(135deg, #eef5ff, #f9fbff);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7);
}

.emotion-card::after {
  content: "";
  position: absolute;
  top: -26px;
  right: -18px;
  width: 96px;
  height: 96px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.45);
}

.emotion-card[data-theme="joy"] {
  border-color: #ffd98a;
  background: linear-gradient(135deg, #fff4c9, #fff9e7);
}

.emotion-card[data-theme="energy"] {
  border-color: #ffbe8a;
  background: linear-gradient(135deg, #ffe0c2, #fff1e7);
}

.emotion-card[data-theme="calm"] {
  border-color: #cfe2ff;
  background: linear-gradient(135deg, #edf5ff, #f6faff);
}

.emotion-card[data-theme="sad"] {
  border-color: #c8d6f5;
  background: linear-gradient(135deg, #eaf0ff, #f6f8ff);
}

.emotion-card[data-theme="worry"] {
  border-color: #d8cbff;
  background: linear-gradient(135deg, #f0eaff, #f9f5ff);
}

.emotion-card[data-theme="rest"] {
  border-color: #c7ead9;
  background: linear-gradient(135deg, #e8fbf1, #f6fff9);
}

.emotion-kicker,
.emotion-name,
.emotion-sentence {
  position: relative;
  z-index: 1;
}

.emotion-kicker {
  color: var(--muted);
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.emotion-name {
  margin-top: 0.2rem;
  font-size: clamp(1.2rem, 2.2vw, 1.5rem);
  font-weight: 800;
  color: #1f3050;
}

.emotion-sentence {
  margin-top: 0.4rem;
  max-width: 26rem;
  color: #415674;
  font-size: 1rem;
  line-height: 1.45;
}

.controls {
  display: grid;
  gap: 1rem;
}

.control {
  display: grid;
  gap: 0.45rem;
  padding: 1rem;
  background: #f8fbff;
  border: 2px solid #dfebf7;
  border-radius: 20px;
}

.control-title {
  font-size: 1.1rem;
  font-weight: 700;
}

.control-caption {
  color: var(--muted);
}

input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
  min-height: 2.25rem;
  cursor: pointer;
}

input[type="range"]:focus-visible {
  outline: 3px solid rgba(76, 136, 255, 0.2);
  border-radius: 999px;
}

@media (max-width: 860px) {
  .app {
    grid-template-columns: 1fr;
  }

  .card-header {
    align-items: flex-start;
    flex-direction: column;
  }
}

@media (max-width: 560px) {
  html,
  body {
    height: 100%;
  }

  body {
    font-size: 15px;
    overflow: hidden;
  }

  .app {
    width: 100%;
    height: 100dvh;
    padding: 0.45rem;
    gap: 0.5rem;
    grid-template-columns: 1fr;
    grid-template-rows: minmax(0, 0.95fr) minmax(0, 1.05fr);
  }

  .face-card,
  .controls-card {
    padding: 0.7rem;
    min-height: 0;
  }

  .face-card {
    display: grid;
    grid-template-rows: auto auto minmax(0, 1fr) auto;
    gap: 0.3rem;
  }

  .controls-card {
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
  }

  .card-header {
    flex-direction: row;
    align-items: center;
    gap: 0.5rem;
  }

  h1 {
    font-size: 1.25rem;
  }

  h2 {
    margin-bottom: 0.55rem;
    font-size: 1.15rem;
  }

  .intro {
    margin-top: 0;
    font-size: 0.88rem;
  }

  .secondary-button {
    padding: 0.55rem 0.8rem;
    font-size: 0.88rem;
  }

  .face-stage {
    margin-top: 0;
    min-height: 0;
    padding: 0.35rem;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .emotion-face {
    width: min(100%, 195px);
  }

  .emotion-card {
    margin-top: 0;
    padding: 0.55rem 0.75rem;
    border-radius: 18px;
  }

  .emotion-kicker {
    font-size: 0.8rem;
  }

  .emotion-name {
    font-size: 1.05rem;
  }

  .emotion-sentence {
    display: none;
  }

  .controls {
    grid-template-columns: 1fr 1fr;
    gap: 0.45rem;
    align-content: start;
  }

  .control {
    padding: 0.55rem 0.6rem;
    gap: 0.2rem;
    border-radius: 16px;
  }

  .control-title {
    font-size: 0.95rem;
  }

  .control-caption {
    font-size: 0.76rem;
  }

  input[type="range"] {
    min-height: 1.75rem;
  }
}
