/* Type It Real: a picture on the left, challenges and word ideas on the right, the typing line below. */
.game.magic { background: #fff4e0; }
.game.magic .magic-body {
  flex: 1; min-height: 0; display: grid; grid-template-columns: 1fr minmax(280px, 400px); gap: 12px;
  padding: 12px max(16px, env(safe-area-inset-right, 0px)) 12px max(16px, env(safe-area-inset-left, 0px));
}

/* the picture */
.game.magic .magic-scene { position: relative; isolation: isolate; min-height: 0; overflow: hidden; border: 4px solid var(--ink); border-radius: 22px; box-shadow: var(--shadow); background: #8fd46a; }
.game.magic .mg-sky { position: absolute; left: 0; right: 0; top: 0; height: 60%; background: linear-gradient(#7fd3ff, #d7f3ff); transition: background 1s; }
.game.magic .mg-grass { position: absolute; left: 0; right: 0; top: 58%; bottom: 0; background: linear-gradient(#93d86c, #6ec04e); border-top: 5px solid #5e8f3a; border-radius: 40% 40% 0 0 / 18px 18px 0 0; transition: filter 1s; }
.game.magic .mg-sea {
  position: absolute; left: 55%; right: -2%; top: 57%; bottom: 0; background: linear-gradient(#3cc6e8, #1d86bd);
  border-top-left-radius: 80px 36px; border-top: 5px solid #bdf0ff; transform: translateX(110%); transition: transform .9s cubic-bezier(.2, 1.2, .4, 1), filter 1s; overflow: hidden;
}
.game.magic .has-sea .mg-sea { transform: none; }
.game.magic .mg-sea .wave { position: absolute; left: -20%; width: 140%; height: 10px; border-radius: 50%; border-top: 4px solid rgba(255, 255, 255, .6); animation: mgwave 3s ease-in-out infinite alternate; }
.game.magic .mg-sea .w1 { top: 26%; } .game.magic .mg-sea .w2 { top: 58%; animation-delay: -1.5s; }
.game.magic .night .mg-sky { background: linear-gradient(#0d1b4c, #34418a); }
.game.magic .night .mg-sky::after {
  content: ''; position: absolute; inset: 0; animation: twinkle 3s ease-in-out infinite;
  background-image: radial-gradient(2px 2px at 8% 20%, #fff, transparent), radial-gradient(2px 2px at 22% 60%, #fff, transparent), radial-gradient(3px 3px at 40% 30%, #fff, transparent),
    radial-gradient(2px 2px at 58% 12%, #fff, transparent), radial-gradient(2px 2px at 70% 48%, #fff, transparent), radial-gradient(3px 3px at 86% 24%, #fff, transparent), radial-gradient(2px 2px at 94% 62%, #fff, transparent);
}
.game.magic .night .mg-grass, .game.magic .night .mg-sea { filter: brightness(.55); }
.game.magic .night .mg-items { filter: brightness(.85); }
.game.magic .mg-empty { position: absolute; left: 50%; top: 24%; transform: translateX(-50%); z-index: 220; background: #fff; border: 3px solid var(--ink); border-radius: 18px; padding: 8px 18px; font-size: 22px; text-align: center; box-shadow: var(--shadow); width: max-content; max-width: 90%; }
.game.magic .mg-empty small { display: block; font-size: 16px; color: var(--ink-soft); margin-top: 2px; }

/* things in the picture */
.game.magic .mg-items { position: absolute; inset: 0; }
.game.magic .mg-item { position: absolute; transform: translate(-50%, -100%); font-size: calc(var(--s) * clamp(30px, 7vh, 62px)); line-height: 1; cursor: pointer; transition: left .6s ease, font-size .4s ease; }
.game.magic .mg-item.z-sky, .game.magic .mg-item.z-air { transform: translate(-50%, -50%); }
.game.magic .mg-wiggle { display: inline-block; transform-origin: bottom center; }
.game.magic .mg-wiggle.wiggle { animation: mgwig .5s ease-in-out; }
.game.magic .mg-item.bye .mg-wiggle { animation: mgbye .5s ease-in forwards; }
.game.magic .mg-e { display: inline-block; animation: mgpop .5s cubic-bezier(.2, 1.6, .4, 1) both; }
.game.magic .mg-e.m-fly { animation: mgpop .5s cubic-bezier(.2, 1.6, .4, 1) both, mgfly 5s ease-in-out infinite alternate; }
.game.magic .mg-e.m-drift { animation: mgpop .5s cubic-bezier(.2, 1.6, .4, 1) both, mgdrift 12s ease-in-out infinite alternate; }
.game.magic .mg-e.m-float { animation: mgpop .5s cubic-bezier(.2, 1.6, .4, 1) both, mgfloat 2.6s ease-in-out infinite alternate; }
.game.magic .mg-e.m-hop { animation: mgpop .5s cubic-bezier(.2, 1.6, .4, 1) both, mghop 1.5s ease-in-out infinite; }
.game.magic .mg-e.m-swim { animation: mgpop .5s cubic-bezier(.2, 1.6, .4, 1) both, mgswim 7s linear infinite; }
.game.magic .mg-e.m-twinkle { animation: mgpop .5s cubic-bezier(.2, 1.6, .4, 1) both, mgtwinkle 1.6s ease-in-out infinite; }
.game.magic .mg-e.m-spin { animation: mgpop .5s cubic-bezier(.2, 1.6, .4, 1) both, mgspin 2.4s linear infinite; }
.game.magic .magic-scene.windy .mg-wiggle { animation: mgwind .35s ease-in-out infinite alternate; }

/* weather and sparkles */
.game.magic .mg-weather, .game.magic .mg-sparkles { position: absolute; inset: 0; pointer-events: none; }
.game.magic .mg-weather { z-index: 200; }
.game.magic .mg-weather.rain { background: rgba(60, 80, 110, .18); }
.game.magic .drop { position: absolute; top: -12%; width: 3px; height: 22px; border-radius: 3px; background: rgba(230, 245, 255, .9); animation: mgrain 1s linear infinite; }
.game.magic .flake { position: absolute; top: -8%; color: #fff; font-size: 20px; text-shadow: 0 0 4px rgba(0, 60, 120, .4); animation: mgsnow 5s linear infinite; }
.game.magic .mg-sparkles { z-index: 210; }
.game.magic .mg-sparkles span { position: absolute; font-size: 32px; opacity: 0; }
.game.magic .mg-sparkles.on span { animation: mgsparkle 1s ease-in-out 3; }

/* side panel */
.game.magic .magic-side { display: flex; flex-direction: column; gap: 8px; min-height: 0; overflow: auto; }
.game.magic .magic-side h3 { font-size: 18px; margin-bottom: 4px; }
.game.magic .challenge { display: flex; flex-wrap: wrap; align-items: center; gap: 5px; background: #fff; border: 4px solid var(--ink); border-radius: 20px; padding: 6px 10px; box-shadow: var(--shadow); }
.game.magic .magic-side .challenge h3 { margin: 0 2px 0 0; font-size: 16px; }
.game.magic .ch-item { border: 3px solid var(--ink); border-radius: 999px; padding: 0 8px; background: #fff8d6; font-weight: 800; font-size: 16px; white-space: nowrap; }
.game.magic .ch-item.done { background: var(--mint); color: #fff; }
.game.magic .ch-e { margin-right: 4px; }
/* what just happened ("three tiny… what?"), in a bubble at the top of the picture */
.game.magic .mg-msg {
  position: absolute; left: 50%; top: 10px; z-index: 230; width: max-content; max-width: 90%; transform: translate(-50%, -10px);
  background: #fff; border: 3px solid var(--ink); border-radius: 16px; padding: 4px 14px; font-size: 20px; box-shadow: var(--shadow);
  opacity: 0; pointer-events: none; transition: opacity .3s, transform .3s, background .3s;
}
.game.magic .mg-msg.show { opacity: 1; transform: translate(-50%, 0); }
.game.magic .mg-msg.good { background: #eafff0; }
.game.magic .mg-msg.warn { background: #fff0f3; }
.game.magic .ideas-wrap { background: rgba(255, 255, 255, .7); border: 3px dashed var(--ink-soft); border-radius: 16px; padding: 6px 10px; }
.game.magic .ideas-wrap .small-p { font-size: 13px; margin: 6px 0 0; }
.game.magic .ideas-wrap.nudge { animation: shake .4s; }
.game.magic .ideas-wrap h3 { display: flex; align-items: baseline; gap: 6px; font-size: 16px; margin: 0 0 3px; }
.game.magic .ideas-wrap h3 .sub { font-size: 13px; color: var(--ink-soft); }
.game.magic .ideas-wrap h3 .more { margin-left: auto; font-size: 13px; padding: 0 8px; }
.game.magic .ideas, .game.magic .magic-words, .game.magic .mod-row { display: flex; flex-wrap: wrap; align-items: center; gap: 5px; }
.game.magic .idea { border: 2px solid var(--ink); background: #fff; border-radius: 999px; padding: 0 9px; font-weight: 700; font-size: 15px; line-height: 1.4; }
.game.magic .idea.heard { animation: pulse .4s; background: var(--sun); }
/* describing words are lavender (like the words waiting in the typing line); things are white */
.game.magic .mods { display: grid; grid-template-columns: auto 1fr; align-items: center; gap: 3px 8px; margin-bottom: 8px; }
.game.magic .mod-q { font-size: 13px; font-weight: 800; color: var(--ink-soft); }
.game.magic .idea.mod { background: #eadcff; padding: 0 7px; font-size: 14px; }
.game.magic .idea.mod[data-w="tiny"] { font-size: 11px; }
.game.magic .idea.mod[data-w="little"] { font-size: 13px; }
.game.magic .idea.mod[data-w="big"] { font-size: 17px; }
.game.magic .idea.mod[data-w="huge"] { font-size: 20px; line-height: 1.2; }
.game.magic .idea.mod .sw { display: inline-block; width: 11px; height: 11px; margin-right: 4px; border: 2px solid var(--ink); border-radius: 50%; background: var(--c); vertical-align: -1px; }
.game.magic .idea.fx { background: #dff4ff; font-size: 14px; padding: 0 7px; }
.game.magic .mg-example { margin: 4px 0 6px; font-weight: 800; font-size: 15px; line-height: 1.8; }
.game.magic .ex-m, .game.magic .ex-t { border: 2px solid var(--ink); border-radius: 999px; padding: 0 7px; white-space: nowrap; }
.game.magic .ex-m { background: #eadcff; }
.game.magic .ex-t { background: #fff; }

/* typing line */
.game.magic .mg-input {
  display: flex; align-items: center; justify-content: center; gap: 4px; min-height: 70px; font-size: 48px; font-weight: 800; letter-spacing: 3px;
  background: var(--paper); border-top: 4px solid var(--ink); padding: 4px 16px; position: relative; z-index: 3;
}
.game.magic .mg-input.empty::before { content: 'Type a word, then press space ✨'; font-size: 24px; color: var(--ink-soft); letter-spacing: 0; font-weight: 700; }
.game.magic .mg-typed { color: var(--ink); }
.game.magic .mg-ghost { color: #cbbfd8; }
.game.magic .mg-caret { width: 4px; height: 46px; border-radius: 2px; background: var(--coral); animation: mgblink 1s steps(2) infinite; }
.game.magic .pend { font-size: 26px; letter-spacing: 1px; background: #eadcff; border: 3px solid var(--ink); border-radius: 999px; padding: 0 12px; margin-right: 6px; }

@keyframes mgpop { 0% { transform: scale(0) rotate(-20deg); } 70% { transform: scale(1.2) rotate(6deg); } 100% { transform: scale(1) rotate(0); } }
@keyframes mgbye { to { transform: scale(0) rotate(30deg); opacity: 0; } }
@keyframes mgwig { 25% { transform: rotate(-14deg) scale(1.1); } 75% { transform: rotate(14deg) scale(1.1); } }
@keyframes mgfly { from { transform: translateX(-60px); } to { transform: translateX(60px); } }
@keyframes mgdrift { from { transform: translateX(-40px); } to { transform: translateX(40px); } }
@keyframes mgfloat { from { transform: translateY(-8px); } to { transform: translateY(8px); } }
@keyframes mghop { 0%, 60%, 100% { transform: translateY(0); } 75% { transform: translateY(-22px); } }
@keyframes mgswim { 0% { transform: translateX(30px) scaleX(1); } 49% { transform: translateX(-30px) scaleX(1); } 50% { transform: translateX(-30px) scaleX(-1); } 99% { transform: translateX(30px) scaleX(-1); } 100% { transform: translateX(30px) scaleX(1); } }
@keyframes mgtwinkle { 0%, 100% { transform: scale(.9); } 50% { transform: scale(1.12); } }
@keyframes mgspin { to { transform: rotate(360deg); } }
@keyframes mgwind { from { transform: rotate(-10deg) translateX(-6px); } to { transform: rotate(10deg) translateX(6px); } }
@keyframes mgrain { to { top: 110%; } }
@keyframes mgsnow { 0% { top: -8%; transform: translateX(0); } 50% { transform: translateX(24px); } 100% { top: 108%; transform: translateX(-10px); } }
@keyframes mgsparkle { 0%, 100% { opacity: 0; transform: scale(.4); } 50% { opacity: 1; transform: scale(1.2); } }
@keyframes mgwave { from { transform: translateX(-6%); } to { transform: translateX(6%); } }
@keyframes mgblink { to { opacity: 0; } }

@media (max-width: 900px) {
  .game.magic .magic-body { grid-template-columns: 1fr; grid-template-rows: 1fr auto; }
  .game.magic .magic-side { max-height: 210px; }
  .game.magic .mg-input { font-size: 40px; min-height: 64px; }
}
