:root {
  --bg1: #fdf6ec;
  --bg2: #f6ecd8;
  --ink: #2b2620;
  --paper: #fffdf8;
  --line: #e4d9c3;
  --purple: #7c5ce6;
  --green: #3ec98a;
  --red: #e8482e;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: 'Space Grotesk', sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at 15% 10%, #fff7e6 0%, transparent 45%),
    radial-gradient(circle at 85% 90%, #eef4ff 0%, transparent 50%),
    linear-gradient(160deg, var(--bg1), var(--bg2));
  background-attachment: fixed;
  min-height: 100vh;
}

.mm-mono { font-family: 'JetBrains Mono', monospace; }

.app-shell { animation: fadeUp .5s ease both; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }

/* header */
.mm-title {
  font-size: clamp(2.2rem, 7vw, 3.4rem);
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1;
  margin: 0;
  background: linear-gradient(120deg, var(--red), var(--purple) 55%, #2e9ee8);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}
.mm-tag { font-weight: 300; margin: .5rem 0 .6rem; opacity: .8; font-size: .95rem; }
.mm-help-btn {
  font-family: 'JetBrains Mono', monospace;
  font-size: .72rem;
  border: 1px solid var(--line);
  background: var(--paper);
  padding: .25rem .6rem;
  border-radius: 999px;
  cursor: pointer;
  color: var(--ink);
  transition: .2s;
}
.mm-help-btn:hover { border-color: var(--purple); color: var(--purple); }

.mm-panel {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 1.25rem;
  box-shadow: 0 8px 26px -18px rgba(80,60,20,.5);
}

/* stats */
.mm-stats {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: .5rem;
  text-align: center;
}
.mm-stat {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: .55rem .25rem;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.mm-stat-n { font-size: 1.15rem; font-weight: 700; }
.mm-stat-l { font-size: .62rem; text-transform: uppercase; letter-spacing: .1em; opacity: .55; }
.mm-flame { color: var(--red); }
@media (max-width: 520px) {
  .mm-stats { grid-template-columns: repeat(3, 1fr); }
  .mm-stat-n { font-size: 1rem; }
}

/* difficulty */
.mm-diff {
  display: flex; flex-direction: column; align-items: center;
  gap: 2px;
  padding: .5rem 1rem;
  border-radius: 14px;
  border: 1.5px solid var(--line);
  background: var(--paper);
  cursor: pointer;
  transition: .2s;
  color: var(--ink);
}
.mm-diff:hover { transform: translateY(-2px); border-color: var(--purple); }
.mm-diff-on { border-color: var(--purple); background: linear-gradient(135deg, #f2ecff, #fff); box-shadow: 0 6px 16px -10px var(--purple); }
.mm-diff-sub { font-size: .62rem; opacity: .6; font-family: 'JetBrains Mono', monospace; }

.mm-levelup {
  background: linear-gradient(135deg, #fff2c4, #ffe08a);
  border: 1px solid #e6c24a;
  padding: .5rem 1rem;
  border-radius: 12px;
  font-weight: 500;
  font-size: .9rem;
  animation: pulseGlow 1.6s ease-in-out infinite;
}
@keyframes pulseGlow { 0%,100% { box-shadow: 0 0 0 0 rgba(230,194,74,.4); } 50% { box-shadow: 0 0 0 8px rgba(230,194,74,0); } }

/* board */
.mm-board { overflow-x: auto; }
.mm-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .6rem;
  flex-wrap: wrap;
}
.mm-op { font-size: 2rem; font-weight: 300; opacity: .5; padding: 0 .2rem; }

.mm-name { font-family: 'JetBrains Mono', monospace; font-weight: 800; font-size: .95rem; }

.mm-matrix { position: relative; display: flex; align-items: stretch; padding: 0 10px; }
.mm-bracket {
  width: 10px;
  border: 2px solid var(--ink);
  align-self: stretch;
}
.mm-bracket-l { border-right: none; border-radius: 6px 0 0 6px; }
.mm-bracket-r { border-left: none; border-radius: 0 6px 6px 0; }

.mm-grid { display: grid; gap: 4px; padding: 6px; }

.mm-cell {
  width: 48px; height: 48px;
  display: flex; align-items: center; justify-content: center;
  font-family: 'JetBrains Mono', monospace;
  font-weight: 700;
  font-size: 1.15rem;
  border-radius: 8px;
  background: #faf5ea;
  border: 1.5px solid transparent;
  transition: .18s;
}
.mm-cell-hot { transform: scale(1.06); }

.mm-input-wrap { position: relative; }
.mm-input {
  width: 48px; height: 48px;
  text-align: center;
  font-family: 'JetBrains Mono', monospace;
  font-weight: 700;
  font-size: 1.1rem;
  border-radius: 8px;
  border: 1.5px solid var(--line);
  background: #fff;
  color: var(--ink);
  box-shadow: inset 0 2px 4px rgba(0,0,0,.05);
  transition: .15s;
  outline: none;
}
.mm-input:focus, .mm-focus { border-color: var(--purple); box-shadow: 0 0 0 3px rgba(124,92,230,.25); }
.mm-input.mm-ok {
  border-color: var(--green);
  background: #e8fbf1;
  color: #1f7a4d;
  animation: pop .35s ease;
}
.mm-input.mm-bad {
  border-color: var(--red);
  background: #ffeceb;
  color: var(--red);
  animation: shake .4s ease;
}
.mm-correction {
  position: absolute;
  bottom: -16px; left: 0; right: 0;
  text-align: center;
  font-family: 'JetBrains Mono', monospace;
  font-size: .68rem;
  color: var(--green);
  font-weight: 700;
}
@keyframes pop { 0% { transform: scale(1); } 40% { transform: scale(1.18); } 100% { transform: scale(1); } }
@keyframes shake { 0%,100% { transform: translateX(0); } 20% { transform: translateX(-5px); } 40% { transform: translateX(5px); } 60% { transform: translateX(-3px); } 80% { transform: translateX(3px); } }

.mm-helper {
  margin-top: 1rem;
  padding-top: .9rem;
  border-top: 1px dashed var(--line);
  font-size: .8rem;
  text-align: center;
  opacity: .85;
  min-height: 1.6em;
}

/* feedback */
.mm-feedback {
  margin-top: 1.2rem;
  padding: .7rem 1.4rem;
  border-radius: 999px;
  font-weight: 500;
  animation: fadeUp .3s ease both;
}
.mm-feedback-ok { background: #e2fbef; color: #1f7a4d; border: 1px solid var(--green); }
.mm-feedback-nudge { background: #fff0d6; color: #a5661a; border: 1px solid #e9b355; }

/* buttons */
.mm-btn {
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 500;
  font-size: 1rem;
  padding: .7rem 1.6rem;
  border-radius: 12px;
  cursor: pointer;
  border: 1.5px solid transparent;
  transition: .2s;
}
.mm-btn-primary {
  background: linear-gradient(135deg, var(--purple), #9a7cf0);
  color: #fff;
  box-shadow: 0 8px 20px -8px var(--purple);
}
.mm-btn-primary:hover { transform: translateY(-2px); box-shadow: 0 12px 24px -8px var(--purple); }
.mm-btn-primary:active { transform: translateY(0); }
.mm-btn-ghost { background: var(--paper); border-color: var(--line); color: var(--ink); }
.mm-btn-ghost:hover { border-color: var(--purple); color: var(--purple); }

.mm-link { color: var(--purple); text-decoration: none; border-bottom: 1px dotted var(--purple); }

/* confetti */
.mm-confetti-layer { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 50; }
.mm-confetti {
  position: absolute;
  top: -12px;
  width: 9px; height: 14px;
  border-radius: 2px;
  animation: fall 1.7s ease-in forwards;
}
@keyframes fall {
  to { transform: translateY(105vh) rotate(540deg); opacity: .2; }
}

@media (max-width: 560px) {
  .mm-cell, .mm-input { width: 40px; height: 40px; font-size: .95rem; }
  .mm-op { font-size: 1.5rem; }
}
</parameter>