:root {
  --tile: 64px;
  --wood: #6b3f14;
  --wood-dark: #3e2307;
  --wood-light: #9a6a35;
  --parch: #fbf1d9;
  --parch-dark: #efdcb2;
  --ink: #3a2410;
  --muted: #8a6a3e;
  --green: #2f9e44;
  --green-dark: #1f7a31;
  --gold: #ffd23f;
  --red: #c0392b;
  --sea: #1f86c4;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: "Trebuchet MS", "Segoe UI", Verdana, sans-serif;
  color: var(--ink);
  background: var(--sea) radial-gradient(circle at 50% 40%, #39b0e6 0%, #1a73ad 75%);
  display: flex; flex-direction: column; overflow: hidden;
}
button, select, input { font: inherit; }
.hidden { display: none !important; }

/* ---------------------------------------------------------------- Kopfleiste */
#topbar {
  display: flex; align-items: center; gap: 16px; padding: 6px 14px;
  background: linear-gradient(#8a5420, var(--wood));
  border-bottom: 4px solid var(--wood-dark);
  box-shadow: 0 3px 10px rgba(0,0,0,.35);
  color: #fff6dc; z-index: 5;
}
#topbar .logo { height: 54px; }
.stats { display: flex; gap: 10px; flex: 1; flex-wrap: wrap; }
.stat {
  display: flex; align-items: center; gap: 6px; padding: 4px 12px 4px 6px;
  background: rgba(0,0,0,.25); border-radius: 20px; font-weight: bold; font-size: 15px;
  border: 1px solid rgba(255,255,255,.15);
}
.stat img { width: 26px; height: 26px; }
.stat.level { min-width: 230px; font-weight: normal; }
.stat.inv { gap: 10px; padding: 4px 12px 4px 8px; }
.stat.inv span { display: inline-flex; align-items: center; gap: 3px; font-variant-numeric: tabular-nums; }
.stat.inv span.empty { opacity: .45; }
.stat.inv img { width: 20px; height: 20px; }
.xpbar { height: 7px; background: rgba(0,0,0,.4); border-radius: 4px; overflow: hidden; margin-top: 3px; }
.xpbar i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, #ffe066, #f0a020); transition: width .4s; }
.player { display: flex; align-items: center; gap: 6px; font-weight: bold; }
.player img { width: 28px; }
.secure { font-size: 11px; font-weight: normal; background: var(--green); padding: 2px 7px; border-radius: 10px; }
.secure.warn { background: #b86d12; }

/* ---------------------------------------------------------------- Layout */
main { flex: 1; display: flex; min-height: 0; }
#world { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.toolbar {
  display: flex; gap: 8px; align-items: center; padding: 8px 12px;
  background: rgba(0,40,70,.35); flex-wrap: wrap;
}
.toolbar .group { display: flex; gap: 4px; align-items: center; }
.toolbar .spacer { flex: 1; }
.toolbar select { padding: 5px; border-radius: 6px; border: 2px solid var(--wood-dark); background: var(--parch); }
#map-wrap { flex: 1; overflow: auto; display: flex; padding: 20px; }
#map {
  margin: auto; display: grid; position: relative;
  grid-template-columns: repeat(var(--cols, 16), var(--tile));
  grid-auto-rows: var(--tile);
  border-radius: 14px; overflow: hidden;
  box-shadow: 0 10px 40px rgba(0,30,60,.5);
}

/* ---------------------------------------------------------------- Kacheln */
.tile { position: relative; width: var(--tile); height: var(--tile); cursor: pointer; user-select: none; }
.tile > img { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; -webkit-user-drag: none; }
.tile.water { cursor: default; }
.tile.water .ground { animation: sea 6s ease-in-out infinite alternate; }
.tile.water:nth-child(3n) .ground { animation-delay: -2s; }
@keyframes sea { from { transform: translateX(-2px); } to { transform: translateX(2px) scale(1.05); } }
.tile .jungle { opacity: .93; }
.tile.buyable .jungle { opacity: .6; }
.tile.buyable::after {
  content: ""; position: absolute; inset: 3px; border: 2px dashed rgba(255,240,160,.9); border-radius: 6px;
}
.tile.buyable:hover .jungle { opacity: .35; }
.tile.owned:hover::before, .tile.buyable:hover::before {
  content: ""; position: absolute; inset: 0; background: rgba(255,255,255,.15); z-index: 3;
}
.tile.selected::after {
  content: ""; position: absolute; inset: 1px; border: 3px solid #fff; border-radius: 6px; z-index: 4;
  box-shadow: 0 0 0 2px var(--gold), inset 0 0 12px rgba(255,210,63,.6);
  animation: pulse 1.2s ease-in-out infinite;
}
@keyframes pulse { 50% { box-shadow: 0 0 0 3px var(--gold), inset 0 0 18px rgba(255,210,63,.9); } }
.tile .obj { z-index: 1; }
.tile .crop { z-index: 2; transition: transform .2s; }
.tile.ripe .crop { animation: bob 1.6s ease-in-out infinite; transform-origin: 50% 90%; }
@keyframes bob { 50% { transform: rotate(-3deg) scale(1.04); } }
.tile .bar {
  position: absolute; left: 8%; right: 8%; bottom: 4%; height: 6px; z-index: 3;
  background: rgba(0,0,0,.45); border-radius: 3px; overflow: hidden;
}
.tile .bar i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, #9be15d, #00c853); }
.tile .badge, .tile .auto {
  position: absolute; z-index: 3; font-size: 10px; font-weight: bold; line-height: 1;
  padding: 2px 4px; border-radius: 6px; background: rgba(0,0,0,.6); color: var(--gold);
}
.tile .badge { top: 3px; left: 3px; }
.tile .auto { top: 3px; right: 3px; padding: 1px; background: rgba(255,255,255,.85); }
.tile .auto img { width: 14px; height: 14px; display: block; }
.tile .ready-mark {
  position: absolute; z-index: 3; top: 2px; right: 2px; width: 16px; height: 16px; border-radius: 50%;
  background: var(--gold); color: var(--wood-dark); font-size: 12px; font-weight: bold; text-align: center; line-height: 16px;
  animation: pop 1s ease-in-out infinite;
}
@keyframes pop { 50% { transform: scale(1.25); } }

.float {
  position: absolute; z-index: 20; pointer-events: none; font-weight: bold; color: #fff;
  text-shadow: 0 0 3px #000, 0 2px 2px #000; white-space: nowrap; font-size: 15px;
  animation: floatUp 1.4s ease-out forwards; transform: translateX(-50%);
}
@keyframes floatUp { from { opacity: 1; margin-top: 0; } to { opacity: 0; margin-top: -48px; } }

/* ---------------------------------------------------------------- Seitenleiste */
#side {
  width: 380px; display: flex; flex-direction: column;
  background: var(--parch); border-left: 4px solid var(--wood-dark);
  box-shadow: -3px 0 10px rgba(0,0,0,.3);
}
.tabs { display: flex; background: var(--wood); }
.tabs button {
  flex: 1; border: 0; background: transparent; color: #f3dfb8; padding: 8px 2px 6px; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 12px; font-weight: bold;
  border-bottom: 3px solid transparent;
}
.tabs button img { width: 24px; height: 24px; }
.tabs button.active { background: var(--parch); color: var(--ink); border-bottom-color: var(--parch); border-radius: 8px 8px 0 0; }
.tabs button:hover:not(.active) { background: rgba(255,255,255,.1); }
.panel { display: none; flex: 1; overflow-y: auto; padding: 14px; }
.panel.active { display: block; }
.panel h2 { margin: 0 0 4px; font-family: Georgia, serif; color: var(--wood); font-size: 22px; }
.panel h3 { margin: 16px 0 6px; font-size: 14px; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); }
.panel p { margin: 6px 0; line-height: 1.4; }
.hint { color: var(--muted); font-size: 13px; }
.head { display: flex; gap: 12px; align-items: center; margin-bottom: 8px; }
.head img { width: 64px; height: 64px; background: var(--parch-dark); border-radius: 10px; padding: 2px; }

.list { display: flex; flex-direction: column; gap: 6px; }
.item {
  display: flex; align-items: center; gap: 10px; padding: 6px 8px; border-radius: 10px;
  background: #fff8e6; border: 2px solid var(--parch-dark);
}
.item.locked { opacity: .55; }
.item > img { width: 44px; height: 44px; flex: none; }
.item .info { flex: 1; min-width: 0; }
.item .name { font-weight: bold; }
.item .meta { font-size: 12px; color: var(--muted); }
.item .meta img { width: 13px; height: 13px; vertical-align: -2px; }
.item .actions { display: flex; gap: 4px; flex-wrap: wrap; justify-content: flex-end; }

.btn {
  border: 2px solid var(--green-dark); background: linear-gradient(#4cc35f, var(--green)); color: #fff;
  font-weight: bold; padding: 6px 12px; border-radius: 8px; cursor: pointer; white-space: nowrap;
  box-shadow: 0 2px 0 var(--green-dark); text-shadow: 0 1px 1px rgba(0,0,0,.3);
}
.btn:hover:not(:disabled) { filter: brightness(1.08); }
.btn:active:not(:disabled) { transform: translateY(2px); box-shadow: none; }
.btn:disabled { filter: grayscale(1); opacity: .55; cursor: not-allowed; }
.btn.small { padding: 3px 9px; font-size: 13px; }
.btn.gold { background: linear-gradient(#ffe066, #e8b923); border-color: #a0740b; color: var(--ink); box-shadow: 0 2px 0 #a0740b; text-shadow: none; }
.btn.red { background: linear-gradient(#e2584a, var(--red)); border-color: #7b1f16; box-shadow: 0 2px 0 #7b1f16; }
.btn.wood { background: linear-gradient(var(--wood-light), var(--wood)); border-color: var(--wood-dark); box-shadow: 0 2px 0 var(--wood-dark); }
.btn img { width: 15px; height: 15px; vertical-align: -3px; }
.row { display: flex; gap: 8px; flex-wrap: wrap; margin: 10px 0; align-items: center; }

.progress { height: 14px; background: var(--parch-dark); border-radius: 7px; overflow: hidden; border: 1px solid #d6bf8e; }
.progress i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, #9be15d, #00c853); }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 3px 12px; font-size: 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: bold; }

.spark { width: 70px; height: 26px; flex: none; }
.trend-up { color: var(--green-dark); }
.trend-down { color: var(--red); }

table.ranks { width: 100%; border-collapse: collapse; font-size: 14px; }
.ranks th { text-align: left; color: var(--muted); font-size: 12px; padding: 4px; }
.ranks td { padding: 6px 4px; border-top: 1px solid var(--parch-dark); }
.ranks tr.me td { background: #fff1b8; font-weight: bold; }
.ranks img { width: 16px; vertical-align: -3px; }

/* ---------------------------------------------------------------- Toasts & Dialog */
#toasts { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); display: flex; flex-direction: column; gap: 6px; z-index: 50; align-items: center; }
.toast {
  background: rgba(30,20,8,.92); color: #fff6dc; padding: 9px 18px; border-radius: 20px; font-weight: bold;
  box-shadow: 0 4px 14px rgba(0,0,0,.4); animation: toastIn .25s ease-out; border: 2px solid var(--wood-light);
}
.toast.err { background: rgba(140,25,15,.95); border-color: #e2584a; }
.toast.lvl { background: linear-gradient(#ffe066, #e8b923); color: var(--ink); border-color: #a0740b; font-size: 18px; }
@keyframes toastIn { from { opacity: 0; transform: translateY(12px); } }

.overlay { position: fixed; inset: 0; background: rgba(0,25,45,.75); display: flex; z-index: 100; padding: 16px; }
.dialog {
  margin: auto; background: var(--parch); border: 5px solid var(--wood); border-radius: 16px; padding: 22px;
  width: min(560px, 100%); max-height: 100%; overflow: auto; box-shadow: 0 12px 50px rgba(0,0,0,.6); text-align: center;
}
.dialog .logo { width: 100%; max-width: 330px; background: var(--wood); border-radius: 10px; padding: 6px; }
.dialog ol { text-align: left; line-height: 1.5; }
.dialog code { background: var(--parch-dark); padding: 1px 5px; border-radius: 4px; word-break: break-all; }
.dialog input { padding: 8px 10px; border-radius: 8px; border: 2px solid var(--wood); width: 220px; }
.dialog a { color: var(--wood); font-weight: bold; }

@media (max-width: 900px) {
  main { flex-direction: column; }
  #side { width: auto; height: 45vh; min-width: 0; border-left: 0; border-top: 4px solid var(--wood-dark); }
  .tabs button { min-width: 0; font-size: 11px; }
  .tabs button img { width: 20px; height: 20px; }
  #topbar { flex-wrap: wrap; gap: 6px; }
  #topbar .logo { height: 40px; }
  .stat.level { min-width: 0; }
}

/* Marktzeilen: Verkaufsknöpfe in eigener Zeile */
.item.mk { flex-wrap: wrap; }
.item.mk .actions { width: 100%; }
.tile .scrub { opacity: .9; }
.tile.buyable .scrub { opacity: .55; }

/* Hilfe-Knopf */
.help-btn {
  display: inline-grid; place-items: center; width: 30px; height: 30px; margin-left: 6px; border-radius: 50%;
  background: var(--gold); color: var(--wood-dark); font-weight: bold; font-size: 17px; text-decoration: none;
  border: 2px solid #a0740b; box-shadow: 0 2px 0 #a0740b;
}
.help-btn:hover { filter: brightness(1.1); }
a.btn { text-decoration: none; display: inline-block; }

/* Admin-Knopf (nur für Admins sichtbar) */
.admin-btn {
  margin-left: 6px; padding: 4px 10px; border-radius: 15px; cursor: pointer; font-weight: bold; font-size: 13px;
  background: #1c2633; color: #ffcc33; border: 2px solid #ffcc33; box-shadow: 0 2px 0 #a0740b;
}
.admin-btn:hover { background: #263345; }

/* Ankündigung der Admins */
.announcement {
  display: flex; align-items: center; gap: 10px; padding: 9px 14px;
  background: linear-gradient(90deg, #ffe066, #f0a020); color: #3a2600; font-weight: bold;
  border-bottom: 3px solid #a0740b; box-shadow: 0 3px 10px rgba(0,0,0,.25);
}
.announcement .ann-icon { font-size: 20px; animation: pop 1.6s ease-in-out infinite; }
.announcement #ann-text { flex: 1; }
.ann-close { border: 0; background: rgba(0,0,0,.12); color: #3a2600; border-radius: 50%; width: 26px; height: 26px; cursor: pointer; font-weight: bold; }
.ann-close:hover { background: rgba(0,0,0,.22); }

/* Naturereignisse */
.disaster {
  display: flex; align-items: center; gap: 12px; padding: 9px 14px; color: #fff; font-size: 14px;
  background: linear-gradient(90deg, #5d4037, #3e2723); border-bottom: 3px solid #1b0f0a; box-shadow: 0 3px 10px rgba(0,0,0,.3);
}
.disaster .dis-icon { font-size: 26px; animation: pop 1.6s ease-in-out infinite; }
.disaster b { font-size: 15px; }
.disaster .dis-left { font-weight: bold; font-variant-numeric: tabular-nums; background: rgba(0,0,0,.25); border-radius: 8px; padding: 1px 7px; }
.disaster .dis-left:empty { display: none; }
.dis-sturm { background: linear-gradient(90deg, #455a64, #263238); }
.dis-duerre { background: linear-gradient(90deg, #e65100, #bf360c); }
.dis-flut { background: linear-gradient(90deg, #0277bd, #01579b); }
.dis-blitz { background: linear-gradient(90deg, #4a148c, #311b92); }
.dis-schaedlinge { background: linear-gradient(90deg, #558b2f, #33691e); }
.dis-regen { background: linear-gradient(90deg, #00897b, #00695c); }
.drought-note { background: #ffe0b2; border: 2px solid #ffb74d; border-radius: 8px; padding: 6px 10px; color: #8a3b00; font-weight: bold; font-size: 13px; }

/* Forschungszentrum */
.item.buff { align-items: flex-start; }
.item.buff.on { border-color: #9ccc65; background: #f1f8e9; }
.item.buff .against { font-weight: normal; font-size: 12px; color: var(--muted); }
.buff-state { font-size: 12px; font-weight: bold; color: var(--green-dark); margin: 4px 0; }
.buff-state.off { color: var(--muted); font-weight: normal; }
.tiers { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.btn.tier { display: inline-flex; flex-direction: column; align-items: center; line-height: 1.15; padding: 3px 7px; }
.btn.tier small { font-size: 10px; font-weight: normal; opacity: .9; }
.tier.locked { font-size: 12px; color: var(--muted); border: 1px dashed var(--parch-dark); border-radius: 8px; padding: 6px 8px; }

/* Markt-Events */
.item .event { font-size: 12px; font-weight: bold; border-radius: 6px; padding: 1px 6px; margin: 2px 0; display: inline-block; }
.item .event.up { background: #ffe1cc; color: #b23c00; }
.item .event.down { background: #d6ecff; color: #1d4f7a; }

/* ---------------------------------------------------------------- Chat */
.tabs button { position: relative; }
.tab-badge {
  position: absolute; top: 3px; right: calc(50% - 26px); min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
  background: var(--wood-light); color: #fff; font-size: 11px; line-height: 18px; text-align: center; box-shadow: 0 1px 2px rgba(0,0,0,.4);
}
.tab-badge.dm { background: var(--red); }
.panel.chat { padding: 0; flex-direction: column; overflow: hidden; }
.panel.chat.active { display: flex; }
.chat-convs { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; padding: 10px 12px 8px; border-bottom: 2px solid var(--parch-dark); }
.chip {
  border: 2px solid var(--parch-dark); background: #fff8e6; color: var(--ink); border-radius: 14px; padding: 2px 10px;
  font-size: 13px; font-weight: bold; cursor: pointer; display: inline-flex; gap: 6px; align-items: center; max-width: 100%;
}
.chip:hover { border-color: var(--wood-light); }
.chip.active { background: var(--wood); border-color: var(--wood-dark); color: #fff6dc; }
.chip .count { background: var(--wood-light); color: #fff; border-radius: 8px; padding: 0 6px; font-size: 11px; }
.chip.dm .count { background: var(--red); }
.chat-convs select { flex: 1; min-width: 150px; padding: 3px 4px; border-radius: 8px; border: 2px solid var(--parch-dark); background: #fff8e6; font-size: 13px; }
.chat-head { padding: 6px 12px; font-size: 14px; }
.chat-muted { margin-top: 4px; padding: 5px 8px; border-radius: 8px; background: #fbd9d3; color: #7b1f16; font-size: 13px; font-weight: bold; }
.chat-log { flex: 1; overflow-y: auto; padding: 4px 12px 10px; display: flex; flex-direction: column; gap: 6px; }
.chat-empty { margin: auto; text-align: center; }
.msg { max-width: 86%; align-self: flex-start; background: #fff8e6; border: 2px solid var(--parch-dark); border-radius: 4px 12px 12px 12px; padding: 4px 10px 6px; }
.msg.me { align-self: flex-end; background: #e2f5d6; border-color: #b9dea0; border-radius: 12px 4px 12px 12px; }
.msg.adm { border-color: #e8b923; }
.msg .meta { display: flex; gap: 6px; align-items: baseline; font-size: 12px; }
.msg .who { font-weight: bold; color: var(--wood); background: none; border: 0; padding: 0; font-size: 12px; }
button.who { cursor: pointer; }
button.who:hover { text-decoration: underline; }
.msg .adm-badge { background: #1c2633; color: #ffcc33; border-radius: 6px; padding: 0 5px; font-size: 10px; font-weight: bold; letter-spacing: .3px; }
.msg time { color: var(--muted); margin-left: auto; padding-left: 8px; }
.msg .text { white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.35; }
.chat-form { display: flex; gap: 6px; padding: 8px 12px 10px; border-top: 2px solid var(--parch-dark); background: var(--parch); }
.chat-form input { flex: 1; min-width: 0; padding: 7px 10px; border-radius: 8px; border: 2px solid var(--wood-light); background: #fffdf5; }
.chat-form input:focus { outline: none; border-color: var(--wood); }
.toast.chat { background: rgba(62,35,7,.95); border-color: var(--gold); max-width: min(520px, 90vw); }

/* ---------------------------------------------------------------- Registrierung (register.html) */
body.reg-page { overflow-y: auto; display: block; }
.reg { display: block; flex: none; max-width: 560px; margin: 0 auto; padding: 24px 16px 40px; }  /* nicht das Flex-Layout von main im Spiel */
.reg-logo { display: block; width: 100%; max-width: 340px; margin: 0 auto 16px; background: var(--wood); border-radius: 12px; padding: 8px; border: 3px solid var(--wood-dark); }
.reg-card { background: var(--parch); border: 5px solid var(--wood); border-radius: 16px; box-shadow: 0 12px 40px rgba(0,0,0,.45); overflow: hidden; }
.reg-tabs { display: flex; background: var(--wood); }
.reg-tabs button { flex: 1; border: 0; background: transparent; color: #f3dfb8; padding: 10px 6px; font-weight: bold; cursor: pointer; }
.reg-tabs button.active { background: var(--parch); color: var(--ink); border-radius: 8px 8px 0 0; }
.reg-tabs button:hover:not(.active) { background: rgba(255,255,255,.1); }
.reg-form, #reg-done, #reg-off { padding: 18px 22px 22px; }
.reg-form p { margin: 0 0 14px; line-height: 1.45; }
.reg-form label { display: block; font-weight: bold; margin: 0 0 12px; color: var(--wood); }
.reg-form input { display: block; width: 100%; margin-top: 4px; padding: 9px 11px; border-radius: 8px; border: 2px solid var(--wood-light); background: #fffdf5; color: var(--ink); }
.reg-form input:focus { outline: none; border-color: var(--wood); }
.reg-form input:user-invalid { border-color: var(--red); }
.reg-form small { display: block; font-weight: normal; color: var(--muted); margin-top: 3px; }
.reg-form .btn { width: 100%; padding: 10px; font-size: 16px; margin-top: 4px; }
#reg-done h2 { margin: 0 0 6px; font-family: Georgia, serif; color: var(--wood); }
.reg-dl .btn { flex: 1; }
.reg-steps { line-height: 1.5; padding-left: 22px; }
.reg-steps li { margin: 6px 0; }
.reg code { background: var(--parch-dark); padding: 1px 5px; border-radius: 4px; word-break: break-all; }
.reg a { color: var(--wood); font-weight: bold; }
.reg-foot { text-align: center; margin-top: 16px; }
.reg-foot a { color: #fff6dc; }

/* ---------------------------------------------------------------- Spionage & Sicherheitsdienst */
.staff { display: flex; flex-wrap: wrap; gap: 3px; margin: 6px 0; }
.staff img { width: 26px; height: 26px; }
.staff img.off { filter: grayscale(1); opacity: .25; }
.raidlog .item { padding: 5px 8px; border-left-width: 5px; }
.raidlog .item.good { border-left-color: var(--green); }
.raidlog .item.bad { border-left-color: var(--red); }
.raidlog .name { font-size: 13px; }
.ranks td:last-child { text-align: right; }

/* Besuch einer fremden Plantage */
.dialog.visit { width: min(1000px, 100%); text-align: left; position: relative; }
.dialog.visit h2 { margin: 0; font-family: Georgia, serif; color: var(--wood); display: flex; align-items: center; gap: 8px; padding-right: 40px; }
.dialog.visit h2 .crown { width: 30px; height: 30px; }
.visit-close {
  position: absolute; top: 10px; right: 10px; width: 34px; height: 34px; border-radius: 50%; cursor: pointer;
  border: 2px solid var(--wood); background: var(--parch-dark); color: var(--wood-dark); font-weight: bold; font-size: 16px;
}
.visit-close:hover { background: var(--gold); }
.visit-body { display: flex; gap: 18px; align-items: flex-start; margin-top: 12px; flex-wrap: wrap; }
.island {
  --tile: 34px; flex: none; display: grid; grid-template-columns: repeat(var(--cols, 16), var(--tile)); grid-auto-rows: var(--tile);
  border-radius: 12px; overflow: hidden; box-shadow: 0 6px 24px rgba(0,30,60,.4); max-width: 100%;
}
.island .tile { cursor: default; }
.island .badge { font-size: 8px; padding: 1px 3px; }
.visit-side { flex: 1; min-width: 240px; }
.visit-side h3 { margin: 0 0 8px; font-size: 14px; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); }
.inv-row { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0; }
.inv-row span { display: inline-flex; align-items: center; gap: 3px; font-weight: bold; background: #fff8e6; border: 2px solid var(--parch-dark); border-radius: 12px; padding: 1px 8px 1px 4px; }
.inv-row img { width: 20px; height: 20px; }
.chance { display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; align-items: center; margin: 12px 0; }
.chance b { font-size: 22px; color: var(--wood); }
.chance .progress { grid-column: 1 / -1; }
.chance .progress i { background: linear-gradient(90deg, #e2584a, #ffd23f, #4cc35f); }
.raid-btn { width: 100%; font-size: 17px; padding: 10px; }
.hint.blocked { background: var(--parch-dark); border-radius: 8px; padding: 8px 10px; color: var(--wood-dark); font-weight: bold; }
@media (max-width: 900px) {
  .island { --tile: 20px; }
}

/* ---------------------------------------------------------------- Marktplatz (Handel unter Spielern) */
.trade-teaser { background: #fff8e6; border: 2px solid var(--parch-dark); border-radius: 10px; padding: 8px 12px; margin: 8px 0 12px; }
.trade-teaser p { margin: 0; }
.trade-teaser .row { margin: 8px 0 2px; }
.dialog.trade { width: min(1080px, 100%); text-align: left; position: relative; }
.dialog.trade h2 { margin: 0; font-family: Georgia, serif; color: var(--wood); display: flex; align-items: center; gap: 10px; padding-right: 40px; }
.dialog.trade .title-img { width: 46px; height: 46px; }
.trade-body { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); gap: 18px; margin-top: 12px; }
.trade-filter { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-bottom: 8px; }
.trade-filter select { margin-left: auto; padding: 3px 6px; border-radius: 8px; border: 2px solid var(--parch-dark); background: #fff8e6; }
#trade-offers { max-height: 56vh; overflow-y: auto; padding-right: 4px; }
#trade-offers > .hint { margin: 0 0 2px; }
.item.offer.mine { background: #eef7e4; border-color: #b9dea0; }
.item.offer > img { width: 36px; height: 36px; }
.tag { display: inline-block; font-size: 11px; font-weight: bold; border-radius: 6px; padding: 0 6px; vertical-align: 1px; }
.tag.sell { background: #ffe1cc; color: #b23c00; }
.tag.buy { background: #d6ecff; color: #1d4f7a; }
.cmp { font-weight: bold; }
.cmp.bad { color: var(--red); }
.cmp.good { color: var(--green-dark); }
.trade-empty { text-align: center; padding: 24px 0; }
.trade-side h3 { margin: 0 0 8px; font-size: 14px; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); }
.trade-side h3 + .list, #trade-log { margin-bottom: 4px; }
#trade-form { background: #fff8e6; border: 2px solid var(--parch-dark); border-radius: 12px; padding: 12px; margin-bottom: 16px; }
#trade-form label { display: block; font-weight: bold; color: var(--wood); margin-bottom: 8px; font-size: 14px; }
#trade-form select, #trade-form input[type=number] { display: block; width: 100%; margin-top: 3px; padding: 7px 9px; border-radius: 8px; border: 2px solid var(--wood-light); background: #fffdf5; }
#trade-form .two { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
#trade-form .btn { width: 100%; }
#trade-form .hint { margin: 2px 0 10px; line-height: 1.45; }
.segs { display: flex; gap: 6px; margin-bottom: 10px; }
.segs .seg { flex: 1; margin: 0; text-align: center; border: 2px solid var(--parch-dark); border-radius: 10px; padding: 6px; cursor: pointer; background: #fffdf5; }
.segs .seg input { position: absolute; opacity: 0; pointer-events: none; }
#trade-form .segs .seg:has(input:checked) { background: var(--wood); border-color: var(--wood-dark); color: #fff6dc; }
#trade-log .item > img { width: 28px; height: 28px; }
#trade-log .item { padding: 4px 8px; border-left-width: 5px; }
#trade-log .item.good { border-left-color: var(--green); }
#trade-log .item.bad { border-left-color: var(--wood-light); }
@media (max-width: 900px) {
  .trade-body { grid-template-columns: minmax(0, 1fr); }
  #trade-offers { max-height: none; }
}

/* ---------------------------------------------------------------- Erfolge */
.item.ach { align-items: center; }
.item.ach .ach-icon { font-size: 28px; width: 44px; text-align: center; flex: none; filter: grayscale(1); opacity: .45; }
.item.ach.done { background: #fff6d0; border-color: #e8b923; }
.item.ach.done .ach-icon { filter: none; opacity: 1; }
.item.ach .progress { height: 8px; margin: 4px 0 2px; }
.item.ach .ach-reward { flex: none; white-space: nowrap; font-size: 12px; font-weight: bold; color: #a0740b; display: inline-flex; gap: 3px; align-items: center; }
.item.ach .ach-reward img { width: 14px; height: 14px; }
.badges { display: flex; flex-wrap: wrap; gap: 4px; font-size: 22px; margin-bottom: 8px; }
.badges span { cursor: help; }

/* ---------------------------------------------------------------- Manufaktur */
.item.recipe, .item.job { flex-wrap: wrap; }
.item.recipe .actions select { padding: 2px 4px; }
.item.job .progress { height: 8px; margin: 4px 0 2px; }
.ings { display: flex; flex-wrap: wrap; gap: 6px; margin: 2px 0; font-size: 12px; font-weight: bold; }
.ing { display: inline-flex; align-items: center; gap: 2px; }
.ing img { width: 16px; height: 16px; }
.ing.miss { color: var(--red, #c0392b); }

/* ---------------------------------------------------------------- Tagesbonus */
.login-box { background: #fff8e6; border: 2px solid var(--parch-dark); border-radius: 10px; padding: 8px 10px; margin: 10px 0; }
.login-head { margin-bottom: 6px; }
.login-days { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.login-day { display: flex; flex-direction: column; align-items: center; padding: 4px 2px; border-radius: 8px;
  border: 2px solid var(--parch-dark); background: #fffdf5; font-size: 11px; color: var(--muted); }
.login-day b { font-size: 12px; color: var(--ink); }
.login-day.done { background: #e8f5d9; border-color: #9ccc65; }
.login-day.done b { color: #2f7d32; }
.login-day.today { background: #fff1b8; border-color: #e8b923; box-shadow: 0 0 0 2px #ffd23f inset; }
.login-day.today b { color: #2f7d32; }

/* ---------------------------------------------------------------- Tagesaufgaben */
.quest-box { background: #fff8e6; border: 2px solid var(--parch-dark); border-radius: 10px; padding: 8px 10px; margin: 10px 0; }
.quest { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 8px; background: #fffdf5; border: 2px solid var(--parch-dark); }
.quest.done { background: #e8f5d9; border-color: #9ccc65; }
.quest .info { flex: 1; min-width: 0; }
.quest .progress { height: 8px; margin: 4px 0 2px; }
.quest-mark { width: 18px; text-align: center; font-weight: bold; color: var(--muted); }
.quest.done .quest-mark { color: #2f7d32; }
.quest .ach-reward { flex: none; white-space: nowrap; font-size: 12px; font-weight: bold; color: #a0740b; display: inline-flex; gap: 3px; align-items: center; }
.quest .ach-reward img { width: 14px; height: 14px; }
.quest-bonus { margin-top: 6px; font-size: 13px; font-weight: bold; color: #a0740b; }
.quest-bonus.done { color: #2f7d32; }
