* { box-sizing: border-box; }
html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  background: #12151c;
  color: #e9edf5;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
}

.hidden { display: none !important; }

.screen {
  min-height: 100vh;
  padding: 16px;
}

.center-screen {
  display: flex;
  align-items: center;
  justify-content: center;
}

.card {
  background: #1b202b;
  border: 1px solid #2b3242;
  border-radius: 10px;
  padding: 18px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.35);
}

.card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.card-head h2, .card h2 {
  margin: 0 0 6px;
  font-size: 1.15rem;
}

.auth-card {
  width: 100%;
  max-width: 400px;
}

.brand, .brand-sm {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand h1 {
  margin: 0;
  font-size: 1.4rem;
}

.badge {
  background: #233349;
  color: #8cc8ff;
  border: 1px solid #355175;
  border-radius: 999px;
  padding: 2px 9px;
  font-size: 0.74rem;
  font-weight: 600;
}

.cube-badge {
  width: 36px;
  height: 36px;
  border-radius: 6px;
  background: linear-gradient(180deg, #5ca342 0%, #5ca342 32%, #7e593c 32%, #7e593c 100%);
  border: 2px solid #8bd46e;
  flex-shrink: 0;
}

.cube-badge.sm {
  width: 24px;
  height: 24px;
}

.muted {
  color: #9ba5b8;
  font-size: 0.88rem;
  margin: 4px 0 10px;
}

.hint {
  color: #8f9bb0;
  font-size: 0.82rem;
  margin: 14px 0 0;
  text-align: center;
}

.tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin: 12px 0;
}

.tab {
  background: #252c3a;
  color: #aeb7c9;
  border: 1px solid #323b4e;
  border-radius: 6px;
  padding: 8px;
  cursor: pointer;
  font-weight: 600;
}

.tab.active {
  background: #354156;
  color: #fff;
  border-color: #5b78a8;
}

label {
  display: block;
  margin-bottom: 12px;
  font-size: 0.88rem;
  color: #c7d0e0;
}

label span {
  display: block;
  margin-bottom: 5px;
}

input, select, textarea {
  width: 100%;
  background: #12161e;
  color: #fff;
  border: 1px solid #353e52;
  border-radius: 6px;
  padding: 9px 11px;
  font-size: 0.94rem;
  font-family: inherit;
}

textarea {
  margin: 8px 0;
  font-family: ui-monospace, Consolas, monospace;
  font-size: 0.8rem;
  resize: vertical;
}

.btn {
  border: none;
  border-radius: 6px;
  padding: 9px 14px;
  font-weight: 600;
  cursor: pointer;
  color: #fff;
  background: #374151;
}

.btn:hover { filter: brightness(1.08); }
.btn.primary { background: #2e7dd2; }
.btn.green { background: #43a047; }
.btn.danger { background: #c63939; }
.btn.ghost { background: #283040; color: #d5dce8; }
.btn.full { width: 100%; }
.btn.sm { padding: 5px 10px; font-size: 0.82rem; }

.divider {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 14px 0;
  color: #8490a6;
  font-size: 0.82rem;
}

.divider::before, .divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: #2f3749;
}

.import-label {
  display: inline-block;
  margin: 0;
}

.error-box {
  background: rgba(200, 50, 50, 0.2);
  border: 1px solid #d9534f;
  color: #ffb8b8;
  padding: 8px 10px;
  border-radius: 6px;
  margin-bottom: 12px;
  font-size: 0.88rem;
}

.topbar {
  max-width: 1060px;
  margin: 0 auto 14px;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  background: #1b202b;
  border: 1px solid #2b3242;
  border-radius: 10px;
  padding: 12px 14px;
}

.user-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #38bdf8;
}

.rd-inline {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0;
  font-size: 0.84rem;
}

.rd-inline select {
  width: auto;
  padding: 5px 8px;
  font-size: 0.84rem;
}

.dashboard-grid {
  max-width: 1060px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(310px, 1fr));
  gap: 14px;
}

.inline-form {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
}

.seed-input { max-width: 125px; }

.p2p-box {
  background: #141923;
  border: 1px solid #283449;
  border-radius: 8px;
  padding: 10px;
  margin-bottom: 12px;
}

.rooms-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.86rem;
  color: #aab4c7;
  margin: 8px 0;
}

.list-box {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 330px;
  overflow-y: auto;
}

.list-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  background: #131720;
  border: 1px solid #2a3142;
  border-radius: 8px;
  padding: 9px 11px;
}

.list-item small {
  display: block;
  color: #8c96ab;
  font-size: 0.78rem;
}

.item-actions {
  display: flex;
  gap: 5px;
  flex-shrink: 0;
}

/* Game Screen */
.game-screen {
  position: fixed;
  inset: 0;
  background: #000;
  overflow: hidden;
  user-select: none;
  touch-action: none;
}

#gl-canvas {
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}

.crosshair {
  position: fixed;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  color: rgba(255, 255, 255, 0.88);
  font-size: 24px;
  font-weight: 700;
  pointer-events: none;
  text-shadow: 0 1px 2px #000;
}

.hud-top {
  position: fixed;
  top: 8px;
  left: 10px;
  right: 120px;
  pointer-events: none;
  font-family: ui-monospace, Consolas, monospace;
  font-size: 12px;
  text-shadow: 1px 1px 2px #000;
}

.top-right-btns {
  position: fixed;
  top: 8px;
  right: 10px;
  display: flex;
  gap: 6px;
  z-index: 20;
}

.hud-btn {
  background: rgba(20, 24, 34, 0.72);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.debug-panel {
  margin-top: 6px;
  background: rgba(0, 0, 0, 0.45);
  padding: 6px 8px;
  border-radius: 4px;
  line-height: 1.45;
}

.chat-area {
  position: fixed;
  left: 10px;
  bottom: 80px;
  width: min(420px, calc(100vw - 20px));
  pointer-events: none;
  z-index: 15;
}

.chat-log {
  display: flex;
  flex-direction: column;
  gap: 3px;
  font-family: ui-monospace, Consolas, monospace;
  font-size: 12px;
  text-shadow: 1px 1px 2px #000;
}

.chat-line {
  background: rgba(0, 0, 0, 0.42);
  padding: 2px 6px;
  border-radius: 3px;
}

.chat-form {
  margin-top: 6px;
  pointer-events: auto;
}

.hotbar-wrap {
  position: fixed;
  left: 50%;
  bottom: 10px;
  transform: translateX(-50%);
  text-align: center;
  z-index: 16;
  pointer-events: auto;
}

.hotbar-label {
  font-size: 12px;
  font-weight: 600;
  margin-bottom: 3px;
  text-shadow: 1px 1px 2px #000;
  pointer-events: none;
}

.hotbar {
  display: flex;
  gap: 3px;
  background: rgba(16, 20, 28, 0.78);
  padding: 4px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.16);
}

.slot {
  position: relative;
  width: 34px;
  height: 34px;
  background: rgba(38, 44, 58, 0.85);
  border: 2px solid #454e63;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.slot.active {
  border-color: #ffffff;
  box-shadow: 0 0 8px rgba(255, 255, 255, 0.5);
}

.slot img {
  width: 22px;
  height: 22px;
  image-rendering: pixelated;
  pointer-events: none;
}

.slot span {
  position: absolute;
  top: 1px;
  left: 3px;
  font-size: 9px;
  color: #d6deec;
  text-shadow: 1px 1px 1px #000;
  pointer-events: none;
}

/* Mobile Touch Controls */
.touch-controls {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 12;
  touch-action: none;
}

.touch-look-zone {
  position: fixed;
  left: 35%;
  right: 0;
  top: 44px;
  bottom: 64px;
  pointer-events: auto;
  touch-action: none;
}

.joy-base {
  position: fixed;
  left: 18px;
  bottom: 74px;
  width: 112px;
  height: 112px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.12);
  border: 2px solid rgba(255, 255, 255, 0.28);
  pointer-events: auto;
  touch-action: none;
}

.joy-knob {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 46px;
  height: 46px;
  margin-left: -23px;
  margin-top: -23px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.45);
  border: 2px solid rgba(255, 255, 255, 0.8);
  pointer-events: none;
}

.touch-actions {
  position: fixed;
  right: 14px;
  bottom: 74px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: flex-end;
  pointer-events: auto;
  z-index: 18;
}

.touch-row {
  display: flex;
  gap: 8px;
}

.t-btn {
  min-width: 58px;
  height: 44px;
  padding: 0 10px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.35);
  background: rgba(25, 30, 42, 0.72);
  color: #fff;
  font-weight: 700;
  font-size: 13px;
  touch-action: none;
}

.t-btn.red { background: rgba(185, 45, 45, 0.75); }
.t-btn.blue { background: rgba(40, 115, 200, 0.75); }
.t-btn.green { background: rgba(55, 145, 65, 0.75); }

.pause-overlay {
  position: fixed;
  inset: 0;
  background: rgba(8, 10, 15, 0.72);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 30;
  padding: 16px;
}

.pause-box {
  width: 100%;
  max-width: 340px;
  background: #1b202b;
  border: 1px solid #354056;
  border-radius: 10px;
  padding: 20px;
  text-align: center;
}

.modal-wide {
  max-width: 440px;
  text-align: left;
}

.pause-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 14px;
}
