* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: #1d2433; color: #fff; font-family: 'Silkscreen', monospace; overflow: hidden; overscroll-behavior: none; }
body { display: flex; align-items: center; justify-content: center; }
button { font: inherit; cursor: pointer; touch-action: manipulation; }
#game { position: relative; user-select: none; -webkit-user-select: none; font-size: clamp(9px, 1.15vw, 13px); }
#stage { position: relative; }
#scroller { width: 100%; height: 100%; }
canvas { display: block; width: 100%; height: 100%; image-rendering: pixelated; touch-action: none; cursor: pointer; }

.pill { background: rgba(13,18,32,.85); border: 2px solid #f4f0e0; padding: 3px 7px; color: #fff; white-space: nowrap; }
.pill b { color: #ffd84a; font-weight: normal; }
.pill small { color: #9fd8ff; font-size: .85em; }
.pill.click:hover { background: #2c3a58; }
.bar { display: inline-block; width: 42px; height: 8px; border: 2px solid #fff; vertical-align: middle; position: relative; }
.bar i { position: absolute; left: 0; top: 0; bottom: 0; background: #5fe36a; }
.bar i.low { background: #ff6a4a; }
.mini { background: #f4e7c4; color: #3a2a18; border: 2px solid #3a2a18; padding: 0 6px; font-size: .9em; }
.mini.danger { background: #ffb0a0; }
.top { display: flex; gap: 5px; flex-wrap: wrap; align-items: center; }
#missions { background: rgba(13,18,32,.88); border: 2px solid #f4f0e0; padding: 5px 8px; line-height: 1.55; }
#missions .t { color: #ffd84a; display: flex; justify-content: space-between; cursor: pointer; }
#missions .m { display: flex; justify-content: space-between; gap: 6px; }
#missions .m span:last-child { color: #9fd8ff; white-space: nowrap; }
#missions.collapsed .m { display: none; }
.bottom { display: flex; flex-direction: column; align-items: center; gap: 5px; }
.tools, #seeds { display: flex; gap: 5px; flex-wrap: wrap; justify-content: center; }
#seeds:empty, #seeds[hidden] { display: none; }
.btn { white-space: nowrap; background: #f4e7c4; color: #3a2a18; border: 2px solid #3a2a18; box-shadow: inset -2px -2px 0 #c9b083; padding: 5px 9px; }
.btn:hover { background: #fff3d6; }
.btn.on { background: #ffd84a; }
.btn.go { background: #7fd3ff; }
.btn:disabled { opacity: .5; cursor: default; }
.seed { background: #e8f4d8; color: #2a3a18; border: 2px solid #2a3a18; padding: 3px 7px; white-space: nowrap; }
.seed.on { background: #9ae06a; }
.seed i { font-style: normal; color: #8a6a1a; }
#banner { position: absolute; top: 8px; left: 50%; transform: translateX(-50%); background: #ffd84a; color: #3a2a18; border: 2px solid #3a2a18; padding: 4px 10px; white-space: nowrap; z-index: 2; }
#banner button { margin-left: 6px; }
#toasts { position: absolute; left: 50%; top: 30%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 4px; align-items: center; z-index: 3; pointer-events: none; width: max-content; max-width: 96%; }
.toast { background: rgba(13,18,32,.92); border: 2px solid #ffd84a; padding: 4px 10px; animation: fade 3s forwards; pointer-events: auto; text-align: center; }
.toast.long { animation-duration: 7s; }
.toast button { margin-left: 6px; }
@keyframes fade { 0%, 80% { opacity: 1; } 100% { opacity: 0; } }
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.5); display: flex; align-items: center; justify-content: center; z-index: 10; }
.modal[hidden], #banner[hidden], .pill[hidden] { display: none; }
.panel { background: #f4e7c4; color: #3a2a18; border: 3px solid #3a2a18; box-shadow: 0 0 0 3px #f4f0e0; width: min(560px, 94vw); max-height: 88dvh; display: flex; flex-direction: column; }
.head { background: #3a2a18; color: #ffd84a; padding: 6px 8px; display: flex; justify-content: space-between; align-items: center; }
.list { overflow-y: auto; padding: 6px; display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 6px; }
.item { border: 2px solid #3a2a18; background: #fff8e4; padding: 5px; display: flex; flex-direction: column; gap: 3px; }
.item .n { color: #1d1a24; }
.item .d { font-size: .85em; color: #6a5a3a; }
.item .tag { font-size: .8em; color: #2a6a9a; }
.item button { margin-top: auto; }
.foot { padding: 6px; display: flex; justify-content: flex-end; gap: 6px; }

/* Querformat / Desktop: Anzeigen liegen über dem Spielfeld */
@media (orientation: landscape) {
  #game { width: min(100vw, calc(var(--app-h, 100dvh) * 420 / 270)); aspect-ratio: 420 / 270; }
  #stage { position: absolute; inset: 0; }
  .top { position: absolute; top: 6px; left: 6px; right: 250px; }
  #missions { position: absolute; top: 6px; right: 6px; width: 240px; }
  .bottom { position: absolute; bottom: 6px; left: 0; right: 0; }
}
/* Handy quer: wenig Höhe */
@media (orientation: landscape) and (max-height: 500px) {
  #game { font-size: 10px; }
  .top { right: 180px; gap: 3px; }
  .pill { padding: 1px 5px; }
  #missions { width: 175px; padding: 3px 6px; line-height: 1.4; }
  .btn { padding: 7px 12px; font-size: 12px; }
  .seed { padding: 4px 6px; }
}
/* Hochformat (Handy): Anzeigen über und unter dem Spielfeld */
@media (orientation: portrait) {
  body { align-items: stretch; }
  /* Spielfeld 1,45x vergrößert, seitlich wischbar */
  /* fest an den sichtbaren Bereich geheftet; --app-h misst main.js (Adressleiste mobiler Browser) */
  #game { --zoom: 1.45; position: fixed; top: 0; left: 0; right: 0; width: 100%; height: var(--app-h, 100dvh); display: flex; flex-direction: column; gap: 8px; padding: max(6px, env(safe-area-inset-top)) 0 max(12px, env(safe-area-inset-bottom)); font-size: 13px; }
  .top, #missions, .bottom { margin-left: 8px; margin-right: 8px; }
  .top { order: 1; justify-content: center; }
  .pill { padding: 4px 8px; }
  .bar { width: 48px; height: 10px; }
  /* Spielfeld nimmt seine Zoom-Höhe, schrumpft aber, wenn der Bildschirm zu niedrig ist */
  #stage { order: 2; width: 100%; flex: 0 1 calc(100vw * var(--zoom) * 270 / 420); min-height: 140px; border-top: 2px solid #0d1220; border-bottom: 2px solid #0d1220; }
  #scroller { overflow-x: auto; overflow-y: hidden; scrollbar-width: none; }
  #scroller::-webkit-scrollbar { display: none; }
  #scroller canvas { height: 100%; width: auto; aspect-ratio: 420 / 270; max-width: none; }
  #missions { order: 3; font-size: 13px; }
  .bottom { order: 4; margin-top: auto; gap: 10px; }
  .btn { padding: 15px 12px; font-size: 16px; }
  #seeds { display: grid; grid-template-columns: repeat(5, 1fr); width: 100%; gap: 4px; }
  .seed { padding: 10px 2px; font-size: 11px; display: flex; flex-direction: column; align-items: center; gap: 2px; }
  .tools { display: grid; grid-template-columns: 1fr 1fr; width: 100%; gap: 8px; }
  .tools .btn { width: 100%; }
  .mini { padding: 4px 10px; }
}
