:root {
  --bg: #eef7fb;
  --panel: #ffffff;
  --ink: #203040;
  --muted: #65758b;
  --brand: #1478a6;
  --brand-dark: #0f5e82;
  --line: #cdd9e5;
  --good: #147d42;
  --bad: #ad2a2a;
  --warning: #9b6400;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  background: radial-gradient(circle at top, #ffffff, var(--bg));
  color: var(--ink);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: .85rem 1.2rem;
  background: linear-gradient(#1e9ccc, #1377a6);
  color: #fff;
  border-bottom: 4px solid #0a5578;
  box-shadow: 0 3px 12px rgba(0,0,0,.18);
}
.topbar a { color: #fff; font-weight: 700; }
.topbar nav { display: flex; align-items: center; gap: .9rem; flex-wrap: wrap; }
.brand { font-size: 1.2rem; letter-spacing: .02em; }
.credits { background: rgba(255,255,255,.18); padding: .25rem .55rem; border-radius: 999px; }
.container { width: min(1180px, calc(100% - 2rem)); margin: 1.2rem auto 3rem; }
.footer { color: var(--muted); text-align: center; padding: 2rem; }
.notice, .flash {
  padding: .85rem 1rem;
  border-radius: 12px;
  border: 1px solid var(--line);
  margin-bottom: 1rem;
  background: #fff7d8;
}
.flash.success { background: #e5f7ec; border-color: #a9d9bb; color: var(--good); }
.flash.error { background: #ffe8e8; border-color: #f0b8b8; color: var(--bad); }
.flash.info { background: #e9f3ff; border-color: #b7d3f0; }
.hero {
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 2rem;
  background: linear-gradient(135deg, #fff, #dff2fb);
  box-shadow: 0 10px 30px rgba(42, 82, 116, .12);
  margin-bottom: 2rem;
}
h1, h2, h3 { margin-top: 0; }
.button, button.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  background: linear-gradient(#2db9e8, var(--brand));
  color: #fff;
  font-weight: 800;
  padding: .72rem 1rem;
  border-radius: 12px;
  box-shadow: inset 0 1px rgba(255,255,255,.4), 0 3px 0 var(--brand-dark);
  cursor: pointer;
}
.button:hover { text-decoration: none; transform: translateY(1px); }
.button.ghost { background: #fff; color: var(--brand); border: 1px solid var(--brand); box-shadow: none; }
.button.small { padding: .48rem .72rem; border-radius: 9px; font-size: .9rem; }
.button.tiny { padding: .32rem .5rem; border-radius: 7px; font-size: .8rem; }
.button-mini { border: 1px solid rgba(255,255,255,.7); padding: .35rem .6rem; border-radius: 999px; }
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1rem;
}
.room-card, .item-card, .panel, .auth-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 1rem;
  box-shadow: 0 8px 24px rgba(44, 74, 99, .08);
}
.room-preview {
  height: 110px;
  border-radius: 12px;
  background:
    linear-gradient(135deg, transparent 25%, rgba(255,255,255,.18) 25%, rgba(255,255,255,.18) 50%, transparent 50%, transparent 75%, rgba(255,255,255,.18) 75%),
    linear-gradient(var(--wall), var(--floor));
  background-size: 34px 34px, 100% 100%;
  border: 1px solid rgba(0,0,0,.08);
  margin-bottom: .8rem;
}
.meta { color: var(--muted); font-size: .9rem; }
.auth-card, .panel.narrow { width: min(460px, 100%); margin: 0 auto; }
label { display: grid; gap: .35rem; font-weight: 700; color: #34465a; }
input, select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: .7rem .8rem;
  font: inherit;
}
textarea { min-height: 110px; }
form { display: grid; gap: .8rem; }
.stack-form { gap: 1rem; }
.inline { display: flex; align-items: center; gap: .5rem; }
.inline input[type="checkbox"] { width: auto; }
.inline-form { display: inline-flex; align-items: center; gap: .45rem; flex-wrap: wrap; }
.inline-form label { display: inline-flex; align-items: center; gap: .25rem; }
.inline-form input[type="number"] { width: 70px; padding: .35rem; }
.right { margin-left: auto; }
.world-layout { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 1rem; }
.world-main { overflow: hidden; }
.world-toolbar { display: flex; justify-content: space-between; gap: 1rem; align-items: start; }
#roomCanvas { width: 100%; max-width: 100%; background: #b9e4f8; border: 2px solid #77a9c5; border-radius: 14px; image-rendering: pixelated; }
.hint { color: var(--muted); font-size: .9rem; margin-top: .5rem; }
.chat-panel { display: grid; grid-template-rows: auto auto 1fr auto; max-height: 720px; }
.user-list { display: flex; flex-wrap: wrap; gap: .35rem; margin-bottom: .7rem; }
.user-chip { background: #e8f4fa; border: 1px solid #b9d8ea; padding: .2rem .45rem; border-radius: 999px; font-size: .85rem; }
.chat-log { min-height: 390px; overflow: auto; border: 1px solid var(--line); border-radius: 12px; background: #f9fcfe; padding: .75rem; }
.chat-row { padding: .35rem 0; border-bottom: 1px dashed #d9e5ef; }
.chat-row:last-child { border-bottom: 0; }
.chat-form { display: grid; grid-template-columns: 1fr auto; margin-top: .8rem; }
.item-icon {
  width: 58px;
  height: 58px;
  display: grid;
  place-items: center;
  color: #fff;
  font-weight: 900;
  font-size: 1.5rem;
  background: var(--item-color);
  border-radius: 14px;
  border: 3px solid rgba(0,0,0,.16);
  box-shadow: inset 0 8px rgba(255,255,255,.15);
}
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.row-card { display: flex; align-items: center; gap: .65rem; padding: .7rem; border: 1px solid var(--line); border-radius: 12px; margin-bottom: .5rem; background: #fbfdff; flex-wrap: wrap; }
.item-dot { width: 18px; height: 18px; border-radius: 5px; border: 1px solid rgba(0,0,0,.2); }
.adminbar { background: linear-gradient(#495061, #2d3340); border-bottom-color: #171b22; }
.admin-container table { width: 100%; border-collapse: collapse; background: #fff; border: 1px solid var(--line); border-radius: 14px; overflow: hidden; }
th, td { padding: .65rem; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { background: #edf4f8; }
.admin-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 1rem; margin-bottom: 1rem; }
.stat-card { background: #fff; border: 1px solid var(--line); border-radius: 16px; padding: 1rem; }
.stat-card strong { display: block; font-size: 2rem; color: var(--brand); }
.actions { display: flex; gap: .4rem; flex-wrap: wrap; }
@media (max-width: 900px) {
  .world-layout, .two-col { grid-template-columns: 1fr; }
  .topbar { align-items: flex-start; flex-direction: column; }
}
