/* Aineiden yhdistely — laboratorio UI */

.ain-layout {
  display: grid;
  grid-template-columns: 1fr minmax(220px, 280px);
  grid-template-rows: auto minmax(220px, 1fr);
  gap: 1rem;
  align-items: start;
}

.ain-workbench {
  grid-column: 1;
  grid-row: 1;
}

.ain-inventory {
  grid-column: 1;
  grid-row: 2;
  min-height: 0;
}

.ain-side {
  grid-column: 2;
  grid-row: 1 / -1;
}

@media (max-width: 820px) {
  .ain-layout {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto auto;
  }

  .ain-workbench {
    grid-column: 1;
    grid-row: 1;
  }

  .ain-side {
    grid-column: 1;
    grid-row: 2;
    position: static;
    max-height: none;
    overflow: visible;
  }

  .ain-inventory {
    grid-column: 1;
    grid-row: 3;
  }
}

.ain-hud {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1.25rem;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.75rem;
  font-size: 0.92rem;
}

.ain-progress {
  flex: 1;
  min-width: 160px;
}

.ain-progress-bar {
  height: 8px;
  background: var(--border);
  border-radius: 999px;
  overflow: hidden;
  margin-top: 0.25rem;
}

.ain-progress-bar > div {
  height: 100%;
  background: linear-gradient(90deg, #38bdf8, #22c55e);
  border-radius: 999px;
  transition: width 0.35s ease;
}

.ain-workbench {
  background: linear-gradient(160deg, #0f172a 0%, #1e293b 100%);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1rem;
  text-align: center;
}

.ain-workbench h3 {
  margin: 0 0 0.75rem;
  font-size: 0.95rem;
  color: #94a3b8;
  font-weight: 600;
}

.ain-slots {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.ain-slot {
  position: relative;
  width: 92px;
  min-height: 96px;
  height: auto;
  border: 2px dashed #475569;
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  background: rgba(15, 23, 42, 0.6);
  transition: border-color 0.15s, transform 0.15s;
  padding: 0.35rem;
}

.ain-slot:hover {
  border-color: #38bdf8;
}

.ain-slot.filled {
  border-style: solid;
  border-color: #38bdf8;
}

.ain-slot .ain-slot-z {
  position: absolute;
  top: 0.22rem;
  left: 0.3rem;
  font-size: 0.48rem;
  font-weight: 600;
  line-height: 1;
  color: #64748b;
  font-family: ui-monospace, monospace;
}

.ain-slot .ain-slot-emoji {
  font-size: 1.35rem;
  line-height: 1;
}

.ain-slot .ain-slot-formula {
  display: block;
  width: 100%;
  font-size: 0.95rem;
  font-weight: 700;
  line-height: 1.1;
  color: #7dd3fc;
  font-family: ui-monospace, monospace;
  margin-top: 0.15rem;
}

.ain-slot .ain-slot-name {
  display: block;
  width: 100%;
  font-size: 0.55rem;
  color: #94a3b8;
  margin-top: 0.1rem;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ain-plus {
  font-size: 1.5rem;
  color: #64748b;
  font-weight: 300;
}

.ain-actions {
  margin-top: 1rem;
  display: flex;
  gap: 0.5rem;
  justify-content: center;
  flex-wrap: wrap;
}

.ain-result {
  min-height: 2.5rem;
  margin-top: 0.85rem;
  padding: 0.55rem 0.75rem;
  border-radius: 8px;
  font-size: 0.88rem;
}

.ain-result.ok {
  background: rgba(34, 197, 94, 0.15);
  border: 1px solid rgba(34, 197, 94, 0.35);
  color: #86efac;
}

.ain-result.ok.new {
  animation: ain-pop 0.45s ease, ain-glow 1.2s ease 0.2s;
  background: rgba(56, 189, 248, 0.18);
  border-color: rgba(56, 189, 248, 0.45);
  color: #7dd3fc;
}

.ain-result.fail {
  background: rgba(248, 113, 113, 0.1);
  border: 1px solid rgba(248, 113, 113, 0.3);
  color: #fca5a5;
}

.ain-result-hint {
  display: block;
  margin-top: 0.35rem;
  font-size: 0.78rem;
  opacity: 0.85;
}

@keyframes ain-pop {
  0% { transform: scale(0.96); }
  50% { transform: scale(1.02); }
  100% { transform: scale(1); }
}

.ain-workbench {
  position: relative;
}

.ain-fx-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 5;
}

.ain-flash {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 200;
  opacity: 0;
  transition: opacity 0.35s ease;
}

.ain-flash.active {
  opacity: 1;
}

.ain-result.chain-pulse {
  animation: ain-chain-pulse 0.65s ease;
}

@keyframes ain-chain-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(61, 214, 140, 0); }
  50% { box-shadow: 0 0 24px 6px rgba(61, 214, 140, 0.35); }
}

.ain-share-btn {
  margin-top: 0.65rem;
}

@keyframes ain-glow {
  0%, 100% { filter: brightness(1); }
  50% { filter: brightness(1.15); }
}

.ain-inventory {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 0.85rem;
}

.ain-inventory h3 {
  margin: 0 0 0.5rem;
  font-size: 0.95rem;
  color: var(--accent);
}

.ain-search {
  width: 100%;
  padding: 0.45rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font-size: 0.88rem;
  margin-bottom: 0.55rem;
}

.ain-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(72px, 1fr));
  gap: 0.45rem;
  max-height: min(48vh, 380px);
  overflow-y: auto;
  padding-right: 0.15rem;
}

.ain-grid--s {
  grid-template-columns: repeat(auto-fill, minmax(56px, 1fr));
  gap: 0.35rem;
  max-height: min(42vh, 320px);
}

.ain-grid--s .ain-card {
  padding: 0.4rem 0.2rem 0.3rem;
}

.ain-grid--s .ain-card-emoji {
  font-size: 1.05rem;
}

.ain-grid--s .ain-card-formula {
  font-size: 0.72rem;
}

.ain-grid--s .ain-card-name {
  font-size: 0.5rem;
}

.ain-grid--m {
  grid-template-columns: repeat(auto-fill, minmax(72px, 1fr));
  max-height: min(48vh, 380px);
}

.ain-grid--l {
  grid-template-columns: repeat(auto-fill, minmax(92px, 1fr));
  gap: 0.55rem;
  max-height: min(54vh, 440px);
}

.ain-grid--l .ain-card {
  padding: 0.65rem 0.3rem 0.45rem;
}

.ain-grid--l .ain-card-emoji {
  font-size: 1.55rem;
}

.ain-grid--l .ain-card-formula {
  font-size: 0.92rem;
}

.ain-grid--l .ain-card-name {
  font-size: 0.62rem;
}

.ain-grid-zoom {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.45rem;
  margin-bottom: 0.65rem;
  padding-bottom: 0.65rem;
  border-bottom: 1px solid var(--border);
}

.ain-grid-zoom-label {
  font-size: 0.78rem;
  color: var(--muted);
  font-weight: 600;
}

.ain-grid-zoom-btns {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.ain-grid-zoom-btns .btn-secondary {
  min-width: 2rem;
  padding: 0.35rem 0.55rem;
  font-size: 1rem;
  line-height: 1;
}

.ain-grid-zoom-value {
  min-width: 4.5rem;
  text-align: center;
  font-size: 0.78rem;
  color: var(--text);
  font-weight: 600;
}

.ain-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.1rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.55rem 0.25rem 0.4rem;
  text-align: center;
  cursor: pointer;
  background: var(--bg);
  transition: transform 0.12s, box-shadow 0.12s, border-color 0.12s;
  user-select: none;
}

.ain-card-z {
  position: absolute;
  top: 0.2rem;
  left: 0.28rem;
  font-size: 0.5rem;
  font-weight: 600;
  line-height: 1;
  color: var(--muted);
  font-family: ui-monospace, monospace;
}

.ain-card:hover {
  transform: translateY(-2px);
  border-color: var(--accent);
}

.ain-card.selected {
  border-color: #38bdf8;
  box-shadow: 0 0 0 2px rgba(56, 189, 248, 0.35);
}

.ain-card.in-slot {
  opacity: 0.55;
}

.ain-card-emoji {
  font-size: 1.35rem;
  line-height: 1.1;
}

.ain-card-formula {
  display: block;
  width: 100%;
  font-size: 0.82rem;
  font-weight: 600;
  line-height: 1.15;
  color: var(--accent);
  font-family: ui-monospace, monospace;
}

.ain-card-name {
  display: block;
  width: 100%;
  font-size: 0.58rem;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ain-side {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  position: sticky;
  top: 0.75rem;
  max-height: calc(100vh - 1.5rem);
  overflow-y: auto;
}

.ain-detail {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 0.85rem;
  min-height: 120px;
}

.ain-detail h3 {
  margin: 0 0 0.35rem;
  font-size: 1rem;
}

.ain-detail-formula {
  font-family: ui-monospace, monospace;
  color: var(--accent);
  font-size: 0.95rem;
  margin: 0 0 0.35rem;
}

.ain-detail-z {
  font-size: 0.78rem;
  color: var(--muted);
  margin: -0.15rem 0 0.35rem;
  font-family: ui-monospace, monospace;
}

.ain-detail-kind {
  font-size: 0.75rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.35rem;
}

.ain-detail-desc {
  font-size: 0.84rem;
  color: var(--muted);
  margin: 0;
  line-height: 1.45;
}

.ain-recent {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 0.85rem;
}

.ain-recent h3 {
  margin: 0 0 0.5rem;
  font-size: 0.9rem;
  color: var(--accent);
}

.ain-recent-list {
  list-style: none;
  margin: 0;
  padding: 0;
  font-size: 0.82rem;
}

.ain-recent-list li {
  padding: 0.25rem 0;
  border-bottom: 1px solid var(--border);
  color: var(--muted);
}

.ain-recent-list li:last-child {
  border-bottom: none;
}

.ain-expansion-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 0.85rem;
}

.ain-expansion-panel h3 {
  margin: 0 0 0.5rem;
  font-size: 0.9rem;
}

.ain-exp-item {
  font-size: 0.82rem;
  padding: 0.35rem 0;
  border-bottom: 1px solid var(--border);
}

.ain-exp-item:last-child {
  border-bottom: none;
}

.ain-exp-item.unlocked {
  color: #86efac;
}

.ain-exp-item.locked {
  color: var(--muted);
}

.ain-toast {
  position: fixed;
  bottom: 1.25rem;
  left: 50%;
  transform: translateX(-50%);
  background: #0f172a;
  border: 1px solid #38bdf8;
  color: #e2e8f0;
  padding: 0.65rem 1rem;
  border-radius: 10px;
  font-size: 0.88rem;
  z-index: 100;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  max-width: min(92vw, 420px);
  text-align: center;
}

.ain-toast.hidden {
  display: none;
}

.ain-toast.expansion {
  border-color: #22c55e;
}

.ain-intro {
  text-align: left;
  max-width: 40rem;
  margin: 0 auto 1rem;
}

.ain-intro ul {
  margin: 0.5rem 0 0;
  padding-left: 1.2rem;
  color: var(--muted);
  font-size: 0.88rem;
}

.ain-chain {
  margin-top: 0.75rem;
  padding: 0.65rem 0.85rem;
  background: rgba(56, 189, 248, 0.08);
  border-radius: 8px;
  font-size: 0.82rem;
  color: var(--muted);
}

.ain-chain strong {
  color: var(--text);
}

.ain-toolbar {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 0.75rem;
}

.ain-pick-mode .ain-card {
  cursor: copy;
}

.ain-new-game {
  margin-top: 0.5rem;
}
