/* ============================================================
   ATOMIC MATCH — styles
   Palette: sage & cream, from your color reference,
   extended with deeper mosses and lighter creams.
   ============================================================ */
:root {
  /* from your palette */
  --sage:        #9BB179;
  --sage-light:  #C3CC9A;
  --khaki:       #E2DFB4;
  --cream:       #F8E8CE;
  /* deeper + lighter shades in the same range */
  --moss-900:    #2E3D23;  /* main text */
  --moss-700:    #4B6536;
  --moss-500:    #6E8C4E;
  --sage-deep:   #82995F;
  --khaki-deep:  #C9C38C;
  --cream-light: #FFF9EE;
  /* feedback */
  --good:        #4F9A3E;
  --good-dark:   #357029;
  --bad:         #B5563F;
  --bad-dark:    #86392A;

  --display: "Baloo 2", "Trebuchet MS", "Segoe UI", system-ui, sans-serif;
  --body: "Nunito", "Segoe UI", system-ui, sans-serif;
}

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

html, body {
  width: 100%; height: 100%;
  overflow: hidden;
  background: #2E3D23;
  font-family: var(--body);
  color: var(--moss-900);
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

/* ---------- Stage (fixed 960x540, scaled by JS) ---------- */
#stage {
  position: absolute;
  left: 50%; top: 50%;
  width: 960px; height: 540px;
  transform-origin: center center;
  overflow: hidden;
  background-color: var(--cream);
  background-image: url("assets/images/background.jpg");
  background-size: cover;
  background-position: center;
  border-radius: 6px;
}

.screen {
  position: absolute; inset: 0;
  display: none;
}
.screen.active { display: block; animation: fadeIn .35s ease; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.hidden { display: none !important; }

/* ---------- Buttons ---------- */
.btn {
  font-family: var(--display);
  font-weight: 800;
  font-size: 22px;
  color: var(--cream-light);
  background: var(--moss-500);
  border: none;
  border-radius: 14px;
  padding: 8px 28px 6px;
  cursor: pointer;
  box-shadow: 0 6px 0 var(--moss-700);
  transition: transform .08s, box-shadow .08s;
}
.btn:hover { filter: brightness(1.07); }
.btn:active { transform: translateY(4px); box-shadow: 0 2px 0 var(--moss-700); }
.btn:focus-visible { outline: 3px solid var(--moss-900); outline-offset: 4px; }
.btn-ghost {
  background: transparent;
  color: var(--moss-700);
  box-shadow: inset 0 0 0 3px var(--sage-light);
}
.btn-ghost:active { transform: translateY(2px); box-shadow: inset 0 0 0 3px var(--sage-light); }

/* ============ TITLE ============ */
.title-block {
  position: absolute;
  left: 70px; top: 50%;
  transform: translateY(-50%);
  width: 470px;
  padding: 34px 40px 36px;
  background: rgba(255, 249, 238, .78);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  border-radius: 26px;
  box-shadow: 0 8px 0 rgba(75, 101, 54, .25);
}
.game-title {
  position: relative;
  font-family: var(--display);
  font-weight: 800;
  font-size: 100px;
  line-height: .86;
  color: var(--moss-700);
  letter-spacing: -2px;
  text-shadow: 0 5px 0 var(--sage-light);
}
.tagline {
  margin: 18px 0 24px;
  font-size: 19px;
  font-weight: 600;
  color: var(--moss-500);
}
.btn-big { font-size: 30px; padding: 10px 54px 8px; }

/* orbiting electrons behind the title */
.orbit {
  position: absolute;
  left: 200px; top: -30px;
  width: 280px; height: 280px;
  pointer-events: none;
}
.ring {
  position: absolute; inset: 0;
  border: 2px solid rgba(110, 140, 78, .3);
  border-radius: 50%;
  animation: spin 6s linear infinite;
}
.ring i {
  position: absolute; top: -7px; left: 50%;
  width: 14px; height: 14px; margin-left: -7px;
  border-radius: 50%;
  background: var(--moss-500);
}
.r2 { inset: 30px 0; animation-duration: 8s; }
.r3 { inset: 0 60px; animation-duration: 10s; animation-direction: reverse; }
.r2 i { background: var(--sage); }
.r3 i { background: var(--khaki-deep); }
.nucleus {
  position: absolute; left: 50%; top: 50%;
  width: 22px; height: 22px; margin: -11px;
  border-radius: 50%;
  background: var(--moss-700);
}
@keyframes spin { to { rotate: 360deg; } }

.title-sprite {
  position: absolute;
  right: 40px; bottom: -40px;
  height: 520px;
  filter: drop-shadow(0 10px 18px rgba(46, 61, 35, .3));
}

/* ============ DIALOGUE ============ */
.dialogue-sprite {
  position: absolute;
  left: 40px; bottom: -30px;
  height: 500px;
  filter: drop-shadow(0 10px 18px rgba(46, 61, 35, .3));
  transition: transform .15s;
}
.dialogue-sprite.bump { transform: translateY(-8px); }

.dialogue-box {
  position: absolute;
  left: 340px; right: 36px; bottom: 36px;
  min-height: 190px;
  background: var(--cream-light);
  border: 4px solid var(--sage-light);
  border-radius: 20px;
  padding: 36px 34px 30px;
  box-shadow: 0 8px 0 rgba(75, 101, 54, .3);
  cursor: pointer;
}
.name-tag {
  position: absolute;
  top: -20px; left: 26px;
  font-family: var(--display);
  font-weight: 800;
  font-size: 20px;
  color: var(--cream-light);
  background: var(--moss-500);
  padding: 4px 18px 2px;
  border-radius: 10px;
}
#dialogue-text {
  font-size: 23px;
  line-height: 1.45;
  font-weight: 600;
  min-height: 100px;
}
.next-hint {
  position: absolute;
  right: 26px; bottom: 16px;
  font-family: var(--display);
  font-weight: 800;
  font-size: 22px;
  color: var(--sage-deep);
  animation: blink 1s steps(2) infinite;
}
@keyframes blink { 50% { opacity: .2; } }
.btn-ready {
  position: absolute;
  right: 26px; bottom: -24px;
  font-size: 24px;
  animation: popIn .35s cubic-bezier(.3,1.6,.5,1);
}
@keyframes popIn { from { transform: scale(.6); opacity: 0; } to { transform: scale(1); opacity: 1; } }

/* ============ GAME ============ */
/* soft cream wash so the card stands out from the classroom */
#screen-game::before {
  content: "";
  position: absolute; inset: 0;
  background: rgba(248, 232, 206, .35);
}
.hud {
  position: absolute;
  top: 18px; left: 24px; right: 24px;
  display: flex; align-items: center; gap: 16px;
}
.hud-pill {
  font-family: var(--display);
  font-weight: 800;
  font-size: 18px;
  color: var(--moss-700);
  background: rgba(255, 249, 238, .9);
  padding: 4px 14px 2px;
  border-radius: 10px;
  white-space: nowrap;
  box-shadow: 0 3px 0 rgba(75, 101, 54, .2);
}
.hud-pill.points { color: var(--cream-light); background: var(--moss-500); min-width: 110px; text-align: center; }
.progress {
  flex: 1; height: 12px;
  background: rgba(255, 249, 238, .8);
  border-radius: 6px;
  overflow: hidden;
}
#progress-fill {
  height: 100%; width: 0;
  background: var(--sage);
  border-radius: 6px;
  transition: width .4s ease;
}

.prompt {
  position: absolute;
  top: 60px; left: 50%;
  transform: translateX(-50%);
  font-family: var(--display);
  font-weight: 800;
  font-size: 21px;
  color: var(--moss-700);
  background: rgba(255, 249, 238, .85);
  padding: 2px 18px 0;
  border-radius: 10px;
  white-space: nowrap;
}

.card-row {
  position: absolute;
  top: 100px; left: 0; right: 0;
  height: 250px;
}
.element-card {
  position: absolute;
  left: 50%; top: 0;
  width: 210px; height: 240px;
  margin-left: -105px;
  background: var(--cream-light);
  border-radius: 16px;
  border: 6px solid var(--sage); /* changed by JS per category */
  box-shadow: 0 10px 0 rgba(75, 101, 54, .3);
  display: flex; flex-direction: column;
  padding: 10px 14px;
}
.element-card.pop { animation: cardPop .4s cubic-bezier(.3,1.5,.5,1); }
@keyframes cardPop { from { transform: scale(.7) rotate(-4deg); opacity: 0; } to { transform: none; opacity: 1; } }
.card-top {
  display: flex; justify-content: space-between;
  font-weight: 800; font-size: 20px;
  color: var(--moss-700);
}
#card-mass { font-size: 16px; opacity: .7; padding-top: 3px; }
.card-symbol {
  flex: 1;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--display);
  font-weight: 800;
  font-size: 110px;
  line-height: 1;
  padding-top: 12px;
  color: var(--moss-900);
}
.card-group {
  text-align: center;
  font-size: 15px; font-weight: 800;
  color: #fff;
  border-radius: 8px;
  padding: 3px 0;
}

.game-sprite {
  position: absolute;
  left: 60px; top: -20px;
  height: 330px;
  filter: drop-shadow(0 8px 14px rgba(46, 61, 35, .25));
}
.float-points {
  position: absolute;
  left: 50%; top: 40px;
  margin-left: 130px;
  font-family: var(--display);
  font-weight: 800;
  font-size: 40px;
  color: var(--good);
  text-shadow: 0 3px 0 var(--cream-light);
  opacity: 0;
  pointer-events: none;
}
.float-points.show { animation: floatUp 1s ease forwards; }
@keyframes floatUp {
  0% { opacity: 0; transform: translateY(10px); }
  20% { opacity: 1; }
  100% { opacity: 0; transform: translateY(-40px); }
}

.options {
  position: absolute;
  left: 24px; right: 24px; bottom: 24px;
  height: 130px;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
}
.opt {
  position: relative;
  border: none;
  border-radius: 16px;
  font-family: var(--display);
  font-weight: 800;
  font-size: 28px;
  cursor: pointer;
  transition: transform .08s, filter .2s;
}
.opt kbd {
  position: absolute; top: 8px; left: 10px;
  font-family: var(--body);
  font-size: 13px;
  width: 22px; height: 22px; line-height: 22px;
  border-radius: 6px;
  background: rgba(46, 61, 35, .15);
}
/* 4 answer colors: deep → light, all sage/cream family */
.opt-0 { background: var(--moss-700);  color: var(--cream-light); box-shadow: 0 7px 0 #334824; }
.opt-1 { background: var(--sage-deep); color: var(--cream-light); box-shadow: 0 7px 0 #5E7342; }
.opt-2 { background: var(--sage-light); color: var(--moss-900);   box-shadow: 0 7px 0 #98A370; }
.opt-3 { background: var(--khaki);     color: var(--moss-900);    box-shadow: 0 7px 0 #B3AE80; }
.opt:hover { filter: brightness(1.06); }
.opt:active { transform: translateY(4px); }
.opt:focus-visible { outline: 3px solid var(--moss-900); outline-offset: 3px; }

.options.locked .opt { cursor: default; }
.opt.dim { filter: grayscale(.5) brightness(.8) opacity(.75); }
.opt.right { background: var(--good); color: #fff; box-shadow: 0 7px 0 var(--good-dark), 0 0 0 5px var(--cream-light); }
.opt.wrong { background: var(--bad);  color: #fff; box-shadow: 0 7px 0 var(--bad-dark); animation: shake .4s; }
/* ✓ / ✗ so right and wrong aren't shown by color alone */
.opt.right::after, .opt.wrong::after {
  position: absolute; top: 6px; right: 12px;
  font-size: 24px;
}
.opt.right::after { content: "✓"; }
.opt.wrong::after { content: "✗"; }
@keyframes shake {
  20%, 60% { transform: translateX(-8px); }
  40%, 80% { transform: translateX(8px); }
}

/* ============ RESULTS ============ */
/* score panel sits in the middle */
.result-panel {
  position: absolute;
  left: 410px; top: 50%;   /* slightly left of center to make room for the chibi */
  width: 500px;
  max-height: 516px;
  transform: translate(-50%, -50%);
  background: var(--cream-light);
  border: 4px solid var(--sage-light);
  border-radius: 22px;
  box-shadow: 0 8px 0 rgba(75, 101, 54, .3);
  padding: 16px 30px;
  display: flex; flex-direction: column; align-items: center;
}
/* chibi sits on the panel's bottom-right corner (it lives inside the panel) */
.result-chibi {
  position: absolute;
  left: calc(100% - 45px);
  bottom: -45px;
  height: 320px;
  max-width: none;
  filter: drop-shadow(0 8px 12px rgba(46, 61, 35, .3));
  z-index: 2;
}
.result-chibi.enter { animation: chibiIn .6s cubic-bezier(.3,1.6,.5,1); }
@keyframes chibiIn {
  from { transform: translateY(60px) scale(.6); opacity: 0; }
  to   { transform: none; opacity: 1; }
}
.result-message {
  font-family: var(--display);
  font-weight: 800;
  font-size: 30px;
  color: var(--moss-700);
  text-align: center;
  line-height: 1.1;
  margin-bottom: 6px;
}
.result-points {
  font-family: var(--display);
  font-weight: 800;
  font-size: 22px;
  color: var(--sage-deep);
  line-height: 1;
}
#result-points { font-size: 64px; color: var(--moss-900); }
.result-stats {
  display: flex; gap: 14px;
  margin: 10px 0 12px;
}
.stat {
  width: 130px;
  border-radius: 14px;
  padding: 6px 0 4px;
  text-align: center;
  color: #fff;
}
.stat b { display: block; font-family: var(--display); font-size: 36px; line-height: 1; }
.stat span { font-weight: 800; font-size: 15px; }
.stat.good { background: var(--good); }
.stat.bad { background: var(--bad); }

.review-wrap { width: 100%; flex: 0 1 auto; min-height: 0; display: flex; flex-direction: column; }
.review-title { font-weight: 800; font-size: 15px; margin-bottom: 6px; color: var(--moss-500); }
.review-list {
  display: flex; flex-wrap: wrap; gap: 6px;
  overflow-y: auto;
  align-content: flex-start;
}
.review-chip {
  font-size: 13px; font-weight: 800;
  background: var(--cream);
  border: 2px solid var(--khaki);
  border-radius: 9px;
  padding: 2px 9px;
}
.review-chip b { font-family: var(--display); font-size: 16px; margin-right: 4px; color: var(--moss-700); }
.result-buttons { display: flex; gap: 12px; margin-top: 10px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition: none !important; }
}
