/* Layout: Vollbild-Spielwelt (Canvas), darüber kleine "Holzschild"-Panels in den Ecken */
:root {
  --ink: #2e2216;
  --paper: #fff8e6;
  --paper2: #f3e6c4;
  --accent: #ff8a2a;
  --leaf: #3f8f3a;
  --sky: #8fd0ff;
  --coin: #ffd23f;
  --display: 'Pixelify Sans', 'Courier New', monospace;
  --body: 'Nunito', 'Trebuchet MS', system-ui, sans-serif;
  color-scheme: light;
}
[hidden] {
  display: none !important;
}
html,
body {
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: #6fb851;
  color: var(--ink);
  font-family: var(--body);
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
}
canvas#game {
  position: fixed;
  inset: 0;
  display: block;
  image-rendering: pixelated;
}
.panel {
  background: var(--paper);
  border: 3px solid var(--ink);
  border-radius: 6px;
  box-shadow: 0 4px 0 var(--ink);
}
#top {
  position: fixed;
  top: calc(12px + env(safe-area-inset-top, 0px));
  left: max(16px, env(safe-area-inset-left, 0px));
  right: max(16px, env(safe-area-inset-right, 0px));
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
  pointer-events: none;
}
#stat {
  padding: 8px 12px;
  display: grid;
  gap: 2px;
  pointer-events: auto;
  min-width: 0;
}
#stat .row {
  display: flex;
  gap: 10px;
  align-items: baseline;
  font-family: var(--display);
  font-size: 18px;
  font-variant-numeric: tabular-nums;
}
#stat .place {
  font-size: 13px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  opacity: 0.75;
  font-family: var(--body);
  font-weight: 800;
}
#coins {
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: var(--display);
  font-size: 20px;
}
#coins img {
  width: 22px;
  height: 22px;
  image-rendering: pixelated;
}
#coins small {
  font-family: var(--body);
  font-size: 12px;
  opacity: 0.75;
}
.btns {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
  pointer-events: auto;
}
button {
  font-family: var(--display);
  font-size: 15px;
  color: var(--ink);
  background: var(--paper);
  border: 3px solid var(--ink);
  border-radius: 6px;
  box-shadow: 0 3px 0 var(--ink);
  padding: 6px 10px;
  cursor: pointer;
}
button:active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 var(--ink);
}
button:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}
button.go {
  background: var(--accent);
}
button[disabled] {
  opacity: 0.45;
  cursor: not-allowed;
}
#views {
  display: flex;
}
#views button {
  border-radius: 0;
  margin-left: -3px;
}
#views button:first-child {
  border-radius: 6px 0 0 6px;
  margin-left: 0;
}
#views button:last-child {
  border-radius: 0 6px 6px 0;
}
#views button.on {
  background: var(--accent);
}
#goals {
  position: fixed;
  top: calc(64px + env(safe-area-inset-top, 0px));
  right: max(16px, env(safe-area-inset-right, 0px));
  width: min(300px, calc(100vw - 32px));
  padding: 12px 14px;
}
#keys {
  position: fixed;
  left: max(16px, env(safe-area-inset-left, 0px));
  top: calc(84px + env(safe-area-inset-top, 0px));
  width: 250px;
  padding: 10px 12px;
  max-height: calc(100vh - 200px);
  overflow: auto;
}
#keys h3 {
  margin: 0 0 8px;
  font-family: var(--display);
  font-size: 18px;
}
#keys dl {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 4px 10px;
  margin: 0;
  font-size: 13.5px;
  align-items: center;
}
#keys dt {
  font-family: var(--display);
  background: var(--paper2);
  border: 2px solid var(--ink);
  border-radius: 4px;
  padding: 0 6px;
  text-align: center;
  min-width: 26px;
}
#keys dd {
  margin: 0;
}
#bKeys.on {
  background: var(--accent);
}
#keysx {
  position: absolute;
  top: 6px;
  right: 6px;
  padding: 0 8px;
  font-size: 16px;
  box-shadow: 0 2px 0 var(--ink);
}
body.touch #keys,
body.touch #bKeys {
  display: none;
}
#goals dl.ctl {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 3px 10px;
  margin: 0;
  font-size: 14px;
}
#goals dl.ctl dt {
  font-family: var(--display);
  background: var(--paper2);
  border: 2px solid var(--ink);
  border-radius: 4px;
  padding: 0 6px;
  text-align: center;
}
#goals dl.ctl dd {
  margin: 0;
}
#focushint {
  position: fixed;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  padding: 12px 16px;
  font-weight: 800;
  font-size: 16px;
  pointer-events: none;
  max-width: calc(100vw - 32px);
  text-align: center;
}
#focushint kbd {
  font-family: var(--display);
  background: var(--accent);
  border: 2px solid var(--ink);
  border-radius: 4px;
  padding: 0 6px;
}
#goals h3 {
  margin: 0 0 8px;
  font-family: var(--display);
  font-size: 18px;
}
#goals ol {
  margin: 0;
  padding-left: 20px;
  display: grid;
  gap: 5px;
  font-size: 14px;
}
#goals li.done {
  text-decoration: line-through;
  opacity: 0.5;
}
#toasts {
  position: fixed;
  top: calc(84px + env(safe-area-inset-top, 0px));
  left: 50%;
  transform: translateX(-50%);
  display: grid;
  gap: 6px;
  width: min(420px, calc(100vw - 32px));
  pointer-events: none;
}
.toast {
  padding: 8px 12px;
  font-size: 14px;
  animation: pop 0.25s ease-out;
}
.toast b {
  font-family: var(--display);
  font-weight: 700;
}
@keyframes pop {
  from {
    transform: translateY(-6px);
    opacity: 0;
  }
  to {
    transform: none;
    opacity: 1;
  }
}
#bottom {
  position: fixed;
  left: max(16px, env(safe-area-inset-left, 0px));
  right: max(16px, env(safe-area-inset-right, 0px));
  bottom: calc(12px + env(safe-area-inset-bottom, 0px));
  display: grid;
  justify-items: center;
  gap: 8px;
  pointer-events: none;
}
#sleep {
  padding: 8px 12px;
  font-size: 14px;
  max-width: min(460px, 100%);
  display: flex;
  gap: 10px;
  align-items: center;
  pointer-events: auto;
}
#sheet ul {
  margin: 4px 0 10px;
  padding-left: 20px;
  line-height: 1.5;
}
.paper {
  background: repeating-linear-gradient(#fffdf6 0 23px, #d6e4ee 23px 24px);
  border: 2px solid #c9b48a;
  border-radius: 4px;
  padding: 10px 14px;
  transform: rotate(-0.6deg);
}
#buildbar {
  padding: 8px 10px;
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  justify-content: center;
  pointer-events: auto;
  font-size: 14px;
}
.shopgrid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 8px;
  margin-top: 10px;
}
#bBuild.on {
  background: var(--accent);
}
#bAdmin {
  background: #2e2216;
  color: #ffd23f;
}
.banrow {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 6px 0;
  border-bottom: 1px dashed #c9b48a;
}
.banrow em {
  font-size: 13px;
  opacity: 0.7;
}
button.ban {
  background: #e5484d;
  color: #fff;
}
#banned {
  position: fixed;
  inset: 0;
  background: rgba(20, 14, 8, 0.9);
  display: grid;
  place-items: center;
  z-index: 50;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}
#banned .panel {
  padding: 20px;
  max-width: 420px;
}
#tv {
  position: fixed;
  inset: 0;
  background: rgba(20, 14, 8, 0.7);
  display: grid;
  place-items: center;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  padding-block: 16px;
  z-index: 5;
}
.tvbox {
  width: min(960px, 100%);
  background: #5a3a28;
  border: 4px solid var(--ink);
  border-radius: 22px;
  padding: 18px 18px 12px;
  box-shadow: 0 6px 0 var(--ink);
  animation: tvgrow 0.8s cubic-bezier(0.2, 0.9, 0.3, 1.15);
}
@keyframes tvgrow {
  from {
    transform: scale(0.08);
    opacity: 0.2;
  }
  to {
    transform: none;
    opacity: 1;
  }
}
@media (prefers-reduced-motion: reduce) {
  .tvbox {
    animation: none;
  }
}
.tvscreen {
  position: relative;
  aspect-ratio: 16/9;
  max-height: 72vh;
  width: 100%;
  border-radius: 16px;
  overflow: hidden;
  background: #111;
  border: 4px solid #2b1d14;
}
.tvscreen canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}
.tvch {
  position: absolute;
  top: 10px;
  left: 14px;
  font-family: var(--display);
  color: #fff;
  font-size: 14px;
  letter-spacing: 0.06em;
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.5);
}
.tvtext {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 14px 18px;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.6));
  color: #fff;
}
.tvtext h2 {
  margin: 0;
  font-family: var(--display);
  font-size: clamp(20px, 3.6vw, 36px);
  text-wrap: balance;
  text-shadow: 0 3px 0 rgba(0, 0, 0, 0.45);
}
#tvd {
  font-weight: 800;
  opacity: 0.9;
}
.scan {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: repeating-linear-gradient(rgba(0, 0, 0, 0.08) 0 2px, transparent 2px 4px);
  box-shadow: inset 0 0 60px rgba(0, 0, 0, 0.45);
}
.tvctl {
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: center;
  margin-top: 10px;
  color: #fff8e6;
  font-family: var(--display);
}
#sheet .recipes {
  display: grid;
  gap: 8px;
  margin: 10px 0;
}
.recipe {
  display: grid;
  grid-template-columns: 44px 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 8px;
  border: 2px solid var(--ink);
  border-radius: 6px;
  background: var(--paper2);
}
.recipe img {
  width: 44px;
  height: 44px;
}
.recipe span {
  font-size: 13px;
}
.recipe small {
  opacity: 0.7;
}
.looks {
  display: grid;
  grid-template-columns: 120px 1fr;
  gap: 12px;
  align-items: start;
  margin: 8px 0;
}
.looks img {
  width: 120px;
  border: 2px solid var(--ink);
  border-radius: 4px;
  background: #7cc35a;
}
@media (max-width: 420px) {
  .looks {
    grid-template-columns: 1fr;
  }
}
.stylerow {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  margin: 4px 0;
}
.stylerow span {
  min-width: 110px;
  font-size: 13px;
  font-weight: 800;
}
.stylerow button {
  padding: 3px 8px;
  font-size: 13px;
  box-shadow: 0 2px 0 var(--ink);
}
.stylerow button.on {
  background: var(--accent);
}
.picks {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin: 10px 0;
}
.pick {
  display: grid;
  gap: 4px;
  justify-items: center;
  padding: 6px;
}
.pick img {
  width: 100%;
  background: #7cc35a;
  border-radius: 3px;
}
@media (max-width: 420px) {
  .picks {
    grid-template-columns: 1fr;
  }
}
#prompt {
  padding: 6px 12px;
  font-size: 15px;
  font-weight: 800;
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: 100%;
}
#prompt kbd {
  font-family: var(--display);
  background: var(--accent);
  border: 2px solid var(--ink);
  border-radius: 4px;
  padding: 0 7px;
  font-size: 15px;
}
#inv {
  display: flex;
  gap: 6px;
  padding: 6px;
  flex-wrap: wrap;
  justify-content: center;
  pointer-events: auto;
  max-width: 100%;
}
.slot {
  position: relative;
  width: 44px;
  height: 44px;
  background: var(--paper2);
  border: 2px solid var(--ink);
  border-radius: 4px;
  display: grid;
  place-items: center;
  padding: 0;
  box-shadow: none;
}
.slot img {
  width: 32px;
  height: 32px;
}
.slot span {
  position: absolute;
  right: 2px;
  bottom: 0;
  font-family: var(--display);
  font-size: 13px;
  text-shadow:
    0 0 2px #fff,
    0 0 2px #fff;
}
.slot.sel {
  background: #ffd9a8;
  outline: 3px solid var(--accent);
}
.empty {
  font-size: 13px;
  padding: 6px 8px;
  opacity: 0.7;
}
#stick {
  position: fixed;
  left: max(20px, env(safe-area-inset-left, 0px));
  bottom: calc(110px + env(safe-area-inset-bottom, 0px));
  width: 120px;
  height: 120px;
  border-radius: 50%;
  background: rgba(255, 248, 230, 0.35);
  border: 3px solid rgba(46, 34, 22, 0.5);
  display: none;
  touch-action: none;
}
#knob {
  position: absolute;
  left: 35px;
  top: 35px;
  width: 50px;
  height: 50px;
  border-radius: 50%;
  background: var(--paper);
  border: 3px solid var(--ink);
}
#act {
  position: fixed;
  right: max(20px, env(safe-area-inset-right, 0px));
  bottom: calc(120px + env(safe-area-inset-bottom, 0px));
  width: 76px;
  height: 76px;
  border-radius: 50%;
  font-size: 30px;
  background: var(--accent);
  display: none;
}
#jumpbtn {
  position: fixed;
  right: max(110px, calc(env(safe-area-inset-right, 0px) + 110px));
  bottom: calc(110px + env(safe-area-inset-bottom, 0px));
  width: 64px;
  height: 64px;
  border-radius: 50%;
  font-size: 15px;
  display: none;
}
body.touch #stick,
body.touch #act,
body.touch #jumpbtn {
  display: block;
}
#modal {
  position: fixed;
  inset: 0;
  background: rgba(30, 22, 14, 0.45);
  display: grid;
  place-items: center;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  padding-block: 16px;
}
#sheet {
  width: min(460px, 100%);
  max-height: calc(100% - 20px);
  overflow: auto;
  padding: 16px 18px;
}
#sheet h2 {
  margin: 0 0 4px;
  font-family: var(--display);
  font-size: 26px;
  text-wrap: balance;
}
#sheet p {
  margin: 6px 0;
  line-height: 1.45;
}
.facts {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 4px 14px;
  margin: 10px 0;
  font-size: 15px;
}
.facts dt {
  font-weight: 800;
}
.facts dd {
  margin: 0;
}
.yes {
  color: #2f7a2f;
  font-weight: 800;
}
.no {
  color: #b3372a;
  font-weight: 800;
}
.look {
  display: grid;
  grid-template-columns: 120px 1fr;
  gap: 14px;
  align-items: start;
}
@media (max-width: 420px) {
  .look {
    grid-template-columns: 1fr;
  }
  .look canvas {
    justify-self: center;
  }
}
.look canvas {
  width: 120px;
  height: 160px;
  background: var(--sky);
  border: 3px solid var(--ink);
  border-radius: 6px;
  image-rendering: pixelated;
}
.sw {
  display: grid;
  gap: 8px;
}
.sw label {
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  display: block;
  margin-bottom: 3px;
}
.sw .opts {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.sw .opts button {
  width: 28px;
  height: 28px;
  padding: 0;
  border-radius: 4px;
  box-shadow: none;
  border: 2px solid var(--ink);
}
.sw .opts.txt button {
  width: auto;
  height: auto;
  padding: 4px 8px;
  font-size: 13px;
  background: var(--paper2);
}
.sw .opts.txt button.on {
  background: var(--accent);
}
.sw .opts button.on {
  outline: 3px solid var(--accent);
  outline-offset: 1px;
}
input#pname {
  font-family: var(--display);
  font-size: 18px;
  padding: 6px 8px;
  border: 3px solid var(--ink);
  border-radius: 6px;
  background: #fff;
  width: 100%;
  box-sizing: border-box;
  color: var(--ink);
}
.actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 12px;
}
.keys {
  font-size: 13px;
  opacity: 0.8;
}
#fightbar {
  position: fixed;
  left: 50%;
  top: calc(64px + env(safe-area-inset-top, 0px));
  transform: translateX(-50%);
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 6px 12px;
  align-items: center;
  padding: 8px 14px;
  width: min(520px, calc(100vw - 32px));
  z-index: 6;
}
#fightbar .fside b {
  font-size: 13px;
}
#fightbar .vs {
  font-size: 20px;
}
#fightbar .fhint {
  grid-column: 1/-1;
  text-align: center;
  font-size: 12.5px;
}
#fightbar .hpb {
  height: 12px;
  border: 2px solid var(--ink);
  border-radius: 6px;
  background: #3a2a22;
  overflow: hidden;
  margin-top: 3px;
}
#fightbar .hpb i {
  display: block;
  height: 100%;
  background: linear-gradient(#7be07b, #3f9a3a);
  transition: width 0.15s;
}
#fightbar .hpb.foe i {
  background: linear-gradient(#ff8a8a, #c92a2a);
}
.offer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 7px 0;
  border-bottom: 1px dashed #c9b48a;
  font-size: 14px;
}
.offer small {
  opacity: 0.7;
  white-space: nowrap;
}
.offerform {
  display: grid;
  grid-template-columns: auto 64px 1fr;
  gap: 6px 8px;
  align-items: center;
  font-size: 14px;
  margin-top: 6px;
}
.offerform input,
.offerform select {
  font-family: inherit;
  font-size: 14px;
  padding: 4px 6px;
  border: 2px solid var(--ink);
  border-radius: 5px;
  background: #fff;
  color: var(--ink);
  min-width: 0;
}
.boxline {
  background: var(--paper2);
  border: 2px solid var(--ink);
  border-radius: 6px;
  padding: 8px 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  font-size: 14px;
}
.codebox {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-top: 14px;
  padding-top: 10px;
  border-top: 2px dashed rgba(46, 34, 22, 0.3);
  font-size: 13px;
}
.codebox label {
  font-weight: 800;
}
.codebox input {
  font-family: var(--display);
  font-size: 15px;
  padding: 4px 8px;
  border: 3px solid var(--ink);
  border-radius: 6px;
  width: 110px;
  background: #fff;
  color: var(--ink);
}
.codebox button {
  padding: 3px 10px;
  font-size: 13px;
  box-shadow: 0 2px 0 var(--ink);
}
/* durchsichtige Anzeige oben */
#top .panel,
#top button,
#keys {
  background: rgba(255, 248, 230, 0.12);
  border-color: rgba(46, 34, 22, 0.6);
  box-shadow: none;
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
  text-shadow:
    -1px -1px 0 #fff8e6,
    1px -1px 0 #fff8e6,
    -1px 1px 0 #fff8e6,
    1px 1px 0 #fff8e6,
    0 0 4px #fff8e6;
}
#top button:hover {
  background: rgba(255, 248, 230, 0.3);
}
#top #bAdmin {
  color: var(--ink);
  background: rgba(255, 210, 63, 0.35);
}
#top button.on,
#views button.on,
#bKeys.on {
  background: rgba(255, 138, 42, 0.35);
}
#keys dt {
  background: rgba(243, 230, 196, 0.25);
}

/* Passwort-Fenster vor dem Spiel */
#login {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(46, 34, 22, 0.82);
}
#loginform {
  width: min(380px, 100%);
  padding: 18px 20px;
  display: grid;
  gap: 10px;
}
#loginform h3 {
  margin: 0;
  font-family: var(--display);
  font-size: 24px;
}
#loginform p {
  margin: 0;
  font-size: 14px;
}
#loginform input {
  font-family: var(--display);
  font-size: 18px;
  padding: 8px 10px;
  border: 3px solid var(--ink);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
}
#loginmsg {
  min-height: 1.2em;
  font-size: 13px;
  opacity: 0.85;
}
