/* =========================================================================
   PARADOX ENGINE — Game styles (v2)
   Layout: full-canvas stage + right items panel + bottom toolbar
   Aesthetic: dark, atmospheric, with our serif identity
   ========================================================================= */

:root {
  /* World theme — JS rewrites these as world evolves */
  --bg-a: #0A0E14;
  --bg-b: #0F1520;
  --bg-c: #16203A;
  --accent: #7CF9C0;
  --accent-glow: rgba(124, 249, 192, 0.4);
  --ink: #F0F2F8;
  --ink-2: #B4B8C8;
  --ink-3: #7A8090;
  --ink-4: #4A5060;
  --line: rgba(255, 255, 255, 0.08);
  --line-2: rgba(255, 255, 255, 0.16);
  --panel-bg: rgba(8, 10, 16, 0.72);
  --piece-bg: rgba(20, 22, 32, 0.88);

  /* Rarity colors */
  --r-common:    #C4C9D6;
  --r-rare:      #7CB8FF;
  --r-epic:      #C97BFF;
  --r-legendary: #FFB44F;
  --r-cosmic:    #7CFFE5;

  --font-display: "Instrument Serif", "Times New Roman", serif;
  --font-body:    "Inter Tight", system-ui, -apple-system, sans-serif;
  --font-mono:    "JetBrains Mono", ui-monospace, monospace;

  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);

  --panel-w: 400px;
}

/* Light theme override */
body[data-theme="light"] {
  --bg-a: #FAFAF5;
  --bg-b: #F2F0E8;
  --bg-c: #E8E5D6;
  --ink: #1A1814;
  --ink-2: #3D3830;
  --ink-3: #6B6357;
  --ink-4: #A39A88;
  --line: rgba(0, 0, 0, 0.08);
  --line-2: rgba(0, 0, 0, 0.16);
  --panel-bg: rgba(250, 250, 245, 0.82);
  --piece-bg: rgba(255, 255, 255, 0.9);
  --r-common: #4A4438;
}

/* =========================================================================
   Reset
   ========================================================================= */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
}

body {
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.5;
  letter-spacing: -0.005em;
  color: var(--ink);
  background: var(--bg-a);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
  transition: background 1500ms ease, color 400ms ease;
}

button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
a { color: inherit; text-decoration: none; }
::selection { background: var(--accent); color: var(--bg-a); }

/* =========================================================================
   Backdrop
   ========================================================================= */
.world {
  position: fixed; inset: 0;
  z-index: -2;
  background:
    radial-gradient(ellipse at 20% 10%, var(--bg-c) 0%, transparent 55%),
    radial-gradient(ellipse at 85% 90%, var(--bg-b) 0%, transparent 60%),
    linear-gradient(135deg, var(--bg-a) 0%, var(--bg-b) 100%);
  transition: background 2400ms ease;
}

#worldCanvas {
  position: fixed; inset: 0;
  z-index: -1;
  pointer-events: none;
}

/* Subtle grain */
body::before {
  content: "";
  position: fixed; inset: 0;
  pointer-events: none;
  z-index: 999;
  opacity: 0.035;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='200' height='200'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2'/></filter><rect width='100%25' height='100%25' filter='url(%23n)'/></svg>");
}

/* =========================================================================
   Top brand corners
   ========================================================================= */
.topbrand {
  position: fixed;
  top: 22px;
  z-index: 20;
  display: inline-flex;
  align-items: center;
  gap: 12px;
  line-height: 1;
  color: var(--ink);
  pointer-events: auto;
}
.topbrand--left { left: 28px; }
.topbrand--right {
  right: calc(var(--panel-w) + 28px);
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  pointer-events: none;
}

.topbrand__back {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px; height: 34px;
  border-radius: 50%;
  background: var(--panel-bg);
  backdrop-filter: blur(10px);
  border: 1px solid var(--line-2);
  color: var(--ink-2);
  transition: transform 200ms, background 200ms, color 200ms;
}
.topbrand--left:hover .topbrand__back {
  transform: translateX(-3px);
  color: var(--ink);
  background: var(--piece-bg);
}

.topbrand__logo {
  width: 32px;
  height: 32px;
  filter: drop-shadow(0 0 10px var(--accent-glow));
  transition: transform 400ms var(--ease-spring);
}
.topbrand--left:hover .topbrand__logo { transform: rotate(-12deg) scale(1.08); }

.topbrand__name {
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 400;
  letter-spacing: -0.02em;
  line-height: 1;
  color: var(--ink);
}
.topbrand__name em {
  font-style: italic;
  color: var(--accent);
}

.topbrand__small {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-3);
  font-weight: 500;
}
.topbrand__big {
  font-family: var(--font-display);
  font-size: 32px;
  font-weight: 400;
  letter-spacing: -0.025em;
  color: var(--ink);
  line-height: 1;
}
.topbrand__big em {
  font-style: italic;
  color: var(--accent);
}

/* =========================================================================
   Stage — fills the screen except for the panel & toolbar
   ========================================================================= */
.stage {
  position: fixed;
  inset: 0;
  right: var(--panel-w);
  bottom: 64px;
  overflow: hidden;
  z-index: 1;
}

.stage__hint {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
  pointer-events: none;
  font-family: var(--font-display);
  font-size: 32px;
  font-style: italic;
  color: var(--ink-3);
  opacity: 0.5;
  letter-spacing: -0.02em;
  max-width: 80%;
  transition: opacity 600ms;
}
.stage__hint.hide { opacity: 0; }
.stage__hint small {
  display: block;
  font-family: var(--font-mono);
  font-size: 11px;
  font-style: normal;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  margin-top: 14px;
  color: var(--ink-3);
  opacity: 0.7;
}

/* =========================================================================
   Pieces on the stage — vertical layout, real shapes, no oval pill
   ========================================================================= */
.piece {
  position: absolute;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 6px 10px 8px;
  background: transparent;
  border: none;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
  cursor: grab;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  white-space: nowrap;
  transition: transform 280ms var(--ease-spring), filter 200ms;
  z-index: 2;
  animation: piecePop 360ms var(--ease-spring);
  filter: drop-shadow(0 6px 12px rgba(0,0,0,0.35));
}
@keyframes piecePop {
  from { transform: scale(0.4); opacity: 0; }
  to   { transform: scale(1);   opacity: 1; }
}
.piece:hover {
  transform: translateY(-3px);
  filter: drop-shadow(0 10px 18px rgba(0,0,0,0.5)) drop-shadow(0 0 14px var(--cat-glow, transparent));
}
.piece.grabbing {
  cursor: grabbing;
  z-index: 10;
  filter: drop-shadow(0 18px 24px rgba(0,0,0,0.55)) drop-shadow(0 0 22px var(--cat-glow, var(--accent-glow)));
  transition: none;
}
.piece.merging {
  animation: mergePulse 600ms var(--ease-spring) !important;
}
@keyframes mergePulse {
  0%   { transform: scale(1) translate(var(--tx, 0), var(--ty, 0)); }
  50%  { transform: scale(1.2)  translate(var(--tx, 0), var(--ty, 0)); filter: brightness(1.5) drop-shadow(0 0 22px var(--cat-glow, var(--accent-glow))); }
  100% { transform: scale(0)   translate(var(--tx, 0), var(--ty, 0)); opacity: 0; }
}

.piece__icon {
  width: 68px;
  height: 68px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.piece__icon svg { width: 100%; height: 100%; display: block; }

.piece__label {
  letter-spacing: -0.005em;
  font-family: var(--font-body);
  background: var(--piece-bg);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  padding: 4px 12px;
  border-radius: 999px;
  border: 1px solid var(--line-2);
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
  margin-top: 4px;
  box-shadow: 0 2px 6px -3px rgba(0,0,0,0.4);
  text-align: center;
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.piece.is-target .piece__icon {
  animation: targetPulse 600ms ease-in-out infinite alternate;
}
@keyframes targetPulse {
  to { filter: drop-shadow(0 0 12px var(--accent)); transform: scale(1.06); }
}
.piece.is-target .piece__label {
  border-color: var(--accent);
  color: var(--accent);
}

/* =========================================================================
   ITEMS PANEL — right side
   ========================================================================= */
.panel {
  position: fixed;
  top: 0; right: 0; bottom: 0;
  width: var(--panel-w);
  background: var(--panel-bg);
  backdrop-filter: blur(22px);
  -webkit-backdrop-filter: blur(22px);
  border-left: 1px solid var(--line);
  z-index: 15;
  display: flex;
  flex-direction: column;
  padding: 72px 18px 18px;
}

.panel__head {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 0 6px 14px;
}
.panel__title {
  font-family: var(--font-display);
  font-size: 26px;
  font-weight: 400;
  letter-spacing: -0.02em;
  color: var(--ink);
}
.panel__count {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--ink-3);
  font-weight: 500;
}

.panel__items {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 8px 6px 12px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(92px, 1fr));
  gap: 8px;
  align-content: start;
  scrollbar-width: thin;
  scrollbar-color: var(--line-2) transparent;
}
.panel__items::-webkit-scrollbar { width: 6px; }
.panel__items::-webkit-scrollbar-thumb { background: var(--line-2); border-radius: 999px; }

.item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  padding: 8px 4px;
  background: transparent;
  border: none;
  color: var(--ink);
  cursor: grab;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  transition: transform 200ms var(--ease-spring), filter 200ms;
  width: 92px;
  filter: drop-shadow(0 3px 6px rgba(0,0,0,0.25));
}
.item:hover {
  transform: translateY(-3px);
  filter: drop-shadow(0 6px 12px rgba(0,0,0,0.4)) drop-shadow(0 0 10px var(--cat-glow, transparent));
}
.item:active { cursor: grabbing; }
.item.new { animation: itemDrop 520ms var(--ease-spring); }
@keyframes itemDrop {
  0%   { transform: scale(0); opacity: 0; }
  60%  { transform: scale(1.15); opacity: 1; }
  100% { transform: scale(1); opacity: 1; }
}
.item__icon {
  width: 56px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.item__icon svg { width: 100%; height: 100%; display: block; }
.item__name {
  font-family: var(--font-body);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: -0.005em;
  color: var(--ink);
  text-align: center;
  line-height: 1.1;
  max-width: 86px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Bottom of panel — tabs + sort/clear */
.panel__bottom {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 6px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  margin-bottom: 10px;
}
.panel-tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 11px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 500;
  color: var(--ink-3);
  transition: color 200ms, background 200ms;
}
.panel-tab.is-active {
  color: var(--ink);
  background: var(--piece-bg);
}
.panel-tab:hover { color: var(--ink); }
.panel-icon {
  margin-left: auto;
  width: 30px; height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  color: var(--ink-3);
  transition: color 200ms, background 200ms;
}
.panel-icon + .panel-icon { margin-left: 0; }
.panel-icon:hover { color: var(--ink); background: var(--piece-bg); }
.panel-icon.flipped svg { transform: scaleY(-1); }

.panel__search {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 6px;
}
.panel__search svg {
  position: absolute;
  left: 16px;
  color: var(--ink-3);
}
.panel__search input {
  width: 100%;
  padding: 10px 14px 10px 32px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.03);
  color: var(--ink);
  font: inherit;
  font-size: 13px;
  outline: none;
  transition: border-color 200ms, background 200ms;
}
body[data-theme="light"] .panel__search input { background: rgba(0,0,0,0.03); }
.panel__search input::placeholder { color: var(--ink-3); }
.panel__search input:focus { border-color: var(--accent); }

/* =========================================================================
   BOTTOM TOOLBAR
   ========================================================================= */
.toolbar {
  position: fixed;
  left: 0; right: var(--panel-w);
  bottom: 0;
  height: 64px;
  z-index: 12;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 22px;
}
.tool-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 14px;
  border-radius: 12px;
  background: var(--panel-bg);
  backdrop-filter: blur(14px);
  border: 1px solid var(--line);
  color: var(--ink);
  font-size: 13px;
  font-weight: 500;
  transition: background 200ms, transform 200ms, border-color 200ms;
}
.tool-btn:hover { transform: translateY(-2px); border-color: var(--line-2); }
.tool-icon {
  width: 36px; height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  background: var(--panel-bg);
  backdrop-filter: blur(14px);
  border: 1px solid var(--line);
  color: var(--ink-2);
  transition: color 200ms, background 200ms, transform 200ms;
}
.tool-icon:hover { color: var(--ink); transform: translateY(-2px); border-color: var(--line-2); }
.tool-spacer { flex: 1; }

/* =========================================================================
   Drag ghost — mirrors the new vertical piece layout
   ========================================================================= */
.drag-ghost {
  position: fixed;
  pointer-events: none;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 6px 10px 8px;
  background: transparent;
  border: none;
  color: var(--ink);
  transform: translate(-50%, -50%) scale(1.1);
  filter: drop-shadow(0 12px 22px rgba(0,0,0,0.55)) drop-shadow(0 0 18px var(--accent-glow));
  transition: filter 200ms;
}
.drag-ghost__icon {
  width: 68px;
  height: 68px;
}
.drag-ghost__icon svg { width: 100%; height: 100%; }
.drag-ghost__name {
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 600;
  background: var(--piece-bg);
  backdrop-filter: blur(8px);
  padding: 4px 12px;
  border-radius: 999px;
  border: 1px solid var(--accent);
  color: var(--ink);
}
.drag-ghost.snap {
  filter: drop-shadow(0 12px 22px rgba(0,0,0,0.55)) drop-shadow(0 0 22px rgba(255,180,79,0.6));
}
.drag-ghost.snap .drag-ghost__name { border-color: #FFB44F; color: #FFB44F; }

/* =========================================================================
   DISCOVERY REVEAL
   ========================================================================= */
.reveal {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  pointer-events: none;
  opacity: 0;
  transition: opacity 240ms;
}
.reveal.show { opacity: 1; pointer-events: auto; }
.reveal__veil {
  position: absolute; inset: 0;
  background: radial-gradient(ellipse at center, rgba(0,0,0,0.55) 0%, rgba(0,0,0,0.85) 100%);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
body[data-theme="light"] .reveal__veil {
  background: radial-gradient(ellipse at center, rgba(255,255,250,0.6) 0%, rgba(255,255,250,0.9) 100%);
}
.reveal__card {
  position: relative;
  text-align: center;
  padding: 40px 50px 36px;
  border-radius: 24px;
  background: var(--piece-bg);
  border: 1px solid var(--line-2);
  box-shadow: 0 40px 80px -20px rgba(0,0,0,0.7);
  max-width: 90vw;
  transform: scale(0.85) translateY(20px);
  opacity: 0;
  transition: transform 600ms var(--ease-spring), opacity 400ms;
}
.reveal.show .reveal__card {
  transform: scale(1) translateY(0);
  opacity: 1;
}
.reveal__rarity {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin-bottom: 8px;
}
.reveal__emoji {
  width: 120px;
  height: 120px;
  margin: 0 auto 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  filter: drop-shadow(0 0 30px var(--rar-glow, rgba(124,249,192,0.4)));
}
.reveal__emoji svg { width: 100%; height: 100%; display: block; }
.reveal__name {
  font-family: var(--font-display);
  font-size: 56px;
  font-weight: 400;
  letter-spacing: -0.028em;
  line-height: 1.0;
  color: var(--ink);
}
.reveal__name em {
  font-style: italic;
  color: var(--rar-color, var(--accent));
}
.reveal__desc {
  margin-top: 16px;
  font-family: var(--font-display);
  font-style: italic;
  font-size: 18px;
  color: var(--ink-2);
  max-width: 28ch;
  margin-left: auto;
  margin-right: auto;
  line-height: 1.4;
}
.reveal__category {
  margin-top: 24px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: 999px;
  border: 1px solid var(--line-2);
  background: var(--panel-bg);
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-2);
}
.reveal__hint {
  margin-top: 20px;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-3);
}

.reveal__burst { position: absolute; inset: 0; pointer-events: none; overflow: visible; }
.spark {
  position: absolute;
  top: 50%; left: 50%;
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--rar-color, var(--accent));
  box-shadow: 0 0 10px var(--rar-glow, var(--accent-glow));
  animation: spark 1100ms var(--ease) forwards;
}
@keyframes spark {
  0%   { transform: translate(0,0) scale(1); opacity: 1; }
  100% { transform: translate(var(--dx), var(--dy)) scale(0.2); opacity: 0; }
}
@keyframes smallSpark {
  0%   { transform: translate(-50%,-50%) scale(1); opacity: 1; }
  100% { transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy))) scale(0.2); opacity: 0; }
}

/* =========================================================================
   Toast
   ========================================================================= */
.toast {
  position: fixed;
  top: 80px;
  left: calc(50% - var(--panel-w) / 2);
  transform: translateX(-50%) translateY(-20px);
  padding: 9px 18px;
  border-radius: 999px;
  background: var(--piece-bg);
  border: 1px solid var(--line-2);
  font-size: 13px;
  color: var(--ink-2);
  z-index: 50;
  opacity: 0;
  transition: opacity 240ms, transform 240ms var(--ease-spring);
  pointer-events: none;
  backdrop-filter: blur(14px);
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* Screen shake */
.shaking { animation: shake 600ms cubic-bezier(.36,.07,.19,.97) both; }
@keyframes shake {
  10%, 90% { transform: translate3d(-1px, 0, 0); }
  20%, 80% { transform: translate3d(2px, 0, 0); }
  30%, 50%, 70% { transform: translate3d(-4px, 0, 0); }
  40%, 60% { transform: translate3d(4px, 0, 0); }
}

/* =========================================================================
   Settings sheet
   ========================================================================= */
.sheet {
  position: fixed;
  top: 0; left: 0; bottom: 0;
  width: 380px;
  max-width: 90vw;
  background: var(--panel-bg);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border-right: 1px solid var(--line-2);
  padding: 24px;
  transform: translateX(-100%);
  transition: transform 360ms var(--ease);
  z-index: 200;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.sheet.open { transform: translateX(0); }
.sheet__head { display: flex; align-items: center; gap: 12px; }
.sheet__title {
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 400;
  letter-spacing: -0.02em;
}
.sheet__close {
  margin-left: auto;
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--piece-bg);
  border: 1px solid var(--line-2);
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--ink-2);
}
.sheet__sub {
  font-family: var(--font-mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--ink-3);
  margin-top: 8px;
}
.sheet__row {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 0;
  border-top: 1px solid var(--line);
}
.sheet__row .label { flex: 1; font-size: 14px; color: var(--ink-2); }
.sheet__btn {
  padding: 8px 14px;
  border-radius: 10px;
  background: var(--piece-bg);
  border: 1px solid var(--line-2);
  font-size: 13px;
  font-weight: 500;
  color: var(--ink);
  transition: background 200ms;
}
.sheet__btn:hover { background: rgba(255,255,255,0.08); }
.sheet__btn.danger { color: #FF8080; border-color: rgba(255,128,128,0.3); }

.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 4px;
}
.stat-tile {
  padding: 14px;
  border-radius: 12px;
  background: var(--piece-bg);
  border: 1px solid var(--line);
}
.stat-tile .v {
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 400;
  letter-spacing: -0.02em;
  line-height: 1;
}
.stat-tile .k {
  display: block;
  margin-top: 6px;
  font-family: var(--font-mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--ink-3);
}

/* =========================================================================
   Mobile
   ========================================================================= */
@media (max-width: 880px) {
  :root { --panel-w: 100%; }

  .topbrand--left {
    left: 16px; top: 14px;
    gap: 8px;
  }
  .topbrand__back { width: 30px; height: 30px; }
  .topbrand__logo { width: 26px; height: 26px; }
  .topbrand__name { font-size: 22px; }

  .topbrand--right {
    right: 70px;
    top: 16px;
    align-items: flex-end;
    gap: 2px;
  }
  .topbrand__small { display: none; }
  .topbrand__big { font-size: 20px; }

  .stage {
    right: 0;
    bottom: 50vh;
  }
  .panel {
    top: auto;
    left: 0;
    width: 100%;
    height: 50vh;
    padding: 18px 14px 14px;
    border-left: 0;
    border-top: 1px solid var(--line);
  }
  .panel__head { padding-bottom: 10px; }

  .toolbar {
    bottom: auto;
    top: 60px;
    right: 16px;
    left: auto;
    width: auto;
    height: auto;
    padding: 0;
    gap: 6px;
    flex-direction: column;
  }
  .tool-btn { display: none; }
  .tool-spacer { display: none; }
  .tool-icon { width: 34px; height: 34px; }

  /* Slightly smaller pieces/items on mobile */
  .piece__icon { width: 56px; height: 56px; }
  .piece__label { font-size: 12px; padding: 3px 10px; }
  .item { width: 80px; }
  .item__icon { width: 48px; height: 48px; }
  .item__name { font-size: 11px; }
  .drag-ghost__icon { width: 56px; height: 56px; }

  .reveal__emoji { width: 90px; height: 90px; margin-bottom: 14px; }
  .reveal__name { font-size: 40px; }
  .reveal__desc { font-size: 16px; }
  .reveal__card { padding: 32px 24px 28px; }

  .toast { left: 50%; top: 70px; }
}

@media (max-width: 480px) {
  .topbrand--right { right: 64px; }
  .topbrand__big { font-size: 17px; }
  .topbrand__name { font-size: 18px; }
  .panel { height: 55vh; }
  .stage { bottom: 55vh; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
