* {
  box-sizing: border-box;
}

:root {
  --sky: #dff7ff;
  --sand: #f9dc9a;
  --dune: #f0bd63;
  --cactus: #7dc77a;
  --green: #4db66d;
  --green-dark: #2d7a52;
  --wood: #8b5a2b;
  --wood-dark: #4d2a1a;
  --danger: #ef5d6c;
  --danger-dark: #a83240;
  --gold: #ffd166;
  --panel: rgba(255, 255, 255, 0.88);
  --shadow: rgba(65, 35, 18, 0.18);
  --text: #2e180d;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Trebuchet MS", "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at top, #fef7d6 0%, #ffdba0 15%, #efb35f 40%, #d68f45 100%);
  color: var(--text);
}

button {
  font: inherit;
}

#app {
  max-width: 1100px;
  margin: 0 auto;
  padding: 24px 18px 40px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
  margin-bottom: 22px;
}

.brand-wrap {
  display: flex;
  align-items: center;
  gap: 16px;
}

.brand-icon {
  width: 58px;
  height: 58px;
  border-radius: 18px;
  display: grid;
  place-items: center;
  font-size: 2.1rem;
  background: linear-gradient(135deg, #9ee39d, #69b673);
  box-shadow: 0 12px 20px rgba(33, 78, 35, 0.2);
}

.eyebrow {
  margin: 0;
  font-size: 0.7rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: rgba(46, 24, 13, 0.7);
}

h1 {
  margin: 3px 0 0;
  font-size: clamp(2rem, 4vw, 3rem);
}

.status-badges {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.status-badges span {
  background: rgba(255, 255, 255, 0.75);
  border: 2px solid rgba(106, 70, 32, 0.14);
  border-radius: 999px;
  padding: 10px 16px;
  font-weight: 700;
  box-shadow: 0 8px 18px rgba(85, 53, 18, 0.1);
}

main {
  min-height: 72vh;
}

.screen {
  display: none;
}

.screen.active {
  display: block;
}

.panel {
  background: var(--panel);
  border: 4px solid rgba(118, 73, 42, 0.16);
  border-radius: 26px;
  box-shadow: 0 24px 40px var(--shadow);
}

.intro-panel {
  padding: 26px 22px 30px;
  text-align: center;
}

.intro-panel h2 {
  margin: 0 0 12px;
  font-size: clamp(1.8rem, 3vw, 2.6rem);
}

.intro-panel p {
  max-width: 640px;
  margin: 0 auto 20px;
  font-size: 1.08rem;
  line-height: 1.6;
}

.class-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 18px;
  margin-bottom: 24px;
}

.class-card {
  padding: 18px 16px 14px;
  border-radius: 20px;
  background: linear-gradient(180deg, #fefdfb, #f9f0d5);
  border: 3px solid transparent;
  text-align: left;
  cursor: pointer;
  transition: transform 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
}

.class-card:hover,
.class-card.selected {
  transform: translateY(-3px);
  border-color: #f0a64f;
  box-shadow: 0 18px 24px rgba(141, 87, 30, 0.13);
}

.class-card-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.class-card h3 {
  margin: 0;
  font-size: 1.4rem;
}

.class-card .emoji {
  font-size: 2rem;
}

.class-card ul {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 8px;
  color: rgba(46, 24, 13, 0.8);
}

.class-card li {
  display: flex;
  justify-content: space-between;
  gap: 8px;
}

.primary-btn,
.secondary-btn,
.action-btn {
  border: none;
  border-radius: 14px;
  cursor: pointer;
  transition: transform 0.15s ease, filter 0.15s ease;
}

.primary-btn:hover,
.secondary-btn:hover,
.action-btn:hover {
  transform: translateY(-2px);
  filter: brightness(1.02);
}

.primary-btn {
  background: linear-gradient(180deg, #ffcf5d, #ee9b43);
  color: var(--text);
  font-weight: 800;
  padding: 14px 24px;
  min-width: 170px;
  box-shadow: 0 12px 18px rgba(143, 86, 27, 0.18);
}

.secondary-btn {
  background: linear-gradient(180deg, #dfe9ff, #bfd0ff);
  color: var(--text);
  font-weight: 700;
  padding: 12px 18px;
}

.battlefield {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 20px;
  padding: 20px;
  margin-bottom: 18px;
}

.fighter {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
}

.fighter-visual {
  width: min(100%, 280px);
  min-height: 220px;
  display: grid;
  place-items: center;
  border-radius: 26px;
  background: linear-gradient(180deg, rgba(224, 248, 255, 0.95), rgba(183, 222, 255, 0.7));
  border: 4px solid rgba(74, 101, 149, 0.14);
}

.snail {
  position: relative;
  width: 174px;
  height: 146px;
}

.shell {
  position: absolute;
  left: 18px;
  top: 28px;
  width: 132px;
  height: 104px;
  border-radius: 58% 42% 52% 48% / 54% 49% 51% 46%;
  background: linear-gradient(135deg, #ffefb3, #f6cd65 55%, #d99b36 100%);
  border: 6px solid rgba(119, 78, 24, 0.3);
  z-index: 0;
}

.enemy-shell {
  background: linear-gradient(135deg, #d9f5c2, #9ed76b 58%, #5fa252 100%);
}

.body {
  position: absolute;
  left: 28px;
  top: 64px;
  width: 118px;
  height: 58px;
  border-radius: 52% 48% 52% 48% / 56% 44% 56% 44%;
  background: linear-gradient(180deg, #a6df7d, #6cbe67);
  border: 4px solid rgba(38, 78, 36, 0.3);
  z-index: 1;
}

.enemy-body {
  background: linear-gradient(180deg, #c7b1ff, #8e82e0);
}

.head {
  position: absolute;
  right: 10px;
  top: 52px;
  width: 46px;
  height: 40px;
  border-radius: 48% 52% 42% 58% / 56% 44% 56% 44%;
  background: linear-gradient(135deg, #98dd72, #63ba63);
  border: 4px solid rgba(48, 87, 36, 0.3);
  z-index: 2;
}

.enemy-head {
  background: linear-gradient(135deg, #b6a0ff, #8671d9);
}

.eye {
  position: absolute;
  width: 10px;
  height: 10px;
  background: #1c1b1d;
  border-radius: 50%;
  top: 66px;
  z-index: 3;
}

.eye-left {
  left: 112px;
}

.eye-right {
  left: 131px;
}

.antenna {
  position: absolute;
  width: 3px;
  height: 18px;
  background: #3a3b3d;
  top: 26px;
  border-radius: 99px;
  z-index: 2;
}

.antenna-left {
  left: 122px;
  transform: rotate(-22deg);
}

.antenna-right {
  left: 138px;
  transform: rotate(22deg);
}

.fighter-panel {
  width: min(100%, 260px);
  background: rgba(255, 255, 255, 0.72);
  border-radius: 18px;
  border: 3px solid rgba(110, 71, 48, 0.14);
  padding: 12px 14px;
}

.fighter-panel h3 {
  margin: 0 0 8px;
  font-size: 1.3rem;
}

.stat-line {
  display: flex;
  justify-content: space-between;
  margin: 6px 0;
  font-size: 0.98rem;
}

.hp-bar,
.mana-bar {
  width: 100%;
  height: 12px;
  border-radius: 999px;
  background: rgba(120, 126, 126, 0.15);
  overflow: hidden;
  margin-top: 2px;
}

.hp-fill,
.mana-fill {
  height: 100%;
  border-radius: inherit;
}

.hp-fill {
  background: linear-gradient(90deg, #ff6a75, #f3a65d);
}

.mana-fill {
  background: linear-gradient(90deg, #7ec8ff, #3da6f5);
}

.versus-wrap {
  display: grid;
  place-items: center;
}

.versus-badge {
  display: grid;
  place-items: center;
  width: 76px;
  height: 76px;
  border-radius: 50%;
  background: linear-gradient(180deg, #fff4c9, #ffd975);
  border: 4px solid rgba(146, 93, 0, 0.35);
  font-size: 1.7rem;
  font-weight: 900;
  box-shadow: 0 12px 22px rgba(98, 69, 24, 0.2);
}

.action-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(120px, 1fr));
  gap: 12px;
  padding: 16px;
  margin-bottom: 16px;
}

.action-btn {
  background: linear-gradient(180deg, #f4f3ff, #dfe3ff);
  border: 3px solid rgba(103, 93, 162, 0.12);
  padding: 14px 16px;
  font-weight: 800;
  color: var(--text);
}

.action-btn[data-action="attack"] {
  background: linear-gradient(180deg, #ffd0d3, #ff9ca7);
}

.action-btn[data-action="skill"] {
  background: linear-gradient(180deg, #d6f8ff, #9cd5ff);
}

.action-btn[data-action="guard"] {
  background: linear-gradient(180deg, #e5ffd6, #bde398);
}

.action-btn[data-action="heal"] {
  background: linear-gradient(180deg, #ffe7bf, #ffcf6b);
}

.log {
  padding: 18px 18px 22px;
}

.log h3 {
  margin: 0 0 10px;
}

.battle-log {
  display: grid;
  gap: 7px;
  max-height: 200px;
  overflow: auto;
  padding-right: 8px;
}

.log-entry {
  background: rgba(120, 132, 204, 0.06);
  border-radius: 12px;
  padding: 8px 12px;
  font-size: 0.96rem;
}

.result-panel {
  max-width: 560px;
  margin: 60px auto 0;
  text-align: center;
  padding: 30px 24px;
}

.result-panel h2 {
  margin-top: 0;
  margin-bottom: 12px;
  font-size: clamp(2rem, 4vw, 3rem);
}

.result-panel p {
  font-size: 1.08rem;
  line-height: 1.6;
  margin-bottom: 20px;
}

.result-panel button + button {
  margin-left: 10px;
}

@media (max-width: 760px) {
  .topbar {
    flex-direction: column;
    align-items: flex-start;
  }

  .battlefield {
    grid-template-columns: 1fr;
  }

  .versus-wrap {
    order: -1;
  }

  .action-strip {
    grid-template-columns: repeat(2, minmax(120px, 1fr));
  }

  .result-panel button + button {
    margin-left: 0;
    margin-top: 10px;
  }
}
